Rollup merge of #122915 - fmease:lt-opaq-mismatch-delay-bug, r=compiler-errors
Delay a bug if no RPITITs were found Fixes #122655. See the issue for context. r? compiler-errors or compiler
This commit is contained in:
commit
f03326c579
3 changed files with 74 additions and 21 deletions
|
@ -639,10 +639,9 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !unnormalized_trait_sig.output().references_error() {
|
if !unnormalized_trait_sig.output().references_error() && collector.types.is_empty() {
|
||||||
debug_assert!(
|
tcx.dcx().delayed_bug(
|
||||||
!collector.types.is_empty(),
|
"expect >0 RPITITs in call to `collect_return_position_impl_trait_in_trait_tys`",
|
||||||
"expect >0 RPITITs in call to `collect_return_position_impl_trait_in_trait_tys`"
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
struct Wrapper<'rom>(T);
|
struct Wrapper<'rom>(&'rom ());
|
||||||
//~^ ERROR cannot find type `T` in this scope
|
|
||||||
|
|
||||||
trait Foo {
|
trait Foo {
|
||||||
fn bar() -> Wrapper<impl Sized>;
|
fn bar() -> Wrapper<impl Sized>;
|
||||||
|
@ -15,4 +14,18 @@ impl Foo for () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trait Bar {
|
||||||
|
fn foo() -> Wrapper<impl Sized>;
|
||||||
|
//~^ ERROR missing lifetime specifier
|
||||||
|
//~| ERROR struct takes 0 generic arguments but 1 generic argument was supplied
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Bar for () {
|
||||||
|
fn foo() -> Wrapper<impl Sized> {
|
||||||
|
//~^ ERROR missing lifetime specifier
|
||||||
|
//~| ERROR struct takes 0 generic arguments but 1 generic argument was supplied
|
||||||
|
Wrapper(&())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
error[E0106]: missing lifetime specifier
|
error[E0106]: missing lifetime specifier
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:5:24
|
--> $DIR/opaque-and-lifetime-mismatch.rs:4:24
|
||||||
|
|
|
|
||||||
LL | fn bar() -> Wrapper<impl Sized>;
|
LL | fn bar() -> Wrapper<impl Sized>;
|
||||||
| ^ expected named lifetime parameter
|
| ^ expected named lifetime parameter
|
||||||
|
@ -10,19 +10,32 @@ help: consider using the `'static` lifetime, but this is uncommon unless you're
|
||||||
LL | fn bar() -> Wrapper<'static, impl Sized>;
|
LL | fn bar() -> Wrapper<'static, impl Sized>;
|
||||||
| ++++++++
|
| ++++++++
|
||||||
|
|
||||||
error[E0412]: cannot find type `T` in this scope
|
error[E0106]: missing lifetime specifier
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:1:22
|
--> $DIR/opaque-and-lifetime-mismatch.rs:18:24
|
||||||
|
|
|
|
||||||
LL | struct Wrapper<'rom>(T);
|
LL | fn foo() -> Wrapper<impl Sized>;
|
||||||
| ^ not found in this scope
|
| ^ expected named lifetime parameter
|
||||||
|
|
|
|
||||||
help: you might be missing a type parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||||
|
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values
|
||||||
|
|
|
|
||||||
LL | struct Wrapper<'rom, T>(T);
|
LL | fn foo() -> Wrapper<'static, impl Sized>;
|
||||||
| +++
|
| ++++++++
|
||||||
|
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/opaque-and-lifetime-mismatch.rs:24:24
|
||||||
|
|
|
||||||
|
LL | fn foo() -> Wrapper<impl Sized> {
|
||||||
|
| ^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||||
|
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`, or if you will only have owned values
|
||||||
|
|
|
||||||
|
LL | fn foo() -> Wrapper<'static, impl Sized> {
|
||||||
|
| ++++++++
|
||||||
|
|
||||||
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:5:17
|
--> $DIR/opaque-and-lifetime-mismatch.rs:4:17
|
||||||
|
|
|
|
||||||
LL | fn bar() -> Wrapper<impl Sized>;
|
LL | fn bar() -> Wrapper<impl Sized>;
|
||||||
| ^^^^^^^ ---------- help: remove this generic argument
|
| ^^^^^^^ ---------- help: remove this generic argument
|
||||||
|
@ -32,11 +45,25 @@ LL | fn bar() -> Wrapper<impl Sized>;
|
||||||
note: struct defined here, with 0 generic parameters
|
note: struct defined here, with 0 generic parameters
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:1:8
|
--> $DIR/opaque-and-lifetime-mismatch.rs:1:8
|
||||||
|
|
|
|
||||||
LL | struct Wrapper<'rom>(T);
|
LL | struct Wrapper<'rom>(&'rom ());
|
||||||
|
| ^^^^^^^
|
||||||
|
|
||||||
|
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||||
|
--> $DIR/opaque-and-lifetime-mismatch.rs:18:17
|
||||||
|
|
|
||||||
|
LL | fn foo() -> Wrapper<impl Sized>;
|
||||||
|
| ^^^^^^^ ---------- help: remove this generic argument
|
||||||
|
| |
|
||||||
|
| expected 0 generic arguments
|
||||||
|
|
|
||||||
|
note: struct defined here, with 0 generic parameters
|
||||||
|
--> $DIR/opaque-and-lifetime-mismatch.rs:1:8
|
||||||
|
|
|
||||||
|
LL | struct Wrapper<'rom>(&'rom ());
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
|
||||||
error[E0053]: method `bar` has an incompatible return type for trait
|
error[E0053]: method `bar` has an incompatible return type for trait
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:11:17
|
--> $DIR/opaque-and-lifetime-mismatch.rs:10:17
|
||||||
|
|
|
|
||||||
LL | fn bar() -> i32 {
|
LL | fn bar() -> i32 {
|
||||||
| ^^^
|
| ^^^
|
||||||
|
@ -45,7 +72,7 @@ LL | fn bar() -> i32 {
|
||||||
| return type in trait
|
| return type in trait
|
||||||
|
|
||||||
error[E0053]: method `bar` has an incompatible type for trait
|
error[E0053]: method `bar` has an incompatible type for trait
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:11:17
|
--> $DIR/opaque-and-lifetime-mismatch.rs:10:17
|
||||||
|
|
|
|
||||||
LL | fn bar() -> i32 {
|
LL | fn bar() -> i32 {
|
||||||
| ^^^
|
| ^^^
|
||||||
|
@ -54,14 +81,28 @@ LL | fn bar() -> i32 {
|
||||||
| help: change the output type to match the trait: `Wrapper<'static>`
|
| help: change the output type to match the trait: `Wrapper<'static>`
|
||||||
|
|
|
|
||||||
note: type in trait
|
note: type in trait
|
||||||
--> $DIR/opaque-and-lifetime-mismatch.rs:5:17
|
--> $DIR/opaque-and-lifetime-mismatch.rs:4:17
|
||||||
|
|
|
|
||||||
LL | fn bar() -> Wrapper<impl Sized>;
|
LL | fn bar() -> Wrapper<impl Sized>;
|
||||||
| ^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^
|
||||||
= note: expected signature `fn() -> Wrapper<'static>`
|
= note: expected signature `fn() -> Wrapper<'static>`
|
||||||
found signature `fn() -> i32`
|
found signature `fn() -> i32`
|
||||||
|
|
||||||
error: aborting due to 5 previous errors
|
error[E0107]: struct takes 0 generic arguments but 1 generic argument was supplied
|
||||||
|
--> $DIR/opaque-and-lifetime-mismatch.rs:24:17
|
||||||
|
|
|
||||||
|
LL | fn foo() -> Wrapper<impl Sized> {
|
||||||
|
| ^^^^^^^ ---------- help: remove this generic argument
|
||||||
|
| |
|
||||||
|
| expected 0 generic arguments
|
||||||
|
|
|
||||||
|
note: struct defined here, with 0 generic parameters
|
||||||
|
--> $DIR/opaque-and-lifetime-mismatch.rs:1:8
|
||||||
|
|
|
||||||
|
LL | struct Wrapper<'rom>(&'rom ());
|
||||||
|
| ^^^^^^^
|
||||||
|
|
||||||
Some errors have detailed explanations: E0053, E0106, E0107, E0412.
|
error: aborting due to 8 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0053, E0106, E0107.
|
||||||
For more information about an error, try `rustc --explain E0053`.
|
For more information about an error, try `rustc --explain E0053`.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue