-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6fdc303
commit 816d811
Showing
9 changed files
with
73 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/ui/traits/trait-upcasting/migrate-lint-different-substs.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#![deny(deref_into_dyn_supertrait)] | ||
|
||
use std::ops::Deref; | ||
|
||
trait Bar<T> {} | ||
|
||
trait Foo: Bar<i32> { | ||
fn as_dyn_bar_u32<'a>(&self) -> &(dyn Bar<u32> + 'a); | ||
} | ||
|
||
impl<'a> Deref for dyn Foo + 'a { | ||
//~^ ERROR `dyn Foo` implements `Deref<Target = dyn Bar<u32>>` which conflicts with supertrait `Bar<i32>` | ||
//~| WARN this was previously accepted by the compiler | ||
type Target = dyn Bar<u32> + 'a; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
self.as_dyn_bar_u32() | ||
} | ||
} | ||
|
||
fn main() {} |
20 changes: 20 additions & 0 deletions
20
tests/ui/traits/trait-upcasting/migrate-lint-different-substs.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error: `dyn Foo` implements `Deref<Target = dyn Bar<u32>>` which conflicts with supertrait `Bar<i32>` | ||
--> $DIR/migrate-lint-different-substs.rs:11:1 | ||
| | ||
LL | impl<'a> Deref for dyn Foo + 'a { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
... | ||
LL | type Target = dyn Bar<u32> + 'a; | ||
| -------------------------------- target type is set here | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #89460 <https://github.com/rust-lang/rust/issues/89460> | ||
= note: inference and runtime behavior may change after `#[feature(trait_upcasting)]` is enabled by default | ||
note: the lint level is defined here | ||
--> $DIR/migrate-lint-different-substs.rs:1:9 | ||
| | ||
LL | #![deny(deref_into_dyn_supertrait)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|