Rollup merge of #61023 - spastorino:use-iterate-qualify-consts, r=oli-obk
Migrate from recursion to iterate on qualify consts visitor impl r? @oli-obk
This commit is contained in:
commit
fba5ed355a
1 changed files with 51 additions and 49 deletions
|
@ -930,15 +930,15 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
||||||
context: PlaceContext,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
debug!("visit_place: place={:?} context={:?} location={:?}", place, context, location);
|
debug!("visit_place: place={:?} context={:?} location={:?}", place, context, location);
|
||||||
self.super_place(place, context, location);
|
place.iterate(|place_base, place_projections| {
|
||||||
match *place {
|
match place_base {
|
||||||
Place::Base(PlaceBase::Local(_)) => {}
|
PlaceBase::Local(_) => {}
|
||||||
Place::Base(PlaceBase::Static(box Static{ kind: StaticKind::Promoted(_), .. })) => {
|
PlaceBase::Static(box Static{ kind: StaticKind::Promoted(_), .. }) => {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
}
|
}
|
||||||
Place::Base(PlaceBase::Static(box Static{ kind: StaticKind::Static(def_id), .. })) => {
|
PlaceBase::Static(box Static{ kind: StaticKind::Static(def_id), .. }) => {
|
||||||
if self.tcx
|
if self.tcx
|
||||||
.get_attrs(def_id)
|
.get_attrs(*def_id)
|
||||||
.iter()
|
.iter()
|
||||||
.any(|attr| attr.check_name(sym::thread_local)) {
|
.any(|attr| attr.check_name(sym::thread_local)) {
|
||||||
if self.mode != Mode::Fn {
|
if self.mode != Mode::Fn {
|
||||||
|
@ -971,8 +971,8 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
||||||
a constant instead", self.mode);
|
a constant instead", self.mode);
|
||||||
if self.tcx.sess.teach(&err.get_code().unwrap()) {
|
if self.tcx.sess.teach(&err.get_code().unwrap()) {
|
||||||
err.note(
|
err.note(
|
||||||
"Static and const variables can refer to other const variables. But a \
|
"Static and const variables can refer to other const variables. \
|
||||||
const variable cannot refer to a static variable."
|
But a const variable cannot refer to a static variable."
|
||||||
);
|
);
|
||||||
err.help(
|
err.help(
|
||||||
"To fix this, the value can be extracted as a const and then used."
|
"To fix this, the value can be extracted as a const and then used."
|
||||||
|
@ -981,7 +981,9 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
||||||
err.emit()
|
err.emit()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Place::Projection(ref proj) => {
|
}
|
||||||
|
|
||||||
|
for proj in place_projections {
|
||||||
match proj.elem {
|
match proj.elem {
|
||||||
ProjectionElem::Deref => {
|
ProjectionElem::Deref => {
|
||||||
if context.is_mutating_use() {
|
if context.is_mutating_use() {
|
||||||
|
@ -1041,7 +1043,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
|
fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue