Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 567809d

Browse files
committed
Auto merge of rust-lang#127311 - oli-obk:do_not_count_errors, r=compiler-errors
Avoid follow-up errors and ICEs after missing lifetime errors on data structures Tuple struct constructors are functions, so when we call them typeck will use the signature tuple struct constructor function to provide type hints. Since typeck mostly ignores and erases lifetimes, we end up never seeing the error lifetime in writeback, thus not tainting the typeck result. Now, we eagerly taint typeck results by tainting from `resolve_vars_if_possible`, which is called all over the place. I did not carry over all the `crashes` test suite tests, as they are really all the same cause (missing or unknown lifetime names in tuple struct definitions or generic arg lists). fixes rust-lang#124262 fixes rust-lang#124083 fixes rust-lang#125155 fixes rust-lang#125888 fixes rust-lang#125992 fixes rust-lang#126666 fixes rust-lang#126648 fixes rust-lang#127268
2 parents 6be96e3 + 2d5b2d8 commit 567809d

23 files changed

+48
-225
lines changed

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,9 @@ impl<'tcx> InferCtxt<'tcx> {
12641264
where
12651265
T: TypeFoldable<TyCtxt<'tcx>>,
12661266
{
1267+
if let Err(guar) = value.error_reported() {
1268+
self.set_tainted_by_errors(guar);
1269+
}
12671270
if !value.has_non_region_infer() {
12681271
return value;
12691272
}

tests/crashes/124083.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/crashes/124262.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/crashes/125155.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/crashes/125888.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/crashes/125992.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/crashes/126648.rs

Lines changed: 0 additions & 8 deletions
This file was deleted.

tests/crashes/126666.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/rustdoc-ui/unable-fulfill-trait.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub struct Foo<'a, 'b, T> {
44
field1: dyn Bar<'a, 'b>,
55
//~^ ERROR
66
//~| ERROR
7-
//~| ERROR
87
}
98

109
pub trait Bar<'x, 's, U>

tests/rustdoc-ui/unable-fulfill-trait.stderr

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | field1: dyn Bar<'a, 'b>,
55
| ^^^ expected 1 generic argument
66
|
77
note: trait defined here, with 1 generic parameter: `U`
8-
--> $DIR/unable-fulfill-trait.rs:10:11
8+
--> $DIR/unable-fulfill-trait.rs:9:11
99
|
1010
LL | pub trait Bar<'x, 's, U>
1111
| ^^^ -
@@ -20,24 +20,7 @@ error[E0227]: ambiguous lifetime bound, explicit lifetime bound required
2020
LL | field1: dyn Bar<'a, 'b>,
2121
| ^^^^^^^^^^^^^^^
2222

23-
error[E0478]: lifetime bound not satisfied
24-
--> $DIR/unable-fulfill-trait.rs:4:13
25-
|
26-
LL | field1: dyn Bar<'a, 'b>,
27-
| ^^^^^^^^^^^^^^^
28-
|
29-
note: lifetime parameter instantiated with the lifetime `'b` as defined here
30-
--> $DIR/unable-fulfill-trait.rs:3:20
31-
|
32-
LL | pub struct Foo<'a, 'b, T> {
33-
| ^^
34-
note: but lifetime parameter must outlive the lifetime `'a` as defined here
35-
--> $DIR/unable-fulfill-trait.rs:3:16
36-
|
37-
LL | pub struct Foo<'a, 'b, T> {
38-
| ^^
39-
40-
error: aborting due to 3 previous errors
23+
error: aborting due to 2 previous errors
4124

42-
Some errors have detailed explanations: E0107, E0227, E0478.
25+
Some errors have detailed explanations: E0107, E0227.
4326
For more information about an error, try `rustc --explain E0107`.

0 commit comments

Comments
 (0)