File tree 3 files changed +34
-3
lines changed
compiler/rustc_privacy/src
3 files changed +34
-3
lines changed Original file line number Diff line number Diff line change @@ -973,8 +973,12 @@ impl<'tcx> NamePrivacyVisitor<'tcx> {
973
973
974
974
impl < ' tcx > Visitor < ' tcx > for NamePrivacyVisitor < ' tcx > {
975
975
fn visit_nested_body ( & mut self , body_id : hir:: BodyId ) {
976
- let old_maybe_typeck_results =
977
- self . maybe_typeck_results . replace ( self . tcx . typeck_body ( body_id) ) ;
976
+ let new_typeck_results = self . tcx . typeck_body ( body_id) ;
977
+ // Do not try reporting privacy violations if we failed to infer types.
978
+ if new_typeck_results. tainted_by_errors . is_some ( ) {
979
+ return ;
980
+ }
981
+ let old_maybe_typeck_results = self . maybe_typeck_results . replace ( new_typeck_results) ;
978
982
self . visit_body ( self . tcx . hir ( ) . body ( body_id) ) ;
979
983
self . maybe_typeck_results = old_maybe_typeck_results;
980
984
}
Original file line number Diff line number Diff line change 1
- //@ known-bug: #122736
2
1
fn main_ref ( ) {
3
2
let array = [ ( ) ; {
4
3
let mut x = & 0 ;
5
4
let mut n = 0 ;
6
5
while n < 5 {
6
+ //~^ ERROR constant evaluation is taking a long time
7
7
x = & 0 ;
8
8
}
9
9
0
Original file line number Diff line number Diff line change
1
+ error: constant evaluation is taking a long time
2
+ --> $DIR/no-ice-on-inference-failure.rs:5:9
3
+ |
4
+ LL | / while n < 5 {
5
+ LL | |
6
+ LL | | x = &0;
7
+ LL | | }
8
+ | |_________^
9
+ |
10
+ = note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
11
+ If your compilation actually takes a long time, you can safely allow the lint.
12
+ help: the constant being evaluated
13
+ --> $DIR/no-ice-on-inference-failure.rs:2:22
14
+ |
15
+ LL | let array = [(); {
16
+ | ______________________^
17
+ LL | | let mut x = &0;
18
+ LL | | let mut n = 0;
19
+ LL | | while n < 5 {
20
+ ... |
21
+ LL | | 0
22
+ LL | | }];
23
+ | |_____^
24
+ = note: `#[deny(long_running_const_eval)]` on by default
25
+
26
+ error: aborting due to 1 previous error
27
+
You can’t perform that action at this time.
0 commit comments