Skip to content

Commit dce98c5

Browse files
committed
Avoid follow-up errors and ICEs after missing lifetime errors on data structures
1 parent 8c39ac9 commit dce98c5

22 files changed

+37
-211
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ build/
5050
/target
5151
/src/bootstrap/target
5252
/src/tools/x/target
53+
/inc-fat/
5354
# Created by default with `src/ci/docker/run.sh`
5455
/obj/
5556
/rustc-ice*

Diff for: compiler/rustc_infer/src/infer/mod.rs

+3
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
}

Diff for: tests/crashes/124083.rs

-9
This file was deleted.

Diff for: tests/crashes/124262.rs

-5
This file was deleted.

Diff for: tests/crashes/125155.rs

-17
This file was deleted.

Diff for: tests/crashes/125888.rs

-17
This file was deleted.

Diff for: tests/crashes/125992.rs

-19
This file was deleted.

Diff for: tests/crashes/126648.rs

-8
This file was deleted.

Diff for: tests/crashes/126666.rs

-18
This file was deleted.

Diff for: tests/crashes/127266.rs

-17
This file was deleted.

Diff for: tests/crashes/127304.rs

-20
This file was deleted.

Diff for: tests/rustdoc-ui/unable-fulfill-trait.rs

-1
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>

Diff for: tests/rustdoc-ui/unable-fulfill-trait.stderr

