Skip to content

Commit

Permalink
Unrolled build for rust-lang#122749
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
rust-timer authored Mar 21, 2024
2 parents 6ec953c + 0dc006b commit fa215ae
Show file tree
Hide file tree
Showing 49 changed files with 152 additions and 625 deletions.
4 changes: 0 additions & 4 deletions compiler/rustc_borrowck/src/region_infer/opaque_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,6 @@ fn check_opaque_type_parameter_valid(
// Only check the parent generics, which will ignore any of the
// duplicated lifetime args that come from reifying late-bounds.
for (i, arg) in opaque_type_key.args.iter().take(parent_generics.count()).enumerate() {
if let Err(guar) = arg.error_reported() {
return Err(guar);
}

let arg_is_param = match arg.unpack() {
GenericArgKind::Type(ty) => matches!(ty.kind(), ty::Param(_)),
GenericArgKind::Lifetime(lt) if is_ty_alias => {
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_infer/src/infer/opaque_types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ impl<'tcx> InferCtxt<'tcx> {
cause: &ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>,
) -> InferResult<'tcx, ()> {
if a.references_error() || b.references_error() {
return Ok(InferOk { value: (), obligations: vec![] });
}
let process = |a: Ty<'tcx>, b: Ty<'tcx>| match *a.kind() {
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) if def_id.is_local() => {
let def_id = def_id.expect_local();
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ impl<'tcx> Region<'tcx> {
}
ty::ReError(_) => {
flags = flags | TypeFlags::HAS_FREE_REGIONS;
flags = flags | TypeFlags::HAS_ERROR;
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_type_ir/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bitflags! {
| TypeFlags::HAS_TY_INHERENT.bits()
| TypeFlags::HAS_CT_PROJECTION.bits();

/// Is an error type/const reachable?
/// Is an error type/lifetime/const reachable?
const HAS_ERROR = 1 << 15;

/// Does this have any region that "appears free" in the type?
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/async-await/in-trait/return-not-existing-pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ trait MyTrait<'a, 'b, T> {
impl<'a, 'b, T, U> MyTrait<T> for U {
//~^ ERROR: implicit elided lifetime not allowed here [E0726]
async fn foo(_: T) -> (&'a U, &'b T) {}
//~^ ERROR: method `foo` has a `&self` declaration in the trait, but not in the impl [E0186]
//~| ERROR: mismatched types [E0308]
//~^ ERROR: mismatched types [E0308]
}

fn main() {}
15 changes: 3 additions & 12 deletions tests/ui/async-await/in-trait/return-not-existing-pair.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@ error[E0412]: cannot find type `ConnImpl` in this scope
LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
| ^^^^^^^^ not found in this scope

error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl
--> $DIR/return-not-existing-pair.rs:11:5
|
LL | async fn foo(&'a self, key: &'b T) -> (&'a ConnImpl, &'b T);
| ------------------------------------------------------------ `&self` used in trait
...
LL | async fn foo(_: T) -> (&'a U, &'b T) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&self` in impl

error[E0308]: mismatched types
--> $DIR/return-not-existing-pair.rs:11:42
|
Expand All @@ -33,7 +24,7 @@ LL | async fn foo(_: T) -> (&'a U, &'b T) {}
= note: expected tuple `(&'a U, &'b T)`
found unit type `()`

error: aborting due to 4 previous errors
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0186, E0308, E0412, E0726.
For more information about an error, try `rustc --explain E0186`.
Some errors have detailed explanations: E0308, E0412, E0726.
For more information about an error, try `rustc --explain E0308`.
1 change: 1 addition & 0 deletions tests/ui/async-await/in-trait/unconstrained-impl-region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ impl<'a> Actor for () {
//~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
type Message = &'a ();
async fn on_mount(self, _: impl Inbox<&'a ()>) {}
//~^ ERROR the trait bound `impl Inbox<&'a ()>: Inbox<&'a ()>` is not satisfied
}

fn main() {}
21 changes: 19 additions & 2 deletions tests/ui/async-await/in-trait/unconstrained-impl-region.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,26 @@
error[E0277]: the trait bound `impl Inbox<&'a ()>: Inbox<&'a ()>` is not satisfied
--> $DIR/unconstrained-impl-region.rs:16:5
|
LL | async fn on_mount(self, _: impl Inbox<&'a ()>) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Inbox<&'a ()>` is not implemented for `impl Inbox<&'a ()>`
|
note: required by a bound in `<() as Actor>::on_mount`
--> $DIR/unconstrained-impl-region.rs:16:37
|
LL | async fn on_mount(self, _: impl Inbox<&'a ()>) {}
| ^^^^^^^^^^^^^ required by this bound in `<() as Actor>::on_mount`
help: consider further restricting this bound
|
LL | async fn on_mount(self, _: impl Inbox<&'a ()> + Inbox<&'a ()>) {}
| +++++++++++++++

error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates
--> $DIR/unconstrained-impl-region.rs:13:6
|
LL | impl<'a> Actor for () {
| ^^ unconstrained lifetime parameter

error: aborting due to 1 previous error
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0207`.
Some errors have detailed explanations: E0207, E0277.
For more information about an error, try `rustc --explain E0207`.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
impl EntriesBuffer {
fn a(&self) -> impl Iterator {
self.0.iter_mut() //~ ERROR: cannot borrow `*self.0` as mutable, as it is behind a `&` reference
//~| ERROR captures lifetime that does not appear in bounds
}
}

Expand Down
21 changes: 18 additions & 3 deletions tests/ui/const-generics/generic_const_exprs/issue-109141.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0425]: cannot find value `HashesEntryLEN` in this scope
--> $DIR/issue-109141.rs:10:32
--> $DIR/issue-109141.rs:11:32
|
LL | struct EntriesBuffer(Box<[[u8; HashesEntryLEN]; 5]>);
| ^^^^^^^^^^^^^^ not found in this scope
Expand All @@ -20,7 +20,22 @@ help: consider changing this to be a mutable reference
LL | fn a(&mut self) -> impl Iterator {
| ~~~~~~~~~

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

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0425, E0596.
Some errors have detailed explanations: E0425, E0596, E0700.
For more information about an error, try `rustc --explain E0425`.
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,5 @@ error: cannot capture late-bound lifetime in constant
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
| -- lifetime defined here ^^

error: overly complex generic constant
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ blocks are not supported in generic constants
|
= help: consider moving this anonymous constant into a `const` function
= note: this operation may be supported in the future

error[E0391]: cycle detected when evaluating type-level constant
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: ...which requires const-evaluating + checking `bug::{constant#0}`...
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires caching mir of `bug::{constant#0}` for CTFE...
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires elaborating drops for `bug::{constant#0}`...
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires borrow-checking `bug::{constant#0}`...
--> $DIR/late-bound-in-return-issue-77357.rs:9:46
|
LL | fn bug<'a, T>() -> &'static dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
= 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: [] }`...
= note: ...which again requires evaluating type-level constant, completing the cycle
= note: cycle used when normalizing `&dyn MyTrait<[(); { |x: &'a u32| { x }; 4 }]>`
= 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

error: aborting due to 3 previous errors
error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0391`.
4 changes: 2 additions & 2 deletions tests/ui/error-codes/E0637.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
//~^ ERROR: `'_` cannot be used here [E0637]
//~| ERROR: missing lifetime specifier
if str1.len() > str2.len() {
str1 //~ ERROR: lifetime may not live long enough
str1
} else {
str2 //~ ERROR: lifetime may not live long enough
str2
}
}

Expand Down
20 changes: 1 addition & 19 deletions tests/ui/error-codes/E0637.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,7 @@ help: consider introducing a higher-ranked lifetime here
LL | T: for<'a> Into<&'a u32>,
| +++++++ ++

error: lifetime may not live long enough
--> $DIR/E0637.rs:5:9
|
LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
| - let's call the lifetime of this reference `'1`
...
LL | str1
| ^^^^ returning this value requires that `'1` must outlive `'static`

error: lifetime may not live long enough
--> $DIR/E0637.rs:7:9
|
LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str {
| - let's call the lifetime of this reference `'2`
...
LL | str2
| ^^^^ returning this value requires that `'2` must outlive `'static`

error: aborting due to 5 previous errors
error: aborting due to 3 previous errors

Some errors have detailed explanations: E0106, E0637.
For more information about an error, try `rustc --explain E0106`.
2 changes: 1 addition & 1 deletion tests/ui/generic-associated-types/issue-80433.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ fn test_simpler<'a>(dst: &'a mut impl TestMut<Output = &'a mut f32>)

fn main() {
let mut t1: E<f32> = Default::default();
test_simpler(&mut t1); //~ ERROR does not live long enough
test_simpler(&mut t1);
}
17 changes: 2 additions & 15 deletions tests/ui/generic-associated-types/issue-80433.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,7 @@ LL | *dst.test_mut() = n.into();
| `dst` escapes the function body here
| argument requires that `'a` must outlive `'static`

error[E0597]: `t1` does not live long enough
--> $DIR/issue-80433.rs:32:18
|
LL | let mut t1: E<f32> = Default::default();
| ------ binding `t1` declared here
LL | test_simpler(&mut t1);
| -------------^^^^^^^-
| | |
| | borrowed value does not live long enough
| argument requires that `t1` is borrowed for `'static`
LL | }
| - `t1` dropped here while still borrowed

error: aborting due to 5 previous errors
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0107, E0499, E0521, E0597.
Some errors have detailed explanations: E0107, E0499, E0521.
For more information about an error, try `rustc --explain E0107`.
3 changes: 0 additions & 3 deletions tests/ui/impl-trait/impl-fn-hrtb-bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ use std::fmt::Debug;
fn a() -> impl Fn(&u8) -> (impl Debug + '_) {
//~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
|x| x
//~^ ERROR lifetime may not live long enough
}

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

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

fn d() -> impl Fn() -> (impl Debug + '_) {
Expand Down
39 changes: 6 additions & 33 deletions tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0106]: missing lifetime specifier
--> $DIR/impl-fn-hrtb-bounds.rs:22:38
--> $DIR/impl-fn-hrtb-bounds.rs:19:38
|
LL | fn d() -> impl Fn() -> (impl Debug + '_) {
| ^^ expected named lifetime parameter
Expand All @@ -22,58 +22,31 @@ note: lifetime declared here
LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) {
| ^

error: lifetime may not live long enough
--> $DIR/impl-fn-hrtb-bounds.rs:6:9
|
LL | |x| x
| -- ^ returning this value requires that `'1` must outlive `'2`
| ||
| |return type of closure is impl Debug + '2
| has type `&'1 u8`

error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
--> $DIR/impl-fn-hrtb-bounds.rs:10:52
--> $DIR/impl-fn-hrtb-bounds.rs:9:52
|
LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
| ^^
|
note: lifetime declared here
--> $DIR/impl-fn-hrtb-bounds.rs:10:20
--> $DIR/impl-fn-hrtb-bounds.rs:9:20
|
LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
| ^^

error: lifetime may not live long enough
--> $DIR/impl-fn-hrtb-bounds.rs:12:9
|
LL | |x| x
| -- ^ returning this value requires that `'1` must outlive `'2`
| ||
| |return type of closure is impl Debug + '2
| has type `&'1 u8`

error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
--> $DIR/impl-fn-hrtb-bounds.rs:16:52
--> $DIR/impl-fn-hrtb-bounds.rs:14:52
|
LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
| ^^
|
note: lifetime declared here
--> $DIR/impl-fn-hrtb-bounds.rs:16:20
--> $DIR/impl-fn-hrtb-bounds.rs:14:20
|
LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
| ^^

error: lifetime may not live long enough
--> $DIR/impl-fn-hrtb-bounds.rs:18:9
|
LL | |x| x
| -- ^ returning this value requires that `'1` must outlive `'2`
| ||
| |return type of closure is impl Debug + '2
| has type `&'1 u8`

error: aborting due to 7 previous errors
error: aborting due to 4 previous errors

Some errors have detailed explanations: E0106, E0657.
For more information about an error, try `rustc --explain E0106`.
1 change: 0 additions & 1 deletion tests/ui/impl-trait/impl-fn-parsing-ambiguities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ fn a() -> impl Fn(&u8) -> impl Debug + '_ {
//~^ ERROR ambiguous `+` in a type
//~| ERROR cannot capture higher-ranked lifetime from outer `impl Trait`
|x| x
//~^ ERROR lifetime may not live long enough
}

fn b() -> impl Fn() -> impl Debug + Send {
Expand Down
13 changes: 2 additions & 11 deletions tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ {
| ^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + '_)`

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

error: lifetime may not live long enough
--> $DIR/impl-fn-parsing-ambiguities.rs:7:9
|
LL | |x| x
| -- ^ returning this value requires that `'1` must outlive `'2`
| ||
| |return type of closure is impl Debug + '2
| has type `&'1 u8`

error: aborting due to 4 previous errors
error: aborting due to 3 previous errors

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

0 comments on commit fa215ae

Please sign in to comment.