Place, PlaceBase, PlaceProjection, ProjectionElem, Rvalue, Statement, StatementKind,
Static, StaticKind, TerminatorKind, VarBindingForm,
};
-use rustc::ty::{self, DefIdTree};
+use rustc::ty::{self, DefIdTree, Ty};
use rustc::ty::layout::VariantIdx;
use rustc::ty::print::Print;
use rustc_data_structures::fx::FxHashSet;
borrow: &BorrowData<'tcx>,
(place, drop_span): (&Place<'tcx>, Span),
kind: Option<WriteKind>,
- dropped_ty: ty::Ty<'tcx>,
+ dropped_ty: Ty<'tcx>,
) {
debug!(
"report_borrow_conflicts_with_destructor(\
enum StorageDeadOrDrop<'tcx> {
LocalStorageDead,
BoxedStorageDead,
- Destructor(ty::Ty<'tcx>),
+ Destructor(Ty<'tcx>),
}
impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
/// End-user visible description of the `field_index`nth field of `ty`
fn describe_field_from_ty(
&self,
- ty: &ty::Ty<'_>,
+ ty: Ty<'_>,
field: Field,
variant_index: Option<VariantIdx>
) -> String {
#[derive(Debug)]
enum AnnotatedBorrowFnSignature<'tcx> {
NamedFunction {
- arguments: Vec<(ty::Ty<'tcx>, Span)>,
- return_ty: ty::Ty<'tcx>,
+ arguments: Vec<(Ty<'tcx>, Span)>,
+ return_ty: Ty<'tcx>,
return_span: Span,
},
AnonymousFunction {
- argument_ty: ty::Ty<'tcx>,
+ argument_ty: Ty<'tcx>,
argument_span: Span,
- return_ty: ty::Ty<'tcx>,
+ return_ty: Ty<'tcx>,
return_span: Span,
},
Closure {
- argument_ty: ty::Ty<'tcx>,
+ argument_ty: Ty<'tcx>,
argument_span: Span,
},
}
impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
/// Return the name of the provided `Ty` (that must be a reference) with a synthesized lifetime
/// name where required.
- fn get_name_for_ty(&self, ty: ty::Ty<'tcx>, counter: usize) -> String {
+ fn get_name_for_ty(&self, ty: Ty<'tcx>, counter: usize) -> String {
let mut s = String::new();
let mut printer = ty::print::FmtPrinter::new(self.infcx.tcx, &mut s, Namespace::TypeNS);
/// Returns the name of the provided `Ty` (that must be a reference)'s region with a
/// synthesized lifetime name where required.
- fn get_region_name_for_ty(&self, ty: ty::Ty<'tcx>, counter: usize) -> String {
+ fn get_region_name_for_ty(&self, ty: Ty<'tcx>, counter: usize) -> String {
let mut s = String::new();
let mut printer = ty::print::FmtPrinter::new(self.infcx.tcx, &mut s, Namespace::TypeNS);
(Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut { .. }) => {
// Reading from mere reservations of mutable-borrows is OK.
if !is_active(&this.dominators, borrow, context.loc) {
- assert!(allow_two_phase_borrow(&tcx, borrow.kind));
+ assert!(allow_two_phase_borrow(tcx, borrow.kind));
return Control::Continue;
}
BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))),
BorrowKind::Unique | BorrowKind::Mut { .. } => {
let wk = WriteKind::MutableBorrow(bk);
- if allow_two_phase_borrow(&self.infcx.tcx, bk) {
+ if allow_two_phase_borrow(self.infcx.tcx, bk) {
(Deep, Reservation(wk))
} else {
(Deep, Write(wk))
Mutability, Operand, Place, PlaceBase, Projection, ProjectionElem, Static, StaticKind,
};
use rustc::mir::{Terminator, TerminatorKind};
-use rustc::ty::{self, Const, DefIdTree, TyS, TyCtxt};
+use rustc::ty::{self, Const, DefIdTree, Ty, TyS, TyCtxt};
use rustc_data_structures::indexed_vec::Idx;
use syntax_pos::Span;
use syntax_pos::symbol::keywords;
})
}
-fn is_closure_or_generator(ty: ty::Ty<'_>) -> bool {
+fn is_closure_or_generator(ty: Ty<'_>) -> bool {
ty.is_closure() || ty.is_generator()
}
/// ```
fn annotate_struct_field(
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
- ty: ty::Ty<'tcx>,
+ ty: Ty<'tcx>,
field: &mir::Field,
) -> Option<(Span, String)> {
// Expect our local to be a reference to a struct of some kind.
use rustc::mir::{SourceInfo, Statement, Terminator};
use rustc::mir::UserTypeProjection;
use rustc::ty::fold::TypeFoldable;
-use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid};
+use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid, Ty};
use rustc::ty::subst::SubstsRef;
pub(super) fn generate_constraints<'cx, 'gcx, 'tcx>(
/// We sometimes have `ty` within an rvalue, or within a
/// call. Make them live at the location where they appear.
- fn visit_ty(&mut self, ty: ty::Ty<'tcx>, ty_context: TyContext) {
+ fn visit_ty(&mut self, ty: Ty<'tcx>, ty_context: TyContext) {
match ty_context {
TyContext::ReturnTy(SourceInfo { span, .. })
| TyContext::YieldTy(SourceInfo { span, .. })
BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))),
BorrowKind::Unique | BorrowKind::Mut { .. } => {
let wk = WriteKind::MutableBorrow(bk);
- if allow_two_phase_borrow(&self.tcx, bk) {
+ if allow_two_phase_borrow(self.tcx, bk) {
(Deep, Reservation(wk))
} else {
(Deep, Write(wk))
// Reading from mere reservations of mutable-borrows is OK.
if !is_active(&this.dominators, borrow, context.loc) {
// If the borrow isn't active yet, reads don't invalidate it
- assert!(allow_two_phase_borrow(&this.tcx, borrow.kind));
+ assert!(allow_two_phase_borrow(this.tcx, borrow.kind));
return Control::Continue;
}
/// allowed to be split into separate Reservation and
/// Activation phases.
pub(super) fn allow_two_phase_borrow<'a, 'tcx, 'gcx: 'tcx>(
- _tcx: &TyCtxt<'a, 'gcx, 'tcx>,
+ _tcx: TyCtxt<'a, 'gcx, 'tcx>,
kind: BorrowKind
) -> bool {
kind.allows_two_phase_borrow()
let span = ecx.frame().span;
ecx.machine.loop_detector.observe_and_analyze(
- &ecx.tcx,
+ *ecx.tcx,
span,
&ecx.memory,
&ecx.stack[..],
}
fn validate_and_turn_into_const<'a, 'tcx>(
- tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
+ tcx: TyCtxt<'a, 'tcx, 'tcx>,
constant: RawConst<'tcx>,
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> {
-use rustc::ty::{self, TyCtxt};
+use rustc::ty::{Ty, TyCtxt};
use rustc::mir::*;
use rustc::util::nodemap::FxHashMap;
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
/// implements `Drop`. Rust maintains invariant that all `Drop`
/// ADT's remain fully-initialized so that user-defined destructor
/// can safely read from all of the ADT's fields.
- InteriorOfTypeWithDestructor { container_ty: ty::Ty<'tcx> },
+ InteriorOfTypeWithDestructor { container_ty: Ty<'tcx> },
/// Illegal move due to attempt to move out of a slice or array.
- InteriorOfSliceOrArray { ty: ty::Ty<'tcx>, is_index: bool, },
+ InteriorOfSliceOrArray { ty: Ty<'tcx>, is_index: bool, },
}
#[derive(Debug)]
{
pub fn observe_and_analyze<'b>(
&mut self,
- tcx: &TyCtxt<'b, 'tcx, 'tcx>,
+ tcx: TyCtxt<'b, 'tcx, 'tcx>,
span: Span,
memory: &Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>,
stack: &[Frame<'mir, 'tcx>],
pub fn read_drop_type_from_vtable(
&self,
vtable: Pointer<M::PointerTag>,
- ) -> EvalResult<'tcx, (ty::Instance<'tcx>, ty::Ty<'tcx>)> {
+ ) -> EvalResult<'tcx, (ty::Instance<'tcx>, Ty<'tcx>)> {
// we don't care about the pointee type, we just want a pointer
self.memory.check_align(vtable.into(), self.tcx.data_layout.pointer_align.abi)?;
let drop_fn = self.memory
fn tuple_like_shim<I>(&mut self, dest: Place<'tcx>,
src: Place<'tcx>, tys: I)
- where I: Iterator<Item = ty::Ty<'tcx>> {
+ where I: Iterator<Item = Ty<'tcx>> {
let mut previous_field = None;
for (i, ity) in tys.enumerate() {
let field = Field::new(i);
use rustc::mir::{TerminatorKind, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem};
use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUseContext};
use rustc::mir::interpret::{InterpError, Scalar, GlobalId, EvalResult};
-use rustc::ty::{TyCtxt, self, Instance};
+use rustc::ty::{self, Instance, Ty, TyCtxt};
use syntax::source_map::{Span, DUMMY_SP};
use rustc::ty::subst::InternalSubsts;
use rustc_data_structures::indexed_vec::IndexVec;
}
impl<'a, 'b, 'tcx> LayoutOf for ConstPropagator<'a, 'b, 'tcx> {
- type Ty = ty::Ty<'tcx>;
+ type Ty = Ty<'tcx>;
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
- fn layout_of(&self, ty: ty::Ty<'tcx>) -> Self::TyLayout {
+ fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
self.tcx.layout_of(self.param_env.and(ty))
}
}
fn type_size_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
param_env: ty::ParamEnv<'tcx>,
- ty: ty::Ty<'tcx>) -> Option<u64> {
+ ty: Ty<'tcx>) -> Option<u64> {
tcx.layout_of(param_env.and(ty)).ok().map(|layout| layout.size.bytes())
}
) {
trace!("visit_statement: {:?}", statement);
if let StatementKind::Assign(ref place, ref rval) = statement.kind {
- let place_ty: ty::Ty<'tcx> = place
+ let place_ty: Ty<'tcx> = place
.ty(&self.mir.local_decls, self.tcx)
.ty;
if let Ok(place_layout) = self.tcx.layout_of(self.param_env.and(place_ty)) {
use rustc::hir::def_id::DefId;
use rustc::hir;
use rustc::mir::*;
-use rustc::ty::{self, Predicate, TyCtxt, adjustment::{PointerCast}};
+use rustc::ty::{self, Predicate, Ty, TyCtxt, adjustment::{PointerCast}};
use rustc_target::spec::abi;
use std::borrow::Cow;
use syntax_pos::Span;
fn check_ty(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
- ty: ty::Ty<'tcx>,
+ ty: Ty<'tcx>,
span: Span,
fn_def_id: DefId,
) -> McfResult {
use rustc::session::config::BorrowckMode;
-use rustc::ty::{self, TyCtxt};
+use rustc::ty::{self, Ty, TyCtxt};
use rustc_errors::{DiagnosticBuilder, DiagnosticId};
use syntax_pos::{MultiSpan, Span};
fn cannot_move_out_of_interior_noncopy(
self,
move_from_span: Span,
- ty: ty::Ty<'_>,
+ ty: Ty<'_>,
is_index: Option<bool>,
o: Origin,
) -> DiagnosticBuilder<'cx> {
fn cannot_move_out_of_interior_of_drop(
self,
move_from_span: Span,
- container_ty: ty::Ty<'_>,
+ container_ty: Ty<'_>,
o: Origin,
) -> DiagnosticBuilder<'cx> {
let mut err = struct_span_err!(
use core::unicode::property::Pattern_White_Space;
-use rustc::ty;
+use rustc::ty::TyCtxt;
use syntax_pos::Span;
pub mod borrowck_errors;
/// If possible, suggest replacing `ref` with `ref mut`.
pub fn suggest_ref_mut<'cx, 'gcx, 'tcx>(
- tcx: ty::TyCtxt<'cx, 'gcx, 'tcx>,
+ tcx: TyCtxt<'cx, 'gcx, 'tcx>,
binding_span: Span,
) -> Option<(String)> {
let hi_src = tcx.sess.source_map().span_to_snippet(binding_span).unwrap();