+3-20
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`.

Diff for: tests/ui/const-generics/issues/issue-71381.full.stderr

+3-15
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,13 @@ LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "
77
= note: type parameters may not be used in the type of const parameters
88

99
error[E0770]: the type of const parameters must not depend on other generic parameters
10-
--> $DIR/issue-71381.rs:24:40
10+
--> $DIR/issue-71381.rs:23:40
1111
|
1212
LL | const FN: unsafe extern "C" fn(Args),
1313
| ^^^^ the type must not depend on the parameter `Args`
1414
|
1515
= note: type parameters may not be used in the type of const parameters
1616

17-
error[E0594]: cannot assign to `self.0`, which is behind a `&` reference
18-
--> $DIR/issue-71381.rs:17:9
19-
|
20-
LL | self.0 = Self::trampiline::<Args, IDX, FN> as _
21-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
22-
|
23-
help: consider changing this to be a mutable reference
24-
|
25-
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&mut self) {
26-
| ~~~~~~~~~
27-
28-
error: aborting due to 3 previous errors
17+
error: aborting due to 2 previous errors
2918

30-
Some errors have detailed explanations: E0594, E0770.
31-
For more information about an error, try `rustc --explain E0594`.
19+
For more information about this error, try `rustc --explain E0770`.

Diff for: tests/ui/const-generics/issues/issue-71381.min.stderr

+4-16
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "
77
= note: type parameters may not be used in the type of const parameters
88

99
error[E0770]: the type of const parameters must not depend on other generic parameters
10-
--> $DIR/issue-71381.rs:24:40
10+
--> $DIR/issue-71381.rs:23:40
1111
|
1212
LL | const FN: unsafe extern "C" fn(Args),
1313
| ^^^^ the type must not depend on the parameter `Args`
@@ -23,25 +23,13 @@ LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "
2323
= note: the only supported types are integers, `bool` and `char`
2424

2525
error: using function pointers as const generic parameters is forbidden
26-
--> $DIR/issue-71381.rs:24:19
26+
--> $DIR/issue-71381.rs:23:19
2727
|
2828
LL | const FN: unsafe extern "C" fn(Args),
2929
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
3030
|
3131
= note: the only supported types are integers, `bool` and `char`
3232

33-
error[E0594]: cannot assign to `self.0`, which is behind a `&` reference
34-
--> $DIR/issue-71381.rs:17:9
35-
|
36-
LL | self.0 = Self::trampiline::<Args, IDX, FN> as _
37-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `self` is a `&` reference, so the data it refers to cannot be written
38-
|
39-
help: consider changing this to be a mutable reference
40-
|
41-
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&mut self) {
42-
| ~~~~~~~~~
43-
44-
error: aborting due to 5 previous errors
33+
error: aborting due to 4 previous errors
4534

46-
Some errors have detailed explanations: E0594, E0770.
47-
For more information about an error, try `rustc --explain E0594`.
35+
For more information about this error, try `rustc --explain E0770`.

Diff for: tests/ui/const-generics/issues/issue-71381.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ impl Test {
1515
//~^ ERROR: the type of const parameters must not depend on other generic parameters
1616
//[min]~^^ ERROR: using function pointers as const generic parameters is forbidden
1717
self.0 = Self::trampiline::<Args, IDX, FN> as _
18-
//~^ ERROR: cannot assign to `self.0`
1918
}
2019

2120
unsafe extern "C" fn trampiline<

Diff for: tests/ui/impl-trait/issue-72911.rs

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ fn gather_from_file(dir_entry: &foo::MissingItem) -> impl Iterator<Item = Lint>
1515

1616
fn lint_files() -> impl Iterator<Item = foo::MissingItem> {
1717
//~^ ERROR: failed to resolve
18-
//~| ERROR: `()` is not an iterator
1918
unimplemented!()
2019
}
2120

Diff for: tests/ui/impl-trait/issue-72911.stderr

+2-11
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
error[E0277]: `()` is not an iterator
2-
--> $DIR/issue-72911.rs:16:20
3-
|
4-
LL | fn lint_files() -> impl Iterator<Item = foo::MissingItem> {
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `()` is not an iterator
6-
|
7-
= help: the trait `Iterator` is not implemented for `()`
8-
91
error[E0433]: failed to resolve: use of undeclared crate or module `foo`
102
--> $DIR/issue-72911.rs:11:33
113
|
@@ -18,7 +10,6 @@ error[E0433]: failed to resolve: use of undeclared crate or module `foo`
1810
LL | fn lint_files() -> impl Iterator<Item = foo::MissingItem> {
1911
| ^^^ use of undeclared crate or module `foo`
2012

21-
error: aborting due to 3 previous errors
13+
error: aborting due to 2 previous errors
2214

23-
Some errors have detailed explanations: E0277, E0433.
24-
For more information about an error, try `rustc --explain E0277`.
15+
For more information about this error, try `rustc --explain E0433`.

Diff for: tests/ui/mismatched_types/issue-74918-missing-lifetime.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ impl<T, S: Iterator<Item = T>> Iterator for ChunkingIterator<T, S> {
99
type Item = IteratorChunk<T, S>; //~ ERROR missing lifetime
1010

1111
fn next(&mut self) -> Option<IteratorChunk<T, S>> {
12-
//~^ ERROR `impl` item signature doesn't match `trait` item signature
1312
todo!()
1413
}
1514
}

Diff for: tests/ui/mismatched_types/issue-74918-missing-lifetime.stderr

+1-15
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,6 @@ help: consider introducing a named lifetime parameter
99
LL | type Item<'a> = IteratorChunk<'a, T, S>;
1010
| ++++ +++
1111

12-
error: `impl` item signature doesn't match `trait` item signature
13-
--> $DIR/issue-74918-missing-lifetime.rs:11:5
14-
|
15-
LL | fn next(&mut self) -> Option<IteratorChunk<T, S>> {
16-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'1, T, S>>`
17-
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
18-
|
19-
= note: expected `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'2, T, S>>`
20-
|
21-
= note: expected signature `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'2, T, S>>`
22-
found signature `fn(&'1 mut ChunkingIterator<T, S>) -> Option<IteratorChunk<'1, T, S>>`
23-
= help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait`
24-
= help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output
25-
26-
error: aborting due to 2 previous errors
12+
error: aborting due to 1 previous error
2713

2814
For more information about this error, try `rustc --explain E0106`.

Diff for: tests/ui/statics/missing_lifetime.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//! This test checks that we taint typeck results when there are
2+
//! error lifetimes, even though typeck doesn't actually care about lifetimes.
3+
4+
struct Slice(&'reborrow [&'static [u8]]);
5+
//~^ ERROR undeclared lifetime
6+
7+
static MAP: Slice = Slice(&[b"" as &'static [u8]]);
8+
9+
fn main() {}

Diff for: tests/ui/statics/missing_lifetime.stderr

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0261]: use of undeclared lifetime name `'reborrow`
2+
--> $DIR/missing_lifetime.rs:4:15
3+
|
4+
LL | struct Slice(&'reborrow [&'static [u8]]);
5+
| - ^^^^^^^^^ undeclared lifetime
6+
| |
7+
| help: consider introducing lifetime `'reborrow` here: `<'reborrow>`
8+
9+
error: aborting due to 1 previous error
10+
11+
For more information about this error, try `rustc --explain E0261`.

0 commit comments

Comments
 (0)