From 7d96f2c4814cdf07860d31e8e8b9695eb9628972 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 20 Nov 2018 12:25:44 +0100 Subject: [PATCH] Document qualify_consts more --- src/librustc_mir/transform/qualify_consts.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 1371b9a99770..f8ecd9634579 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -247,11 +247,16 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { let mut dest = dest; let index = loop { match dest { + // with `const_let` active, we treat all locals equal Place::Local(index) => break *index, + // projections are transparent for assignments + // we qualify the entire destination at once, even if just a field would have + // stricter qualification Place::Projection(proj) => dest = &proj.base, Place::Promoted(..) => bug!("promoteds don't exist yet during promotion"), Place::Static(..) => { - // Catch more errors in the destination. + // Catch more errors in the destination. `visit_place` also checks that we + // do not try to access statics from constants or try to mutate statics self.visit_place( dest, PlaceContext::MutatingUse(MutatingUseContext::Store),