Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue-125323: ICE non-ADT in struct pattern when long time constant evaluation is in for loop #138679

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
}

fn report_error(&self, p: impl Into<ty::GenericArg<'tcx>>) -> ErrorGuaranteed {
if let Some(guar) = self.fcx.tainted_by_errors() {
if let Some(guar) = self.fcx.dcx().has_errors_excluding_lint_errors() {
guar
} else {
self.fcx
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ impl<'tcx> MarkSymbolVisitor<'tcx> {
self.insert_def_id(def.non_enum_variant().fields[index].did);
}
ty::Tuple(..) => {}
ty::Error(_) => {}
kind => span_bug!(lhs.span, "named field access on non-ADT: {kind:?}"),
}
}
Expand Down
6 changes: 0 additions & 6 deletions tests/crashes/125323.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Issue-125323
fn main() {
for _ in 0..0 { //~ ERROR type annotations needed [E0282]
[(); loop {}]; //~ ERROR constant evaluation is taking a long time
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
error: constant evaluation is taking a long time
--> $DIR/do-not-ice-long-constant-evaluation-in-for-loop.rs:4:14
|
LL | [(); loop {}];
| ^^^^^^^
|
= note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
If your compilation actually takes a long time, you can safely allow the lint.
help: the constant being evaluated
--> $DIR/do-not-ice-long-constant-evaluation-in-for-loop.rs:4:14
|
LL | [(); loop {}];
| ^^^^^^^
= note: `#[deny(long_running_const_eval)]` on by default

error[E0282]: type annotations needed
--> $DIR/do-not-ice-long-constant-evaluation-in-for-loop.rs:3:14
|
LL | for _ in 0..0 {
| ^^^^ cannot infer type for struct `std::ops::Range<{integer}>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0282`.
2 changes: 1 addition & 1 deletion tests/ui/consts/do-not-ice-on-field-access-of-err-type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ impl<T> Foo for T {}
fn main() {
let array = [(); { loop {} }]; //~ ERROR constant evaluation is taking a long time

let tup = (7,);
let tup = (7,); //~ ERROR type annotations needed for `({integer},)` [E0282]
let x: &dyn Foo = &tup.0;
}
14 changes: 13 additions & 1 deletion tests/ui/consts/do-not-ice-on-field-access-of-err-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,17 @@ LL | let array = [(); { loop {} }];
| ^^^^^^^^^^^
= note: `#[deny(long_running_const_eval)]` on by default

error: aborting due to 1 previous error
error[E0282]: type annotations needed for `({integer},)`
--> $DIR/do-not-ice-on-field-access-of-err-type.rs:7:9
|
LL | let tup = (7,);
| ^^^
|
help: consider giving `tup` an explicit type, where the type for tuple `({integer},)` is specified
|
LL | let tup: ({integer},) = (7,);
| ++++++++++++++

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0282`.
1 change: 1 addition & 0 deletions tests/ui/privacy/no-ice-on-inference-failure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ fn main_ref() {
}];

let mut ptrs: Vec<*const [u8]> = vec![&array[0..0], &array[0..1], &array, &array[1..]];
//~^ ERROR type annotations needed [E0282]
}

fn main() {}
9 changes: 8 additions & 1 deletion tests/ui/privacy/no-ice-on-inference-failure.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,12 @@ LL | | }];
| |_____^
= note: `#[deny(long_running_const_eval)]` on by default

error: aborting due to 1 previous error
error[E0282]: type annotations needed
--> $DIR/no-ice-on-inference-failure.rs:12:50
|
LL | let mut ptrs: Vec<*const [u8]> = vec![&array[0..0], &array[0..1], &array, &array[1..]];
| ^^^^ cannot infer type for struct `std::ops::Range<{integer}>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0282`.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ fn main() {
//~| ERROR cannot find type `T` in this scope
//~| ERROR const and type arguments are not allowed on builtin type `str`
//~| ERROR expected unit struct, unit variant or constant, found associated function `str<
//~| ERROR type annotations needed
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,7 @@ error[E0533]: expected unit struct, unit variant or constant, found associated f
LL | let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a unit struct, unit variant or constant

error[E0282]: type annotations needed
--> $DIR/ensure-overriding-bindings-in-pattern-with-ty-err-doesnt-ice.rs:2:31
|
LL | let str::<{fn str() { let str::T>>::as_bytes; }}, T>::as_bytes;
| ^^^^^^^^^^^^^^^^^^
|
help: consider giving this pattern a type
|
LL | let str::<{fn str() { let str::T>>::as_bytes: /* Type */; }}, T>::as_bytes;
| ++++++++++++

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

Some errors have detailed explanations: E0109, E0282, E0412, E0533.
Some errors have detailed explanations: E0109, E0412, E0533.
For more information about an error, try `rustc --explain E0109`.
Loading