mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Clarify some diagnostic messages
This commit is contained in:
parent
5cd3cc134a
commit
64d11fc8e3
@ -2940,8 +2940,9 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||||||
// though we can easily give a hint that ought to be
|
// though we can easily give a hint that ought to be
|
||||||
// relevant.
|
// relevant.
|
||||||
err.note(
|
err.note(
|
||||||
"lifetimes appearing in an associated type are not considered constrained",
|
"lifetimes appearing in an associated or opaque type are not considered constrained",
|
||||||
);
|
);
|
||||||
|
err.note("consider introducing a named lifetime parameter");
|
||||||
}
|
}
|
||||||
|
|
||||||
err.emit();
|
err.emit();
|
||||||
|
@ -10,6 +10,7 @@ impl T<'_> for S {
|
|||||||
|
|
||||||
fn foo(x: impl Fn(<S as T<'_>>::A) -> <S as T<'_>>::A) {}
|
fn foo(x: impl Fn(<S as T<'_>>::A) -> <S as T<'_>>::A) {}
|
||||||
//~^ ERROR binding for associated type `Output` references an anonymous lifetime
|
//~^ ERROR binding for associated type `Output` references an anonymous lifetime
|
||||||
//~^^ NOTE lifetimes appearing in an associated type are not considered constrained
|
//~| NOTE lifetimes appearing in an associated or opaque type are not considered constrained
|
||||||
|
//~| NOTE consider introducing a named lifetime parameter
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
@ -4,7 +4,8 @@ error[E0582]: binding for associated type `Output` references an anonymous lifet
|
|||||||
LL | fn foo(x: impl Fn(<S as T<'_>>::A) -> <S as T<'_>>::A) {}
|
LL | fn foo(x: impl Fn(<S as T<'_>>::A) -> <S as T<'_>>::A) {}
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: lifetimes appearing in an associated type are not considered constrained
|
= note: lifetimes appearing in an associated or opaque type are not considered constrained
|
||||||
|
= note: consider introducing a named lifetime parameter
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@ error[E0581]: return type references an anonymous lifetime, which is not constra
|
|||||||
LL | fn f(_: X) -> X {
|
LL | fn f(_: X) -> X {
|
||||||
| ^
|
| ^
|
||||||
|
|
|
|
||||||
= note: lifetimes appearing in an associated type are not considered constrained
|
= note: lifetimes appearing in an associated or opaque type are not considered constrained
|
||||||
|
= note: consider introducing a named lifetime parameter
|
||||||
|
|
||||||
error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types
|
error[E0581]: return type references lifetime `'a`, which is not constrained by the fn input types
|
||||||
--> $DIR/issue-47511.rs:12:23
|
--> $DIR/issue-47511.rs:12:23
|
||||||
|
@ -12,7 +12,7 @@ mod lifetime_params {
|
|||||||
//~^ ERROR binding for associated type `Output` references an anonymous lifetime
|
//~^ ERROR binding for associated type `Output` references an anonymous lifetime
|
||||||
}
|
}
|
||||||
|
|
||||||
mod type_params {
|
mod lifetime_params_2 {
|
||||||
type Ty<'a> = impl FnOnce() -> &'a str;
|
type Ty<'a> = impl FnOnce() -> &'a str;
|
||||||
fn defining(s: &str) -> Ty<'_> { move || s }
|
fn defining(s: &str) -> Ty<'_> { move || s }
|
||||||
fn execute(ty: Ty<'_>) -> &str { ty() }
|
fn execute(ty: Ty<'_>) -> &str { ty() }
|
||||||
@ -20,7 +20,7 @@ mod type_params {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// regression test for https://github.com/rust-lang/rust/issues/97104
|
// regression test for https://github.com/rust-lang/rust/issues/97104
|
||||||
mod type_params2 {
|
mod type_params {
|
||||||
type Ty<T> = impl Sized;
|
type Ty<T> = impl Sized;
|
||||||
fn define<T>(s: T) -> Ty<T> { s }
|
fn define<T>(s: T) -> Ty<T> { s }
|
||||||
|
|
||||||
|
@ -4,7 +4,8 @@ error[E0581]: return type references an anonymous lifetime, which is not constra
|
|||||||
LL | fn execute(ty: Ty<'_>) -> &str { todo!() }
|
LL | fn execute(ty: Ty<'_>) -> &str { todo!() }
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= note: lifetimes appearing in an associated type are not considered constrained
|
= note: lifetimes appearing in an associated or opaque type are not considered constrained
|
||||||
|
= note: consider introducing a named lifetime parameter
|
||||||
|
|
||||||
error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
|
error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
|
||||||
--> $DIR/constrain_inputs.rs:9:35
|
--> $DIR/constrain_inputs.rs:9:35
|
||||||
@ -12,7 +13,8 @@ error[E0581]: return type references an anonymous lifetime, which is not constra
|
|||||||
LL | type BadFnSig = fn(Ty<'_>) -> &str;
|
LL | type BadFnSig = fn(Ty<'_>) -> &str;
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= note: lifetimes appearing in an associated type are not considered constrained
|
= note: lifetimes appearing in an associated or opaque type are not considered constrained
|
||||||
|
= note: consider introducing a named lifetime parameter
|
||||||
|
|
||||||
error[E0582]: binding for associated type `Output` references an anonymous lifetime, which does not appear in the trait input types
|
error[E0582]: binding for associated type `Output` references an anonymous lifetime, which does not appear in the trait input types
|
||||||
--> $DIR/constrain_inputs.rs:11:42
|
--> $DIR/constrain_inputs.rs:11:42
|
||||||
@ -20,7 +22,8 @@ error[E0582]: binding for associated type `Output` references an anonymous lifet
|
|||||||
LL | type BadTraitRef = dyn Fn(Ty<'_>) -> &str;
|
LL | type BadTraitRef = dyn Fn(Ty<'_>) -> &str;
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= note: lifetimes appearing in an associated type are not considered constrained
|
= note: lifetimes appearing in an associated or opaque type are not considered constrained
|
||||||
|
= note: consider introducing a named lifetime parameter
|
||||||
|
|
||||||
error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
|
error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
|
||||||
--> $DIR/constrain_inputs.rs:18:31
|
--> $DIR/constrain_inputs.rs:18:31
|
||||||
@ -28,7 +31,8 @@ error[E0581]: return type references an anonymous lifetime, which is not constra
|
|||||||
LL | fn execute(ty: Ty<'_>) -> &str { ty() }
|
LL | fn execute(ty: Ty<'_>) -> &str { ty() }
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= note: lifetimes appearing in an associated type are not considered constrained
|
= note: lifetimes appearing in an associated or opaque type are not considered constrained
|
||||||
|
= note: consider introducing a named lifetime parameter
|
||||||
|
|
||||||
error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
|
error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
|
||||||
--> $DIR/constrain_inputs.rs:27:37
|
--> $DIR/constrain_inputs.rs:27:37
|
||||||
@ -36,7 +40,8 @@ error[E0581]: return type references an anonymous lifetime, which is not constra
|
|||||||
LL | type BadFnSig = fn(Ty<&str>) -> &str;
|
LL | type BadFnSig = fn(Ty<&str>) -> &str;
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= note: lifetimes appearing in an associated type are not considered constrained
|
= note: lifetimes appearing in an associated or opaque type are not considered constrained
|
||||||
|
= note: consider introducing a named lifetime parameter
|
||||||
|
|
||||||
error[E0582]: binding for associated type `Output` references an anonymous lifetime, which does not appear in the trait input types
|
error[E0582]: binding for associated type `Output` references an anonymous lifetime, which does not appear in the trait input types
|
||||||
--> $DIR/constrain_inputs.rs:29:44
|
--> $DIR/constrain_inputs.rs:29:44
|
||||||
@ -44,7 +49,8 @@ error[E0582]: binding for associated type `Output` references an anonymous lifet
|
|||||||
LL | type BadTraitRef = dyn Fn(Ty<&str>) -> &str;
|
LL | type BadTraitRef = dyn Fn(Ty<&str>) -> &str;
|
||||||
| ^^^^
|
| ^^^^
|
||||||
|
|
|
|
||||||
= note: lifetimes appearing in an associated type are not considered constrained
|
= note: lifetimes appearing in an associated or opaque type are not considered constrained
|
||||||
|
= note: consider introducing a named lifetime parameter
|
||||||
|
|
||||||
error: aborting due to 6 previous errors
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user