Rollup merge of #144998 - dianqk:visit-no-use-proj, r=cjgillot
mir: Do not modify NonUse in `super_projection_elem` Split from rust-lang/rust#142771. r? cjgillot
This commit is contained in:
commit
c152aa87a1
1 changed files with 20 additions and 14 deletions
|
|
@ -1205,18 +1205,19 @@ macro_rules! visit_place_fns {
|
|||
self.super_projection_elem(place_ref, elem, context, location);
|
||||
}
|
||||
|
||||
fn super_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) {
|
||||
let mut context = context;
|
||||
|
||||
if !place.projection.is_empty() {
|
||||
if context.is_use() {
|
||||
// ^ Only change the context if it is a real use, not a "use" in debuginfo.
|
||||
context = if context.is_mutating_use() {
|
||||
PlaceContext::MutatingUse(MutatingUseContext::Projection)
|
||||
} else {
|
||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection)
|
||||
};
|
||||
}
|
||||
fn super_place(
|
||||
&mut self,
|
||||
place: &Place<'tcx>,
|
||||
mut context: PlaceContext,
|
||||
location: Location,
|
||||
) {
|
||||
if !place.projection.is_empty() && context.is_use() {
|
||||
// ^ Only change the context if it is a real use, not a "use" in debuginfo.
|
||||
context = if context.is_mutating_use() {
|
||||
PlaceContext::MutatingUse(MutatingUseContext::Projection)
|
||||
} else {
|
||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection)
|
||||
};
|
||||
}
|
||||
|
||||
self.visit_local(place.local, context, location);
|
||||
|
|
@ -1239,7 +1240,7 @@ macro_rules! visit_place_fns {
|
|||
&mut self,
|
||||
_place_ref: PlaceRef<'tcx>,
|
||||
elem: PlaceElem<'tcx>,
|
||||
_context: PlaceContext,
|
||||
context: PlaceContext,
|
||||
location: Location,
|
||||
) {
|
||||
match elem {
|
||||
|
|
@ -1252,7 +1253,12 @@ macro_rules! visit_place_fns {
|
|||
ProjectionElem::Index(local) => {
|
||||
self.visit_local(
|
||||
local,
|
||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy),
|
||||
if context.is_use() {
|
||||
// ^ Only change the context if it is a real use, not a "use" in debuginfo.
|
||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy)
|
||||
} else {
|
||||
context
|
||||
},
|
||||
location,
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue