forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#102152 - compiler-errors:issue-102140, r=fe…
…e1-dead Calculate `ProjectionTy::trait_def_id` for return-position `impl Trait` in trait correctly Fixes rust-lang#102140
- Loading branch information
Showing
3 changed files
with
66 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#![feature(return_position_impl_trait_in_trait)] | ||
#![allow(incomplete_features)] | ||
|
||
trait Marker {} | ||
impl Marker for u32 {} | ||
|
||
trait MyTrait { | ||
fn foo(&self) -> impl Marker | ||
where | ||
Self: Sized; | ||
} | ||
|
||
struct Outer; | ||
|
||
impl MyTrait for Outer { | ||
fn foo(&self) -> impl Marker { | ||
42 | ||
} | ||
} | ||
|
||
impl dyn MyTrait { | ||
fn other(&self) -> impl Marker { | ||
MyTrait::foo(&self) | ||
//~^ ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied | ||
//~| ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied | ||
//~| ERROR the trait bound `&dyn MyTrait: MyTrait` is not satisfied | ||
} | ||
} | ||
|
||
fn main() {} |
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,29 @@ | ||
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied | ||
--> $DIR/issue-102140.rs:23:22 | ||
| | ||
LL | MyTrait::foo(&self) | ||
| ------------ -^^^^ | ||
| | | | ||
| | the trait `MyTrait` is not implemented for `&dyn MyTrait` | ||
| | help: consider removing the leading `&`-reference | ||
| required by a bound introduced by this call | ||
|
||
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied | ||
--> $DIR/issue-102140.rs:23:9 | ||
| | ||
LL | MyTrait::foo(&self) | ||
| ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` | ||
| | ||
= help: the trait `MyTrait` is implemented for `Outer` | ||
|
||
error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied | ||
--> $DIR/issue-102140.rs:23:9 | ||
| | ||
LL | MyTrait::foo(&self) | ||
| ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` | ||
| | ||
= help: the trait `MyTrait` is implemented for `Outer` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |