mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Do not ICE in privacy when type inference fails.
This commit is contained in:
parent
55cac26a9e
commit
9074427c69
@ -973,8 +973,12 @@ impl<'tcx> NamePrivacyVisitor<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
|
impl<'tcx> Visitor<'tcx> for NamePrivacyVisitor<'tcx> {
|
||||||
fn visit_nested_body(&mut self, body_id: hir::BodyId) {
|
fn visit_nested_body(&mut self, body_id: hir::BodyId) {
|
||||||
let old_maybe_typeck_results =
|
let new_typeck_results = self.tcx.typeck_body(body_id);
|
||||||
self.maybe_typeck_results.replace(self.tcx.typeck_body(body_id));
|
// Do not try reporting privacy violations if we failed to infer types.
|
||||||
|
if new_typeck_results.tainted_by_errors.is_some() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let old_maybe_typeck_results = self.maybe_typeck_results.replace(new_typeck_results);
|
||||||
self.visit_body(self.tcx.hir().body(body_id));
|
self.visit_body(self.tcx.hir().body(body_id));
|
||||||
self.maybe_typeck_results = old_maybe_typeck_results;
|
self.maybe_typeck_results = old_maybe_typeck_results;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
//@ known-bug: #122736
|
|
||||||
fn main_ref() {
|
fn main_ref() {
|
||||||
let array = [(); {
|
let array = [(); {
|
||||||
let mut x = &0;
|
let mut x = &0;
|
||||||
let mut n = 0;
|
let mut n = 0;
|
||||||
while n < 5 {
|
while n < 5 {
|
||||||
|
//~^ ERROR constant evaluation is taking a long time
|
||||||
x = &0;
|
x = &0;
|
||||||
}
|
}
|
||||||
0
|
0
|
27
tests/ui/privacy/no-ice-on-inference-failure.stderr
Normal file
27
tests/ui/privacy/no-ice-on-inference-failure.stderr
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
error: constant evaluation is taking a long time
|
||||||
|
--> $DIR/no-ice-on-inference-failure.rs:5:9
|
||||||
|
|
|
||||||
|
LL | / while n < 5 {
|
||||||
|
LL | |
|
||||||
|
LL | | x = &0;
|
||||||
|
LL | | }
|
||||||
|
| |_________^
|
||||||
|
|
|
||||||
|
= 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/no-ice-on-inference-failure.rs:2:22
|
||||||
|
|
|
||||||
|
LL | let array = [(); {
|
||||||
|
| ______________________^
|
||||||
|
LL | | let mut x = &0;
|
||||||
|
LL | | let mut n = 0;
|
||||||
|
LL | | while n < 5 {
|
||||||
|
... |
|
||||||
|
LL | | 0
|
||||||
|
LL | | }];
|
||||||
|
| |_____^
|
||||||
|
= note: `#[deny(long_running_const_eval)]` on by default
|
||||||
|
|
||||||
|
error: aborting due to 1 previous error
|
||||||
|
|
Loading…
Reference in New Issue
Block a user