mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 19:17:43 +00:00
Auto merge of #60389 - Centril:rollup-nefreyr, r=Centril
Rollup of 4 pull requests Successful merges: - #59869 (SGX target: implemented vectored I/O) - #60238 (Update rustfmt to 1.2.2) - #60276 (Cleanup the MIR visitor) - #60380 (Fix line number display in source view) Failed merges: r? @ghost
This commit is contained in:
commit
f843ad60ef
@ -2272,7 +2272,7 @@ dependencies = [
|
|||||||
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustc-workspace-hack 1.0.0",
|
"rustc-workspace-hack 1.0.0",
|
||||||
"rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"rustc_tools_util 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"rustfmt-nightly 1.2.1",
|
"rustfmt-nightly 1.2.2",
|
||||||
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_ignored 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -3090,7 +3090,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustfmt-nightly"
|
name = "rustfmt-nightly"
|
||||||
version = "1.2.1"
|
version = "1.2.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"annotate-snippets 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"annotate-snippets 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
"atty 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use crate::hir::def_id::DefId;
|
|
||||||
use crate::ty::subst::SubstsRef;
|
use crate::ty::subst::SubstsRef;
|
||||||
use crate::ty::{CanonicalUserTypeAnnotation, ClosureSubsts, GeneratorSubsts, Region, Ty};
|
use crate::ty::{CanonicalUserTypeAnnotation, ClosureSubsts, GeneratorSubsts, Ty};
|
||||||
use crate::mir::*;
|
use crate::mir::*;
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
|
|
||||||
@ -88,32 +87,28 @@ macro_rules! make_mir_visitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_statement(&mut self,
|
fn visit_statement(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
statement: & $($mutability)? Statement<'tcx>,
|
statement: & $($mutability)? Statement<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
self.super_statement(block, statement, location);
|
self.super_statement(statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_assign(&mut self,
|
fn visit_assign(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
place: & $($mutability)? Place<'tcx>,
|
place: & $($mutability)? Place<'tcx>,
|
||||||
rvalue: & $($mutability)? Rvalue<'tcx>,
|
rvalue: & $($mutability)? Rvalue<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
self.super_assign(block, place, rvalue, location);
|
self.super_assign(place, rvalue, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator(&mut self,
|
fn visit_terminator(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
terminator: & $($mutability)? Terminator<'tcx>,
|
terminator: & $($mutability)? Terminator<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
self.super_terminator(block, terminator, location);
|
self.super_terminator(terminator, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_kind(&mut self,
|
fn visit_terminator_kind(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
kind: & $($mutability)? TerminatorKind<'tcx>,
|
kind: & $($mutability)? TerminatorKind<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
self.super_terminator_kind(block, kind, location);
|
self.super_terminator_kind(kind, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_assert_message(&mut self,
|
fn visit_assert_message(&mut self,
|
||||||
@ -151,14 +146,14 @@ macro_rules! make_mir_visitor {
|
|||||||
|
|
||||||
fn visit_place(&mut self,
|
fn visit_place(&mut self,
|
||||||
place: & $($mutability)? Place<'tcx>,
|
place: & $($mutability)? Place<'tcx>,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
self.super_place(place, context, location);
|
self.super_place(place, context, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_projection(&mut self,
|
fn visit_projection(&mut self,
|
||||||
place: & $($mutability)? PlaceProjection<'tcx>,
|
place: & $($mutability)? PlaceProjection<'tcx>,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
self.super_projection(place, context, location);
|
self.super_projection(place, context, location);
|
||||||
}
|
}
|
||||||
@ -169,24 +164,12 @@ macro_rules! make_mir_visitor {
|
|||||||
self.super_projection_elem(place, location);
|
self.super_projection_elem(place, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_branch(&mut self,
|
|
||||||
source: BasicBlock,
|
|
||||||
target: BasicBlock) {
|
|
||||||
self.super_branch(source, target);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_constant(&mut self,
|
fn visit_constant(&mut self,
|
||||||
constant: & $($mutability)? Constant<'tcx>,
|
constant: & $($mutability)? Constant<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
self.super_constant(constant, location);
|
self.super_constant(constant, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_def_id(&mut self,
|
|
||||||
def_id: & $($mutability)? DefId,
|
|
||||||
_: Location) {
|
|
||||||
self.super_def_id(def_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_span(&mut self,
|
fn visit_span(&mut self,
|
||||||
span: & $($mutability)? Span) {
|
span: & $($mutability)? Span) {
|
||||||
self.super_span(span);
|
self.super_span(span);
|
||||||
@ -256,7 +239,7 @@ macro_rules! make_mir_visitor {
|
|||||||
|
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
_local: & $($mutability)? Local,
|
_local: & $($mutability)? Local,
|
||||||
_context: PlaceContext<'tcx>,
|
_context: PlaceContext,
|
||||||
_location: Location) {
|
_location: Location) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -327,13 +310,13 @@ macro_rules! make_mir_visitor {
|
|||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
for statement in statements {
|
for statement in statements {
|
||||||
let location = Location { block: block, statement_index: index };
|
let location = Location { block: block, statement_index: index };
|
||||||
self.visit_statement(block, statement, location);
|
self.visit_statement(statement, location);
|
||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(terminator) = terminator {
|
if let Some(terminator) = terminator {
|
||||||
let location = Location { block: block, statement_index: index };
|
let location = Location { block: block, statement_index: index };
|
||||||
self.visit_terminator(block, terminator, location);
|
self.visit_terminator(terminator, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +333,6 @@ macro_rules! make_mir_visitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn super_statement(&mut self,
|
fn super_statement(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
statement: & $($mutability)? Statement<'tcx>,
|
statement: & $($mutability)? Statement<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
let Statement {
|
let Statement {
|
||||||
@ -361,7 +343,7 @@ macro_rules! make_mir_visitor {
|
|||||||
self.visit_source_info(source_info);
|
self.visit_source_info(source_info);
|
||||||
match kind {
|
match kind {
|
||||||
StatementKind::Assign(place, rvalue) => {
|
StatementKind::Assign(place, rvalue) => {
|
||||||
self.visit_assign(block, place, rvalue, location);
|
self.visit_assign(place, rvalue, location);
|
||||||
}
|
}
|
||||||
StatementKind::FakeRead(_, place) => {
|
StatementKind::FakeRead(_, place) => {
|
||||||
self.visit_place(
|
self.visit_place(
|
||||||
@ -415,7 +397,6 @@ macro_rules! make_mir_visitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn super_assign(&mut self,
|
fn super_assign(&mut self,
|
||||||
_block: BasicBlock,
|
|
||||||
place: &$($mutability)? Place<'tcx>,
|
place: &$($mutability)? Place<'tcx>,
|
||||||
rvalue: &$($mutability)? Rvalue<'tcx>,
|
rvalue: &$($mutability)? Rvalue<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
@ -428,63 +409,55 @@ macro_rules! make_mir_visitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn super_terminator(&mut self,
|
fn super_terminator(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
terminator: &$($mutability)? Terminator<'tcx>,
|
terminator: &$($mutability)? Terminator<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
let Terminator { source_info, kind } = terminator;
|
let Terminator { source_info, kind } = terminator;
|
||||||
|
|
||||||
self.visit_source_info(source_info);
|
self.visit_source_info(source_info);
|
||||||
self.visit_terminator_kind(block, kind, location);
|
self.visit_terminator_kind(kind, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_terminator_kind(&mut self,
|
fn super_terminator_kind(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
kind: & $($mutability)? TerminatorKind<'tcx>,
|
kind: & $($mutability)? TerminatorKind<'tcx>,
|
||||||
source_location: Location) {
|
source_location: Location) {
|
||||||
match kind {
|
match kind {
|
||||||
TerminatorKind::Goto { target } => {
|
TerminatorKind::Goto { .. } |
|
||||||
self.visit_branch(block, *target);
|
TerminatorKind::Resume |
|
||||||
|
TerminatorKind::Abort |
|
||||||
|
TerminatorKind::Return |
|
||||||
|
TerminatorKind::GeneratorDrop |
|
||||||
|
TerminatorKind::Unreachable |
|
||||||
|
TerminatorKind::FalseEdges { .. } |
|
||||||
|
TerminatorKind::FalseUnwind { .. } => {
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminatorKind::SwitchInt {
|
TerminatorKind::SwitchInt {
|
||||||
discr,
|
discr,
|
||||||
switch_ty,
|
switch_ty,
|
||||||
values: _,
|
values: _,
|
||||||
targets
|
targets: _
|
||||||
} => {
|
} => {
|
||||||
self.visit_operand(discr, source_location);
|
self.visit_operand(discr, source_location);
|
||||||
self.visit_ty(switch_ty, TyContext::Location(source_location));
|
self.visit_ty(switch_ty, TyContext::Location(source_location));
|
||||||
for target in targets {
|
|
||||||
self.visit_branch(block, *target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TerminatorKind::Resume |
|
|
||||||
TerminatorKind::Abort |
|
|
||||||
TerminatorKind::Return |
|
|
||||||
TerminatorKind::GeneratorDrop |
|
|
||||||
TerminatorKind::Unreachable => {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminatorKind::Drop {
|
TerminatorKind::Drop {
|
||||||
location,
|
location,
|
||||||
target,
|
target: _,
|
||||||
unwind,
|
unwind: _,
|
||||||
} => {
|
} => {
|
||||||
self.visit_place(
|
self.visit_place(
|
||||||
location,
|
location,
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Drop),
|
PlaceContext::MutatingUse(MutatingUseContext::Drop),
|
||||||
source_location
|
source_location
|
||||||
);
|
);
|
||||||
self.visit_branch(block, *target);
|
|
||||||
unwind.map(|t| self.visit_branch(block, t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminatorKind::DropAndReplace {
|
TerminatorKind::DropAndReplace {
|
||||||
location,
|
location,
|
||||||
value,
|
value,
|
||||||
target,
|
target: _,
|
||||||
unwind,
|
unwind: _,
|
||||||
} => {
|
} => {
|
||||||
self.visit_place(
|
self.visit_place(
|
||||||
location,
|
location,
|
||||||
@ -492,68 +465,47 @@ macro_rules! make_mir_visitor {
|
|||||||
source_location
|
source_location
|
||||||
);
|
);
|
||||||
self.visit_operand(value, source_location);
|
self.visit_operand(value, source_location);
|
||||||
self.visit_branch(block, *target);
|
|
||||||
unwind.map(|t| self.visit_branch(block, t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminatorKind::Call {
|
TerminatorKind::Call {
|
||||||
func,
|
func,
|
||||||
args,
|
args,
|
||||||
destination,
|
destination,
|
||||||
cleanup,
|
cleanup: _,
|
||||||
from_hir_call: _,
|
from_hir_call: _,
|
||||||
} => {
|
} => {
|
||||||
self.visit_operand(func, source_location);
|
self.visit_operand(func, source_location);
|
||||||
for arg in args {
|
for arg in args {
|
||||||
self.visit_operand(arg, source_location);
|
self.visit_operand(arg, source_location);
|
||||||
}
|
}
|
||||||
if let Some((destination, target)) = destination {
|
if let Some((destination, _)) = destination {
|
||||||
self.visit_place(
|
self.visit_place(
|
||||||
destination,
|
destination,
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Call),
|
PlaceContext::MutatingUse(MutatingUseContext::Call),
|
||||||
source_location
|
source_location
|
||||||
);
|
);
|
||||||
self.visit_branch(block, *target);
|
|
||||||
}
|
}
|
||||||
cleanup.map(|t| self.visit_branch(block, t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminatorKind::Assert {
|
TerminatorKind::Assert {
|
||||||
cond,
|
cond,
|
||||||
expected: _,
|
expected: _,
|
||||||
msg,
|
msg,
|
||||||
target,
|
target: _,
|
||||||
cleanup,
|
cleanup: _,
|
||||||
} => {
|
} => {
|
||||||
self.visit_operand(cond, source_location);
|
self.visit_operand(cond, source_location);
|
||||||
self.visit_assert_message(msg, source_location);
|
self.visit_assert_message(msg, source_location);
|
||||||
self.visit_branch(block, *target);
|
|
||||||
cleanup.map(|t| self.visit_branch(block, t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminatorKind::Yield {
|
TerminatorKind::Yield {
|
||||||
value,
|
value,
|
||||||
resume,
|
resume: _,
|
||||||
drop,
|
drop: _,
|
||||||
} => {
|
} => {
|
||||||
self.visit_operand(value, source_location);
|
self.visit_operand(value, source_location);
|
||||||
self.visit_branch(block, *resume);
|
|
||||||
drop.map(|t| self.visit_branch(block, t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TerminatorKind::FalseEdges { real_target, imaginary_targets } => {
|
|
||||||
self.visit_branch(block, *real_target);
|
|
||||||
for target in imaginary_targets {
|
|
||||||
self.visit_branch(block, *target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TerminatorKind::FalseUnwind { real_target, unwind } => {
|
|
||||||
self.visit_branch(block, *real_target);
|
|
||||||
if let Some(unwind) = unwind {
|
|
||||||
self.visit_branch(block, *unwind);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -583,16 +535,16 @@ macro_rules! make_mir_visitor {
|
|||||||
self.visit_region(r, location);
|
self.visit_region(r, location);
|
||||||
let ctx = match bk {
|
let ctx = match bk {
|
||||||
BorrowKind::Shared => PlaceContext::NonMutatingUse(
|
BorrowKind::Shared => PlaceContext::NonMutatingUse(
|
||||||
NonMutatingUseContext::SharedBorrow(*r)
|
NonMutatingUseContext::SharedBorrow
|
||||||
),
|
),
|
||||||
BorrowKind::Shallow => PlaceContext::NonMutatingUse(
|
BorrowKind::Shallow => PlaceContext::NonMutatingUse(
|
||||||
NonMutatingUseContext::ShallowBorrow(*r)
|
NonMutatingUseContext::ShallowBorrow
|
||||||
),
|
),
|
||||||
BorrowKind::Unique => PlaceContext::NonMutatingUse(
|
BorrowKind::Unique => PlaceContext::NonMutatingUse(
|
||||||
NonMutatingUseContext::UniqueBorrow(*r)
|
NonMutatingUseContext::UniqueBorrow
|
||||||
),
|
),
|
||||||
BorrowKind::Mut { .. } =>
|
BorrowKind::Mut { .. } =>
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Borrow(*r)),
|
PlaceContext::MutatingUse(MutatingUseContext::Borrow),
|
||||||
};
|
};
|
||||||
self.visit_place(path, ctx, location);
|
self.visit_place(path, ctx, location);
|
||||||
}
|
}
|
||||||
@ -650,18 +602,16 @@ macro_rules! make_mir_visitor {
|
|||||||
self.visit_substs(substs, location);
|
self.visit_substs(substs, location);
|
||||||
}
|
}
|
||||||
AggregateKind::Closure(
|
AggregateKind::Closure(
|
||||||
def_id,
|
_,
|
||||||
closure_substs
|
closure_substs
|
||||||
) => {
|
) => {
|
||||||
self.visit_def_id(def_id, location);
|
|
||||||
self.visit_closure_substs(closure_substs, location);
|
self.visit_closure_substs(closure_substs, location);
|
||||||
}
|
}
|
||||||
AggregateKind::Generator(
|
AggregateKind::Generator(
|
||||||
def_id,
|
_,
|
||||||
generator_substs,
|
generator_substs,
|
||||||
_movability,
|
_movability,
|
||||||
) => {
|
) => {
|
||||||
self.visit_def_id(def_id, location);
|
|
||||||
self.visit_generator_substs(generator_substs, location);
|
self.visit_generator_substs(generator_substs, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -723,16 +673,13 @@ macro_rules! make_mir_visitor {
|
|||||||
|
|
||||||
fn super_place(&mut self,
|
fn super_place(&mut self,
|
||||||
place: & $($mutability)? Place<'tcx>,
|
place: & $($mutability)? Place<'tcx>,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
match place {
|
match place {
|
||||||
Place::Base(PlaceBase::Local(local)) => {
|
Place::Base(PlaceBase::Local(local)) => {
|
||||||
self.visit_local(local, context, location);
|
self.visit_local(local, context, location);
|
||||||
}
|
}
|
||||||
Place::Base(PlaceBase::Static(box Static { kind, ty })) => {
|
Place::Base(PlaceBase::Static(box Static { kind: _, ty })) => {
|
||||||
if let StaticKind::Static(def_id) = kind {
|
|
||||||
self.visit_def_id(& $($mutability)? *def_id, location)
|
|
||||||
}
|
|
||||||
self.visit_ty(& $($mutability)? *ty, TyContext::Location(location));
|
self.visit_ty(& $($mutability)? *ty, TyContext::Location(location));
|
||||||
}
|
}
|
||||||
Place::Projection(proj) => {
|
Place::Projection(proj) => {
|
||||||
@ -743,7 +690,7 @@ macro_rules! make_mir_visitor {
|
|||||||
|
|
||||||
fn super_projection(&mut self,
|
fn super_projection(&mut self,
|
||||||
proj: & $($mutability)? PlaceProjection<'tcx>,
|
proj: & $($mutability)? PlaceProjection<'tcx>,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
let Projection { base, elem } = proj;
|
let Projection { base, elem } = proj;
|
||||||
let context = if context.is_mutating_use() {
|
let context = if context.is_mutating_use() {
|
||||||
@ -812,11 +759,6 @@ macro_rules! make_mir_visitor {
|
|||||||
_scope: & $($mutability)? SourceScope) {
|
_scope: & $($mutability)? SourceScope) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_branch(&mut self,
|
|
||||||
_source: BasicBlock,
|
|
||||||
_target: BasicBlock) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn super_constant(&mut self,
|
fn super_constant(&mut self,
|
||||||
constant: & $($mutability)? Constant<'tcx>,
|
constant: & $($mutability)? Constant<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
@ -833,9 +775,6 @@ macro_rules! make_mir_visitor {
|
|||||||
self.visit_const(literal, location);
|
self.visit_const(literal, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_def_id(&mut self, _def_id: & $($mutability)? DefId) {
|
|
||||||
}
|
|
||||||
|
|
||||||
fn super_span(&mut self, _span: & $($mutability)? Span) {
|
fn super_span(&mut self, _span: & $($mutability)? Span) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -890,12 +829,12 @@ macro_rules! make_mir_visitor {
|
|||||||
let basic_block = & $($mutability)? mir[location.block];
|
let basic_block = & $($mutability)? mir[location.block];
|
||||||
if basic_block.statements.len() == location.statement_index {
|
if basic_block.statements.len() == location.statement_index {
|
||||||
if let Some(ref $($mutability)? terminator) = basic_block.terminator {
|
if let Some(ref $($mutability)? terminator) = basic_block.terminator {
|
||||||
self.visit_terminator(location.block, terminator, location)
|
self.visit_terminator(terminator, location)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let statement = & $($mutability)?
|
let statement = & $($mutability)?
|
||||||
basic_block.statements[location.statement_index];
|
basic_block.statements[location.statement_index];
|
||||||
self.visit_statement(location.block, statement, location)
|
self.visit_statement(statement, location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -912,21 +851,21 @@ pub trait MirVisitable<'tcx> {
|
|||||||
impl<'tcx> MirVisitable<'tcx> for Statement<'tcx> {
|
impl<'tcx> MirVisitable<'tcx> for Statement<'tcx> {
|
||||||
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
|
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
|
||||||
{
|
{
|
||||||
visitor.visit_statement(location.block, self, location)
|
visitor.visit_statement(self, location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> MirVisitable<'tcx> for Terminator<'tcx> {
|
impl<'tcx> MirVisitable<'tcx> for Terminator<'tcx> {
|
||||||
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
|
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
|
||||||
{
|
{
|
||||||
visitor.visit_terminator(location.block, self, location)
|
visitor.visit_terminator(self, location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> MirVisitable<'tcx> for Option<Terminator<'tcx>> {
|
impl<'tcx> MirVisitable<'tcx> for Option<Terminator<'tcx>> {
|
||||||
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
|
fn apply(&self, location: Location, visitor: &mut dyn Visitor<'tcx>)
|
||||||
{
|
{
|
||||||
visitor.visit_terminator(location.block, self.as_ref().unwrap(), location)
|
visitor.visit_terminator(self.as_ref().unwrap(), location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -955,7 +894,7 @@ pub enum TyContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum NonMutatingUseContext<'tcx> {
|
pub enum NonMutatingUseContext {
|
||||||
/// Being inspected in some way, like loading a len.
|
/// Being inspected in some way, like loading a len.
|
||||||
Inspect,
|
Inspect,
|
||||||
/// Consumed as part of an operand.
|
/// Consumed as part of an operand.
|
||||||
@ -963,11 +902,11 @@ pub enum NonMutatingUseContext<'tcx> {
|
|||||||
/// Consumed as part of an operand.
|
/// Consumed as part of an operand.
|
||||||
Move,
|
Move,
|
||||||
/// Shared borrow.
|
/// Shared borrow.
|
||||||
SharedBorrow(Region<'tcx>),
|
SharedBorrow,
|
||||||
/// Shallow borrow.
|
/// Shallow borrow.
|
||||||
ShallowBorrow(Region<'tcx>),
|
ShallowBorrow,
|
||||||
/// Unique borrow.
|
/// Unique borrow.
|
||||||
UniqueBorrow(Region<'tcx>),
|
UniqueBorrow,
|
||||||
/// Used as base for another place, e.g., `x` in `x.y`. Will not mutate the place.
|
/// Used as base for another place, e.g., `x` in `x.y`. Will not mutate the place.
|
||||||
/// For example, the projection `x.y` is not marked as a mutation in these cases:
|
/// For example, the projection `x.y` is not marked as a mutation in these cases:
|
||||||
///
|
///
|
||||||
@ -978,7 +917,7 @@ pub enum NonMutatingUseContext<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum MutatingUseContext<'tcx> {
|
pub enum MutatingUseContext {
|
||||||
/// Appears as LHS of an assignment.
|
/// Appears as LHS of an assignment.
|
||||||
Store,
|
Store,
|
||||||
/// Can often be treated as a `Store`, but needs to be separate because
|
/// Can often be treated as a `Store`, but needs to be separate because
|
||||||
@ -990,7 +929,7 @@ pub enum MutatingUseContext<'tcx> {
|
|||||||
/// Being dropped.
|
/// Being dropped.
|
||||||
Drop,
|
Drop,
|
||||||
/// Mutable borrow.
|
/// Mutable borrow.
|
||||||
Borrow(Region<'tcx>),
|
Borrow,
|
||||||
/// Used as base for another place, e.g., `x` in `x.y`. Could potentially mutate the place.
|
/// Used as base for another place, e.g., `x` in `x.y`. Could potentially mutate the place.
|
||||||
/// For example, the projection `x.y` is marked as a mutation in these cases:
|
/// For example, the projection `x.y` is marked as a mutation in these cases:
|
||||||
///
|
///
|
||||||
@ -1013,13 +952,13 @@ pub enum NonUseContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
pub enum PlaceContext<'tcx> {
|
pub enum PlaceContext {
|
||||||
NonMutatingUse(NonMutatingUseContext<'tcx>),
|
NonMutatingUse(NonMutatingUseContext),
|
||||||
MutatingUse(MutatingUseContext<'tcx>),
|
MutatingUse(MutatingUseContext),
|
||||||
NonUse(NonUseContext),
|
NonUse(NonUseContext),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> PlaceContext<'tcx> {
|
impl<'tcx> PlaceContext {
|
||||||
/// Returns `true` if this place context represents a drop.
|
/// Returns `true` if this place context represents a drop.
|
||||||
pub fn is_drop(&self) -> bool {
|
pub fn is_drop(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
@ -1031,10 +970,10 @@ impl<'tcx> PlaceContext<'tcx> {
|
|||||||
/// Returns `true` if this place context represents a borrow.
|
/// Returns `true` if this place context represents a borrow.
|
||||||
pub fn is_borrow(&self) -> bool {
|
pub fn is_borrow(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(..)) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow) |
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(..)) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow) |
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow(..)) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow) |
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Borrow(..)) => true,
|
PlaceContext::MutatingUse(MutatingUseContext::Borrow) => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,11 +97,10 @@ impl<Bx: BuilderMethods<'a, 'tcx>> LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
|
|||||||
impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
||||||
for LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
|
for LocalAnalyzer<'mir, 'a, 'tcx, Bx> {
|
||||||
fn visit_assign(&mut self,
|
fn visit_assign(&mut self,
|
||||||
block: mir::BasicBlock,
|
|
||||||
place: &mir::Place<'tcx>,
|
place: &mir::Place<'tcx>,
|
||||||
rvalue: &mir::Rvalue<'tcx>,
|
rvalue: &mir::Rvalue<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
debug!("visit_assign(block={:?}, place={:?}, rvalue={:?})", block, place, rvalue);
|
debug!("visit_assign(place={:?}, rvalue={:?})", place, rvalue);
|
||||||
|
|
||||||
if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place {
|
if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place {
|
||||||
self.assign(index, location);
|
self.assign(index, location);
|
||||||
@ -120,7 +119,6 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_kind(&mut self,
|
fn visit_terminator_kind(&mut self,
|
||||||
block: mir::BasicBlock,
|
|
||||||
kind: &mir::TerminatorKind<'tcx>,
|
kind: &mir::TerminatorKind<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
let check = match *kind {
|
let check = match *kind {
|
||||||
@ -148,12 +146,12 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.super_terminator_kind(block, kind, location);
|
self.super_terminator_kind(kind, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_place(&mut self,
|
fn visit_place(&mut self,
|
||||||
place: &mir::Place<'tcx>,
|
place: &mir::Place<'tcx>,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
debug!("visit_place(place={:?}, context={:?})", place, context);
|
debug!("visit_place(place={:?}, context={:?})", place, context);
|
||||||
let cx = self.fx.cx;
|
let cx = self.fx.cx;
|
||||||
@ -205,7 +203,7 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
|||||||
|
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
&local: &mir::Local,
|
&local: &mir::Local,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
match context {
|
match context {
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Call) => {
|
PlaceContext::MutatingUse(MutatingUseContext::Call) => {
|
||||||
@ -235,11 +233,11 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
|
|||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) |
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Store) |
|
PlaceContext::MutatingUse(MutatingUseContext::Store) |
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) |
|
PlaceContext::MutatingUse(MutatingUseContext::AsmOutput) |
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Borrow(..)) |
|
PlaceContext::MutatingUse(MutatingUseContext::Borrow) |
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Projection) |
|
PlaceContext::MutatingUse(MutatingUseContext::Projection) |
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(..)) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow) |
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow(..)) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow) |
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(..)) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow) |
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) => {
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::Projection) => {
|
||||||
self.not_ssa(local);
|
self.not_ssa(local);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ impl LocalsStateAtExit {
|
|||||||
struct HasStorageDead(BitSet<Local>);
|
struct HasStorageDead(BitSet<Local>);
|
||||||
|
|
||||||
impl<'tcx> Visitor<'tcx> for HasStorageDead {
|
impl<'tcx> Visitor<'tcx> for HasStorageDead {
|
||||||
fn visit_local(&mut self, local: &Local, ctx: PlaceContext<'tcx>, _: Location) {
|
fn visit_local(&mut self, local: &Local, ctx: PlaceContext, _: Location) {
|
||||||
if ctx == PlaceContext::NonUse(NonUseContext::StorageDead) {
|
if ctx == PlaceContext::NonUse(NonUseContext::StorageDead) {
|
||||||
self.0.insert(*local);
|
self.0.insert(*local);
|
||||||
}
|
}
|
||||||
@ -185,7 +185,6 @@ struct GatherBorrows<'a, 'gcx: 'tcx, 'tcx: 'a> {
|
|||||||
impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
|
||||||
fn visit_assign(
|
fn visit_assign(
|
||||||
&mut self,
|
&mut self,
|
||||||
block: mir::BasicBlock,
|
|
||||||
assigned_place: &mir::Place<'tcx>,
|
assigned_place: &mir::Place<'tcx>,
|
||||||
rvalue: &mir::Rvalue<'tcx>,
|
rvalue: &mir::Rvalue<'tcx>,
|
||||||
location: mir::Location,
|
location: mir::Location,
|
||||||
@ -216,13 +215,13 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.super_assign(block, assigned_place, rvalue, location)
|
self.super_assign(assigned_place, rvalue, location)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_local(
|
fn visit_local(
|
||||||
&mut self,
|
&mut self,
|
||||||
temp: &Local,
|
temp: &Local,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
if !context.is_use() {
|
if !context.is_use() {
|
||||||
@ -288,15 +287,6 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for GatherBorrows<'a, 'gcx, 'tcx> {
|
|||||||
|
|
||||||
return self.super_rvalue(rvalue, location);
|
return self.super_rvalue(rvalue, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_statement(
|
|
||||||
&mut self,
|
|
||||||
block: mir::BasicBlock,
|
|
||||||
statement: &mir::Statement<'tcx>,
|
|
||||||
location: Location,
|
|
||||||
) {
|
|
||||||
return self.super_statement(block, statement, location);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> {
|
impl<'a, 'gcx, 'tcx> GatherBorrows<'a, 'gcx, 'tcx> {
|
||||||
|
@ -100,7 +100,6 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx
|
|||||||
|
|
||||||
fn visit_statement(
|
fn visit_statement(
|
||||||
&mut self,
|
&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
statement: &Statement<'tcx>,
|
statement: &Statement<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
@ -117,12 +116,11 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.super_statement(block, statement, location);
|
self.super_statement(statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_assign(
|
fn visit_assign(
|
||||||
&mut self,
|
&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
place: &Place<'tcx>,
|
place: &Place<'tcx>,
|
||||||
rvalue: &Rvalue<'tcx>,
|
rvalue: &Rvalue<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
@ -141,12 +139,11 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.super_assign(block, place, rvalue, location);
|
self.super_assign(place, rvalue, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator(
|
fn visit_terminator(
|
||||||
&mut self,
|
&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
terminator: &Terminator<'tcx>,
|
terminator: &Terminator<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
@ -167,7 +164,7 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.super_terminator(block, terminator, location);
|
self.super_terminator(terminator, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_ascribe_user_ty(
|
fn visit_ascribe_user_ty(
|
||||||
|
@ -113,7 +113,7 @@ enum DefUseResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'cx, 'gcx, 'tcx> Visitor<'tcx> for DefUseVisitor<'cx, 'gcx, 'tcx> {
|
impl<'cx, 'gcx, 'tcx> Visitor<'tcx> for DefUseVisitor<'cx, 'gcx, 'tcx> {
|
||||||
fn visit_local(&mut self, &local: &Local, context: PlaceContext<'tcx>, _: Location) {
|
fn visit_local(&mut self, &local: &Local, context: PlaceContext, _: Location) {
|
||||||
let local_ty = self.mir.local_decls[local].ty;
|
let local_ty = self.mir.local_decls[local].ty;
|
||||||
|
|
||||||
let mut found_it = false;
|
let mut found_it = false;
|
||||||
|
@ -14,7 +14,7 @@ use rustc::ty::TyCtxt;
|
|||||||
use rustc::mir::visit::Visitor;
|
use rustc::mir::visit::Visitor;
|
||||||
use rustc::mir::{BasicBlock, Location, Mir, Place, PlaceBase, Rvalue};
|
use rustc::mir::{BasicBlock, Location, Mir, Place, PlaceBase, Rvalue};
|
||||||
use rustc::mir::{Statement, StatementKind};
|
use rustc::mir::{Statement, StatementKind};
|
||||||
use rustc::mir::{Terminator, TerminatorKind};
|
use rustc::mir::TerminatorKind;
|
||||||
use rustc::mir::{Operand, BorrowKind};
|
use rustc::mir::{Operand, BorrowKind};
|
||||||
use rustc_data_structures::graph::dominators::Dominators;
|
use rustc_data_structures::graph::dominators::Dominators;
|
||||||
|
|
||||||
@ -58,7 +58,6 @@ struct InvalidationGenerator<'cx, 'tcx: 'cx, 'gcx: 'tcx> {
|
|||||||
impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
|
impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
|
||||||
fn visit_statement(
|
fn visit_statement(
|
||||||
&mut self,
|
&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
statement: &Statement<'tcx>,
|
statement: &Statement<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
@ -134,18 +133,17 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.super_statement(block, statement, location);
|
self.super_statement(statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator(
|
fn visit_terminator_kind(
|
||||||
&mut self,
|
&mut self,
|
||||||
block: BasicBlock,
|
kind: &TerminatorKind<'tcx>,
|
||||||
terminator: &Terminator<'tcx>,
|
|
||||||
location: Location
|
location: Location
|
||||||
) {
|
) {
|
||||||
self.check_activations(location);
|
self.check_activations(location);
|
||||||
|
|
||||||
match terminator.kind {
|
match kind {
|
||||||
TerminatorKind::SwitchInt {
|
TerminatorKind::SwitchInt {
|
||||||
ref discr,
|
ref discr,
|
||||||
switch_ty: _,
|
switch_ty: _,
|
||||||
@ -258,7 +256,7 @@ impl<'cx, 'tcx, 'gcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx, 'gcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.super_terminator(block, terminator, location);
|
self.super_terminator_kind(kind, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ impl LocalUseMapBuild<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Visitor<'tcx> for LocalUseMapBuild<'_> {
|
impl Visitor<'tcx> for LocalUseMapBuild<'_> {
|
||||||
fn visit_local(&mut self, &local: &Local, context: PlaceContext<'tcx>, location: Location) {
|
fn visit_local(&mut self, &local: &Local, context: PlaceContext, location: Location) {
|
||||||
if self.locals_with_use_data[local] {
|
if self.locals_with_use_data[local] {
|
||||||
match categorize(context) {
|
match categorize(context) {
|
||||||
Some(DefUse::Def) => self.insert_def(local, location),
|
Some(DefUse::Def) => self.insert_def(local, location),
|
||||||
|
@ -269,7 +269,7 @@ impl<'a, 'b, 'gcx, 'tcx> Visitor<'tcx> for TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext<'_>, location: Location) {
|
fn visit_place(&mut self, place: &Place<'tcx>, context: PlaceContext, location: Location) {
|
||||||
self.sanitize_place(place, location, context);
|
self.sanitize_place(place, location, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -447,7 +447,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
|
|||||||
&mut self,
|
&mut self,
|
||||||
place: &Place<'tcx>,
|
place: &Place<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
context: PlaceContext<'_>,
|
context: PlaceContext,
|
||||||
) -> PlaceTy<'tcx> {
|
) -> PlaceTy<'tcx> {
|
||||||
debug!("sanitize_place: {:?}", place);
|
debug!("sanitize_place: {:?}", place);
|
||||||
let place_ty = match place {
|
let place_ty = match place {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use rustc::mir::visit::{PlaceContext, Visitor};
|
use rustc::mir::visit::{PlaceContext, Visitor};
|
||||||
use rustc::mir::{
|
use rustc::mir::{
|
||||||
BasicBlock, Local, Location, Place, PlaceBase, Statement, StatementKind, TerminatorKind
|
Local, Location, Place, PlaceBase, Statement, StatementKind, TerminatorKind
|
||||||
};
|
};
|
||||||
|
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
@ -55,7 +55,6 @@ struct GatherUsedMutsVisitor<'visit, 'cx: 'visit, 'gcx: 'tcx, 'tcx: 'cx> {
|
|||||||
impl<'visit, 'cx, 'gcx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'gcx, 'tcx> {
|
impl<'visit, 'cx, 'gcx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'cx, 'gcx, 'tcx> {
|
||||||
fn visit_terminator_kind(
|
fn visit_terminator_kind(
|
||||||
&mut self,
|
&mut self,
|
||||||
_block: BasicBlock,
|
|
||||||
kind: &TerminatorKind<'tcx>,
|
kind: &TerminatorKind<'tcx>,
|
||||||
_location: Location,
|
_location: Location,
|
||||||
) {
|
) {
|
||||||
@ -77,7 +76,6 @@ impl<'visit, 'cx, 'gcx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'c
|
|||||||
|
|
||||||
fn visit_statement(
|
fn visit_statement(
|
||||||
&mut self,
|
&mut self,
|
||||||
_block: BasicBlock,
|
|
||||||
statement: &Statement<'tcx>,
|
statement: &Statement<'tcx>,
|
||||||
_location: Location,
|
_location: Location,
|
||||||
) {
|
) {
|
||||||
@ -104,7 +102,7 @@ impl<'visit, 'cx, 'gcx, 'tcx> Visitor<'tcx> for GatherUsedMutsVisitor<'visit, 'c
|
|||||||
fn visit_local(
|
fn visit_local(
|
||||||
&mut self,
|
&mut self,
|
||||||
local: &Local,
|
local: &Local,
|
||||||
place_context: PlaceContext<'tcx>,
|
place_context: PlaceContext,
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
if place_context.is_place_assignment() && self.temporary_used_locals.contains(local) {
|
if place_context.is_place_assignment() && self.temporary_used_locals.contains(local) {
|
||||||
|
@ -44,7 +44,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for HaveBeenBorrowedLocals<'a, 'tcx> {
|
|||||||
|
|
||||||
BorrowedLocalsVisitor {
|
BorrowedLocalsVisitor {
|
||||||
sets,
|
sets,
|
||||||
}.visit_statement(loc.block, stmt, loc);
|
}.visit_statement(stmt, loc);
|
||||||
|
|
||||||
// StorageDead invalidates all borrows and raw pointers to a local
|
// StorageDead invalidates all borrows and raw pointers to a local
|
||||||
match stmt.kind {
|
match stmt.kind {
|
||||||
@ -58,7 +58,7 @@ impl<'a, 'tcx> BitDenotation<'tcx> for HaveBeenBorrowedLocals<'a, 'tcx> {
|
|||||||
loc: Location) {
|
loc: Location) {
|
||||||
BorrowedLocalsVisitor {
|
BorrowedLocalsVisitor {
|
||||||
sets,
|
sets,
|
||||||
}.visit_terminator(loc.block, self.mir[loc.block].terminator(), loc);
|
}.visit_terminator(self.mir[loc.block].terminator(), loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn propagate_call_return(
|
fn propagate_call_return(
|
||||||
|
@ -615,7 +615,6 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_kind(&mut self,
|
fn visit_terminator_kind(&mut self,
|
||||||
block: mir::BasicBlock,
|
|
||||||
kind: &mir::TerminatorKind<'tcx>,
|
kind: &mir::TerminatorKind<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
debug!("visiting terminator {:?} @ {:?}", kind, location);
|
debug!("visiting terminator {:?} @ {:?}", kind, location);
|
||||||
@ -654,12 +653,12 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> {
|
|||||||
mir::TerminatorKind::FalseUnwind { .. } => bug!(),
|
mir::TerminatorKind::FalseUnwind { .. } => bug!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
self.super_terminator_kind(block, kind, location);
|
self.super_terminator_kind(kind, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_place(&mut self,
|
fn visit_place(&mut self,
|
||||||
place: &mir::Place<'tcx>,
|
place: &mir::Place<'tcx>,
|
||||||
context: mir::visit::PlaceContext<'tcx>,
|
context: mir::visit::PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
match place {
|
match place {
|
||||||
Place::Base(
|
Place::Base(
|
||||||
|
@ -65,7 +65,6 @@ impl<'a, 'gcx, 'tcx> UnsafetyChecker<'a, 'tcx> {
|
|||||||
|
|
||||||
impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
|
impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
|
||||||
fn visit_terminator(&mut self,
|
fn visit_terminator(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
terminator: &Terminator<'tcx>,
|
terminator: &Terminator<'tcx>,
|
||||||
location: Location)
|
location: Location)
|
||||||
{
|
{
|
||||||
@ -97,11 +96,10 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.super_terminator(block, terminator, location);
|
self.super_terminator(terminator, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_statement(&mut self,
|
fn visit_statement(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
statement: &Statement<'tcx>,
|
statement: &Statement<'tcx>,
|
||||||
location: Location)
|
location: Location)
|
||||||
{
|
{
|
||||||
@ -124,7 +122,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
|
|||||||
UnsafetyViolationKind::General)
|
UnsafetyViolationKind::General)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
self.super_statement(block, statement, location);
|
self.super_statement(statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_rvalue(&mut self,
|
fn visit_rvalue(&mut self,
|
||||||
@ -201,7 +199,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> {
|
|||||||
|
|
||||||
fn visit_place(&mut self,
|
fn visit_place(&mut self,
|
||||||
place: &Place<'tcx>,
|
place: &Place<'tcx>,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
match place {
|
match place {
|
||||||
&Place::Projection(box Projection {
|
&Place::Projection(box Projection {
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
//! [`FakeRead`]: rustc::mir::StatementKind::FakeRead
|
//! [`FakeRead`]: rustc::mir::StatementKind::FakeRead
|
||||||
//! [`Nop`]: rustc::mir::StatementKind::Nop
|
//! [`Nop`]: rustc::mir::StatementKind::Nop
|
||||||
|
|
||||||
use rustc::mir::{BasicBlock, BorrowKind, Rvalue, Location, Mir};
|
use rustc::mir::{BorrowKind, Rvalue, Location, Mir};
|
||||||
use rustc::mir::{Statement, StatementKind};
|
use rustc::mir::{Statement, StatementKind};
|
||||||
use rustc::mir::visit::MutVisitor;
|
use rustc::mir::visit::MutVisitor;
|
||||||
use rustc::ty::TyCtxt;
|
use rustc::ty::TyCtxt;
|
||||||
@ -38,7 +38,6 @@ impl MirPass for CleanupNonCodegenStatements {
|
|||||||
|
|
||||||
impl<'tcx> MutVisitor<'tcx> for DeleteNonCodegenStatements {
|
impl<'tcx> MutVisitor<'tcx> for DeleteNonCodegenStatements {
|
||||||
fn visit_statement(&mut self,
|
fn visit_statement(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
statement: &mut Statement<'tcx>,
|
statement: &mut Statement<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
match statement.kind {
|
match statement.kind {
|
||||||
@ -47,6 +46,6 @@ impl<'tcx> MutVisitor<'tcx> for DeleteNonCodegenStatements {
|
|||||||
| StatementKind::FakeRead(..) => statement.make_nop(),
|
| StatementKind::FakeRead(..) => statement.make_nop(),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
self.super_statement(block, statement, location);
|
self.super_statement(statement, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
use rustc::hir::def::Def;
|
use rustc::hir::def::Def;
|
||||||
use rustc::mir::{Constant, Location, Place, PlaceBase, Mir, Operand, Rvalue, Local};
|
use rustc::mir::{Constant, Location, Place, PlaceBase, Mir, Operand, Rvalue, Local};
|
||||||
use rustc::mir::{NullOp, UnOp, StatementKind, Statement, BasicBlock, LocalKind, Static, StaticKind};
|
use rustc::mir::{NullOp, UnOp, StatementKind, Statement, LocalKind, Static, StaticKind};
|
||||||
use rustc::mir::{TerminatorKind, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem};
|
use rustc::mir::{TerminatorKind, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem};
|
||||||
use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUseContext};
|
use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUseContext};
|
||||||
use rustc::mir::interpret::{InterpError, Scalar, GlobalId, EvalResult};
|
use rustc::mir::interpret::{InterpError, Scalar, GlobalId, EvalResult};
|
||||||
@ -510,7 +510,7 @@ impl<'tcx> Visitor<'tcx> for CanConstProp {
|
|||||||
fn visit_local(
|
fn visit_local(
|
||||||
&mut self,
|
&mut self,
|
||||||
&local: &Local,
|
&local: &Local,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
_: Location,
|
_: Location,
|
||||||
) {
|
) {
|
||||||
use rustc::mir::visit::PlaceContext::*;
|
use rustc::mir::visit::PlaceContext::*;
|
||||||
@ -549,7 +549,6 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for ConstPropagator<'b, 'a, 'tcx> {
|
|||||||
|
|
||||||
fn visit_statement(
|
fn visit_statement(
|
||||||
&mut self,
|
&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
statement: &Statement<'tcx>,
|
statement: &Statement<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
@ -571,16 +570,15 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for ConstPropagator<'b, 'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.super_statement(block, statement, location);
|
self.super_statement(statement, location);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_kind(
|
fn visit_terminator_kind(
|
||||||
&mut self,
|
&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
kind: &TerminatorKind<'tcx>,
|
kind: &TerminatorKind<'tcx>,
|
||||||
location: Location,
|
location: Location,
|
||||||
) {
|
) {
|
||||||
self.super_terminator_kind(block, kind, location);
|
self.super_terminator_kind(kind, location);
|
||||||
let source_info = *self.mir.source_info(location);
|
let source_info = *self.mir.source_info(location);
|
||||||
if let TerminatorKind::Assert { expected, msg, cond, .. } = kind {
|
if let TerminatorKind::Assert { expected, msg, cond, .. } = kind {
|
||||||
if let Some(value) = self.eval_operand(cond, source_info) {
|
if let Some(value) = self.eval_operand(cond, source_info) {
|
||||||
@ -601,7 +599,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for ConstPropagator<'b, 'a, 'tcx> {
|
|||||||
},
|
},
|
||||||
Operand::Constant(_) => {}
|
Operand::Constant(_) => {}
|
||||||
}
|
}
|
||||||
let span = self.mir[block]
|
let span = self.mir[location.block]
|
||||||
.terminator
|
.terminator
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
|
@ -134,9 +134,9 @@ impl MirPass for CopyPropagation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn eliminate_self_assignments<'tcx>(
|
fn eliminate_self_assignments(
|
||||||
mir: &mut Mir<'tcx>,
|
mir: &mut Mir<'_>,
|
||||||
def_use_analysis: &DefUseAnalysis<'tcx>,
|
def_use_analysis: &DefUseAnalysis,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ enum Action<'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Action<'tcx> {
|
impl<'tcx> Action<'tcx> {
|
||||||
fn local_copy(mir: &Mir<'tcx>, def_use_analysis: &DefUseAnalysis<'_>, src_place: &Place<'tcx>)
|
fn local_copy(mir: &Mir<'tcx>, def_use_analysis: &DefUseAnalysis, src_place: &Place<'tcx>)
|
||||||
-> Option<Action<'tcx>> {
|
-> Option<Action<'tcx>> {
|
||||||
// The source must be a local.
|
// The source must be a local.
|
||||||
let src_local = if let Place::Base(PlaceBase::Local(local)) = *src_place {
|
let src_local = if let Place::Base(PlaceBase::Local(local)) = *src_place {
|
||||||
@ -233,7 +233,7 @@ impl<'tcx> Action<'tcx> {
|
|||||||
|
|
||||||
fn perform(self,
|
fn perform(self,
|
||||||
mir: &mut Mir<'tcx>,
|
mir: &mut Mir<'tcx>,
|
||||||
def_use_analysis: &DefUseAnalysis<'tcx>,
|
def_use_analysis: &DefUseAnalysis,
|
||||||
dest_local: Local,
|
dest_local: Local,
|
||||||
location: Location)
|
location: Location)
|
||||||
-> bool {
|
-> bool {
|
||||||
|
@ -41,10 +41,9 @@ impl<'a, 'tcx> MutVisitor<'tcx> for EraseRegionsVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_statement(&mut self,
|
fn visit_statement(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
statement: &mut Statement<'tcx>,
|
statement: &mut Statement<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
self.super_statement(block, statement, location);
|
self.super_statement(statement, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ struct RenameLocalVisitor {
|
|||||||
impl<'tcx> MutVisitor<'tcx> for RenameLocalVisitor {
|
impl<'tcx> MutVisitor<'tcx> for RenameLocalVisitor {
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
local: &mut Local,
|
local: &mut Local,
|
||||||
_: PlaceContext<'tcx>,
|
_: PlaceContext,
|
||||||
_: Location) {
|
_: Location) {
|
||||||
if *local == self.from {
|
if *local == self.from {
|
||||||
*local = self.to;
|
*local = self.to;
|
||||||
@ -93,14 +93,14 @@ struct DerefArgVisitor;
|
|||||||
impl<'tcx> MutVisitor<'tcx> for DerefArgVisitor {
|
impl<'tcx> MutVisitor<'tcx> for DerefArgVisitor {
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
local: &mut Local,
|
local: &mut Local,
|
||||||
_: PlaceContext<'tcx>,
|
_: PlaceContext,
|
||||||
_: Location) {
|
_: Location) {
|
||||||
assert_ne!(*local, self_arg());
|
assert_ne!(*local, self_arg());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_place(&mut self,
|
fn visit_place(&mut self,
|
||||||
place: &mut Place<'tcx>,
|
place: &mut Place<'tcx>,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
if *place == Place::Base(PlaceBase::Local(self_arg())) {
|
if *place == Place::Base(PlaceBase::Local(self_arg())) {
|
||||||
*place = Place::Projection(Box::new(Projection {
|
*place = Place::Projection(Box::new(Projection {
|
||||||
@ -120,14 +120,14 @@ struct PinArgVisitor<'tcx> {
|
|||||||
impl<'tcx> MutVisitor<'tcx> for PinArgVisitor<'tcx> {
|
impl<'tcx> MutVisitor<'tcx> for PinArgVisitor<'tcx> {
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
local: &mut Local,
|
local: &mut Local,
|
||||||
_: PlaceContext<'tcx>,
|
_: PlaceContext,
|
||||||
_: Location) {
|
_: Location) {
|
||||||
assert_ne!(*local, self_arg());
|
assert_ne!(*local, self_arg());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_place(&mut self,
|
fn visit_place(&mut self,
|
||||||
place: &mut Place<'tcx>,
|
place: &mut Place<'tcx>,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
if *place == Place::Base(PlaceBase::Local(self_arg())) {
|
if *place == Place::Base(PlaceBase::Local(self_arg())) {
|
||||||
*place = Place::Projection(Box::new(Projection {
|
*place = Place::Projection(Box::new(Projection {
|
||||||
@ -221,14 +221,14 @@ impl<'a, 'tcx> TransformVisitor<'a, 'tcx> {
|
|||||||
impl<'a, 'tcx> MutVisitor<'tcx> for TransformVisitor<'a, 'tcx> {
|
impl<'a, 'tcx> MutVisitor<'tcx> for TransformVisitor<'a, 'tcx> {
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
local: &mut Local,
|
local: &mut Local,
|
||||||
_: PlaceContext<'tcx>,
|
_: PlaceContext,
|
||||||
_: Location) {
|
_: Location) {
|
||||||
assert_eq!(self.remap.get(local), None);
|
assert_eq!(self.remap.get(local), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_place(&mut self,
|
fn visit_place(&mut self,
|
||||||
place: &mut Place<'tcx>,
|
place: &mut Place<'tcx>,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
if let Place::Base(PlaceBase::Local(l)) = *place {
|
if let Place::Base(PlaceBase::Local(l)) = *place {
|
||||||
// Replace an Local in the remap with a generator struct access
|
// Replace an Local in the remap with a generator struct access
|
||||||
@ -369,7 +369,6 @@ struct StorageIgnored(liveness::LiveVarSet);
|
|||||||
|
|
||||||
impl<'tcx> Visitor<'tcx> for StorageIgnored {
|
impl<'tcx> Visitor<'tcx> for StorageIgnored {
|
||||||
fn visit_statement(&mut self,
|
fn visit_statement(&mut self,
|
||||||
_block: BasicBlock,
|
|
||||||
statement: &Statement<'tcx>,
|
statement: &Statement<'tcx>,
|
||||||
_location: Location) {
|
_location: Location) {
|
||||||
match statement.kind {
|
match statement.kind {
|
||||||
|
@ -665,7 +665,7 @@ impl<'a, 'tcx> Integrator<'a, 'tcx> {
|
|||||||
impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
|
impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
local: &mut Local,
|
local: &mut Local,
|
||||||
_ctxt: PlaceContext<'tcx>,
|
_ctxt: PlaceContext,
|
||||||
_location: Location) {
|
_location: Location) {
|
||||||
if *local == RETURN_PLACE {
|
if *local == RETURN_PLACE {
|
||||||
match self.destination {
|
match self.destination {
|
||||||
@ -686,7 +686,7 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
|
|||||||
|
|
||||||
fn visit_place(&mut self,
|
fn visit_place(&mut self,
|
||||||
place: &mut Place<'tcx>,
|
place: &mut Place<'tcx>,
|
||||||
_ctxt: PlaceContext<'tcx>,
|
_ctxt: PlaceContext,
|
||||||
_location: Location) {
|
_location: Location) {
|
||||||
|
|
||||||
match place {
|
match place {
|
||||||
@ -726,9 +726,9 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_kind(&mut self, block: BasicBlock,
|
fn visit_terminator_kind(&mut self,
|
||||||
kind: &mut TerminatorKind<'tcx>, loc: Location) {
|
kind: &mut TerminatorKind<'tcx>, loc: Location) {
|
||||||
self.super_terminator_kind(block, kind, loc);
|
self.super_terminator_kind(kind, loc);
|
||||||
|
|
||||||
match *kind {
|
match *kind {
|
||||||
TerminatorKind::GeneratorDrop |
|
TerminatorKind::GeneratorDrop |
|
||||||
|
@ -24,13 +24,12 @@ pub fn no_landing_pads<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, mir: &mut Mir<'tcx
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> MutVisitor<'tcx> for NoLandingPads {
|
impl<'tcx> MutVisitor<'tcx> for NoLandingPads {
|
||||||
fn visit_terminator(&mut self,
|
fn visit_terminator_kind(&mut self,
|
||||||
bb: BasicBlock,
|
kind: &mut TerminatorKind<'tcx>,
|
||||||
terminator: &mut Terminator<'tcx>,
|
|
||||||
location: Location) {
|
location: Location) {
|
||||||
if let Some(unwind) = terminator.kind.unwind_mut() {
|
if let Some(unwind) = kind.unwind_mut() {
|
||||||
unwind.take();
|
unwind.take();
|
||||||
}
|
}
|
||||||
self.super_terminator(bb, terminator, location);
|
self.super_terminator_kind(kind, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ struct TempCollector<'tcx> {
|
|||||||
impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> {
|
impl<'tcx> Visitor<'tcx> for TempCollector<'tcx> {
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
&index: &Local,
|
&index: &Local,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
debug!("visit_local: index={:?} context={:?} location={:?}", index, context, location);
|
debug!("visit_local: index={:?} context={:?} location={:?}", index, context, location);
|
||||||
// We're only interested in temporaries and the return place
|
// We're only interested in temporaries and the return place
|
||||||
@ -361,7 +361,7 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> {
|
|||||||
impl<'a, 'tcx> MutVisitor<'tcx> for Promoter<'a, 'tcx> {
|
impl<'a, 'tcx> MutVisitor<'tcx> for Promoter<'a, 'tcx> {
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
local: &mut Local,
|
local: &mut Local,
|
||||||
_: PlaceContext<'tcx>,
|
_: PlaceContext,
|
||||||
_: Location) {
|
_: Location) {
|
||||||
if self.source.local_kind(*local) == LocalKind::Temp {
|
if self.source.local_kind(*local) == LocalKind::Temp {
|
||||||
*local = self.promote_temp(*local);
|
*local = self.promote_temp(*local);
|
||||||
|
@ -926,7 +926,7 @@ impl<'a, 'tcx> Checker<'a, 'tcx> {
|
|||||||
impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
||||||
fn visit_place(&mut self,
|
fn visit_place(&mut self,
|
||||||
place: &Place<'tcx>,
|
place: &Place<'tcx>,
|
||||||
context: PlaceContext<'tcx>,
|
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);
|
self.super_place(place, context, location);
|
||||||
@ -1063,7 +1063,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
|||||||
debug!("visit_rvalue: rvalue={:?} location={:?}", rvalue, location);
|
debug!("visit_rvalue: rvalue={:?} location={:?}", rvalue, location);
|
||||||
|
|
||||||
// Check nested operands and places.
|
// Check nested operands and places.
|
||||||
if let Rvalue::Ref(region, kind, ref place) = *rvalue {
|
if let Rvalue::Ref(_, kind, ref place) = *rvalue {
|
||||||
// Special-case reborrows.
|
// Special-case reborrows.
|
||||||
let mut is_reborrow = false;
|
let mut is_reborrow = false;
|
||||||
if let Place::Projection(ref proj) = *place {
|
if let Place::Projection(ref proj) = *place {
|
||||||
@ -1078,16 +1078,16 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
|||||||
if is_reborrow {
|
if is_reborrow {
|
||||||
let ctx = match kind {
|
let ctx = match kind {
|
||||||
BorrowKind::Shared => PlaceContext::NonMutatingUse(
|
BorrowKind::Shared => PlaceContext::NonMutatingUse(
|
||||||
NonMutatingUseContext::SharedBorrow(region),
|
NonMutatingUseContext::SharedBorrow,
|
||||||
),
|
),
|
||||||
BorrowKind::Shallow => PlaceContext::NonMutatingUse(
|
BorrowKind::Shallow => PlaceContext::NonMutatingUse(
|
||||||
NonMutatingUseContext::ShallowBorrow(region),
|
NonMutatingUseContext::ShallowBorrow,
|
||||||
),
|
),
|
||||||
BorrowKind::Unique => PlaceContext::NonMutatingUse(
|
BorrowKind::Unique => PlaceContext::NonMutatingUse(
|
||||||
NonMutatingUseContext::UniqueBorrow(region),
|
NonMutatingUseContext::UniqueBorrow,
|
||||||
),
|
),
|
||||||
BorrowKind::Mut { .. } => PlaceContext::MutatingUse(
|
BorrowKind::Mut { .. } => PlaceContext::MutatingUse(
|
||||||
MutatingUseContext::Borrow(region),
|
MutatingUseContext::Borrow,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
self.super_place(place, ctx, location);
|
self.super_place(place, ctx, location);
|
||||||
@ -1179,10 +1179,9 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator_kind(&mut self,
|
fn visit_terminator_kind(&mut self,
|
||||||
bb: BasicBlock,
|
|
||||||
kind: &TerminatorKind<'tcx>,
|
kind: &TerminatorKind<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
debug!("visit_terminator_kind: bb={:?} kind={:?} location={:?}", bb, kind, location);
|
debug!("visit_terminator_kind: kind={:?} location={:?}", kind, location);
|
||||||
if let TerminatorKind::Call { ref func, ref args, ref destination, .. } = *kind {
|
if let TerminatorKind::Call { ref func, ref args, ref destination, .. } = *kind {
|
||||||
if let Some((ref dest, _)) = *destination {
|
if let Some((ref dest, _)) = *destination {
|
||||||
self.assign(dest, ValueSource::Call {
|
self.assign(dest, ValueSource::Call {
|
||||||
@ -1310,7 +1309,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let candidate = Candidate::Argument { bb, index: i };
|
let candidate = Candidate::Argument { bb: location.block, index: i };
|
||||||
// Since the argument is required to be constant,
|
// Since the argument is required to be constant,
|
||||||
// we care about constness, not promotability.
|
// we care about constness, not promotability.
|
||||||
// If we checked for promotability, we'd miss out on
|
// If we checked for promotability, we'd miss out on
|
||||||
@ -1343,7 +1342,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
|||||||
self.visit_operand(arg, location);
|
self.visit_operand(arg, location);
|
||||||
}
|
}
|
||||||
} else if let TerminatorKind::Drop { location: ref place, .. } = *kind {
|
} else if let TerminatorKind::Drop { location: ref place, .. } = *kind {
|
||||||
self.super_terminator_kind(bb, kind, location);
|
self.super_terminator_kind(kind, location);
|
||||||
|
|
||||||
// Deny *any* live drops anywhere other than functions.
|
// Deny *any* live drops anywhere other than functions.
|
||||||
if self.mode != Mode::Fn {
|
if self.mode != Mode::Fn {
|
||||||
@ -1374,12 +1373,11 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Qualify any operands inside other terminators.
|
// Qualify any operands inside other terminators.
|
||||||
self.super_terminator_kind(bb, kind, location);
|
self.super_terminator_kind(kind, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_assign(&mut self,
|
fn visit_assign(&mut self,
|
||||||
_: BasicBlock,
|
|
||||||
dest: &Place<'tcx>,
|
dest: &Place<'tcx>,
|
||||||
rvalue: &Rvalue<'tcx>,
|
rvalue: &Rvalue<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
@ -1394,11 +1392,11 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
|||||||
self.span = source_info.span;
|
self.span = source_info.span;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_statement(&mut self, bb: BasicBlock, statement: &Statement<'tcx>, location: Location) {
|
fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
|
||||||
debug!("visit_statement: bb={:?} statement={:?} location={:?}", bb, statement, location);
|
debug!("visit_statement: statement={:?} location={:?}", statement, location);
|
||||||
match statement.kind {
|
match statement.kind {
|
||||||
StatementKind::Assign(..) => {
|
StatementKind::Assign(..) => {
|
||||||
self.super_statement(bb, statement, location);
|
self.super_statement(statement, location);
|
||||||
}
|
}
|
||||||
// FIXME(eddyb) should these really do nothing?
|
// FIXME(eddyb) should these really do nothing?
|
||||||
StatementKind::FakeRead(..) |
|
StatementKind::FakeRead(..) |
|
||||||
@ -1411,14 +1409,6 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> {
|
|||||||
StatementKind::Nop => {}
|
StatementKind::Nop => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_terminator(&mut self,
|
|
||||||
bb: BasicBlock,
|
|
||||||
terminator: &Terminator<'tcx>,
|
|
||||||
location: Location) {
|
|
||||||
debug!("visit_terminator: bb={:?} terminator={:?} location={:?}", bb, terminator, location);
|
|
||||||
self.super_terminator(bb, terminator, location);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn provide(providers: &mut Providers<'_>) {
|
pub fn provide(providers: &mut Providers<'_>) {
|
||||||
|
@ -345,7 +345,7 @@ struct DeclMarker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Visitor<'tcx> for DeclMarker {
|
impl<'tcx> Visitor<'tcx> for DeclMarker {
|
||||||
fn visit_local(&mut self, local: &Local, ctx: PlaceContext<'tcx>, _: Location) {
|
fn visit_local(&mut self, local: &Local, ctx: PlaceContext, _: Location) {
|
||||||
// Ignore storage markers altogether, they get removed along with their otherwise unused
|
// Ignore storage markers altogether, they get removed along with their otherwise unused
|
||||||
// decls.
|
// decls.
|
||||||
// FIXME: Extend this to all non-uses.
|
// FIXME: Extend this to all non-uses.
|
||||||
@ -372,7 +372,7 @@ impl<'tcx> MutVisitor<'tcx> for LocalUpdater {
|
|||||||
});
|
});
|
||||||
self.super_basic_block_data(block, data);
|
self.super_basic_block_data(block, data);
|
||||||
}
|
}
|
||||||
fn visit_local(&mut self, l: &mut Local, _: PlaceContext<'tcx>, _: Location) {
|
fn visit_local(&mut self, l: &mut Local, _: PlaceContext, _: Location) {
|
||||||
*l = self.map[*l].unwrap();
|
*l = self.map[*l].unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,6 @@ struct UniformArrayMoveOutVisitor<'a, 'tcx: 'a> {
|
|||||||
|
|
||||||
impl<'a, 'tcx> Visitor<'tcx> for UniformArrayMoveOutVisitor<'a, 'tcx> {
|
impl<'a, 'tcx> Visitor<'tcx> for UniformArrayMoveOutVisitor<'a, 'tcx> {
|
||||||
fn visit_assign(&mut self,
|
fn visit_assign(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
dst_place: &Place<'tcx>,
|
dst_place: &Place<'tcx>,
|
||||||
rvalue: &Rvalue<'tcx>,
|
rvalue: &Rvalue<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
@ -82,7 +81,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UniformArrayMoveOutVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.super_assign(block, dst_place, rvalue, location)
|
self.super_assign(dst_place, rvalue, location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,19 +293,18 @@ struct RestoreDataCollector {
|
|||||||
|
|
||||||
impl<'tcx> Visitor<'tcx> for RestoreDataCollector {
|
impl<'tcx> Visitor<'tcx> for RestoreDataCollector {
|
||||||
fn visit_assign(&mut self,
|
fn visit_assign(&mut self,
|
||||||
block: BasicBlock,
|
|
||||||
place: &Place<'tcx>,
|
place: &Place<'tcx>,
|
||||||
rvalue: &Rvalue<'tcx>,
|
rvalue: &Rvalue<'tcx>,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
if let Rvalue::Aggregate(box AggregateKind::Array(_), _) = *rvalue {
|
if let Rvalue::Aggregate(box AggregateKind::Array(_), _) = *rvalue {
|
||||||
self.candidates.push(location);
|
self.candidates.push(location);
|
||||||
}
|
}
|
||||||
self.super_assign(block, place, rvalue, location)
|
self.super_assign(place, rvalue, location)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
local: &Local,
|
local: &Local,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
let local_use = &mut self.locals_use[*local];
|
let local_use = &mut self.locals_use[*local];
|
||||||
match context {
|
match context {
|
||||||
|
@ -27,7 +27,7 @@ struct FindLocalAssignmentVisitor {
|
|||||||
impl<'tcx> Visitor<'tcx> for FindLocalAssignmentVisitor {
|
impl<'tcx> Visitor<'tcx> for FindLocalAssignmentVisitor {
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
local: &Local,
|
local: &Local,
|
||||||
place_context: PlaceContext<'tcx>,
|
place_context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
if self.needle != *local {
|
if self.needle != *local {
|
||||||
return;
|
return;
|
||||||
|
@ -3,34 +3,31 @@
|
|||||||
use rustc::mir::{Local, Location, Mir};
|
use rustc::mir::{Local, Location, Mir};
|
||||||
use rustc::mir::visit::{PlaceContext, MutVisitor, Visitor};
|
use rustc::mir::visit::{PlaceContext, MutVisitor, Visitor};
|
||||||
use rustc_data_structures::indexed_vec::IndexVec;
|
use rustc_data_structures::indexed_vec::IndexVec;
|
||||||
use std::marker::PhantomData;
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::slice;
|
|
||||||
use std::iter;
|
|
||||||
|
|
||||||
pub struct DefUseAnalysis<'tcx> {
|
pub struct DefUseAnalysis {
|
||||||
info: IndexVec<Local, Info<'tcx>>,
|
info: IndexVec<Local, Info>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Info<'tcx> {
|
pub struct Info {
|
||||||
pub defs_and_uses: Vec<Use<'tcx>>,
|
pub defs_and_uses: Vec<Use>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Use<'tcx> {
|
pub struct Use {
|
||||||
pub context: PlaceContext<'tcx>,
|
pub context: PlaceContext,
|
||||||
pub location: Location,
|
pub location: Location,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> DefUseAnalysis<'tcx> {
|
impl DefUseAnalysis {
|
||||||
pub fn new(mir: &Mir<'tcx>) -> DefUseAnalysis<'tcx> {
|
pub fn new(mir: &Mir<'_>) -> DefUseAnalysis {
|
||||||
DefUseAnalysis {
|
DefUseAnalysis {
|
||||||
info: IndexVec::from_elem_n(Info::new(), mir.local_decls.len()),
|
info: IndexVec::from_elem_n(Info::new(), mir.local_decls.len()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn analyze(&mut self, mir: &Mir<'tcx>) {
|
pub fn analyze(&mut self, mir: &Mir<'_>) {
|
||||||
self.clear();
|
self.clear();
|
||||||
|
|
||||||
let mut finder = DefUseFinder {
|
let mut finder = DefUseFinder {
|
||||||
@ -46,13 +43,13 @@ impl<'tcx> DefUseAnalysis<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn local_info(&self, local: Local) -> &Info<'tcx> {
|
pub fn local_info(&self, local: Local) -> &Info {
|
||||||
&self.info[local]
|
&self.info[local]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mutate_defs_and_uses<F>(&self, local: Local, mir: &mut Mir<'tcx>, mut callback: F)
|
fn mutate_defs_and_uses<F>(&self, local: Local, mir: &mut Mir<'_>, mut callback: F)
|
||||||
where F: for<'a> FnMut(&'a mut Local,
|
where F: for<'a> FnMut(&'a mut Local,
|
||||||
PlaceContext<'tcx>,
|
PlaceContext,
|
||||||
Location) {
|
Location) {
|
||||||
for place_use in &self.info[local].defs_and_uses {
|
for place_use in &self.info[local].defs_and_uses {
|
||||||
MutateUseVisitor::new(local,
|
MutateUseVisitor::new(local,
|
||||||
@ -64,20 +61,20 @@ impl<'tcx> DefUseAnalysis<'tcx> {
|
|||||||
// FIXME(pcwalton): this should update the def-use chains.
|
// FIXME(pcwalton): this should update the def-use chains.
|
||||||
pub fn replace_all_defs_and_uses_with(&self,
|
pub fn replace_all_defs_and_uses_with(&self,
|
||||||
local: Local,
|
local: Local,
|
||||||
mir: &mut Mir<'tcx>,
|
mir: &mut Mir<'_>,
|
||||||
new_local: Local) {
|
new_local: Local) {
|
||||||
self.mutate_defs_and_uses(local, mir, |local, _, _| *local = new_local)
|
self.mutate_defs_and_uses(local, mir, |local, _, _| *local = new_local)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DefUseFinder<'tcx> {
|
struct DefUseFinder {
|
||||||
info: IndexVec<Local, Info<'tcx>>,
|
info: IndexVec<Local, Info>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Visitor<'tcx> for DefUseFinder<'tcx> {
|
impl Visitor<'_> for DefUseFinder {
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
&local: &Local,
|
&local: &Local,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
self.info[local].defs_and_uses.push(Use {
|
self.info[local].defs_and_uses.push(Use {
|
||||||
context,
|
context,
|
||||||
@ -86,8 +83,8 @@ impl<'tcx> Visitor<'tcx> for DefUseFinder<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Info<'tcx> {
|
impl Info {
|
||||||
fn new() -> Info<'tcx> {
|
fn new() -> Info {
|
||||||
Info {
|
Info {
|
||||||
defs_and_uses: vec![],
|
defs_and_uses: vec![],
|
||||||
}
|
}
|
||||||
@ -107,7 +104,7 @@ impl<'tcx> Info<'tcx> {
|
|||||||
|
|
||||||
pub fn defs_not_including_drop(
|
pub fn defs_not_including_drop(
|
||||||
&self,
|
&self,
|
||||||
) -> iter::Filter<slice::Iter<'_, Use<'tcx>>, fn(&&Use<'tcx>) -> bool> {
|
) -> impl Iterator<Item=&Use> {
|
||||||
self.defs_and_uses.iter().filter(|place_use| {
|
self.defs_and_uses.iter().filter(|place_use| {
|
||||||
place_use.context.is_mutating_use() && !place_use.context.is_drop()
|
place_use.context.is_mutating_use() && !place_use.context.is_drop()
|
||||||
})
|
})
|
||||||
@ -120,29 +117,27 @@ impl<'tcx> Info<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MutateUseVisitor<'tcx, F> {
|
struct MutateUseVisitor<F> {
|
||||||
query: Local,
|
query: Local,
|
||||||
callback: F,
|
callback: F,
|
||||||
phantom: PhantomData<&'tcx ()>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, F> MutateUseVisitor<'tcx, F> {
|
impl<F> MutateUseVisitor<F> {
|
||||||
fn new(query: Local, callback: F, _: &Mir<'tcx>)
|
fn new(query: Local, callback: F, _: &Mir<'_>)
|
||||||
-> MutateUseVisitor<'tcx, F>
|
-> MutateUseVisitor<F>
|
||||||
where F: for<'a> FnMut(&'a mut Local, PlaceContext<'tcx>, Location) {
|
where F: for<'a> FnMut(&'a mut Local, PlaceContext, Location) {
|
||||||
MutateUseVisitor {
|
MutateUseVisitor {
|
||||||
query,
|
query,
|
||||||
callback,
|
callback,
|
||||||
phantom: PhantomData,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx, F> MutVisitor<'tcx> for MutateUseVisitor<'tcx, F>
|
impl<F> MutVisitor<'_> for MutateUseVisitor<F>
|
||||||
where F: for<'a> FnMut(&'a mut Local, PlaceContext<'tcx>, Location) {
|
where F: for<'a> FnMut(&'a mut Local, PlaceContext, Location) {
|
||||||
fn visit_local(&mut self,
|
fn visit_local(&mut self,
|
||||||
local: &mut Local,
|
local: &mut Local,
|
||||||
context: PlaceContext<'tcx>,
|
context: PlaceContext,
|
||||||
location: Location) {
|
location: Location) {
|
||||||
if *local == self.query {
|
if *local == self.query {
|
||||||
(self.callback)(local, context, location)
|
(self.callback)(local, context, location)
|
||||||
|
@ -110,7 +110,7 @@ pub enum DefUse {
|
|||||||
Drop,
|
Drop,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn categorize<'tcx>(context: PlaceContext<'tcx>) -> Option<DefUse> {
|
pub fn categorize<'tcx>(context: PlaceContext) -> Option<DefUse> {
|
||||||
match context {
|
match context {
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// DEFS
|
// DEFS
|
||||||
@ -147,10 +147,10 @@ pub fn categorize<'tcx>(context: PlaceContext<'tcx>) -> Option<DefUse> {
|
|||||||
// This won't affect the results since we use this analysis for generators
|
// This won't affect the results since we use this analysis for generators
|
||||||
// and we only care about the result at suspension points. Borrows cannot
|
// and we only care about the result at suspension points. Borrows cannot
|
||||||
// cross suspension points so this behavior is unproblematic.
|
// cross suspension points so this behavior is unproblematic.
|
||||||
PlaceContext::MutatingUse(MutatingUseContext::Borrow(..)) |
|
PlaceContext::MutatingUse(MutatingUseContext::Borrow) |
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow(..)) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::SharedBorrow) |
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow(..)) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::ShallowBorrow) |
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow(..)) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::UniqueBorrow) |
|
||||||
|
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::Inspect) |
|
||||||
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) |
|
PlaceContext::NonMutatingUse(NonMutatingUseContext::Copy) |
|
||||||
@ -220,7 +220,7 @@ impl DefsUses {
|
|||||||
|
|
||||||
impl<'tcx> Visitor<'tcx> for DefsUsesVisitor
|
impl<'tcx> Visitor<'tcx> for DefsUsesVisitor
|
||||||
{
|
{
|
||||||
fn visit_local(&mut self, &local: &Local, context: PlaceContext<'tcx>, _: Location) {
|
fn visit_local(&mut self, &local: &Local, context: PlaceContext, _: Location) {
|
||||||
match categorize(context) {
|
match categorize(context) {
|
||||||
Some(DefUse::Def) => self.defs_uses.add_def(local),
|
Some(DefUse::Def) => self.defs_uses.add_def(local),
|
||||||
Some(DefUse::Use) | Some(DefUse::Drop) => self.defs_uses.add_use(local),
|
Some(DefUse::Use) | Some(DefUse::Drop) => self.defs_uses.add_use(local),
|
||||||
@ -247,9 +247,9 @@ fn block<'tcx>(
|
|||||||
|
|
||||||
// Visit the various parts of the basic block in reverse. If we go
|
// Visit the various parts of the basic block in reverse. If we go
|
||||||
// forward, the logic in `add_def` and `add_use` would be wrong.
|
// forward, the logic in `add_def` and `add_use` would be wrong.
|
||||||
visitor.visit_terminator(BasicBlock::new(0), b.terminator(), dummy_location);
|
visitor.visit_terminator(b.terminator(), dummy_location);
|
||||||
for statement in b.statements.iter().rev() {
|
for statement in b.statements.iter().rev() {
|
||||||
visitor.visit_statement(BasicBlock::new(0), statement, dummy_location);
|
visitor.visit_statement(statement, dummy_location);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitor.defs_uses
|
visitor.defs_uses
|
||||||
|
@ -337,7 +337,7 @@ where
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
write_extra(tcx, w, |visitor| {
|
write_extra(tcx, w, |visitor| {
|
||||||
visitor.visit_statement(current_location.block, statement, current_location);
|
visitor.visit_statement(statement, current_location);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
extra_data(PassWhere::AfterLocation(current_location), w)?;
|
extra_data(PassWhere::AfterLocation(current_location), w)?;
|
||||||
@ -358,7 +358,7 @@ where
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
write_extra(tcx, w, |visitor| {
|
write_extra(tcx, w, |visitor| {
|
||||||
visitor.visit_terminator(current_location.block, data.terminator(), current_location);
|
visitor.visit_terminator(data.terminator(), current_location);
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
extra_data(PassWhere::AfterLocation(current_location), w)?;
|
extra_data(PassWhere::AfterLocation(current_location), w)?;
|
||||||
|
@ -1113,6 +1113,10 @@ span.since {
|
|||||||
h1.fqn {
|
h1.fqn {
|
||||||
overflow: initial;
|
overflow: initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#main > .line-numbers {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
|
@ -523,7 +523,11 @@ impl<T, I: SliceIndex<[T]>> Index<I> for UserRef<[T]> where [T]: UserSafe, I::Ou
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn index(&self, index: I) -> &UserRef<I::Output> {
|
fn index(&self, index: I) -> &UserRef<I::Output> {
|
||||||
unsafe {
|
unsafe {
|
||||||
UserRef::from_ptr(index.index(&*self.as_raw_ptr()))
|
if let Some(slice) = index.get(&*self.as_raw_ptr()) {
|
||||||
|
UserRef::from_ptr(slice)
|
||||||
|
} else {
|
||||||
|
rtabort!("index out of range for user slice");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -533,7 +537,11 @@ impl<T, I: SliceIndex<[T]>> IndexMut<I> for UserRef<[T]> where [T]: UserSafe, I:
|
|||||||
#[inline]
|
#[inline]
|
||||||
fn index_mut(&mut self, index: I) -> &mut UserRef<I::Output> {
|
fn index_mut(&mut self, index: I) -> &mut UserRef<I::Output> {
|
||||||
unsafe {
|
unsafe {
|
||||||
UserRef::from_mut_ptr(index.index_mut(&mut*self.as_raw_mut_ptr()))
|
if let Some(slice) = index.get_mut(&mut*self.as_raw_mut_ptr()) {
|
||||||
|
UserRef::from_mut_ptr(slice)
|
||||||
|
} else {
|
||||||
|
rtabort!("index out of range for user slice");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::io::{Error as IoError, Result as IoResult};
|
use crate::cmp;
|
||||||
|
use crate::io::{Error as IoError, Result as IoResult, IoSlice, IoSliceMut};
|
||||||
use crate::time::Duration;
|
use crate::time::Duration;
|
||||||
|
|
||||||
pub(crate) mod alloc;
|
pub(crate) mod alloc;
|
||||||
@ -8,13 +9,27 @@ pub(crate) mod raw;
|
|||||||
use self::raw::*;
|
use self::raw::*;
|
||||||
|
|
||||||
/// Usercall `read`. See the ABI documentation for more information.
|
/// Usercall `read`. See the ABI documentation for more information.
|
||||||
|
///
|
||||||
|
/// This will do a single `read` usercall and scatter the read data among
|
||||||
|
/// `bufs`. To read to a single buffer, just pass a slice of length one.
|
||||||
#[unstable(feature = "sgx_platform", issue = "56975")]
|
#[unstable(feature = "sgx_platform", issue = "56975")]
|
||||||
pub fn read(fd: Fd, buf: &mut [u8]) -> IoResult<usize> {
|
pub fn read(fd: Fd, bufs: &mut [IoSliceMut<'_>]) -> IoResult<usize> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut userbuf = alloc::User::<[u8]>::uninitialized(buf.len());
|
let total_len = bufs.iter().fold(0usize, |sum, buf| sum.saturating_add(buf.len()));
|
||||||
let len = raw::read(fd, userbuf.as_mut_ptr(), userbuf.len()).from_sgx_result()?;
|
let mut userbuf = alloc::User::<[u8]>::uninitialized(total_len);
|
||||||
userbuf[..len].copy_to_enclave(&mut buf[..len]);
|
let ret_len = raw::read(fd, userbuf.as_mut_ptr(), userbuf.len()).from_sgx_result()?;
|
||||||
Ok(len)
|
let userbuf = &userbuf[..ret_len];
|
||||||
|
let mut index = 0;
|
||||||
|
for buf in bufs {
|
||||||
|
let end = cmp::min(index + buf.len(), userbuf.len());
|
||||||
|
if let Some(buflen) = end.checked_sub(index) {
|
||||||
|
userbuf[index..end].copy_to_enclave(&mut buf[..buflen]);
|
||||||
|
index += buf.len();
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(userbuf.len())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,10 +45,24 @@ pub fn read_alloc(fd: Fd) -> IoResult<Vec<u8>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Usercall `write`. See the ABI documentation for more information.
|
/// Usercall `write`. See the ABI documentation for more information.
|
||||||
|
///
|
||||||
|
/// This will do a single `write` usercall and gather the written data from
|
||||||
|
/// `bufs`. To write from a single buffer, just pass a slice of length one.
|
||||||
#[unstable(feature = "sgx_platform", issue = "56975")]
|
#[unstable(feature = "sgx_platform", issue = "56975")]
|
||||||
pub fn write(fd: Fd, buf: &[u8]) -> IoResult<usize> {
|
pub fn write(fd: Fd, bufs: &[IoSlice<'_>]) -> IoResult<usize> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let userbuf = alloc::User::new_from_enclave(buf);
|
let total_len = bufs.iter().fold(0usize, |sum, buf| sum.saturating_add(buf.len()));
|
||||||
|
let mut userbuf = alloc::User::<[u8]>::uninitialized(total_len);
|
||||||
|
let mut index = 0;
|
||||||
|
for buf in bufs {
|
||||||
|
let end = cmp::min(index + buf.len(), userbuf.len());
|
||||||
|
if let Some(buflen) = end.checked_sub(index) {
|
||||||
|
userbuf[index..end].copy_from_enclave(&buf[..buflen]);
|
||||||
|
index += buf.len();
|
||||||
|
} else {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
raw::write(fd, userbuf.as_ptr(), userbuf.len()).from_sgx_result()
|
raw::write(fd, userbuf.as_ptr(), userbuf.len()).from_sgx_result()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use fortanix_sgx_abi::Fd;
|
use fortanix_sgx_abi::Fd;
|
||||||
|
|
||||||
use crate::io;
|
use crate::io::{self, IoSlice, IoSliceMut};
|
||||||
use crate::mem;
|
use crate::mem;
|
||||||
use crate::sys::{AsInner, FromInner, IntoInner};
|
use crate::sys::{AsInner, FromInner, IntoInner};
|
||||||
use super::abi::usercalls;
|
use super::abi::usercalls;
|
||||||
@ -25,11 +25,19 @@ impl FileDesc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
|
pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
|
||||||
usercalls::read(self.fd, buf)
|
usercalls::read(self.fd, &mut [IoSliceMut::new(buf)])
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
|
||||||
|
usercalls::read(self.fd, bufs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
|
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
|
||||||
usercalls::write(self.fd, buf)
|
usercalls::write(self.fd, &[IoSlice::new(buf)])
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
|
||||||
|
usercalls::write(self.fd, bufs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn flush(&self) -> io::Result<()> {
|
pub fn flush(&self) -> io::Result<()> {
|
||||||
|
@ -137,7 +137,7 @@ impl TcpStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
|
pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
|
||||||
io::default_read_vectored(|b| self.read(b), bufs)
|
self.inner.inner.read_vectored(bufs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
|
pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
|
||||||
@ -145,7 +145,7 @@ impl TcpStream {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
|
pub fn write_vectored(&self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
|
||||||
io::default_write_vectored(|b| self.write(b), bufs)
|
self.inner.inner.write_vectored(bufs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn peer_addr(&self) -> io::Result<SocketAddr> {
|
pub fn peer_addr(&self) -> io::Result<SocketAddr> {
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit b860feaffccb81199c045e9b1511c2e25825dc0c
|
Subproject commit 5274b49caa1a7db6ac10c76bf1a3d5710ccef569
|
Loading…
Reference in New Issue
Block a user