Skip to content

Commit 4e792df

Browse files
authored
Rollup merge of #122749 - aliemjay:region-err, r=compiler-errors
make `type_flags(ReError) & HAS_ERROR` Self-explanatory. `TypeVisitableExt::references_error(ReError)` incorrectly returned `false`.
2 parents d53df5a + 0dc006b commit 4e792df

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

Lines changed: 0 additions & 4 deletions
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

Lines changed: 0 additions & 3 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 3 additions & 12 deletions
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

Lines changed: 1 addition & 0 deletions
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() {}
Lines changed: 19 additions & 2 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 18 additions & 3 deletions
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`.

0 commit comments

Comments
 (0)