mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 02:03:53 +00:00
Move rustc_mir::borrow_check to new crate rustc_borrowck.
This commit is contained in:
parent
8ceea01bb4
commit
31a61ccc38
29
Cargo.lock
29
Cargo.lock
@ -3598,6 +3598,32 @@ dependencies = [
|
||||
"rustc_span",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_borrowck"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"either",
|
||||
"itertools 0.9.0",
|
||||
"polonius-engine",
|
||||
"rustc_data_structures",
|
||||
"rustc_errors",
|
||||
"rustc_graphviz",
|
||||
"rustc_hir",
|
||||
"rustc_index",
|
||||
"rustc_infer",
|
||||
"rustc_lexer",
|
||||
"rustc_middle",
|
||||
"rustc_mir",
|
||||
"rustc_serialize",
|
||||
"rustc_session",
|
||||
"rustc_span",
|
||||
"rustc_target",
|
||||
"rustc_trait_selection",
|
||||
"rustc_traits",
|
||||
"smallvec",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_builtin_macros"
|
||||
version = "0.0.0"
|
||||
@ -3888,6 +3914,7 @@ dependencies = [
|
||||
"rustc_ast_lowering",
|
||||
"rustc_ast_passes",
|
||||
"rustc_attr",
|
||||
"rustc_borrowck",
|
||||
"rustc_builtin_macros",
|
||||
"rustc_codegen_llvm",
|
||||
"rustc_codegen_ssa",
|
||||
@ -4059,7 +4086,6 @@ dependencies = [
|
||||
"rustc_hir",
|
||||
"rustc_index",
|
||||
"rustc_infer",
|
||||
"rustc_lexer",
|
||||
"rustc_macros",
|
||||
"rustc_middle",
|
||||
"rustc_serialize",
|
||||
@ -4067,7 +4093,6 @@ dependencies = [
|
||||
"rustc_span",
|
||||
"rustc_target",
|
||||
"rustc_trait_selection",
|
||||
"rustc_traits",
|
||||
"smallvec",
|
||||
"tracing",
|
||||
]
|
||||
|
30
compiler/rustc_borrowck/Cargo.toml
Normal file
30
compiler/rustc_borrowck/Cargo.toml
Normal file
@ -0,0 +1,30 @@
|
||||
[package]
|
||||
authors = ["The Rust Project Developers"]
|
||||
name = "rustc_borrowck"
|
||||
version = "0.0.0"
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
either = "1.5.0"
|
||||
itertools = "0.9"
|
||||
tracing = "0.1"
|
||||
polonius-engine = "0.13.0"
|
||||
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_graphviz = { path = "../rustc_graphviz" }
|
||||
rustc_hir = { path = "../rustc_hir" }
|
||||
rustc_index = { path = "../rustc_index" }
|
||||
rustc_infer = { path = "../rustc_infer" }
|
||||
rustc_lexer = { path = "../rustc_lexer" }
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_mir = { path = "../rustc_mir" }
|
||||
rustc_serialize = { path = "../rustc_serialize" }
|
||||
rustc_session = { path = "../rustc_session" }
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
rustc_trait_selection = { path = "../rustc_trait_selection" }
|
||||
rustc_traits = { path = "../rustc_traits" }
|
||||
rustc_span = { path = "../rustc_span" }
|
@ -1,14 +1,14 @@
|
||||
use crate::borrow_check::nll::ToRegionVid;
|
||||
use crate::borrow_check::path_utils::allow_two_phase_borrow;
|
||||
use crate::borrow_check::place_ext::PlaceExt;
|
||||
use crate::dataflow::indexes::BorrowIndex;
|
||||
use crate::dataflow::move_paths::MoveData;
|
||||
use crate::nll::ToRegionVid;
|
||||
use crate::path_utils::allow_two_phase_borrow;
|
||||
use crate::place_ext::PlaceExt;
|
||||
use crate::BorrowIndex;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap};
|
||||
use rustc_index::bit_set::BitSet;
|
||||
use rustc_middle::mir::traversal;
|
||||
use rustc_middle::mir::visit::{MutatingUseContext, NonUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{self, Body, Local, Location};
|
||||
use rustc_middle::ty::{RegionVid, TyCtxt};
|
||||
use rustc_mir::dataflow::move_paths::MoveData;
|
||||
use std::fmt;
|
||||
use std::ops::Index;
|
||||
|
@ -2,7 +2,7 @@ use rustc_errors::{struct_span_err, DiagnosticBuilder, DiagnosticId};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_span::{MultiSpan, Span};
|
||||
|
||||
impl<'cx, 'tcx> crate::borrow_check::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
impl<'cx, 'tcx> crate::MirBorrowckCtxt<'cx, 'tcx> {
|
||||
crate fn cannot_move_when_borrowed(&self, span: Span, desc: &str) -> DiagnosticBuilder<'cx> {
|
||||
struct_span_err!(self, span, E0505, "cannot move out of {} because it is borrowed", desc,)
|
||||
}
|
@ -9,7 +9,7 @@ use rustc_middle::ty::fold::TypeFoldable;
|
||||
use rustc_middle::ty::subst::SubstsRef;
|
||||
use rustc_middle::ty::{self, RegionVid, Ty};
|
||||
|
||||
use crate::borrow_check::{
|
||||
use crate::{
|
||||
borrow_set::BorrowSet, facts::AllFacts, location::LocationTable, nll::ToRegionVid,
|
||||
places_conflict, region_infer::values::LivenessValues,
|
||||
};
|
@ -4,7 +4,7 @@ use rustc_middle::mir::ConstraintCategory;
|
||||
use rustc_middle::ty::{RegionVid, VarianceDiagInfo};
|
||||
use rustc_span::DUMMY_SP;
|
||||
|
||||
use crate::borrow_check::{
|
||||
use crate::{
|
||||
constraints::OutlivesConstraintIndex,
|
||||
constraints::{OutlivesConstraint, OutlivesConstraintSet},
|
||||
type_check::Locations,
|
@ -5,7 +5,7 @@ use rustc_middle::ty::{RegionVid, VarianceDiagInfo};
|
||||
use std::fmt;
|
||||
use std::ops::Index;
|
||||
|
||||
use crate::borrow_check::type_check::Locations;
|
||||
use crate::type_check::Locations;
|
||||
|
||||
crate mod graph;
|
||||
|
@ -1,18 +1,111 @@
|
||||
use rustc_middle::mir::{self, Body, Location, Place};
|
||||
use rustc_middle::ty::RegionVid;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_index::bit_set::BitSet;
|
||||
|
||||
use crate::borrow_check::{
|
||||
places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext, ToRegionVid,
|
||||
};
|
||||
use crate::dataflow::{self, fmt::DebugWithContext, GenKill};
|
||||
|
||||
use rustc_middle::mir::{self, BasicBlock, Body, Location, Place};
|
||||
use rustc_middle::ty::RegionVid;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_mir::dataflow::impls::{EverInitializedPlaces, MaybeUninitializedPlaces};
|
||||
use rustc_mir::dataflow::ResultsVisitable;
|
||||
use rustc_mir::dataflow::{self, fmt::DebugWithContext, GenKill};
|
||||
use rustc_mir::dataflow::{Analysis, Direction, Results};
|
||||
use std::fmt;
|
||||
use std::iter;
|
||||
|
||||
use crate::{
|
||||
places_conflict, BorrowSet, PlaceConflictBias, PlaceExt, RegionInferenceContext, ToRegionVid,
|
||||
};
|
||||
|
||||
/// A tuple with named fields that can hold either the results or the transient state of the
|
||||
/// dataflow analyses used by the borrow checker.
|
||||
#[derive(Debug)]
|
||||
pub struct BorrowckAnalyses<B, U, E> {
|
||||
pub borrows: B,
|
||||
pub uninits: U,
|
||||
pub ever_inits: E,
|
||||
}
|
||||
|
||||
/// The results of the dataflow analyses used by the borrow checker.
|
||||
pub type BorrowckResults<'mir, 'tcx> = BorrowckAnalyses<
|
||||
Results<'tcx, Borrows<'mir, 'tcx>>,
|
||||
Results<'tcx, MaybeUninitializedPlaces<'mir, 'tcx>>,
|
||||
Results<'tcx, EverInitializedPlaces<'mir, 'tcx>>,
|
||||
>;
|
||||
|
||||
/// The transient state of the dataflow analyses used by the borrow checker.
|
||||
pub type BorrowckFlowState<'mir, 'tcx> =
|
||||
<BorrowckResults<'mir, 'tcx> as ResultsVisitable<'tcx>>::FlowState;
|
||||
|
||||
macro_rules! impl_visitable {
|
||||
( $(
|
||||
$T:ident { $( $field:ident : $A:ident ),* $(,)? }
|
||||
)* ) => { $(
|
||||
impl<'tcx, $($A),*, D: Direction> ResultsVisitable<'tcx> for $T<$( Results<'tcx, $A> ),*>
|
||||
where
|
||||
$( $A: Analysis<'tcx, Direction = D>, )*
|
||||
{
|
||||
type Direction = D;
|
||||
type FlowState = $T<$( $A::Domain ),*>;
|
||||
|
||||
fn new_flow_state(&self, body: &mir::Body<'tcx>) -> Self::FlowState {
|
||||
$T {
|
||||
$( $field: self.$field.analysis.bottom_value(body) ),*
|
||||
}
|
||||
}
|
||||
|
||||
fn reset_to_block_entry(
|
||||
&self,
|
||||
state: &mut Self::FlowState,
|
||||
block: BasicBlock,
|
||||
) {
|
||||
$( state.$field.clone_from(&self.$field.entry_set_for_block(block)); )*
|
||||
}
|
||||
|
||||
fn reconstruct_before_statement_effect(
|
||||
&self,
|
||||
state: &mut Self::FlowState,
|
||||
stmt: &mir::Statement<'tcx>,
|
||||
loc: Location,
|
||||
) {
|
||||
$( self.$field.analysis
|
||||
.apply_before_statement_effect(&mut state.$field, stmt, loc); )*
|
||||
}
|
||||
|
||||
fn reconstruct_statement_effect(
|
||||
&self,
|
||||
state: &mut Self::FlowState,
|
||||
stmt: &mir::Statement<'tcx>,
|
||||
loc: Location,
|
||||
) {
|
||||
$( self.$field.analysis
|
||||
.apply_statement_effect(&mut state.$field, stmt, loc); )*
|
||||
}
|
||||
|
||||
fn reconstruct_before_terminator_effect(
|
||||
&self,
|
||||
state: &mut Self::FlowState,
|
||||
term: &mir::Terminator<'tcx>,
|
||||
loc: Location,
|
||||
) {
|
||||
$( self.$field.analysis
|
||||
.apply_before_terminator_effect(&mut state.$field, term, loc); )*
|
||||
}
|
||||
|
||||
fn reconstruct_terminator_effect(
|
||||
&self,
|
||||
state: &mut Self::FlowState,
|
||||
term: &mir::Terminator<'tcx>,
|
||||
loc: Location,
|
||||
) {
|
||||
$( self.$field.analysis
|
||||
.apply_terminator_effect(&mut state.$field, term, loc); )*
|
||||
}
|
||||
}
|
||||
)* }
|
||||
}
|
||||
|
||||
impl_visitable! {
|
||||
BorrowckAnalyses { borrows: B, uninits: U, ever_inits: E }
|
||||
}
|
||||
|
||||
rustc_index::newtype_index! {
|
||||
pub struct BorrowIndex {
|
||||
DEBUG_FORMAT = "bw{}"
|
@ -14,8 +14,8 @@ use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_
|
||||
use std::fmt;
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::borrow_check::region_infer::values::RegionElement;
|
||||
use crate::borrow_check::MirBorrowckCtxt;
|
||||
use crate::region_infer::values::RegionElement;
|
||||
use crate::MirBorrowckCtxt;
|
||||
|
||||
#[derive(Clone)]
|
||||
crate struct UniverseInfo<'tcx>(UniverseInfoInner<'tcx>);
|
@ -15,11 +15,11 @@ use rustc_span::symbol::sym;
|
||||
use rustc_span::{BytePos, MultiSpan, Span, DUMMY_SP};
|
||||
use rustc_trait_selection::infer::InferCtxtExt;
|
||||
|
||||
use crate::dataflow::drop_flag_effects;
|
||||
use crate::dataflow::indexes::{MoveOutIndex, MovePathIndex};
|
||||
use crate::util::borrowck_errors;
|
||||
use crate::borrowck_errors;
|
||||
use rustc_mir::dataflow::drop_flag_effects;
|
||||
use rustc_mir::dataflow::move_paths::{MoveOutIndex, MovePathIndex};
|
||||
|
||||
use crate::borrow_check::{
|
||||
use crate::{
|
||||
borrow_set::BorrowData, diagnostics::Instance, prefixes::IsPrefixOf,
|
||||
InitializationRequiringAction, MirBorrowckCtxt, PrefixSet, WriteKind,
|
||||
};
|
||||
@ -49,7 +49,7 @@ enum StorageDeadOrDrop<'tcx> {
|
||||
}
|
||||
|
||||
impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
pub(in crate::borrow_check) fn report_use_of_moved_or_uninitialized(
|
||||
pub(crate) fn report_use_of_moved_or_uninitialized(
|
||||
&mut self,
|
||||
location: Location,
|
||||
desired_action: InitializationRequiringAction,
|
||||
@ -441,7 +441,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(in crate::borrow_check) fn report_move_out_while_borrowed(
|
||||
pub(crate) fn report_move_out_while_borrowed(
|
||||
&mut self,
|
||||
location: Location,
|
||||
(place, span): (Place<'tcx>, Span),
|
||||
@ -489,7 +489,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
err.buffer(&mut self.errors_buffer);
|
||||
}
|
||||
|
||||
pub(in crate::borrow_check) fn report_use_while_mutably_borrowed(
|
||||
pub(crate) fn report_use_while_mutably_borrowed(
|
||||
&mut self,
|
||||
location: Location,
|
||||
(place, _span): (Place<'tcx>, Span),
|
||||
@ -535,7 +535,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
err
|
||||
}
|
||||
|
||||
pub(in crate::borrow_check) fn report_conflicting_borrow(
|
||||
pub(crate) fn report_conflicting_borrow(
|
||||
&mut self,
|
||||
location: Location,
|
||||
(place, span): (Place<'tcx>, Span),
|
||||
@ -798,7 +798,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
/// cannot borrow `a.u` (via `a.u.z.c`) as immutable because it is also borrowed as
|
||||
/// mutable (via `a.u.s.b`) [E0502]
|
||||
/// ```
|
||||
pub(in crate::borrow_check) fn describe_place_for_conflicting_borrow(
|
||||
pub(crate) fn describe_place_for_conflicting_borrow(
|
||||
&self,
|
||||
first_borrowed_place: Place<'tcx>,
|
||||
second_borrowed_place: Place<'tcx>,
|
||||
@ -875,7 +875,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
/// short a lifetime. (But sometimes it is more useful to report
|
||||
/// it as a more direct conflict between the execution of a
|
||||
/// `Drop::drop` with an aliasing borrow.)
|
||||
pub(in crate::borrow_check) fn report_borrowed_value_does_not_live_long_enough(
|
||||
pub(crate) fn report_borrowed_value_does_not_live_long_enough(
|
||||
&mut self,
|
||||
location: Location,
|
||||
borrow: &BorrowData<'tcx>,
|
||||
@ -1634,7 +1634,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
(result, reinits_reachable)
|
||||
}
|
||||
|
||||
pub(in crate::borrow_check) fn report_illegal_mutation_of_borrowed(
|
||||
pub(crate) fn report_illegal_mutation_of_borrowed(
|
||||
&mut self,
|
||||
location: Location,
|
||||
(place, span): (Place<'tcx>, Span),
|
||||
@ -1695,7 +1695,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
Some((method_did, method_substs)),
|
||||
) = (
|
||||
&self.body[loan.reserve_location.block].terminator,
|
||||
crate::util::find_self_call(
|
||||
rustc_mir::util::find_self_call(
|
||||
tcx,
|
||||
self.body,
|
||||
loan.assigned_place.local,
|
||||
@ -1726,7 +1726,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
/// assigned; `err_place` is a place providing a reason why
|
||||
/// `place` is not mutable (e.g., the non-`mut` local `x` in an
|
||||
/// assignment to `x.f`).
|
||||
pub(in crate::borrow_check) fn report_illegal_reassignment(
|
||||
pub(crate) fn report_illegal_reassignment(
|
||||
&mut self,
|
||||
_location: Location,
|
||||
(place, span): (Place<'tcx>, Span),
|
||||
@ -2226,7 +2226,7 @@ enum AnnotatedBorrowFnSignature<'tcx> {
|
||||
impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
|
||||
/// Annotate the provided diagnostic with information about borrow from the fn signature that
|
||||
/// helps explain.
|
||||
pub(in crate::borrow_check) fn emit(
|
||||
pub(crate) fn emit(
|
||||
&self,
|
||||
cx: &mut MirBorrowckCtxt<'_, 'tcx>,
|
||||
diag: &mut DiagnosticBuilder<'_>,
|
@ -15,8 +15,8 @@ use rustc_middle::ty::{self, RegionVid, TyCtxt};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::Span;
|
||||
|
||||
use crate::borrow_check::region_infer::BlameConstraint;
|
||||
use crate::borrow_check::{
|
||||
use crate::region_infer::BlameConstraint;
|
||||
use crate::{
|
||||
borrow_set::BorrowData, nll::ConstraintDescription, region_infer::Cause, MirBorrowckCtxt,
|
||||
WriteKind,
|
||||
};
|
||||
@ -24,7 +24,7 @@ use crate::borrow_check::{
|
||||
use super::{find_use, RegionName, UseSpans};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(in crate::borrow_check) enum BorrowExplanation {
|
||||
pub(crate) enum BorrowExplanation {
|
||||
UsedLater(LaterUseKind, Span, Option<Span>),
|
||||
UsedLaterInLoop(LaterUseKind, Span, Option<Span>),
|
||||
UsedLaterWhenDropped {
|
||||
@ -43,7 +43,7 @@ pub(in crate::borrow_check) enum BorrowExplanation {
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub(in crate::borrow_check) enum LaterUseKind {
|
||||
pub(crate) enum LaterUseKind {
|
||||
TraitCapture,
|
||||
ClosureCapture,
|
||||
Call,
|
||||
@ -52,13 +52,13 @@ pub(in crate::borrow_check) enum LaterUseKind {
|
||||
}
|
||||
|
||||
impl BorrowExplanation {
|
||||
pub(in crate::borrow_check) fn is_explained(&self) -> bool {
|
||||
pub(crate) fn is_explained(&self) -> bool {
|
||||
match self {
|
||||
BorrowExplanation::Unexplained => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
pub(in crate::borrow_check) fn add_explanation_to_diagnostic<'tcx>(
|
||||
pub(crate) fn add_explanation_to_diagnostic<'tcx>(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
body: &Body<'tcx>,
|
||||
@ -267,7 +267,7 @@ impl BorrowExplanation {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
pub(in crate::borrow_check) fn add_lifetime_bound_suggestion_to_diagnostic(
|
||||
pub(crate) fn add_lifetime_bound_suggestion_to_diagnostic(
|
||||
&self,
|
||||
err: &mut DiagnosticBuilder<'_>,
|
||||
category: &ConstraintCategory,
|
||||
@ -326,7 +326,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
/// - second half is the place being accessed
|
||||
///
|
||||
/// [d]: https://rust-lang.github.io/rfcs/2094-nll.html#leveraging-intuition-framing-errors-in-terms-of-points
|
||||
pub(in crate::borrow_check) fn explain_why_borrow_contains_point(
|
||||
pub(crate) fn explain_why_borrow_contains_point(
|
||||
&self,
|
||||
location: Location,
|
||||
borrow: &BorrowData<'tcx>,
|
@ -1,7 +1,7 @@
|
||||
use std::collections::VecDeque;
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::borrow_check::{
|
||||
use crate::{
|
||||
def_use::{self, DefUse},
|
||||
nll::ToRegionVid,
|
||||
region_infer::{Cause, RegionInferenceContext},
|
@ -12,6 +12,7 @@ use rustc_middle::mir::{
|
||||
};
|
||||
use rustc_middle::ty::print::Print;
|
||||
use rustc_middle::ty::{self, DefIdTree, Instance, Ty, TyCtxt};
|
||||
use rustc_mir::dataflow::move_paths::{InitLocation, LookupResult};
|
||||
use rustc_span::{
|
||||
hygiene::{DesugaringKind, ForLoopLoc},
|
||||
symbol::sym,
|
||||
@ -21,7 +22,6 @@ use rustc_target::abi::VariantIdx;
|
||||
|
||||
use super::borrow_set::BorrowData;
|
||||
use super::MirBorrowckCtxt;
|
||||
use crate::dataflow::move_paths::{InitLocation, LookupResult};
|
||||
|
||||
mod find_use;
|
||||
mod outlives_suggestion;
|
||||
@ -899,9 +899,12 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
kind: TerminatorKind::Call { fn_span, from_hir_call, .. }, ..
|
||||
}) = &self.body[location.block].terminator
|
||||
{
|
||||
let (method_did, method_substs) = if let Some(info) =
|
||||
crate::util::find_self_call(self.infcx.tcx, &self.body, target_temp, location.block)
|
||||
{
|
||||
let (method_did, method_substs) = if let Some(info) = rustc_mir::util::find_self_call(
|
||||
self.infcx.tcx,
|
||||
&self.body,
|
||||
target_temp,
|
||||
location.block,
|
||||
) {
|
||||
info
|
||||
} else {
|
||||
return normal_ret;
|
@ -2,16 +2,16 @@ use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_infer::infer::TyCtxtInferExt;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty;
|
||||
use rustc_mir::dataflow::move_paths::{
|
||||
IllegalMoveOrigin, IllegalMoveOriginKind, LookupResult, MoveError, MovePathIndex,
|
||||
};
|
||||
use rustc_span::source_map::DesugaringKind;
|
||||
use rustc_span::{sym, Span, DUMMY_SP};
|
||||
use rustc_trait_selection::traits::type_known_to_meet_bound_modulo_regions;
|
||||
|
||||
use crate::borrow_check::diagnostics::UseSpans;
|
||||
use crate::borrow_check::prefixes::PrefixSet;
|
||||
use crate::borrow_check::MirBorrowckCtxt;
|
||||
use crate::dataflow::move_paths::{
|
||||
IllegalMoveOrigin, IllegalMoveOriginKind, LookupResult, MoveError, MovePathIndex,
|
||||
};
|
||||
use crate::diagnostics::UseSpans;
|
||||
use crate::prefixes::PrefixSet;
|
||||
use crate::MirBorrowckCtxt;
|
||||
|
||||
// Often when desugaring a pattern match we may have many individual moves in
|
||||
// MIR that are all part of one operation from the user's point-of-view. For
|
@ -14,10 +14,10 @@ use rustc_span::source_map::DesugaringKind;
|
||||
use rustc_span::symbol::{kw, Symbol};
|
||||
use rustc_span::{BytePos, Span};
|
||||
|
||||
use crate::borrow_check::diagnostics::BorrowedContentSource;
|
||||
use crate::borrow_check::MirBorrowckCtxt;
|
||||
use crate::util::collect_writes::FindAssignments;
|
||||
use crate::diagnostics::BorrowedContentSource;
|
||||
use crate::MirBorrowckCtxt;
|
||||
use rustc_errors::{Applicability, DiagnosticBuilder};
|
||||
use rustc_mir::util::collect_writes::FindAssignments;
|
||||
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
pub(crate) enum AccessKind {
|
@ -1,16 +1,14 @@
|
||||
//! Contains utilities for generating suggestions for borrowck errors related to unsatisfied
|
||||
//! outlives constraints.
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::DiagnosticBuilder;
|
||||
use rustc_middle::ty::RegionVid;
|
||||
use smallvec::SmallVec;
|
||||
use std::collections::BTreeMap;
|
||||
use tracing::debug;
|
||||
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::borrow_check::MirBorrowckCtxt;
|
||||
use crate::MirBorrowckCtxt;
|
||||
|
||||
use super::{ErrorConstraintInfo, RegionName, RegionNameSource};
|
||||
|
@ -11,10 +11,10 @@ use rustc_middle::ty::{self, RegionVid, Ty};
|
||||
use rustc_span::symbol::{kw, sym};
|
||||
use rustc_span::{BytePos, Span};
|
||||
|
||||
use crate::util::borrowck_errors;
|
||||
use crate::borrowck_errors;
|
||||
|
||||
use crate::borrow_check::region_infer::BlameConstraint;
|
||||
use crate::borrow_check::{
|
||||
use crate::region_infer::BlameConstraint;
|
||||
use crate::{
|
||||
nll::ConstraintDescription,
|
||||
region_infer::{values::RegionElement, TypeTest},
|
||||
universal_regions::DefiningTy,
|
||||
@ -152,7 +152,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
/// Produces nice borrowck error diagnostics for all the errors collected in `nll_errors`.
|
||||
pub(in crate::borrow_check) fn report_region_errors(&mut self, nll_errors: RegionErrors<'tcx>) {
|
||||
pub(crate) fn report_region_errors(&mut self, nll_errors: RegionErrors<'tcx>) {
|
||||
// Iterate through all the errors, producing a diagnostic for each one. The diagnostics are
|
||||
// buffered in the `MirBorrowckCtxt`.
|
||||
|
||||
@ -265,7 +265,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
|
||||
/// ```
|
||||
///
|
||||
/// Here we would be invoked with `fr = 'a` and `outlived_fr = `'b`.
|
||||
pub(in crate::borrow_check) fn report_region_error(
|
||||
pub(crate) fn report_region_error(
|
||||
&mut self,
|
||||
fr: RegionVid,
|
||||
fr_origin: NllRegionVariableOrigin,
|
@ -10,7 +10,7 @@ use rustc_middle::ty::{self, RegionVid, Ty};
|
||||
use rustc_span::symbol::{kw, sym, Ident, Symbol};
|
||||
use rustc_span::{Span, DUMMY_SP};
|
||||
|
||||
use crate::borrow_check::{nll::ToRegionVid, universal_regions::DefiningTy, MirBorrowckCtxt};
|
||||
use crate::{nll::ToRegionVid, universal_regions::DefiningTy, MirBorrowckCtxt};
|
||||
|
||||
/// A name for a particular region used in emitting diagnostics. This name could be a generated
|
||||
/// name like `'1`, a name used by the user like `'a`, or a name like `'static`.
|
@ -1,5 +1,5 @@
|
||||
use crate::borrow_check::Upvar;
|
||||
use crate::borrow_check::{nll::ToRegionVid, region_infer::RegionInferenceContext};
|
||||
use crate::Upvar;
|
||||
use crate::{nll::ToRegionVid, region_infer::RegionInferenceContext};
|
||||
use rustc_index::vec::{Idx, IndexVec};
|
||||
use rustc_middle::mir::{Body, Local};
|
||||
use rustc_middle::ty::{RegionVid, TyCtxt};
|
@ -1,10 +1,11 @@
|
||||
use crate::borrow_check::location::{LocationIndex, LocationTable};
|
||||
use crate::dataflow::indexes::{BorrowIndex, MovePathIndex};
|
||||
use crate::location::{LocationIndex, LocationTable};
|
||||
use crate::BorrowIndex;
|
||||
use polonius_engine::AllFacts as PoloniusFacts;
|
||||
use polonius_engine::Atom;
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_middle::mir::Local;
|
||||
use rustc_middle::ty::{RegionVid, TyCtxt};
|
||||
use rustc_mir::dataflow::move_paths::MovePathIndex;
|
||||
use std::error::Error;
|
||||
use std::fmt::Debug;
|
||||
use std::fs::{self, File};
|
||||
@ -100,12 +101,6 @@ impl Atom for LocationIndex {
|
||||
}
|
||||
}
|
||||
|
||||
impl Atom for MovePathIndex {
|
||||
fn index(self) -> usize {
|
||||
Idx::index(self)
|
||||
}
|
||||
}
|
||||
|
||||
struct FactWriter<'w> {
|
||||
location_table: &'w LocationTable,
|
||||
dir: &'w Path,
|
@ -7,12 +7,10 @@ use rustc_middle::mir::{Statement, StatementKind};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use std::iter;
|
||||
|
||||
use crate::dataflow::indexes::BorrowIndex;
|
||||
|
||||
use crate::borrow_check::{
|
||||
use crate::{
|
||||
borrow_set::BorrowSet, facts::AllFacts, location::LocationTable, path_utils::*, AccessDepth,
|
||||
Activation, ArtificialField, Deep, JustWrite, LocalMutationIsAllowed, MutateMode, Read,
|
||||
ReadKind, ReadOrWrite, Reservation, Shallow, Write, WriteAndRead, WriteKind,
|
||||
Activation, ArtificialField, BorrowIndex, Deep, JustWrite, LocalMutationIsAllowed, MutateMode,
|
||||
Read, ReadKind, ReadOrWrite, Reservation, Shallow, Write, WriteAndRead, WriteKind,
|
||||
};
|
||||
|
||||
pub(super) fn generate_invalidates<'tcx>(
|
@ -1,5 +1,22 @@
|
||||
//! This query borrow-checks the MIR to (further) ensure it is not broken.
|
||||
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(const_panic)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(format_args_capture)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(trusted_step)]
|
||||
#![feature(try_blocks)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate rustc_middle;
|
||||
#[macro_use]
|
||||
extern crate tracing;
|
||||
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::graph::dominators::Dominators;
|
||||
use rustc_errors::{Applicability, Diagnostic, DiagnosticBuilder, ErrorReported};
|
||||
@ -29,14 +46,13 @@ use std::iter;
|
||||
use std::mem;
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::dataflow;
|
||||
use crate::dataflow::impls::{
|
||||
Borrows, EverInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces,
|
||||
use rustc_mir::dataflow::impls::{
|
||||
EverInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces,
|
||||
};
|
||||
use crate::dataflow::indexes::{BorrowIndex, InitIndex, MoveOutIndex, MovePathIndex};
|
||||
use crate::dataflow::move_paths::{InitLocation, LookupResult, MoveData, MoveError};
|
||||
use crate::dataflow::MoveDataParamEnv;
|
||||
use crate::dataflow::{Analysis, BorrowckFlowState as Flows, BorrowckResults};
|
||||
use rustc_mir::dataflow::move_paths::{InitIndex, MoveOutIndex, MovePathIndex};
|
||||
use rustc_mir::dataflow::move_paths::{InitLocation, LookupResult, MoveData, MoveError};
|
||||
use rustc_mir::dataflow::Analysis;
|
||||
use rustc_mir::dataflow::MoveDataParamEnv;
|
||||
|
||||
use self::diagnostics::{AccessKind, RegionName};
|
||||
use self::location::LocationTable;
|
||||
@ -47,9 +63,10 @@ use facts::AllFacts;
|
||||
use self::path_utils::*;
|
||||
|
||||
mod borrow_set;
|
||||
mod borrowck_errors;
|
||||
mod constraint_generation;
|
||||
mod constraints;
|
||||
pub mod consumers;
|
||||
mod dataflow;
|
||||
mod def_use;
|
||||
mod diagnostics;
|
||||
mod facts;
|
||||
@ -67,15 +84,19 @@ mod type_check;
|
||||
mod universal_regions;
|
||||
mod used_muts;
|
||||
|
||||
crate use borrow_set::{BorrowData, BorrowSet};
|
||||
crate use nll::{PoloniusOutput, ToRegionVid};
|
||||
crate use place_ext::PlaceExt;
|
||||
crate use places_conflict::{places_conflict, PlaceConflictBias};
|
||||
crate use region_infer::RegionInferenceContext;
|
||||
// A public API provided for the Rust compiler consumers.
|
||||
pub mod consumers;
|
||||
|
||||
use borrow_set::{BorrowData, BorrowSet};
|
||||
use dataflow::{BorrowIndex, BorrowckFlowState as Flows, BorrowckResults, Borrows};
|
||||
use nll::{PoloniusOutput, ToRegionVid};
|
||||
use place_ext::PlaceExt;
|
||||
use places_conflict::{places_conflict, PlaceConflictBias};
|
||||
use region_infer::RegionInferenceContext;
|
||||
|
||||
// FIXME(eddyb) perhaps move this somewhere more centrally.
|
||||
#[derive(Debug)]
|
||||
crate struct Upvar<'tcx> {
|
||||
struct Upvar<'tcx> {
|
||||
place: CapturedPlace<'tcx>,
|
||||
|
||||
/// If true, the capture is behind a reference.
|
||||
@ -352,7 +373,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
||||
|
||||
mbcx.report_move_errors(move_errors);
|
||||
|
||||
dataflow::visit_results(
|
||||
rustc_mir::dataflow::visit_results(
|
||||
&body,
|
||||
traversal::reverse_postorder(&body).map(|(bb, _)| bb),
|
||||
&results,
|
||||
@ -495,8 +516,8 @@ pub struct BodyWithBorrowckFacts<'tcx> {
|
||||
pub location_table: LocationTable,
|
||||
}
|
||||
|
||||
crate struct MirBorrowckCtxt<'cx, 'tcx> {
|
||||
crate infcx: &'cx InferCtxt<'cx, 'tcx>,
|
||||
struct MirBorrowckCtxt<'cx, 'tcx> {
|
||||
infcx: &'cx InferCtxt<'cx, 'tcx>,
|
||||
param_env: ParamEnv<'tcx>,
|
||||
body: &'cx Body<'tcx>,
|
||||
move_data: &'cx MoveData<'tcx>,
|
||||
@ -594,7 +615,7 @@ crate struct MirBorrowckCtxt<'cx, 'tcx> {
|
||||
// 2. loans made in overlapping scopes do not conflict
|
||||
// 3. assignments do not affect things loaned out as immutable
|
||||
// 4. moves do not affect things loaned out in any way
|
||||
impl<'cx, 'tcx> dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx> {
|
||||
impl<'cx, 'tcx> rustc_mir::dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtxt<'cx, 'tcx> {
|
||||
type FlowState = Flows<'cx, 'tcx>;
|
||||
|
||||
fn visit_statement_before_primary_effect(
|
||||
@ -2344,7 +2365,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
/// then returns the index of the field being projected. Note that this closure will always
|
||||
/// be `self` in the current MIR, because that is the only time we directly access the fields
|
||||
/// of a closure type.
|
||||
pub fn is_upvar_field_projection(&self, place_ref: PlaceRef<'tcx>) -> Option<Field> {
|
||||
fn is_upvar_field_projection(&self, place_ref: PlaceRef<'tcx>) -> Option<Field> {
|
||||
path_utils::is_upvar_field_projection(self.infcx.tcx, &self.upvars, place_ref, self.body())
|
||||
}
|
||||
}
|
@ -20,13 +20,13 @@ use std::str::FromStr;
|
||||
use self::mir_util::PassWhere;
|
||||
use polonius_engine::{Algorithm, Output};
|
||||
|
||||
use crate::dataflow::impls::MaybeInitializedPlaces;
|
||||
use crate::dataflow::move_paths::{InitKind, InitLocation, MoveData};
|
||||
use crate::dataflow::ResultsCursor;
|
||||
use crate::util as mir_util;
|
||||
use crate::util::pretty;
|
||||
use rustc_mir::dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir::dataflow::move_paths::{InitKind, InitLocation, MoveData};
|
||||
use rustc_mir::dataflow::ResultsCursor;
|
||||
use rustc_mir::util as mir_util;
|
||||
use rustc_mir::util::pretty;
|
||||
|
||||
use crate::borrow_check::{
|
||||
use crate::{
|
||||
borrow_set::BorrowSet,
|
||||
constraint_generation,
|
||||
diagnostics::RegionErrors,
|
||||
@ -56,7 +56,7 @@ crate struct NllOutput<'tcx> {
|
||||
/// Rewrites the regions in the MIR to use NLL variables, also scraping out the set of universal
|
||||
/// regions (e.g., region parameters) declared on the function. That set will need to be given to
|
||||
/// `compute_regions`.
|
||||
pub(in crate::borrow_check) fn replace_regions_in_mir<'cx, 'tcx>(
|
||||
pub(crate) fn replace_regions_in_mir<'cx, 'tcx>(
|
||||
infcx: &InferCtxt<'cx, 'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
body: &mut Body<'tcx>,
|
||||
@ -155,7 +155,7 @@ fn populate_polonius_move_facts(
|
||||
/// Computes the (non-lexical) regions from the input MIR.
|
||||
///
|
||||
/// This may result in errors being reported.
|
||||
pub(in crate::borrow_check) fn compute_regions<'cx, 'tcx>(
|
||||
pub(crate) fn compute_regions<'cx, 'tcx>(
|
||||
infcx: &InferCtxt<'cx, 'tcx>,
|
||||
universal_regions: UniversalRegions<'tcx>,
|
||||
body: &Body<'tcx>,
|
@ -1,8 +1,8 @@
|
||||
use crate::borrow_check::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
|
||||
use crate::borrow_check::places_conflict;
|
||||
use crate::borrow_check::AccessDepth;
|
||||
use crate::borrow_check::Upvar;
|
||||
use crate::dataflow::indexes::BorrowIndex;
|
||||
use crate::borrow_set::{BorrowData, BorrowSet, TwoPhaseActivation};
|
||||
use crate::places_conflict;
|
||||
use crate::AccessDepth;
|
||||
use crate::BorrowIndex;
|
||||
use crate::Upvar;
|
||||
use rustc_data_structures::graph::dominators::Dominators;
|
||||
use rustc_middle::mir::BorrowKind;
|
||||
use rustc_middle::mir::{BasicBlock, Body, Field, Location, Place, PlaceRef, ProjectionElem};
|
@ -1,4 +1,4 @@
|
||||
use crate::borrow_check::borrow_set::LocalsStateAtExit;
|
||||
use crate::borrow_set::LocalsStateAtExit;
|
||||
use rustc_hir as hir;
|
||||
use rustc_middle::mir::ProjectionElem;
|
||||
use rustc_middle::mir::{Body, Mutability, Place};
|
@ -1,6 +1,6 @@
|
||||
use crate::borrow_check::ArtificialField;
|
||||
use crate::borrow_check::Overlap;
|
||||
use crate::borrow_check::{AccessDepth, Deep, Shallow};
|
||||
use crate::ArtificialField;
|
||||
use crate::Overlap;
|
||||
use crate::{AccessDepth, Deep, Shallow};
|
||||
use rustc_hir as hir;
|
||||
use rustc_middle::mir::{Body, BorrowKind, Local, Place, PlaceElem, PlaceRef, ProjectionElem};
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
@ -4,7 +4,7 @@
|
||||
//! context internal state.
|
||||
|
||||
use super::{OutlivesConstraint, RegionInferenceContext};
|
||||
use crate::borrow_check::type_check::Locations;
|
||||
use crate::type_check::Locations;
|
||||
use rustc_infer::infer::NllRegionVariableOrigin;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use std::io::{self, Write};
|
@ -6,7 +6,7 @@ use std::borrow::Cow;
|
||||
use std::io::{self, Write};
|
||||
|
||||
use super::*;
|
||||
use crate::borrow_check::constraints::OutlivesConstraint;
|
||||
use crate::constraints::OutlivesConstraint;
|
||||
use rustc_graphviz as dot;
|
||||
|
||||
impl<'tcx> RegionInferenceContext<'tcx> {
|
@ -17,7 +17,7 @@ use rustc_middle::mir::{
|
||||
use rustc_middle::ty::{self, subst::SubstsRef, RegionVid, Ty, TyCtxt, TypeFoldable};
|
||||
use rustc_span::Span;
|
||||
|
||||
use crate::borrow_check::{
|
||||
use crate::{
|
||||
constraints::{
|
||||
graph::NormalConstraintGraph, ConstraintSccIndex, OutlivesConstraint, OutlivesConstraintSet,
|
||||
},
|
||||
@ -132,33 +132,33 @@ pub(crate) struct AppliedMemberConstraint {
|
||||
///
|
||||
/// The vector if `AppliedMemberConstraint` elements is kept sorted
|
||||
/// by this field.
|
||||
pub(in crate::borrow_check) member_region_scc: ConstraintSccIndex,
|
||||
pub(crate) member_region_scc: ConstraintSccIndex,
|
||||
|
||||
/// The "best option" that `apply_member_constraint` found -- this was
|
||||
/// added as an "ad-hoc" lower-bound to `member_region_scc`.
|
||||
pub(in crate::borrow_check) min_choice: ty::RegionVid,
|
||||
pub(crate) min_choice: ty::RegionVid,
|
||||
|
||||
/// The "member constraint index" -- we can find out details about
|
||||
/// the constraint from
|
||||
/// `set.member_constraints[member_constraint_index]`.
|
||||
pub(in crate::borrow_check) member_constraint_index: NllMemberConstraintIndex,
|
||||
pub(crate) member_constraint_index: NllMemberConstraintIndex,
|
||||
}
|
||||
|
||||
pub(crate) struct RegionDefinition<'tcx> {
|
||||
/// What kind of variable is this -- a free region? existential
|
||||
/// variable? etc. (See the `NllRegionVariableOrigin` for more
|
||||
/// info.)
|
||||
pub(in crate::borrow_check) origin: NllRegionVariableOrigin,
|
||||
pub(crate) origin: NllRegionVariableOrigin,
|
||||
|
||||
/// Which universe is this region variable defined in? This is
|
||||
/// most often `ty::UniverseIndex::ROOT`, but when we encounter
|
||||
/// forall-quantifiers like `for<'a> { 'a = 'b }`, we would create
|
||||
/// the variable for `'a` in a fresh universe that extends ROOT.
|
||||
pub(in crate::borrow_check) universe: ty::UniverseIndex,
|
||||
pub(crate) universe: ty::UniverseIndex,
|
||||
|
||||
/// If this is 'static or an early-bound region, then this is
|
||||
/// `Some(X)` where `X` is the name of the region.
|
||||
pub(in crate::borrow_check) external_name: Option<ty::Region<'tcx>>,
|
||||
pub(crate) external_name: Option<ty::Region<'tcx>>,
|
||||
}
|
||||
|
||||
/// N.B., the variants in `Cause` are intentionally ordered. Lower
|
||||
@ -245,7 +245,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
///
|
||||
/// The `outlives_constraints` and `type_tests` are an initial set
|
||||
/// of constraints produced by the MIR type check.
|
||||
pub(in crate::borrow_check) fn new(
|
||||
pub(crate) fn new(
|
||||
var_infos: VarInfos,
|
||||
universal_regions: Rc<UniversalRegions<'tcx>>,
|
||||
placeholder_indices: Rc<PlaceholderIndices>,
|
||||
@ -534,7 +534,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
/// Once region solving has completed, this function will return
|
||||
/// the member constraints that were applied to the value of a given
|
||||
/// region `r`. See `AppliedMemberConstraint`.
|
||||
pub(in crate::borrow_check) fn applied_member_constraints(
|
||||
pub(crate) fn applied_member_constraints(
|
||||
&self,
|
||||
r: impl ToRegionVid,
|
||||
) -> &[AppliedMemberConstraint] {
|
||||
@ -1088,7 +1088,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
/// include the CFG anyhow.
|
||||
/// - For each `end('x)` element in `'r`, compute the mutual LUB, yielding
|
||||
/// a result `'y`.
|
||||
pub(in crate::borrow_check) fn universal_upper_bound(&self, r: RegionVid) -> RegionVid {
|
||||
pub(crate) fn universal_upper_bound(&self, r: RegionVid) -> RegionVid {
|
||||
debug!("universal_upper_bound(r={:?}={})", r, self.region_value_str(r));
|
||||
|
||||
// Find the smallest universal region that contains all other
|
||||
@ -1115,7 +1115,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
/// Therefore, this method should only be used in diagnostic code,
|
||||
/// where displaying *some* named universal region is better than
|
||||
/// falling back to 'static.
|
||||
pub(in crate::borrow_check) fn approx_universal_upper_bound(&self, r: RegionVid) -> RegionVid {
|
||||
pub(crate) fn approx_universal_upper_bound(&self, r: RegionVid) -> RegionVid {
|
||||
debug!("approx_universal_upper_bound(r={:?}={})", r, self.region_value_str(r));
|
||||
|
||||
// Find the smallest universal region that contains all other
|
@ -47,7 +47,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
/// which has no `external_name` in which case we use `'empty` as the
|
||||
/// region to pass to `infer_opaque_definition_from_instantiation`.
|
||||
#[instrument(skip(self, infcx))]
|
||||
pub(in crate::borrow_check) fn infer_opaque_types(
|
||||
pub(crate) fn infer_opaque_types(
|
||||
&self,
|
||||
infcx: &InferCtxt<'_, 'tcx>,
|
||||
opaque_ty_decls: VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>,
|
||||
@ -105,7 +105,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
|
||||
/// that the regions produced are in fact equal to the named region they are
|
||||
/// replaced with. This is fine because this function is only to improve the
|
||||
/// region names in error messages.
|
||||
pub(in crate::borrow_check) fn name_regions<T>(&self, tcx: TyCtxt<'tcx>, ty: T) -> T
|
||||
pub(crate) fn name_regions<T>(&self, tcx: TyCtxt<'tcx>, ty: T) -> T
|
||||
where
|
||||
T: TypeFoldable<'tcx>,
|
||||
{
|
@ -1,5 +1,5 @@
|
||||
use crate::borrow_check::constraints::ConstraintSccIndex;
|
||||
use crate::borrow_check::RegionInferenceContext;
|
||||
use crate::constraints::ConstraintSccIndex;
|
||||
use crate::RegionInferenceContext;
|
||||
use itertools::Itertools;
|
||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||
use rustc_data_structures::graph::vec_graph::VecGraph;
|
@ -8,7 +8,7 @@ use rustc_span::Span;
|
||||
use rustc_trait_selection::traits::query::type_op::{self, TypeOpOutput};
|
||||
use rustc_trait_selection::traits::query::Fallible;
|
||||
|
||||
use crate::borrow_check::diagnostics::{ToUniverseInfo, UniverseInfo};
|
||||
use crate::diagnostics::{ToUniverseInfo, UniverseInfo};
|
||||
|
||||
use super::{Locations, NormalizeLocation, TypeChecker};
|
||||
|
@ -9,7 +9,7 @@ use rustc_middle::ty::subst::GenericArgKind;
|
||||
use rustc_middle::ty::{self, TyCtxt};
|
||||
use rustc_span::DUMMY_SP;
|
||||
|
||||
use crate::borrow_check::{
|
||||
use crate::{
|
||||
constraints::OutlivesConstraint,
|
||||
nll::ToRegionVid,
|
||||
region_infer::TypeTest,
|
@ -13,7 +13,7 @@ use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
|
||||
use std::rc::Rc;
|
||||
use type_op::TypeOpOutput;
|
||||
|
||||
use crate::borrow_check::{
|
||||
use crate::{
|
||||
nll::ToRegionVid,
|
||||
type_check::constraint_conversion,
|
||||
type_check::{Locations, MirTypeckRegionConstraints},
|
||||
@ -55,7 +55,7 @@ type RegionBoundPairs<'tcx> = Vec<(ty::Region<'tcx>, GenericKind<'tcx>)>;
|
||||
type NormalizedInputsAndOutput<'tcx> = Vec<Ty<'tcx>>;
|
||||
|
||||
crate struct CreateResult<'tcx> {
|
||||
pub(in crate::borrow_check) universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
|
||||
crate universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
|
||||
crate region_bound_pairs: RegionBoundPairs<'tcx>,
|
||||
crate normalized_inputs_and_output: NormalizedInputsAndOutput<'tcx>,
|
||||
}
|
@ -7,16 +7,15 @@
|
||||
//! `RETURN_PLACE` the MIR arguments) are always fully normalized (and
|
||||
//! contain revealed `impl Trait` values).
|
||||
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_infer::infer::LateBoundRegionConversionTime;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::traits::ObligationCause;
|
||||
use rustc_middle::ty::{self, Ty};
|
||||
use rustc_span::Span;
|
||||
use rustc_trait_selection::traits::query::normalize::AtExt;
|
||||
|
||||
use rustc_index::vec::Idx;
|
||||
use rustc_span::Span;
|
||||
|
||||
use crate::borrow_check::universal_regions::UniversalRegions;
|
||||
use crate::universal_regions::UniversalRegions;
|
||||
|
||||
use super::{Locations, TypeChecker};
|
||||
|
@ -3,8 +3,8 @@ use rustc_index::vec::IndexVec;
|
||||
use rustc_middle::mir::visit::{PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{Body, Local, Location};
|
||||
|
||||
use crate::borrow_check::def_use::{self, DefUse};
|
||||
use crate::borrow_check::region_infer::values::{PointIndex, RegionValueElements};
|
||||
use crate::def_use::{self, DefUse};
|
||||
use crate::region_infer::values::{PointIndex, RegionValueElements};
|
||||
|
||||
/// A map that cross references each local with the locations where it
|
||||
/// is defined (assigned), used, or dropped. Used during liveness
|
@ -3,11 +3,11 @@ use rustc_middle::mir::{Body, Local};
|
||||
use rustc_middle::ty::{RegionVid, TyCtxt};
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::dataflow::impls::MaybeInitializedPlaces;
|
||||
use crate::dataflow::move_paths::MoveData;
|
||||
use crate::dataflow::ResultsCursor;
|
||||
use rustc_mir::dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir::dataflow::move_paths::MoveData;
|
||||
use rustc_mir::dataflow::ResultsCursor;
|
||||
|
||||
use crate::borrow_check::{
|
||||
use crate::{
|
||||
constraints::OutlivesConstraintSet,
|
||||
facts::{AllFacts, AllFactsExt},
|
||||
location::LocationTable,
|
@ -1,10 +1,9 @@
|
||||
use crate::borrow_check::def_use::{self, DefUse};
|
||||
use crate::borrow_check::location::{LocationIndex, LocationTable};
|
||||
use crate::dataflow::indexes::MovePathIndex;
|
||||
use crate::dataflow::move_paths::{LookupResult, MoveData};
|
||||
use crate::def_use::{self, DefUse};
|
||||
use crate::location::{LocationIndex, LocationTable};
|
||||
use rustc_middle::mir::visit::{MutatingUseContext, PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{Body, Local, Location, Place};
|
||||
use rustc_middle::ty::subst::GenericArg;
|
||||
use rustc_mir::dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
|
||||
|
||||
use super::TypeChecker;
|
||||
|
@ -8,12 +8,11 @@ use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives;
|
||||
use rustc_trait_selection::traits::query::type_op::{TypeOp, TypeOpOutput};
|
||||
use std::rc::Rc;
|
||||
|
||||
use crate::dataflow::impls::MaybeInitializedPlaces;
|
||||
use crate::dataflow::indexes::MovePathIndex;
|
||||
use crate::dataflow::move_paths::{HasMoveData, MoveData};
|
||||
use crate::dataflow::ResultsCursor;
|
||||
use rustc_mir::dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir::dataflow::move_paths::{HasMoveData, MoveData, MovePathIndex};
|
||||
use rustc_mir::dataflow::ResultsCursor;
|
||||
|
||||
use crate::borrow_check::{
|
||||
use crate::{
|
||||
region_infer::values::{self, PointIndex, RegionValueElements},
|
||||
type_check::liveness::local_use_map::LocalUseMap,
|
||||
type_check::liveness::polonius,
|
@ -41,14 +41,14 @@ use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
|
||||
use rustc_trait_selection::traits::query::Fallible;
|
||||
use rustc_trait_selection::traits::{self, ObligationCause, PredicateObligations};
|
||||
|
||||
use crate::dataflow::impls::MaybeInitializedPlaces;
|
||||
use crate::dataflow::move_paths::MoveData;
|
||||
use crate::dataflow::ResultsCursor;
|
||||
use crate::transform::{
|
||||
use rustc_mir::dataflow::impls::MaybeInitializedPlaces;
|
||||
use rustc_mir::dataflow::move_paths::MoveData;
|
||||
use rustc_mir::dataflow::ResultsCursor;
|
||||
use rustc_mir::transform::{
|
||||
check_consts::ConstCx, promote_consts::is_const_fn_in_array_repeat_expression,
|
||||
};
|
||||
|
||||
use crate::borrow_check::{
|
||||
use crate::{
|
||||
borrow_set::BorrowSet,
|
||||
constraints::{OutlivesConstraint, OutlivesConstraintSet},
|
||||
diagnostics::UniverseInfo,
|
||||
@ -68,7 +68,7 @@ use crate::borrow_check::{
|
||||
|
||||
macro_rules! span_mirbug {
|
||||
($context:expr, $elem:expr, $($message:tt)*) => ({
|
||||
$crate::borrow_check::type_check::mirbug(
|
||||
$crate::type_check::mirbug(
|
||||
$context.tcx(),
|
||||
$context.last_span,
|
||||
&format!(
|
||||
@ -887,7 +887,7 @@ struct BorrowCheckContext<'a, 'tcx> {
|
||||
|
||||
crate struct MirTypeckResults<'tcx> {
|
||||
crate constraints: MirTypeckRegionConstraints<'tcx>,
|
||||
pub(in crate::borrow_check) universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
|
||||
crate universal_region_relations: Frozen<UniversalRegionRelations<'tcx>>,
|
||||
crate opaque_type_values: VecMap<OpaqueTypeKey<'tcx>, Ty<'tcx>>,
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ use rustc_middle::ty::relate::TypeRelation;
|
||||
use rustc_middle::ty::{self, Const, Ty};
|
||||
use rustc_trait_selection::traits::query::Fallible;
|
||||
|
||||
use crate::borrow_check::constraints::OutlivesConstraint;
|
||||
use crate::borrow_check::diagnostics::UniverseInfo;
|
||||
use crate::borrow_check::type_check::{BorrowCheckContext, Locations};
|
||||
use crate::constraints::OutlivesConstraint;
|
||||
use crate::diagnostics::UniverseInfo;
|
||||
use crate::type_check::{BorrowCheckContext, Locations};
|
||||
|
||||
/// Adds sufficient constraints to ensure that `a R b` where `R` depends on `v`:
|
||||
///
|
@ -26,7 +26,7 @@ use rustc_middle::ty::subst::{InternalSubsts, Subst, SubstsRef};
|
||||
use rustc_middle::ty::{self, RegionVid, Ty, TyCtxt};
|
||||
use std::iter;
|
||||
|
||||
use crate::borrow_check::nll::ToRegionVid;
|
||||
use crate::nll::ToRegionVid;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct UniversalRegions<'tcx> {
|
@ -1,11 +1,10 @@
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_middle::mir::visit::{PlaceContext, Visitor};
|
||||
use rustc_middle::mir::{
|
||||
Local, Location, Place, Statement, StatementKind, Terminator, TerminatorKind,
|
||||
};
|
||||
|
||||
use rustc_data_structures::fx::FxHashSet;
|
||||
|
||||
use crate::borrow_check::MirBorrowckCtxt;
|
||||
use crate::MirBorrowckCtxt;
|
||||
|
||||
impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
/// Walks the MIR adding to the set of `used_mut` locals that will be ignored for the purposes
|
@ -14,6 +14,7 @@ rayon = { version = "0.3.1", package = "rustc-rayon" }
|
||||
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_attr = { path = "../rustc_attr" }
|
||||
rustc_borrowck = { path = "../rustc_borrowck" }
|
||||
rustc_builtin_macros = { path = "../rustc_builtin_macros" }
|
||||
rustc_expand = { path = "../rustc_expand" }
|
||||
rustc_parse = { path = "../rustc_parse" }
|
||||
|
@ -4,6 +4,7 @@ use crate::util;
|
||||
|
||||
use rustc_ast::mut_visit::MutVisitor;
|
||||
use rustc_ast::{self as ast, visit};
|
||||
use rustc_borrowck as mir_borrowck;
|
||||
use rustc_codegen_ssa::back::link::emit_metadata;
|
||||
use rustc_codegen_ssa::traits::CodegenBackend;
|
||||
use rustc_data_structures::parallel;
|
||||
@ -739,6 +740,7 @@ pub static DEFAULT_QUERY_PROVIDERS: SyncLazy<Providers> = SyncLazy::new(|| {
|
||||
proc_macro_decls::provide(providers);
|
||||
rustc_middle::hir::provide(providers);
|
||||
mir::provide(providers);
|
||||
mir_borrowck::provide(providers);
|
||||
mir_build::provide(providers);
|
||||
rustc_privacy::provide(providers);
|
||||
typeck::provide(providers);
|
||||
|
@ -8,30 +8,28 @@ doctest = false
|
||||
|
||||
[dependencies]
|
||||
either = "1.5.0"
|
||||
rustc_graphviz = { path = "../rustc_graphviz" }
|
||||
gsgdt = "0.1.2"
|
||||
itertools = "0.9"
|
||||
tracing = "0.1"
|
||||
polonius-engine = "0.13.0"
|
||||
regex = "1"
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
|
||||
tracing = "0.1"
|
||||
rustc_apfloat = { path = "../rustc_apfloat" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_attr = { path = "../rustc_attr" }
|
||||
rustc_data_structures = { path = "../rustc_data_structures" }
|
||||
rustc_errors = { path = "../rustc_errors" }
|
||||
rustc_graphviz = { path = "../rustc_graphviz" }
|
||||
rustc_hir = { path = "../rustc_hir" }
|
||||
rustc_index = { path = "../rustc_index" }
|
||||
rustc_infer = { path = "../rustc_infer" }
|
||||
rustc_lexer = { path = "../rustc_lexer" }
|
||||
rustc_macros = { path = "../rustc_macros" }
|
||||
rustc_middle = { path = "../rustc_middle" }
|
||||
rustc_serialize = { path = "../rustc_serialize" }
|
||||
rustc_session = { path = "../rustc_session" }
|
||||
rustc_target = { path = "../rustc_target" }
|
||||
rustc_trait_selection = { path = "../rustc_trait_selection" }
|
||||
rustc_traits = { path = "../rustc_traits" }
|
||||
rustc_ast = { path = "../rustc_ast" }
|
||||
rustc_span = { path = "../rustc_span" }
|
||||
rustc_apfloat = { path = "../rustc_apfloat" }
|
||||
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
|
||||
|
||||
[dev-dependencies]
|
||||
coverage_test_macros = { path = "src/transform/coverage/test_macros" }
|
||||
|
@ -204,7 +204,7 @@ pub(crate) fn drop_flag_effects_for_location<'tcx, F>(
|
||||
for_location_inits(tcx, body, move_data, loc, |mpi| callback(mpi, DropFlagState::Present));
|
||||
}
|
||||
|
||||
pub(crate) fn for_location_inits<'tcx, F>(
|
||||
pub fn for_location_inits<'tcx, F>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
body: &Body<'tcx>,
|
||||
move_data: &MoveData<'tcx>,
|
||||
|
@ -50,8 +50,7 @@ pub use self::cursor::{ResultsCursor, ResultsRefCursor};
|
||||
pub use self::direction::{Backward, Direction, Forward};
|
||||
pub use self::engine::{Engine, Results};
|
||||
pub use self::lattice::{JoinSemiLattice, MeetSemiLattice};
|
||||
pub use self::visitor::{visit_results, ResultsVisitor};
|
||||
pub use self::visitor::{BorrowckFlowState, BorrowckResults};
|
||||
pub use self::visitor::{visit_results, ResultsVisitable, ResultsVisitor};
|
||||
|
||||
/// Define the domain of a dataflow problem.
|
||||
///
|
||||
|
@ -1,7 +1,6 @@
|
||||
use rustc_middle::mir::{self, BasicBlock, Location};
|
||||
|
||||
use super::{Analysis, Direction, Results};
|
||||
use crate::dataflow::impls::{borrows::Borrows, EverInitializedPlaces, MaybeUninitializedPlaces};
|
||||
|
||||
/// Calls the corresponding method in `ResultsVisitor` for every location in a `mir::Body` with the
|
||||
/// dataflow state at that location.
|
||||
@ -186,95 +185,3 @@ where
|
||||
self.analysis.apply_terminator_effect(state, term, loc);
|
||||
}
|
||||
}
|
||||
|
||||
/// A tuple with named fields that can hold either the results or the transient state of the
|
||||
/// dataflow analyses used by the borrow checker.
|
||||
#[derive(Debug)]
|
||||
pub struct BorrowckAnalyses<B, U, E> {
|
||||
pub borrows: B,
|
||||
pub uninits: U,
|
||||
pub ever_inits: E,
|
||||
}
|
||||
|
||||
/// The results of the dataflow analyses used by the borrow checker.
|
||||
pub type BorrowckResults<'mir, 'tcx> = BorrowckAnalyses<
|
||||
Results<'tcx, Borrows<'mir, 'tcx>>,
|
||||
Results<'tcx, MaybeUninitializedPlaces<'mir, 'tcx>>,
|
||||
Results<'tcx, EverInitializedPlaces<'mir, 'tcx>>,
|
||||
>;
|
||||
|
||||
/// The transient state of the dataflow analyses used by the borrow checker.
|
||||
pub type BorrowckFlowState<'mir, 'tcx> =
|
||||
<BorrowckResults<'mir, 'tcx> as ResultsVisitable<'tcx>>::FlowState;
|
||||
|
||||
macro_rules! impl_visitable {
|
||||
( $(
|
||||
$T:ident { $( $field:ident : $A:ident ),* $(,)? }
|
||||
)* ) => { $(
|
||||
impl<'tcx, $($A),*, D: Direction> ResultsVisitable<'tcx> for $T<$( Results<'tcx, $A> ),*>
|
||||
where
|
||||
$( $A: Analysis<'tcx, Direction = D>, )*
|
||||
{
|
||||
type Direction = D;
|
||||
type FlowState = $T<$( $A::Domain ),*>;
|
||||
|
||||
fn new_flow_state(&self, body: &mir::Body<'tcx>) -> Self::FlowState {
|
||||
$T {
|
||||
$( $field: self.$field.analysis.bottom_value(body) ),*
|
||||
}
|
||||
}
|
||||
|
||||
fn reset_to_block_entry(
|
||||
&self,
|
||||
state: &mut Self::FlowState,
|
||||
block: BasicBlock,
|
||||
) {
|
||||
$( state.$field.clone_from(&self.$field.entry_set_for_block(block)); )*
|
||||
}
|
||||
|
||||
fn reconstruct_before_statement_effect(
|
||||
&self,
|
||||
state: &mut Self::FlowState,
|
||||
stmt: &mir::Statement<'tcx>,
|
||||
loc: Location,
|
||||
) {
|
||||
$( self.$field.analysis
|
||||
.apply_before_statement_effect(&mut state.$field, stmt, loc); )*
|
||||
}
|
||||
|
||||
fn reconstruct_statement_effect(
|
||||
&self,
|
||||
state: &mut Self::FlowState,
|
||||
stmt: &mir::Statement<'tcx>,
|
||||
loc: Location,
|
||||
) {
|
||||
$( self.$field.analysis
|
||||
.apply_statement_effect(&mut state.$field, stmt, loc); )*
|
||||
}
|
||||
|
||||
fn reconstruct_before_terminator_effect(
|
||||
&self,
|
||||
state: &mut Self::FlowState,
|
||||
term: &mir::Terminator<'tcx>,
|
||||
loc: Location,
|
||||
) {
|
||||
$( self.$field.analysis
|
||||
.apply_before_terminator_effect(&mut state.$field, term, loc); )*
|
||||
}
|
||||
|
||||
fn reconstruct_terminator_effect(
|
||||
&self,
|
||||
state: &mut Self::FlowState,
|
||||
term: &mir::Terminator<'tcx>,
|
||||
loc: Location,
|
||||
) {
|
||||
$( self.$field.analysis
|
||||
.apply_terminator_effect(&mut state.$field, term, loc); )*
|
||||
}
|
||||
}
|
||||
)* }
|
||||
}
|
||||
|
||||
impl_visitable! {
|
||||
BorrowckAnalyses { borrows: B, uninits: U, ever_inits: E }
|
||||
}
|
||||
|
@ -21,13 +21,11 @@ use crate::dataflow::drop_flag_effects;
|
||||
use crate::dataflow::framework::SwitchIntEdgeEffects;
|
||||
|
||||
mod borrowed_locals;
|
||||
pub(super) mod borrows;
|
||||
mod init_locals;
|
||||
mod liveness;
|
||||
mod storage_liveness;
|
||||
|
||||
pub use self::borrowed_locals::{MaybeBorrowedLocals, MaybeMutBorrowedLocals};
|
||||
pub use self::borrows::Borrows;
|
||||
pub use self::init_locals::MaybeInitializedLocals;
|
||||
pub use self::liveness::MaybeLiveLocals;
|
||||
pub use self::storage_liveness::{MaybeRequiresStorage, MaybeStorageLive};
|
||||
|
@ -5,9 +5,9 @@ use rustc_span::symbol::{sym, Symbol};
|
||||
|
||||
pub(crate) use self::drop_flag_effects::*;
|
||||
pub use self::framework::{
|
||||
fmt, graphviz, lattice, visit_results, Analysis, AnalysisDomain, Backward, BorrowckFlowState,
|
||||
BorrowckResults, Engine, Forward, GenKill, GenKillAnalysis, JoinSemiLattice, Results,
|
||||
ResultsCursor, ResultsRefCursor, ResultsVisitor, SwitchIntEdgeEffects,
|
||||
fmt, lattice, visit_results, Analysis, AnalysisDomain, Backward, Direction, Engine, Forward,
|
||||
GenKill, GenKillAnalysis, JoinSemiLattice, Results, ResultsCursor, ResultsRefCursor,
|
||||
ResultsVisitable, ResultsVisitor,
|
||||
};
|
||||
|
||||
use self::move_paths::MoveData;
|
||||
@ -18,15 +18,12 @@ pub mod impls;
|
||||
pub mod move_paths;
|
||||
|
||||
pub(crate) mod indexes {
|
||||
pub(crate) use super::{
|
||||
impls::borrows::BorrowIndex,
|
||||
move_paths::{InitIndex, MoveOutIndex, MovePathIndex},
|
||||
};
|
||||
pub(crate) use super::move_paths::MovePathIndex;
|
||||
}
|
||||
|
||||
pub struct MoveDataParamEnv<'tcx> {
|
||||
pub(crate) move_data: MoveData<'tcx>,
|
||||
pub(crate) param_env: ty::ParamEnv<'tcx>,
|
||||
pub move_data: MoveData<'tcx>,
|
||||
pub param_env: ty::ParamEnv<'tcx>,
|
||||
}
|
||||
|
||||
pub(crate) fn has_rustc_mir_with(
|
||||
|
@ -19,6 +19,12 @@ rustc_index::newtype_index! {
|
||||
}
|
||||
}
|
||||
|
||||
impl polonius_engine::Atom for MovePathIndex {
|
||||
fn index(self) -> usize {
|
||||
rustc_index::vec::Idx::index(self)
|
||||
}
|
||||
}
|
||||
|
||||
rustc_index::newtype_index! {
|
||||
pub struct MoveOutIndex {
|
||||
DEBUG_FORMAT = "mo{}"
|
||||
@ -276,7 +282,7 @@ impl fmt::Debug for Init {
|
||||
}
|
||||
|
||||
impl Init {
|
||||
crate fn span<'tcx>(&self, body: &Body<'tcx>) -> Span {
|
||||
pub fn span<'tcx>(&self, body: &Body<'tcx>) -> Span {
|
||||
match self.location {
|
||||
InitLocation::Argument(local) => body.local_decls[local].source_info.span,
|
||||
InitLocation::Statement(location) => body.source_info(location).span,
|
||||
@ -338,12 +344,12 @@ impl MovePathLookup {
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct IllegalMoveOrigin<'tcx> {
|
||||
pub(crate) location: Location,
|
||||
pub(crate) kind: IllegalMoveOriginKind<'tcx>,
|
||||
pub location: Location,
|
||||
pub kind: IllegalMoveOriginKind<'tcx>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) enum IllegalMoveOriginKind<'tcx> {
|
||||
pub enum IllegalMoveOriginKind<'tcx> {
|
||||
/// Illegal move due to attempt to move from behind a reference.
|
||||
BorrowedContent {
|
||||
/// The place the reference refers to: if erroneous code was trying to
|
||||
|
@ -4,40 +4,35 @@ Rust MIR: a lowered representation of Rust.
|
||||
|
||||
*/
|
||||
|
||||
#![feature(nll)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(array_windows)]
|
||||
#![feature(assert_matches)]
|
||||
#![cfg_attr(bootstrap, feature(bindings_after_at))]
|
||||
#![feature(associated_type_defaults)]
|
||||
#![feature(bool_to_option)]
|
||||
#![feature(box_patterns)]
|
||||
#![feature(control_flow_enum)]
|
||||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(decl_macro)]
|
||||
#![feature(exact_size_is_empty)]
|
||||
#![feature(format_args_capture)]
|
||||
#![feature(in_band_lifetimes)]
|
||||
#![feature(iter_zip)]
|
||||
#![feature(never_type)]
|
||||
#![feature(map_try_insert)]
|
||||
#![feature(min_specialization)]
|
||||
#![feature(slice_ptr_get)]
|
||||
#![feature(trusted_len)]
|
||||
#![feature(try_blocks)]
|
||||
#![feature(associated_type_defaults)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(trait_alias)]
|
||||
#![feature(option_get_or_insert_default)]
|
||||
#![feature(once_cell)]
|
||||
#![feature(control_flow_enum)]
|
||||
#![feature(try_reserve)]
|
||||
#![feature(try_reserve_kind)]
|
||||
#![recursion_limit = "256"]
|
||||
#![feature(never_type)]
|
||||
#![feature(stmt_expr_attributes)]
|
||||
#![feature(trait_alias)]
|
||||
#![feature(trusted_len)]
|
||||
#![feature(trusted_step)]
|
||||
#![feature(try_blocks)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate tracing;
|
||||
#[macro_use]
|
||||
extern crate rustc_middle;
|
||||
|
||||
mod borrow_check;
|
||||
pub mod const_eval;
|
||||
pub mod dataflow;
|
||||
pub mod interpret;
|
||||
@ -46,13 +41,9 @@ mod shim;
|
||||
pub mod transform;
|
||||
pub mod util;
|
||||
|
||||
// A public API provided for the Rust compiler consumers.
|
||||
pub use self::borrow_check::consumers;
|
||||
|
||||
use rustc_middle::ty::query::Providers;
|
||||
|
||||
pub fn provide(providers: &mut Providers) {
|
||||
borrow_check::provide(providers);
|
||||
const_eval::provide(providers);
|
||||
shim::provide(providers);
|
||||
transform::provide(providers);
|
||||
|
@ -1058,7 +1058,7 @@ pub fn promote_candidates<'tcx>(
|
||||
|
||||
/// This function returns `true` if the function being called in the array
|
||||
/// repeat expression is a `const` function.
|
||||
crate fn is_const_fn_in_array_repeat_expression<'tcx>(
|
||||
pub fn is_const_fn_in_array_repeat_expression<'tcx>(
|
||||
ccx: &ConstCx<'_, 'tcx>,
|
||||
place: &Place<'tcx>,
|
||||
body: &Body<'tcx>,
|
||||
|
@ -2,7 +2,7 @@ use rustc_middle::mir::visit::PlaceContext;
|
||||
use rustc_middle::mir::visit::Visitor;
|
||||
use rustc_middle::mir::{Body, Local, Location};
|
||||
|
||||
crate trait FindAssignments {
|
||||
pub trait FindAssignments {
|
||||
// Finds all statements that assign directly to local (i.e., X = ...)
|
||||
// and returns their locations.
|
||||
fn find_assignments(&self, local: Local) -> Vec<Location>;
|
||||
|
@ -1,5 +1,4 @@
|
||||
pub mod aggregate;
|
||||
pub mod borrowck_errors;
|
||||
pub mod elaborate_drops;
|
||||
pub mod patch;
|
||||
pub mod storage;
|
||||
@ -10,7 +9,7 @@ mod find_self_call;
|
||||
mod generic_graph;
|
||||
pub(crate) mod generic_graphviz;
|
||||
mod graphviz;
|
||||
pub(crate) mod pretty;
|
||||
pub mod pretty;
|
||||
pub(crate) mod spanview;
|
||||
|
||||
pub use self::aggregate::expand_aggregate;
|
||||
|
@ -250,7 +250,7 @@ fn create_dump_file_with_basename(
|
||||
/// bit of MIR-related data. Used by `mir-dump`, but also by other
|
||||
/// bits of code (e.g., NLL inference) that dump graphviz data or
|
||||
/// other things, and hence takes the extension as an argument.
|
||||
pub(crate) fn create_dump_file(
|
||||
pub fn create_dump_file(
|
||||
tcx: TyCtxt<'_>,
|
||||
extension: &str,
|
||||
pass_num: Option<&dyn Display>,
|
||||
|
Loading…
Reference in New Issue
Block a user