Skip to content

Commit e1da67e

Browse files
committed
Fix lint findings in librustc_mir
1 parent 654d045 commit e1da67e

15 files changed

+41
-41
lines changed

src/librustc_mir/borrow_check/error_reporting.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc::mir::{
1212
Place, PlaceBase, PlaceProjection, ProjectionElem, Rvalue, Statement, StatementKind,
1313
Static, StaticKind, TerminatorKind, VarBindingForm,
1414
};
15-
use rustc::ty::{self, DefIdTree};
15+
use rustc::ty::{self, DefIdTree, Ty};
1616
use rustc::ty::layout::VariantIdx;
1717
use rustc::ty::print::Print;
1818
use rustc_data_structures::fx::FxHashSet;
@@ -918,7 +918,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
918918
borrow: &BorrowData<'tcx>,
919919
(place, drop_span): (&Place<'tcx>, Span),
920920
kind: Option<WriteKind>,
921-
dropped_ty: ty::Ty<'tcx>,
921+
dropped_ty: Ty<'tcx>,
922922
) {
923923
debug!(
924924
"report_borrow_conflicts_with_destructor(\
@@ -1483,7 +1483,7 @@ pub(super) struct IncludingDowncast(bool);
14831483
enum StorageDeadOrDrop<'tcx> {
14841484
LocalStorageDead,
14851485
BoxedStorageDead,
1486-
Destructor(ty::Ty<'tcx>),
1486+
Destructor(Ty<'tcx>),
14871487
}
14881488

14891489
impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
@@ -1787,7 +1787,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
17871787
/// End-user visible description of the `field_index`nth field of `ty`
17881788
fn describe_field_from_ty(
17891789
&self,
1790-
ty: &ty::Ty<'_>,
1790+
ty: Ty<'_>,
17911791
field: Field,
17921792
variant_index: Option<VariantIdx>
17931793
) -> String {
@@ -2258,18 +2258,18 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
22582258
#[derive(Debug)]
22592259
enum AnnotatedBorrowFnSignature<'tcx> {
22602260
NamedFunction {
2261-
arguments: Vec<(ty::Ty<'tcx>, Span)>,
2262-
return_ty: ty::Ty<'tcx>,
2261+
arguments: Vec<(Ty<'tcx>, Span)>,
2262+
return_ty: Ty<'tcx>,
22632263
return_span: Span,
22642264
},
22652265
AnonymousFunction {
2266-
argument_ty: ty::Ty<'tcx>,
2266+
argument_ty: Ty<'tcx>,
22672267
argument_span: Span,
2268-
return_ty: ty::Ty<'tcx>,
2268+
return_ty: Ty<'tcx>,
22692269
return_span: Span,
22702270
},
22712271
Closure {
2272-
argument_ty: ty::Ty<'tcx>,
2272+
argument_ty: Ty<'tcx>,
22732273
argument_span: Span,
22742274
},
22752275
}
@@ -2355,7 +2355,7 @@ impl<'tcx> AnnotatedBorrowFnSignature<'tcx> {
23552355
impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
23562356
/// Return the name of the provided `Ty` (that must be a reference) with a synthesized lifetime
23572357
/// name where required.
2358-
fn get_name_for_ty(&self, ty: ty::Ty<'tcx>, counter: usize) -> String {
2358+
fn get_name_for_ty(&self, ty: Ty<'tcx>, counter: usize) -> String {
23592359
let mut s = String::new();
23602360
let mut printer = ty::print::FmtPrinter::new(self.infcx.tcx, &mut s, Namespace::TypeNS);
23612361

@@ -2378,7 +2378,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
23782378

23792379
/// Returns the name of the provided `Ty` (that must be a reference)'s region with a
23802380
/// synthesized lifetime name where required.
2381-
fn get_region_name_for_ty(&self, ty: ty::Ty<'tcx>, counter: usize) -> String {
2381+
fn get_region_name_for_ty(&self, ty: Ty<'tcx>, counter: usize) -> String {
23822382
let mut s = String::new();
23832383
let mut printer = ty::print::FmtPrinter::new(self.infcx.tcx, &mut s, Namespace::TypeNS);
23842384

src/librustc_mir/borrow_check/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1076,7 +1076,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
10761076
(Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut { .. }) => {
10771077
// Reading from mere reservations of mutable-borrows is OK.
10781078
if !is_active(&this.dominators, borrow, context.loc) {
1079-
assert!(allow_two_phase_borrow(&tcx, borrow.kind));
1079+
assert!(allow_two_phase_borrow(tcx, borrow.kind));
10801080
return Control::Continue;
10811081
}
10821082

@@ -1233,7 +1233,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
12331233
BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))),
12341234
BorrowKind::Unique | BorrowKind::Mut { .. } => {
12351235
let wk = WriteKind::MutableBorrow(bk);
1236-
if allow_two_phase_borrow(&self.infcx.tcx, bk) {
1236+
if allow_two_phase_borrow(self.infcx.tcx, bk) {
12371237
(Deep, Reservation(wk))
12381238
} else {
12391239
(Deep, Write(wk))

src/librustc_mir/borrow_check/mutability_errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc::mir::{
55
Mutability, Operand, Place, PlaceBase, Projection, ProjectionElem, Static, StaticKind,
66
};
77
use rustc::mir::{Terminator, TerminatorKind};
8-
use rustc::ty::{self, Const, DefIdTree, TyS, TyCtxt};
8+
use rustc::ty::{self, Const, DefIdTree, Ty, TyS, TyCtxt};
99
use rustc_data_structures::indexed_vec::Idx;
1010
use syntax_pos::Span;
1111
use syntax_pos::symbol::keywords;
@@ -613,7 +613,7 @@ fn suggest_ampmut<'cx, 'gcx, 'tcx>(
613613
})
614614
}
615615

616-
fn is_closure_or_generator(ty: ty::Ty<'_>) -> bool {
616+
fn is_closure_or_generator(ty: Ty<'_>) -> bool {
617617
ty.is_closure() || ty.is_generator()
618618
}
619619

@@ -626,7 +626,7 @@ fn is_closure_or_generator(ty: ty::Ty<'_>) -> bool {
626626
/// ```
627627
fn annotate_struct_field(
628628
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
629-
ty: ty::Ty<'tcx>,
629+
ty: Ty<'tcx>,
630630
field: &mir::Field,
631631
) -> Option<(Span, String)> {
632632
// Expect our local to be a reference to a struct of some kind.

src/librustc_mir/borrow_check/nll/constraint_generation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc::mir::{BasicBlock, BasicBlockData, Location, Mir, Place, PlaceBase, Rv
1010
use rustc::mir::{SourceInfo, Statement, Terminator};
1111
use rustc::mir::UserTypeProjection;
1212
use rustc::ty::fold::TypeFoldable;
13-
use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid};
13+
use rustc::ty::{self, ClosureSubsts, GeneratorSubsts, RegionVid, Ty};
1414
use rustc::ty::subst::SubstsRef;
1515

1616
pub(super) fn generate_constraints<'cx, 'gcx, 'tcx>(
@@ -64,7 +64,7 @@ impl<'cg, 'cx, 'gcx, 'tcx> Visitor<'tcx> for ConstraintGeneration<'cg, 'cx, 'gcx
6464

6565
/// We sometimes have `ty` within an rvalue, or within a
6666
/// call. Make them live at the location where they appear.
67-
fn visit_ty(&mut self, ty: ty::Ty<'tcx>, ty_context: TyContext) {
67+
fn visit_ty(&mut self, ty: Ty<'tcx>, ty_context: TyContext) {
6868
match ty_context {
6969
TyContext::ReturnTy(SourceInfo { span, .. })
7070
| TyContext::YieldTy(SourceInfo { span, .. })

src/librustc_mir/borrow_check/nll/invalidation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> {
321321
BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))),
322322
BorrowKind::Unique | BorrowKind::Mut { .. } => {
323323
let wk = WriteKind::MutableBorrow(bk);
324-
if allow_two_phase_borrow(&self.tcx, bk) {
324+
if allow_two_phase_borrow(self.tcx, bk) {
325325
(Deep, Reservation(wk))
326326
} else {
327327
(Deep, Write(wk))
@@ -439,7 +439,7 @@ impl<'cg, 'cx, 'tcx, 'gcx> InvalidationGenerator<'cx, 'tcx, 'gcx> {
439439
// Reading from mere reservations of mutable-borrows is OK.
440440
if !is_active(&this.dominators, borrow, context.loc) {
441441
// If the borrow isn't active yet, reads don't invalidate it
442-
assert!(allow_two_phase_borrow(&this.tcx, borrow.kind));
442+
assert!(allow_two_phase_borrow(this.tcx, borrow.kind));
443443
return Control::Continue;
444444
}
445445

src/librustc_mir/borrow_check/path_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_data_structures::graph::dominators::Dominators;
1212
/// allowed to be split into separate Reservation and
1313
/// Activation phases.
1414
pub(super) fn allow_two_phase_borrow<'a, 'tcx, 'gcx: 'tcx>(
15-
_tcx: &TyCtxt<'a, 'gcx, 'tcx>,
15+
_tcx: TyCtxt<'a, 'gcx, 'tcx>,
1616
kind: BorrowKind
1717
) -> bool {
1818
kind.allows_two_phase_borrow()

src/librustc_mir/const_eval.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx>
440440

441441
let span = ecx.frame().span;
442442
ecx.machine.loop_detector.observe_and_analyze(
443-
&ecx.tcx,
443+
*ecx.tcx,
444444
span,
445445
&ecx.memory,
446446
&ecx.stack[..],
@@ -513,7 +513,7 @@ pub fn error_to_const_error<'a, 'mir, 'tcx>(
513513
}
514514

515515
fn validate_and_turn_into_const<'a, 'tcx>(
516-
tcx: ty::TyCtxt<'a, 'tcx, 'tcx>,
516+
tcx: TyCtxt<'a, 'tcx, 'tcx>,
517517
constant: RawConst<'tcx>,
518518
key: ty::ParamEnvAnd<'tcx, GlobalId<'tcx>>,
519519
) -> ::rustc::mir::interpret::ConstEvalResult<'tcx> {

src/librustc_mir/dataflow/move_paths/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use rustc::ty::{self, TyCtxt};
1+
use rustc::ty::{Ty, TyCtxt};
22
use rustc::mir::*;
33
use rustc::util::nodemap::FxHashMap;
44
use rustc_data_structures::indexed_vec::{Idx, IndexVec};
@@ -285,10 +285,10 @@ pub(crate) enum IllegalMoveOriginKind<'tcx> {
285285
/// implements `Drop`. Rust maintains invariant that all `Drop`
286286
/// ADT's remain fully-initialized so that user-defined destructor
287287
/// can safely read from all of the ADT's fields.
288-
InteriorOfTypeWithDestructor { container_ty: ty::Ty<'tcx> },
288+
InteriorOfTypeWithDestructor { container_ty: Ty<'tcx> },
289289

290290
/// Illegal move due to attempt to move out of a slice or array.
291-
InteriorOfSliceOrArray { ty: ty::Ty<'tcx>, is_index: bool, },
291+
InteriorOfSliceOrArray { ty: Ty<'tcx>, is_index: bool, },
292292
}
293293

294294
#[derive(Debug)]

src/librustc_mir/interpret/snapshot.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a, 'mir, 'tcx> InfiniteLoopDetector<'a, 'mir, 'tcx>
4747
{
4848
pub fn observe_and_analyze<'b>(
4949
&mut self,
50-
tcx: &TyCtxt<'b, 'tcx, 'tcx>,
50+
tcx: TyCtxt<'b, 'tcx, 'tcx>,
5151
span: Span,
5252
memory: &Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>,
5353
stack: &[Frame<'mir, 'tcx>],

src/librustc_mir/interpret/traits.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> InterpretCx<'a, 'mir, 'tcx, M>
101101
pub fn read_drop_type_from_vtable(
102102
&self,
103103
vtable: Pointer<M::PointerTag>,
104-
) -> EvalResult<'tcx, (ty::Instance<'tcx>, ty::Ty<'tcx>)> {
104+
) -> EvalResult<'tcx, (ty::Instance<'tcx>, Ty<'tcx>)> {
105105
// we don't care about the pointee type, we just want a pointer
106106
self.memory.check_align(vtable.into(), self.tcx.data_layout.pointer_align.abi)?;
107107
let drop_fn = self.memory

src/librustc_mir/shim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> {
644644

645645
fn tuple_like_shim<I>(&mut self, dest: Place<'tcx>,
646646
src: Place<'tcx>, tys: I)
647-
where I: Iterator<Item = ty::Ty<'tcx>> {
647+
where I: Iterator<Item = Ty<'tcx>> {
648648
let mut previous_field = None;
649649
for (i, ity) in tys.enumerate() {
650650
let field = Field::new(i);

src/librustc_mir/transform/const_prop.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc::mir::{NullOp, UnOp, StatementKind, Statement, BasicBlock, LocalKind,
88
use rustc::mir::{TerminatorKind, ClearCrossCrate, SourceInfo, BinOp, ProjectionElem};
99
use rustc::mir::visit::{Visitor, PlaceContext, MutatingUseContext, NonMutatingUseContext};
1010
use rustc::mir::interpret::{InterpError, Scalar, GlobalId, EvalResult};
11-
use rustc::ty::{TyCtxt, self, Instance};
11+
use rustc::ty::{self, Instance, Ty, TyCtxt};
1212
use syntax::source_map::{Span, DUMMY_SP};
1313
use rustc::ty::subst::InternalSubsts;
1414
use rustc_data_structures::indexed_vec::IndexVec;
@@ -80,10 +80,10 @@ struct ConstPropagator<'a, 'mir, 'tcx:'a+'mir> {
8080
}
8181

8282
impl<'a, 'b, 'tcx> LayoutOf for ConstPropagator<'a, 'b, 'tcx> {
83-
type Ty = ty::Ty<'tcx>;
83+
type Ty = Ty<'tcx>;
8484
type TyLayout = Result<TyLayout<'tcx>, LayoutError<'tcx>>;
8585

86-
fn layout_of(&self, ty: ty::Ty<'tcx>) -> Self::TyLayout {
86+
fn layout_of(&self, ty: Ty<'tcx>) -> Self::TyLayout {
8787
self.tcx.layout_of(self.param_env.and(ty))
8888
}
8989
}
@@ -476,7 +476,7 @@ impl<'a, 'mir, 'tcx> ConstPropagator<'a, 'mir, 'tcx> {
476476

477477
fn type_size_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
478478
param_env: ty::ParamEnv<'tcx>,
479-
ty: ty::Ty<'tcx>) -> Option<u64> {
479+
ty: Ty<'tcx>) -> Option<u64> {
480480
tcx.layout_of(param_env.and(ty)).ok().map(|layout| layout.size.bytes())
481481
}
482482

@@ -555,7 +555,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for ConstPropagator<'b, 'a, 'tcx> {
555555
) {
556556
trace!("visit_statement: {:?}", statement);
557557
if let StatementKind::Assign(ref place, ref rval) = statement.kind {
558-
let place_ty: ty::Ty<'tcx> = place
558+
let place_ty: Ty<'tcx> = place
559559
.ty(&self.mir.local_decls, self.tcx)
560560
.ty;
561561
if let Ok(place_layout) = self.tcx.layout_of(self.param_env.and(place_ty)) {

src/librustc_mir/transform/qualify_min_const_fn.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc::hir::def_id::DefId;
22
use rustc::hir;
33
use rustc::mir::*;
4-
use rustc::ty::{self, Predicate, TyCtxt, adjustment::{PointerCast}};
4+
use rustc::ty::{self, Predicate, Ty, TyCtxt, adjustment::{PointerCast}};
55
use rustc_target::spec::abi;
66
use std::borrow::Cow;
77
use syntax_pos::Span;
@@ -81,7 +81,7 @@ pub fn is_min_const_fn(
8181

8282
fn check_ty(
8383
tcx: TyCtxt<'a, 'tcx, 'tcx>,
84-
ty: ty::Ty<'tcx>,
84+
ty: Ty<'tcx>,
8585
span: Span,
8686
fn_def_id: DefId,
8787
) -> McfResult {

src/librustc_mir/util/borrowck_errors.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc::session::config::BorrowckMode;
2-
use rustc::ty::{self, TyCtxt};
2+
use rustc::ty::{self, Ty, TyCtxt};
33
use rustc_errors::{DiagnosticBuilder, DiagnosticId};
44
use syntax_pos::{MultiSpan, Span};
55

@@ -437,7 +437,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy {
437437
fn cannot_move_out_of_interior_noncopy(
438438
self,
439439
move_from_span: Span,
440-
ty: ty::Ty<'_>,
440+
ty: Ty<'_>,
441441
is_index: Option<bool>,
442442
o: Origin,
443443
) -> DiagnosticBuilder<'cx> {
@@ -464,7 +464,7 @@ pub trait BorrowckErrors<'cx>: Sized + Copy {
464464
fn cannot_move_out_of_interior_of_drop(
465465
self,
466466
move_from_span: Span,
467-
container_ty: ty::Ty<'_>,
467+
container_ty: Ty<'_>,
468468
o: Origin,
469469
) -> DiagnosticBuilder<'cx> {
470470
let mut err = struct_span_err!(

src/librustc_mir/util/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use core::unicode::property::Pattern_White_Space;
2-
use rustc::ty;
2+
use rustc::ty::TyCtxt;
33
use syntax_pos::Span;
44

55
pub mod borrowck_errors;
@@ -20,7 +20,7 @@ pub use self::graphviz::write_node_label as write_graphviz_node_label;
2020

2121
/// If possible, suggest replacing `ref` with `ref mut`.
2222
pub fn suggest_ref_mut<'cx, 'gcx, 'tcx>(
23-
tcx: ty::TyCtxt<'cx, 'gcx, 'tcx>,
23+
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
2424
binding_span: Span,
2525
) -> Option<(String)> {
2626
let hi_src = tcx.sess.source_map().span_to_snippet(binding_span).unwrap();

0 commit comments

Comments
 (0)