Fix lint findings in librustc_mir
This commit is contained in:
parent
654d045b6f
commit
e1da67e69c
15 changed files with 41 additions and 41 deletions
|
|
@ -12,7 +12,7 @@ use rustc::mir::{
|
|||
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;
|
||||
|
|
@ -918,7 +918,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
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(\
|
||||
|
|
@ -1483,7 +1483,7 @@ pub(super) struct IncludingDowncast(bool);
|
|||
enum StorageDeadOrDrop<'tcx> {
|
||||
LocalStorageDead,
|
||||
BoxedStorageDead,
|
||||
Destructor(ty::Ty<'tcx>),
|
||||
Destructor(Ty<'tcx>),
|
||||
}
|
||||
|
||||
impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
||||
|
|
@ -1787,7 +1787,7 @@ 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 {
|
||||
|
|
@ -2258,18 +2258,18 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
#[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,
|
||||
},
|
||||
}
|
||||
|
|
@ -2355,7 +2355,7 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
|
|||
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);
|
||||
|
||||
|
|
@ -2378,7 +2378,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
|
||||
/// 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);
|
||||
|
||||
|
|
|
|||
|
|
@ -1076,7 +1076,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
(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;
|
||||
}
|
||||
|
||||
|
|
@ -1233,7 +1233,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
|
|||
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))
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use rustc::mir::{
|
|||
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;
|
||||
|
|
@ -613,7 +613,7 @@ fn suggest_ampmut<'cx, 'gcx, 'tcx>(
|
|||
})
|
||||
}
|
||||
|
||||
fn is_closure_or_generator(ty: ty::Ty<'_>) -> bool {
|
||||
fn is_closure_or_generator(ty: Ty<'_>) -> bool {
|
||||
ty.is_closure() || ty.is_generator()
|
||||
}
|
||||
|
||||
|
|
@ -626,7 +626,7 @@ fn is_closure_or_generator(ty: ty::Ty<'_>) -> bool {
|
|||
/// ```
|
||||
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.
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use rustc::mir::{BasicBlock, BasicBlockData, Location, Mir, Place, PlaceBase, Rv
|
|||
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>(
|
||||
|
|
@ -64,7 +64,7 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx
|
|||
|
||||
/// 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, .. })
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> {
|
|||
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))
|
||||
|
|
@ -439,7 +439,7 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> {
|
|||
// 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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use rustc_data_structures::graph::dominators::Dominators;
|
|||
/// 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()
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx>
|
|||
|
||||
let span = ecx.frame().span;
|
||||
ecx.machine.loop_detector.observe_and_analyze(
|
||||
&ecx.tcx,
|
||||
*ecx.tcx,
|
||||
span,
|
||||
&ecx.memory,
|
||||
&ecx.stack[..],
|
||||
|
|
@ -513,7 +513,7 @@ pub fn error_to_const_error<'a, 'mir, 'tcx>(
|
|||
}
|
||||
|
||||
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> {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
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};
|
||||
|
|
@ -285,10 +285,10 @@ pub(crate) enum IllegalMoveOriginKind<'tcx> {
|
|||
/// 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)]
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ impl<'a, 'mir, 'tcx> InfiniteLoopDetector<'a, 'mir, 'tcx>
|
|||
{
|
||||
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>],
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
|
|||
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
|
||||
|
|
|
|||
|
|
@ -644,7 +644,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
|
|||
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use rustc::mir::{NullOp, UnOp, StatementKind, Statement, BasicBlock, LocalKind,
|
|||
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;
|
||||
|
|
@ -80,10 +80,10 @@ struct ConstPropagator<'a, 'mir, 'tcx:'a+'mir> {
|
|||
}
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
|
@ -476,7 +476,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
|
|||
|
||||
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())
|
||||
}
|
||||
|
||||
|
|
@ -555,7 +555,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for ConstPropagator<'b, 'a, 'tcx> {
|
|||
) {
|
||||
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)) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
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;
|
||||
|
|
@ -81,7 +81,7 @@ pub fn is_min_const_fn(
|
|||
|
||||
fn check_ty(
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
ty: ty::Ty<'tcx>,
|
||||
ty: Ty<'tcx>,
|
||||
span: Span,
|
||||
fn_def_id: DefId,
|
||||
) -> McfResult {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
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};
|
||||
|
||||
|
|
@ -437,7 +437,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy {
|
|||
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> {
|
||||
|
|
@ -464,7 +464,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy {
|
|||
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!(
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use core::unicode::property::Pattern_White_Space;
|
||||
use rustc::ty;
|
||||
use rustc::ty::TyCtxt;
|
||||
use syntax_pos::Span;
|
||||
|
||||
pub mod borrowck_errors;
|
||||
|
|
@ -20,7 +20,7 @@ pub use self::graphviz::write_node_label as write_graphviz_node_label;
|
|||
|
||||
/// 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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue