Skip to content

Commit fa215ae

Browse files
authored
Unrolled build for rust-lang#122749
Rollup merge of rust-lang#122749 - aliemjay:region-err, r=compiler-errors make `type_flags(ReError) & HAS_ERROR` Self-explanatory. `TypeVisitableExt::references_error(ReError)` incorrectly returned `false`.
2 parents 6ec953c + 0dc006b commit fa215ae

File tree

49 files changed

+152
-625
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+152
-625
lines changed

compiler/rustc_borrowck/src/region_infer/opaque_types.rs

-4
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,6 @@ fn check_opaque_type_parameter_valid(
434434
// Only check the parent generics, which will ignore any of the
435435
// duplicated lifetime args that come from reifying late-bounds.
436436
for (i, arg) in opaque_type_key.args.iter().take(parent_generics.count()).enumerate() {
437-
if let Err(guar) = arg.error_reported() {
438-
return Err(guar);
439-
}
440-
441437
let arg_is_param = match arg.unpack() {
442438
GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)),
443439
GenericArgKind::Lifetime(lt) if is_ty_alias => {

compiler/rustc_infer/src/infer/opaque_types/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,6 @@ impl<'tcx> InferCtxt<'tcx> {
9494
cause: &ObligationCause<'tcx>,
9595
param_env: ty::ParamEnv<'tcx>,
9696
) -> InferResult<'tcx, ()> {
97-
if a.references_error() || b.references_error() {
98-
return Ok(InferOk { value: (), obligations: vec![] });
99-
}
10097
let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() {
10198
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) if def_id.is_local() => {
10299
let def_id = def_id.expect_local();

compiler/rustc_middle/src/ty/region.rs

+1
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@ impl<'tcx> Region<'tcx> {
251251
}
252252
ty::ReError(_) => {
253253
flags = flags | TypeFlags::HAS_FREE_REGIONS;
254+
flags = flags | TypeFlags::HAS_ERROR;
254255
}
255256
}
256257

compiler/rustc_type_ir/src/flags.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ bitflags! {
8585
| TypeFlags::HAS_TY_INHERENT.bits()
8686
| TypeFlags::HAS_CT_PROJECTION.bits();
8787

88-
/// Is an error type/const reachable?
88+
/// Is an error type/lifetime/const reachable?
8989
const HAS_ERROR = 1 << 15;
9090

9191
/// Does this have any region that "appears free" in the type?

tests/ui/async-await/in-trait/return-not-existing-pair.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ trait MyTrait<'a, 'b, T> {
99
impl<'a, 'b, T, U> MyTrait<T> for U {
1010
//~^ ERROR: implicit elided lifetime not allowed here [E0726]
1111
async fn foo(_: T) -> (&'a U, &'b T) {}
12-
//~^ ERROR: method `foo` has a `&self` declaration in the trait, but not in the impl [E0186]
13-
//~| ERROR: mismatched types [E0308]
12+
//~^ ERROR: mismatched types [E0308]
1413
}
1514

1615
fn main() {}

tests/ui/async-await/in-trait/return-not-existing-pair.stderr

+3-12
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,6 @@ error[E0412]: cannot find type `ConnImpl` in this scope
1515
LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
1616
| ^^^^^^^^ not found in this scope
1717

18-
error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl
19-
--> $DIR/return-not-existing-pair.rs:11:5
20-
|
21-
LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
22-
| ------------------------------------------------------------ `&self` used in trait
23-
...
24-
LL | async fn foo(_: T) -> (&'a U, &'b T) {}
25-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&self` in impl
26-
2718
error[E0308]: mismatched types
2819
--> $DIR/return-not-existing-pair.rs:11:42
2920
|
@@ -33,7 +24,7 @@ LL | async fn foo(_: T) -> (&'a U, &'b T) {}
3324
= note: expected tuple `(&'a U, &'b T)`
3425
found unit type `()`
3526

36-
error: aborting due to 4 previous errors
27+
error: aborting due to 3 previous errors
3728

38-
Some errors have detailed explanations: E0186, E0308, E0412, E0726.
39-
For more information about an error, try `rustc --explain E0186`.
29+
Some errors have detailed explanations: E0308, E0412, E0726.
30+
For more information about an error, try `rustc --explain E0308`.

tests/ui/async-await/in-trait/unconstrained-impl-region.rs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ impl<'a> Actor for () {
1414
//~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
1515
type Message = &'a ();
1616
async fn on_mount(self, _: impl Inbox<&'a ()>) {}
17+
//~^ ERROR the trait bound `impl Inbox<&'a ()>: Inbox<&'a ()>` is not satisfied
1718
}
1819

1920
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
1+
error[E0277]: the trait bound `impl Inbox<&'a ()>: Inbox<&'a ()>` is not satisfied
2+
--> $DIR/unconstrained-impl-region.rs:16:5
3+
|
4+
LL | async fn on_mount(self, _: impl Inbox<&'a ()>) {}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Inbox<&'a ()>` is not implemented for `impl Inbox<&'a ()>`
6+
|
7+
note: required by a bound in `<() as Actor>::on_mount`
8+
--> $DIR/unconstrained-impl-region.rs:16:37
9+
|
10+
LL | async fn on_mount(self, _: impl Inbox<&'a ()>) {}
11+
| ^^^^^^^^^^^^^ required by this bound in `<() as Actor>::on_mount`
12+
help: consider further restricting this bound
13+
|
14+
LL | async fn on_mount(self, _: impl Inbox<&'a ()> + Inbox<&'a ()>) {}
15+
| +++++++++++++++
16+
117
error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
218
--> $DIR/unconstrained-impl-region.rs:13:6
319
|
420
LL | impl<'a> Actor for () {
521
| ^^ unconstrained lifetime parameter
622

7-
error: aborting due to 1 previous error
23+
error: aborting due to 2 previous errors
824

9-
For more information about this error, try `rustc --explain E0207`.
25+
Some errors have detailed explanations: E0207, E0277.
26+
For more information about an error, try `rustc --explain E0207`.

tests/ui/const-generics/generic_const_exprs/issue-109141.rs

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
impl EntriesBuffer {
55
fn a(&self) -> impl Iterator {
66
self.0.iter_mut() //~ ERROR: cannot borrow `*self.0` as mutable, as it is behind a `&` reference
7+
//~| ERROR captures lifetime that does not appear in bounds
78
}
89
}
910

tests/ui/const-generics/generic_const_exprs/issue-109141.stderr

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0425]: cannot find value `HashesEntryLEN` in this scope
2-
--> $DIR/issue-109141.rs:10:32
2+
--> $DIR/issue-109141.rs:11:32
33
|
44
LL | struct EntriesBuffer(Box<[[u8; HashesEntryLEN]; 5]>);
55
| ^^^^^^^^^^^^^^ not found in this scope
@@ -20,7 +20,22 @@ help: consider changing this to be a mutable reference
2020
LL | fn a(&mut self) -> impl Iterator {
2121
| ~~~~~~~~~
2222

23-
error: aborting due to 2 previous errors
23+
error[E0700]: hidden type for `impl Iterator` captures lifetime that does not appear in bounds
24+
--> $DIR/issue-109141.rs:6:9
25+
|
26+
LL | fn a(&self) -> impl Iterator {
27+
| ----- ------------- opaque type defined here
28+
| |
29+
| hidden type `std::slice::IterMut<'_, [u8; {const error}]>` captures the anonymous lifetime defined here
30+
LL | self.0.iter_mut()
31+
| ^^^^^^^^^^^^^^^^^
32+
|
33+
help: to declare that `impl Iterator` captures `'_`, you can add an explicit `'_` lifetime bound
34+
|
35+
LL | fn a(&self) -> impl Iterator + '_ {
36+
| ++++
37+
38+
error: aborting due to 3 previous errors
2439

25-
Some errors have detailed explanations: E0425, E0596.
40+
Some errors have detailed explanations: E0425, E0596, E0700.
2641
For more information about an error, try `rustc --explain E0425`.

tests/ui/const-generics/late-bound-vars/late-bound-in-return-issue-77357.stderr

+1-42
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,5 @@ error: cannot capture late-bound lifetime in constant
44
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
55
| -- lifetime defined here ^^
66

7-
error: overly complex generic constant
8-
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
9-
|
10-
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
11-
| ^^^^^^^^^^^^^^^^^^^^^^^^^ blocks are not supported in generic constants
12-
|
13-
= help: consider moving this anonymous constant into a `const` function
14-
= note: this operation may be supported in the future
15-
16-
error[E0391]: cycle detected when evaluating type-level constant
17-
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
18-
|
19-
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
20-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
21-
|
22-
note: ...which requires const-evaluating + checking `bug::{constant#0}`...
23-
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
24-
|
25-
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
26-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
27-
note: ...which requires caching mir of `bug::{constant#0}` for CTFE...
28-
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
29-
|
30-
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
31-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
32-
note: ...which requires elaborating drops for `bug::{constant#0}`...
33-
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
34-
|
35-
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
36-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
37-
note: ...which requires borrow-checking `bug::{constant#0}`...
38-
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
39-
|
40-
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
41-
| ^^^^^^^^^^^^^^^^^^^^^^^^^
42-
= note: ...which requires normalizing `Binder { value: ConstEvaluatable(UnevaluatedConst { def: DefId(0:8 ~ late_bound_in_return_issue_77357[9394]::bug::{constant#0}), args: [T/#0] }: usize), bound_vars: [] }`...
43-
= note: ...which again requires evaluating type-level constant, completing the cycle
44-
= note: cycle used when normalizing `&dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]>`
45-
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
46-
47-
error: aborting due to 3 previous errors
7+
error: aborting due to 1 previous error
488

49-
For more information about this error, try `rustc --explain E0391`.

tests/ui/error-codes/E0637.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
22
//~^ ERROR: `'_` cannot be used here [E0637]
33
//~| ERROR: missing lifetime specifier
44
if str1.len() > str2.len() {
5-
str1 //~ ERROR: lifetime may not live long enough
5+
str1
66
} else {
7-
str2 //~ ERROR: lifetime may not live long enough
7+
str2
88
}
99
}
1010

tests/ui/error-codes/E0637.stderr

+1-19
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,7 @@ help: consider introducing a higher-ranked lifetime here
2727
LL | T: for<'a> Into<&'a u32>,
2828
| +++++++ ++
2929

30-
error: lifetime may not live long enough
31-
--> $DIR/E0637.rs:5:9
32-
|
33-
LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
34-
| - let's call the lifetime of this reference `'1`
35-
...
36-
LL | str1
37-
| ^^^^ returning this value requires that `'1` must outlive `'static`
38-
39-
error: lifetime may not live long enough
40-
--> $DIR/E0637.rs:7:9
41-
|
42-
LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
43-
| - let's call the lifetime of this reference `'2`
44-
...
45-
LL | str2
46-
| ^^^^ returning this value requires that `'2` must outlive `'static`
47-
48-
error: aborting due to 5 previous errors
30+
error: aborting due to 3 previous errors
4931

5032
Some errors have detailed explanations: E0106, E0637.
5133
For more information about an error, try `rustc --explain E0106`.

tests/ui/generic-associated-types/issue-80433.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ fn test_simpler<'a>(dst: &'a mut impl TestMut<Output = &'a mut f32>)
2929

3030
fn main() {
3131
let mut t1: E<f32> = Default::default();
32-
test_simpler(&mut t1); //~ ERROR does not live long enough
32+
test_simpler(&mut t1);
3333
}

tests/ui/generic-associated-types/issue-80433.stderr

+2-15
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,7 @@ LL | *dst.test_mut() = n.into();
4848
| `dst` escapes the function body here
4949
| argument requires that `'a` must outlive `'static`
5050

51-
error[E0597]: `t1` does not live long enough
52-
--> $DIR/issue-80433.rs:32:18
53-
|
54-
LL | let mut t1: E<f32> = Default::default();
55-
| ------ binding `t1` declared here
56-
LL | test_simpler(&mut t1);
57-
| -------------^^^^^^^-
58-
| | |
59-
| | borrowed value does not live long enough
60-
| argument requires that `t1` is borrowed for `'static`
61-
LL | }
62-
| - `t1` dropped here while still borrowed
63-
64-
error: aborting due to 5 previous errors
51+
error: aborting due to 4 previous errors
6552

66-
Some errors have detailed explanations: E0107, E0499, E0521, E0597.
53+
Some errors have detailed explanations: E0107, E0499, E0521.
6754
For more information about an error, try `rustc --explain E0107`.

tests/ui/impl-trait/impl-fn-hrtb-bounds.rs

-3
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ use std::fmt::Debug;
44
fn a() -> impl Fn(&u8) -> (impl Debug + '_) {
55
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
66
|x| x
7-
//~^ ERROR lifetime may not live long enough
87
}
98

109
fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
1110
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
1211
|x| x
13-
//~^ ERROR lifetime may not live long enough
1412
}
1513

1614
fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
1715
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
1816
|x| x
19-
//~^ ERROR lifetime may not live long enough
2017
}
2118

2219
fn d() -> impl Fn() -> (impl Debug + '_) {
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0106]: missing lifetime specifier
2-
--> $DIR/impl-fn-hrtb-bounds.rs:22:38
2+
--> $DIR/impl-fn-hrtb-bounds.rs:19:38
33
|
44
LL | fn d() -> impl Fn() -> (impl Debug + '_) {
55
| ^^ expected named lifetime parameter
@@ -22,58 +22,31 @@ note: lifetime declared here
2222
LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) {
2323
| ^
2424

25-
error: lifetime may not live long enough
26-
--> $DIR/impl-fn-hrtb-bounds.rs:6:9
27-
|
28-
LL | |x| x
29-
| -- ^ returning this value requires that `'1` must outlive `'2`
30-
| ||
31-
| |return type of closure is impl Debug + '2
32-
| has type `&'1 u8`
33-
3425
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
35-
--> $DIR/impl-fn-hrtb-bounds.rs:10:52
26+
--> $DIR/impl-fn-hrtb-bounds.rs:9:52
3627
|
3728
LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
3829
| ^^
3930
|
4031
note: lifetime declared here
41-
--> $DIR/impl-fn-hrtb-bounds.rs:10:20
32+
--> $DIR/impl-fn-hrtb-bounds.rs:9:20
4233
|
4334
LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
4435
| ^^
4536

46-
error: lifetime may not live long enough
47-
--> $DIR/impl-fn-hrtb-bounds.rs:12:9
48-
|
49-
LL | |x| x
50-
| -- ^ returning this value requires that `'1` must outlive `'2`
51-
| ||
52-
| |return type of closure is impl Debug + '2
53-
| has type `&'1 u8`
54-
5537
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
56-
--> $DIR/impl-fn-hrtb-bounds.rs:16:52
38+
--> $DIR/impl-fn-hrtb-bounds.rs:14:52
5739
|
5840
LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
5941
| ^^
6042
|
6143
note: lifetime declared here
62-
--> $DIR/impl-fn-hrtb-bounds.rs:16:20
44+
--> $DIR/impl-fn-hrtb-bounds.rs:14:20
6345
|
6446
LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
6547
| ^^
6648

67-
error: lifetime may not live long enough
68-
--> $DIR/impl-fn-hrtb-bounds.rs:18:9
69-
|
70-
LL | |x| x
71-
| -- ^ returning this value requires that `'1` must outlive `'2`
72-
| ||
73-
| |return type of closure is impl Debug + '2
74-
| has type `&'1 u8`
75-
76-
error: aborting due to 7 previous errors
49+
error: aborting due to 4 previous errors
7750

7851
Some errors have detailed explanations: E0106, E0657.
7952
For more information about an error, try `rustc --explain E0106`.

tests/ui/impl-trait/impl-fn-parsing-ambiguities.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ fn a() -> impl Fn(&u8) -> impl Debug + '_ {
55
//~^ ERROR ambiguous `+` in a type
66
//~| ERROR cannot capture higher-ranked lifetime from outer `impl Trait`
77
|x| x
8-
//~^ ERROR lifetime may not live long enough
98
}
109

1110
fn b() -> impl Fn() -> impl Debug + Send {

tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr

+2-11
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ {
55
| ^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + '_)`
66

77
error: ambiguous `+` in a type
8-
--> $DIR/impl-fn-parsing-ambiguities.rs:11:24
8+
--> $DIR/impl-fn-parsing-ambiguities.rs:10:24
99
|
1010
LL | fn b() -> impl Fn() -> impl Debug + Send {
1111
| ^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + Send)`
@@ -22,15 +22,6 @@ note: lifetime declared here
2222
LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ {
2323
| ^
2424

25-
error: lifetime may not live long enough
26-
--> $DIR/impl-fn-parsing-ambiguities.rs:7:9
27-
|
28-
LL | |x| x
29-
| -- ^ returning this value requires that `'1` must outlive `'2`
30-
| ||
31-
| |return type of closure is impl Debug + '2
32-
| has type `&'1 u8`
33-
34-
error: aborting due to 4 previous errors
25+
error: aborting due to 3 previous errors
3526

3627
For more information about this error, try `rustc --explain E0657`.

0 commit comments

Comments
 (0)