Rollup merge of #111038 - tmiasko:untainted-promoteds, r=compiler-errors
Leave promoteds untainted by errors when borrowck fails Previously, when borrowck failed it would taint all promoteds within the MIR body. An attempt to evaluated the promoteds would subsequently fail with spurious "note: erroneous constant used". For example: ```console ... note: erroneous constant used --> tests/ui/borrowck/tainted-promoteds.rs:7:9 | 7 | a = &0 * &1 * &2 * &3; | ^^ note: erroneous constant used --> tests/ui/borrowck/tainted-promoteds.rs:7:14 | 7 | a = &0 * &1 * &2 * &3; | ^^ note: erroneous constant used --> tests/ui/borrowck/tainted-promoteds.rs:7:19 | 7 | a = &0 * &1 * &2 * &3; | ^^ note: erroneous constant used --> tests/ui/borrowck/tainted-promoteds.rs:7:24 | 7 | a = &0 * &1 * &2 * &3; | ^^ ``` Borrowck failure doesn't indicate that there is anything wrong with promoteds. Leave them untainted. Fixes #110856.
This commit is contained in:
commit
f835b13812
3 changed files with 27 additions and 4 deletions
|
@ -616,13 +616,10 @@ fn promoted_mir(tcx: TyCtxt<'_>, def: LocalDefId) -> &IndexVec<Promoted, Body<'_
|
|||
return tcx.arena.alloc(IndexVec::new());
|
||||
}
|
||||
|
||||
let tainted_by_errors = tcx.mir_borrowck(def).tainted_by_errors;
|
||||
tcx.ensure_with_value().mir_borrowck(def);
|
||||
let mut promoted = tcx.mir_promoted(def).1.steal();
|
||||
|
||||
for body in &mut promoted {
|
||||
if let Some(error_reported) = tainted_by_errors {
|
||||
body.tainted_by_errors = Some(error_reported);
|
||||
}
|
||||
run_analysis_to_runtime_passes(tcx, body);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue