]> git.lizzy.rs Git - rust.git/commitdiff
Fix lint findings in librustc_mir
authorflip1995 <hello@philkrones.com>
Fri, 26 Apr 2019 12:26:49 +0000 (14:26 +0200)
committerflip1995 <hello@philkrones.com>
Sun, 28 Apr 2019 19:19:27 +0000 (21:19 +0200)
15 files changed:
src/librustc_mir/borrow_check/error_reporting.rs
src/librustc_mir/borrow_check/mod.rs
src/librustc_mir/borrow_check/mutability_errors.rs
src/librustc_mir/borrow_check/nll/constraint_generation.rs
src/librustc_mir/borrow_check/nll/invalidation.rs
src/librustc_mir/borrow_check/path_utils.rs
src/librustc_mir/const_eval.rs
src/librustc_mir/dataflow/move_paths/mod.rs
src/librustc_mir/interpret/snapshot.rs
src/librustc_mir/interpret/traits.rs
src/librustc_mir/shim.rs
src/librustc_mir/transform/const_prop.rs
src/librustc_mir/transform/qualify_min_const_fn.rs
src/librustc_mir/util/borrowck_errors.rs
src/librustc_mir/util/mod.rs

index a883ae40dbf45458af5ad4b86968a78162d87d08..a8ebe85e2510ca651ae2663b99911ad4c8b705d3 100644 (file)
@@ -12,7 +12,7 @@
     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 @@ fn report_borrow_conflicts_with_destructor(
         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) fn report_illegal_reassignment(
 enum StorageDeadOrDrop<'tcx> {
     LocalStorageDead,
     BoxedStorageDead,
-    Destructor(ty::Ty<'tcx>),
+    Destructor(Ty<'tcx>),
 }
 
 impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
@@ -1787,7 +1787,7 @@ fn describe_field(&self, base: &Place<'tcx>, field: Field) -> String {
     /// 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 @@ fn annotate_fn_sig(
 #[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 @@ fn emit(
 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 @@ fn get_name_for_ty(&self, ty: ty::Ty<'tcx>, counter: usize) -> String {
 
     /// 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);
 
index 14cafdef67d7de8b2cf931f3f22a66bf0009b3e5..aa6c152a37ffbb2d625f516470321239fa7e4137 100644 (file)
@@ -1076,7 +1076,7 @@ fn check_access_for_conflict(
                 (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 @@ fn consume_rvalue(
                     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))
index c5ad2b18c23fcf634b31a2ea7c61dd3e58a1d4e6..32088ff9f61eee5c1a094d59ee3d8f8b2d0c57ef 100644 (file)
@@ -5,7 +5,7 @@
     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.
index cc753252758821e34ed6ea7463b4c9538c8171ae..ec2555886ce1fd2a3896bfe6b6bbf5dd7a6d1b82 100644 (file)
@@ -10,7 +10,7 @@
 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 @@ fn visit_region(&mut self, region: &ty::Region<'tcx>, location: Location) {
 
     /// 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, .. })
index 8cbf68c476a7e77cae156a4da2dc1c3848c87896..5008627972aa649e291c6cb732ad2726ea27f943 100644 (file)
@@ -321,7 +321,7 @@ fn consume_rvalue(
                     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 @@ fn check_access_for_conflict(
                         // 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;
                         }
 
index f6a22cf040797b19d3b61f55d4b2a484ef2f488d..ec3c0bf68ad87409c1854b40ddc41cab0ec4b228 100644 (file)
@@ -12,7 +12,7 @@
 /// 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()
index b65f2ba2601e44927c2a4cfc17dd006eacaf3da3..4b8b3232bfa3da6075cb4b8282bb9371528e248f 100644 (file)
@@ -440,7 +440,7 @@ fn before_terminator(ecx: &mut InterpretCx<'a, 'mir, 'tcx, Self>) -> EvalResult<
 
         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> {
index 8810be9326bf5f2dfda105efa618b82e37821906..6d619793160fba312112709aa02b49f52a5ba0d3 100644 (file)
@@ -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)]
index 0bb8b1d9d02ca343c62ae817f28d8ebe808e8faa..83bd3666b3d3b3d24d9fe3350879dae133391b17 100644 (file)
@@ -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>],
index 0bed62ccf500a227688af85362de56d46797d910..4eb79cf56fcf2a764f1ba9a4d4ae3f08a7c7a708 100644 (file)
@@ -101,7 +101,7 @@ pub fn get_vtable(
     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
index a3708d064ec3b86100fff969a88a2d42292c1cbc..ea139e6e9fc582fe7c674ca62ccf124e26be12ce 100644 (file)
@@ -644,7 +644,7 @@ fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len:
 
     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);
index b5bdc9e1c8c6e61f9ce0e8736c145e483fa7fde5..1e0ba9023317133bb2b3e01f4361bcd141df898a 100644 (file)
@@ -8,7 +8,7 @@
 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 @@ fn const_prop(
 
 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 @@ fn visit_statement(
     ) {
         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)) {
index d5f04ca64e4c4ecb8907fe909aa0461b89ea03cc..e1d41ba4fc509f151800216059972090e7dd1ae9 100644 (file)
@@ -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 {
index e334e27cc855663e12527bb4a009c0e78ac4c347..bf3cdf4abf797fbda244b9f3d7f9bd75405e2c06 100644 (file)
@@ -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 @@ fn cannot_move_out_of(
     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 @@ fn cannot_move_out_of_interior_noncopy(
     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!(
index 1a5a2a92247dd3f120bd354f0ca370ca5369af71..0e7f473a3e70d2af498488f8531661fdf6cac6bd 100644 (file)
@@ -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 @@
 
 /// 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();