forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#103827 - compiler-errors:rpitit-substs-comp…
…at, r=wesleywiser Properly remap and check for substs compatibility in `confirm_impl_trait_in_trait_candidate` Fixes rust-lang#103824
- Loading branch information
Showing
7 changed files
with
127 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#![feature(return_position_impl_trait_in_trait)] | ||
#![allow(incomplete_features)] | ||
|
||
struct U; | ||
|
||
trait Foo { | ||
fn bar(&self) -> impl Sized; | ||
} | ||
|
||
impl Foo for U { | ||
fn bar<T>(&self) {} | ||
//~^ ERROR method `bar` has 1 type parameter but its trait declaration has 0 type parameters | ||
} | ||
|
||
fn main() { | ||
U.bar(); | ||
} |
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,12 @@ | ||
error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters | ||
--> $DIR/generics-mismatch.rs:11:12 | ||
| | ||
LL | fn bar(&self) -> impl Sized; | ||
| - expected 0 type parameters | ||
... | ||
LL | fn bar<T>(&self) {} | ||
| ^ found 1 type parameter | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0049`. |
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,26 @@ | ||
// FIXME(compiler-errors): I'm not exactly sure if this is expected to pass or not. | ||
// But we fixed an ICE anyways. | ||
|
||
#![feature(specialization)] | ||
#![feature(return_position_impl_trait_in_trait)] | ||
#![allow(incomplete_features)] | ||
|
||
trait Foo { | ||
fn bar(&self) -> impl Sized; | ||
} | ||
|
||
default impl<U> Foo for U | ||
where | ||
U: Copy, | ||
{ | ||
fn bar(&self) -> U { | ||
//~^ ERROR method `bar` has an incompatible type for trait | ||
*self | ||
} | ||
} | ||
|
||
impl Foo for i32 {} | ||
|
||
fn main() { | ||
1i32.bar(); | ||
} |
23 changes: 23 additions & 0 deletions
23
src/test/ui/impl-trait/in-trait/specialization-broken.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,23 @@ | ||
error[E0053]: method `bar` has an incompatible type for trait | ||
--> $DIR/specialization-broken.rs:16:22 | ||
| | ||
LL | default impl<U> Foo for U | ||
| - this type parameter | ||
... | ||
LL | fn bar(&self) -> U { | ||
| ^ | ||
| | | ||
| expected associated type, found type parameter `U` | ||
| help: change the output type to match the trait: `impl Sized` | ||
| | ||
note: type in trait | ||
--> $DIR/specialization-broken.rs:9:22 | ||
| | ||
LL | fn bar(&self) -> impl Sized; | ||
| ^^^^^^^^^^ | ||
= note: expected fn pointer `fn(&U) -> impl Sized` | ||
found fn pointer `fn(&U) -> U` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0053`. |
24 changes: 24 additions & 0 deletions
24
src/test/ui/impl-trait/in-trait/specialization-substs-remap.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,24 @@ | ||
// check-pass | ||
|
||
#![feature(specialization)] | ||
#![feature(return_position_impl_trait_in_trait)] | ||
#![allow(incomplete_features)] | ||
|
||
trait Foo { | ||
fn bar(&self) -> impl Sized; | ||
} | ||
|
||
impl<U> Foo for U | ||
where | ||
U: Copy, | ||
{ | ||
fn bar(&self) -> U { | ||
*self | ||
} | ||
} | ||
|
||
impl Foo for i32 {} | ||
|
||
fn main() { | ||
let _: i32 = 1i32.bar(); | ||
} |