Rollup merge of #104295 - compiler-errors:rpitit-generics-parity, r=eholk
Check generics parity before collecting return-position `impl Trait`s in trait The only thing is that this duplicates the error message for number of generics mismatch, but we already deduplicate that error message in Cargo. I could add a flag to delay the error if the reviewer cares. Fixes #104281 Also drive-by adds a few comments to the `collect_trait_impl_trait_tys` method, and removes an unused argument from `compare_number_of_generics`.
This commit is contained in:
commit
680ba90f96
3 changed files with 65 additions and 32 deletions
|
|
@ -0,0 +1,17 @@
|
|||
#![feature(return_position_impl_trait_in_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
struct S;
|
||||
|
||||
trait Foo {
|
||||
fn bar<T>() -> impl Sized;
|
||||
}
|
||||
|
||||
impl Foo for S {
|
||||
fn bar() -> impl Sized {}
|
||||
//~^ ERROR method `bar` has 0 type parameters but its trait declaration has 1 type parameter
|
||||
}
|
||||
|
||||
fn main() {
|
||||
S::bar();
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
error[E0049]: method `bar` has 0 type parameters but its trait declaration has 1 type parameter
|
||||
--> $DIR/trait-more-generics-than-impl.rs:11:11
|
||||
|
|
||||
LL | fn bar<T>() -> impl Sized;
|
||||
| - expected 1 type parameter
|
||||
...
|
||||
LL | fn bar() -> impl Sized {}
|
||||
| ^ found 0 type parameters
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0049`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue