Skip to content

Commit 62ad354

Browse files
committed
error messages aren't really causing happiness
1 parent 328249d commit 62ad354

14 files changed

+85
-41
lines changed

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2162,10 +2162,24 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
21622162
}
21632163
}
21642164

2165+
ty::PredicateKind::TypeOutlives(outlives) => {
2166+
if self.tcx.sess.has_errors().is_some() || self.is_tainted_by_errors() {
2167+
return;
2168+
}
2169+
self.emit_inference_failure_err(
2170+
body_id,
2171+
span,
2172+
outlives.0.into(),
2173+
vec![],
2174+
ErrorCode::E0284,
2175+
)
2176+
}
2177+
21652178
_ => {
21662179
if self.tcx.sess.has_errors().is_some() || self.is_tainted_by_errors() {
21672180
return;
21682181
}
2182+
21692183
let mut err = struct_span_err!(
21702184
self.tcx.sess,
21712185
span,

src/test/ui/fn/implied-bounds-unnorm-associated-type-3.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn zero_copy_from<'b>(cart: &'b [T]) -> &'b [T] {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
77
= help: consider adding an explicit lifetime bound `T: 'static`...
8-
= note: ...so that the type `[T]` will meet its required lifetime bounds
8+
= note: ...so that the type `T` will meet its required lifetime bounds
99

1010
error: aborting due to previous error
1111

src/test/ui/generic-associated-types/bugs/issue-86218.stderr

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
error[E0477]: the type `<() as Yay<&'a ()>>::InnerStream<'s>` does not fulfill the required lifetime
1+
error[E0478]: lifetime bound not satisfied
22
--> $DIR/issue-86218.rs:23:28
33
|
44
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
66
|
7-
note: type must outlive the lifetime `'s` as defined here as required by this binding
7+
note: lifetime parameter instantiated with the lifetime `'a` as defined here
8+
--> $DIR/issue-86218.rs:22:6
9+
|
10+
LL | impl<'a> Yay<&'a ()> for () {
11+
| ^^
12+
note: but lifetime parameter must outlive the lifetime `'s` as defined here
813
--> $DIR/issue-86218.rs:23:22
914
|
1015
LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
@@ -20,4 +25,4 @@ LL | type InnerStream<'s> = impl Stream<Item = i32> + 's;
2025

2126
error: aborting due to 2 previous errors
2227

23-
For more information about this error, try `rustc --explain E0477`.
28+
For more information about this error, try `rustc --explain E0478`.

src/test/ui/generic-associated-types/issue-90014.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ trait MakeFut {
1212

1313
impl MakeFut for &'_ mut () {
1414
type Fut<'a> = impl Future<Output = ()>;
15-
//~^ ERROR: the type `&mut ()` does not fulfill the required lifetime
15+
//~^ ERROR: lifetime bound not satisfied
1616

1717
fn make_fut<'a>(&'a self) -> Self::Fut<'a> {
1818
async { () }
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0477]: the type `&mut ()` does not fulfill the required lifetime
1+
error[E0478]: lifetime bound not satisfied
22
--> $DIR/issue-90014.rs:14:20
33
|
44
LL | type Fut<'a> where Self: 'a;
@@ -7,12 +7,17 @@ LL | type Fut<'a> where Self: 'a;
77
LL | type Fut<'a> = impl Future<Output = ()>;
88
| ^^^^^^^^^^^^^^^^^^^^^^^^- help: try copying this clause from the trait: `where Self: 'a`
99
|
10-
note: type must outlive the lifetime `'a` as defined here
10+
note: lifetime parameter instantiated with the anonymous lifetime as defined here
11+
--> $DIR/issue-90014.rs:13:19
12+
|
13+
LL | impl MakeFut for &'_ mut () {
14+
| ^^
15+
note: but lifetime parameter must outlive the lifetime `'a` as defined here
1116
--> $DIR/issue-90014.rs:14:14
1217
|
1318
LL | type Fut<'a> = impl Future<Output = ()>;
1419
| ^^
1520

1621
error: aborting due to previous error
1722

18-
For more information about this error, try `rustc --explain E0477`.
23+
For more information about this error, try `rustc --explain E0478`.

src/test/ui/generic-associated-types/issue-92033.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ trait Swapchain {
2020

2121
impl<'s> Surface for &'s Texture {
2222
type TextureIter<'a> = std::option::IntoIter<&'a Texture>;
23-
//~^ ERROR the type
23+
//~^ ERROR lifetime bound not satisfied
2424

2525
fn get_texture(&self) -> Self::TextureIter<'_> {
2626
let option: Option<&Texture> = Some(self);
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0477]: the type `&'s Texture` does not fulfill the required lifetime
1+
error[E0478]: lifetime bound not satisfied
22
--> $DIR/issue-92033.rs:22:28
33
|
44
LL | / type TextureIter<'a>: Iterator<Item = &'a Texture>
@@ -9,12 +9,17 @@ LL | | Self: 'a;
99
LL | type TextureIter<'a> = std::option::IntoIter<&'a Texture>;
1010
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^- help: try copying this clause from the trait: `where Self: 'a`
1111
|
12-
note: type must outlive the lifetime `'a` as defined here
12+
note: lifetime parameter instantiated with the lifetime `'s` as defined here
13+
--> $DIR/issue-92033.rs:21:6
14+
|
15+
LL | impl<'s> Surface for &'s Texture {
16+
| ^^
17+
note: but lifetime parameter must outlive the lifetime `'a` as defined here
1318
--> $DIR/issue-92033.rs:22:22
1419
|
1520
LL | type TextureIter<'a> = std::option::IntoIter<&'a Texture>;
1621
| ^^
1722

1823
error: aborting due to previous error
1924

20-
For more information about this error, try `rustc --explain E0477`.
25+
For more information about this error, try `rustc --explain E0478`.

src/test/ui/generic-associated-types/unsatisfied-outlives-bound.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ trait ATy {
66

77
impl<'b> ATy for &'b () {
88
type Item<'a> = &'b ();
9-
//~^ ERROR the type `&'b ()` does not fulfill the required lifetime
9+
//~^ ERROR lifetime bound not satisfied
1010
}
1111

1212
trait StaticTy {
@@ -15,7 +15,7 @@ trait StaticTy {
1515

1616
impl StaticTy for () {
1717
type Item<'a> = &'a ();
18-
//~^ ERROR the type `&'a ()` does not fulfill the required lifetime
18+
//~^ ERROR lifetime bound not satisfied
1919
}
2020

2121
fn main() {}
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1-
error[E0477]: the type `&'b ()` does not fulfill the required lifetime
1+
error[E0478]: lifetime bound not satisfied
22
--> $DIR/unsatisfied-outlives-bound.rs:8:21
33
|
44
LL | type Item<'a> = &'b ();
55
| ^^^^^^
66
|
7-
note: type must outlive the lifetime `'a` as defined here as required by this binding
7+
note: lifetime parameter instantiated with the lifetime `'b` as defined here
8+
--> $DIR/unsatisfied-outlives-bound.rs:7:6
9+
|
10+
LL | impl<'b> ATy for &'b () {
11+
| ^^
12+
note: but lifetime parameter must outlive the lifetime `'a` as defined here
813
--> $DIR/unsatisfied-outlives-bound.rs:8:15
914
|
1015
LL | type Item<'a> = &'b ();
1116
| ^^
1217

13-
error[E0477]: the type `&'a ()` does not fulfill the required lifetime
18+
error[E0478]: lifetime bound not satisfied
1419
--> $DIR/unsatisfied-outlives-bound.rs:17:21
1520
|
1621
LL | type Item<'a> = &'a ();
1722
| ^^^^^^
1823
|
19-
note: type must satisfy the static lifetime as required by this binding
20-
--> $DIR/unsatisfied-outlives-bound.rs:13:20
24+
note: lifetime parameter instantiated with the lifetime `'a` as defined here
25+
--> $DIR/unsatisfied-outlives-bound.rs:17:15
2126
|
22-
LL | type Item<'a>: 'static;
23-
| ^^^^^^^
27+
LL | type Item<'a> = &'a ();
28+
| ^^
29+
= note: but lifetime parameter must outlive the static lifetime
2430

2531
error: aborting due to 2 previous errors
2632

27-
For more information about this error, try `rustc --explain E0477`.
33+
For more information about this error, try `rustc --explain E0478`.

src/test/ui/issues/issue-24013.stderr

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
error[E0282]: type annotations needed
1+
error[E0284]: type annotations needed
22
--> $DIR/issue-24013.rs:5:20
33
|
44
LL | unsafe {swap::<&mut _>(transmute(&a), transmute(&b))};
55
| ^^^^^^ cannot infer type
6+
|
7+
= note: required so that reference `&mut _` does not outlive its referent
68

79
error: aborting due to previous error
810

9-
For more information about this error, try `rustc --explain E0282`.
11+
For more information about this error, try `rustc --explain E0284`.

src/test/ui/regions/regions-assoc-type-region-bound-in-trait-not-met.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ impl<'a> Foo<'a> for &'a i16 {
1313

1414
impl<'a> Foo<'static> for &'a i32 {
1515
type Value = &'a i32;
16-
//~^ ERROR the type `&'a i32` does not fulfill the required lifetime
16+
//~^ ERROR lifetime bound not satisfied
1717
}
1818

1919
impl<'a, 'b> Foo<'b> for &'a i64 {
2020
type Value = &'a i32;
21-
//~^ ERROR the type `&'a i32` does not fulfill the required lifetime
21+
//~^ ERROR lifetime bound not satisfied
2222
}
2323

2424
fn main() {}
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,33 @@
1-
error[E0477]: the type `&'a i32` does not fulfill the required lifetime
1+
error[E0478]: lifetime bound not satisfied
22
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:15:18
33
|
44
LL | type Value = &'a i32;
55
| ^^^^^^^
66
|
7-
note: type must satisfy the static lifetime as required by this binding
8-
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:5:17
7+
note: lifetime parameter instantiated with the lifetime `'a` as defined here
8+
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:14:6
99
|
10-
LL | type Value: 'a;
11-
| ^^
10+
LL | impl<'a> Foo<'static> for &'a i32 {
11+
| ^^
12+
= note: but lifetime parameter must outlive the static lifetime
1213

13-
error[E0477]: the type `&'a i32` does not fulfill the required lifetime
14+
error[E0478]: lifetime bound not satisfied
1415
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:20:18
1516
|
1617
LL | type Value = &'a i32;
1718
| ^^^^^^^
1819
|
19-
note: type must outlive the lifetime `'b` as defined here as required by this binding
20+
note: lifetime parameter instantiated with the lifetime `'a` as defined here
21+
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:6
22+
|
23+
LL | impl<'a, 'b> Foo<'b> for &'a i64 {
24+
| ^^
25+
note: but lifetime parameter must outlive the lifetime `'b` as defined here
2026
--> $DIR/regions-assoc-type-region-bound-in-trait-not-met.rs:19:10
2127
|
2228
LL | impl<'a, 'b> Foo<'b> for &'a i64 {
2329
| ^^
2430

2531
error: aborting due to 2 previous errors
2632

27-
For more information about this error, try `rustc --explain E0477`.
33+
For more information about this error, try `rustc --explain E0478`.

src/test/ui/regions/regions-assoc-type-static-bound-in-trait-not-met.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ trait Foo {
88

99
impl<'a> Foo for &'a i32 {
1010
type Value = &'a i32;
11-
//~^ ERROR the type `&'a i32` does not fulfill the required lifetime
11+
//~^ ERROR lifetime bound not satisfied
1212
}
1313

1414
impl<'a> Foo for i32 {
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
error[E0477]: the type `&'a i32` does not fulfill the required lifetime
1+
error[E0478]: lifetime bound not satisfied
22
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:10:18
33
|
44
LL | type Value = &'a i32;
55
| ^^^^^^^
66
|
7-
note: type must satisfy the static lifetime as required by this binding
8-
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:5:17
7+
note: lifetime parameter instantiated with the lifetime `'a` as defined here
8+
--> $DIR/regions-assoc-type-static-bound-in-trait-not-met.rs:9:6
99
|
10-
LL | type Value: 'static;
11-
| ^^^^^^^
10+
LL | impl<'a> Foo for &'a i32 {
11+
| ^^
12+
= note: but lifetime parameter must outlive the static lifetime
1213

1314
error: aborting due to previous error
1415

15-
For more information about this error, try `rustc --explain E0477`.
16+
For more information about this error, try `rustc --explain E0478`.

0 commit comments

Comments
 (0)