Skip to content

Commit e4b87f5

Browse files
committed
Deny internal lints on librustc_mir
1 parent d2bc991 commit e4b87f5

File tree

14 files changed

+46
-45
lines changed

14 files changed

+46
-45
lines changed

src/librustc_mir/borrow_check/error_reporting.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
223223
Some(ref name) => format!("`{}`", name),
224224
None => "value".to_owned(),
225225
};
226-
if let ty::TyKind::Param(param_ty) = ty.sty {
226+
if let ty::Param(param_ty) = ty.sty {
227227
let tcx = self.infcx.tcx;
228228
let generics = tcx.generics_of(self.mir_def_id);
229229
let def_id = generics.type_param(&param_ty, tcx).def_id;
@@ -1529,7 +1529,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
15291529
if let TerminatorKind::Call {
15301530
func: Operand::Constant(box Constant {
15311531
literal: ty::Const {
1532-
ty: &ty::TyS { sty: ty::TyKind::FnDef(id, _), .. },
1532+
ty: &ty::TyS { sty: ty::FnDef(id, _), .. },
15331533
..
15341534
},
15351535
..
@@ -1547,7 +1547,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
15471547
};
15481548

15491549
debug!("add_moved_or_invoked_closure_note: closure={:?}", closure);
1550-
if let ty::TyKind::Closure(did, _) = self.mir.local_decls[closure].ty.sty {
1550+
if let ty::Closure(did, _) = self.mir.local_decls[closure].ty.sty {
15511551
let hir_id = self.infcx.tcx.hir().as_local_hir_id(did).unwrap();
15521552

15531553
if let Some((span, name)) = self.infcx.tcx.typeck_tables_of(did)
@@ -1570,7 +1570,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
15701570

15711571
// Check if we are just moving a closure after it has been invoked.
15721572
if let Some(target) = target {
1573-
if let ty::TyKind::Closure(did, _) = self.mir.local_decls[target].ty.sty {
1573+
if let ty::Closure(did, _) = self.mir.local_decls[target].ty.sty {
15741574
let hir_id = self.infcx.tcx.hir().as_local_hir_id(did).unwrap();
15751575

15761576
if let Some((span, name)) = self.infcx.tcx.typeck_tables_of(did)
@@ -1919,7 +1919,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
19191919
} else {
19201920
let ty = self.infcx.tcx.type_of(self.mir_def_id);
19211921
match ty.sty {
1922-
ty::TyKind::FnDef(_, _) | ty::TyKind::FnPtr(_) => self.annotate_fn_sig(
1922+
ty::FnDef(_, _) | ty::FnPtr(_) => self.annotate_fn_sig(
19231923
self.mir_def_id,
19241924
self.infcx.tcx.fn_sig(self.mir_def_id),
19251925
),
@@ -2164,12 +2164,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
21642164
// anything.
21652165
let return_ty = sig.output();
21662166
match return_ty.skip_binder().sty {
2167-
ty::TyKind::Ref(return_region, _, _) if return_region.has_name() && !is_closure => {
2167+
ty::Ref(return_region, _, _) if return_region.has_name() && !is_closure => {
21682168
// This is case 1 from above, return type is a named reference so we need to
21692169
// search for relevant arguments.
21702170
let mut arguments = Vec::new();
21712171
for (index, argument) in sig.inputs().skip_binder().iter().enumerate() {
2172-
if let ty::TyKind::Ref(argument_region, _, _) = argument.sty {
2172+
if let ty::Ref(argument_region, _, _) = argument.sty {
21732173
if argument_region == return_region {
21742174
// Need to use the `rustc::ty` types to compare against the
21752175
// `return_region`. Then use the `rustc::hir` type to get only
@@ -2206,7 +2206,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
22062206
return_span,
22072207
})
22082208
}
2209-
ty::TyKind::Ref(_, _, _) if is_closure => {
2209+
ty::Ref(_, _, _) if is_closure => {
22102210
// This is case 2 from above but only for closures, return type is anonymous
22112211
// reference so we select
22122212
// the first argument.
@@ -2215,9 +2215,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
22152215

22162216
// Closure arguments are wrapped in a tuple, so we need to get the first
22172217
// from that.
2218-
if let ty::TyKind::Tuple(elems) = argument_ty.sty {
2218+
if let ty::Tuple(elems) = argument_ty.sty {
22192219
let argument_ty = elems.first()?;
2220-
if let ty::TyKind::Ref(_, _, _) = argument_ty.sty {
2220+
if let ty::Ref(_, _, _) = argument_ty.sty {
22212221
return Some(AnnotatedBorrowFnSignature::Closure {
22222222
argument_ty,
22232223
argument_span,
@@ -2227,7 +2227,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
22272227

22282228
None
22292229
}
2230-
ty::TyKind::Ref(_, _, _) => {
2230+
ty::Ref(_, _, _) => {
22312231
// This is also case 2 from above but for functions, return type is still an
22322232
// anonymous reference so we select the first argument.
22332233
let argument_span = fn_decl.inputs.first()?.span;
@@ -2238,7 +2238,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
22382238

22392239
// We expect the first argument to be a reference.
22402240
match argument_ty.sty {
2241-
ty::TyKind::Ref(_, _, _) => {}
2241+
ty::Ref(_, _, _) => {}
22422242
_ => return None,
22432243
}
22442244

@@ -2366,8 +2366,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
23662366
// this by hooking into the pretty printer and telling it to label the
23672367
// lifetimes without names with the value `'0`.
23682368
match ty.sty {
2369-
ty::TyKind::Ref(ty::RegionKind::ReLateBound(_, br), _, _)
2370-
| ty::TyKind::Ref(
2369+
ty::Ref(ty::RegionKind::ReLateBound(_, br), _, _)
2370+
| ty::Ref(
23712371
ty::RegionKind::RePlaceholder(ty::PlaceholderRegion { name: br, .. }),
23722372
_,
23732373
_,
@@ -2386,7 +2386,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
23862386
let mut printer = ty::print::FmtPrinter::new(self.infcx.tcx, &mut s, Namespace::TypeNS);
23872387

23882388
let region = match ty.sty {
2389-
ty::TyKind::Ref(region, _, _) => {
2389+
ty::Ref(region, _, _) => {
23902390
match region {
23912391
ty::RegionKind::ReLateBound(_, br)
23922392
| ty::RegionKind::RePlaceholder(ty::PlaceholderRegion { name: br, .. }) => {

src/librustc_mir/borrow_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
17411741
// no move out from an earlier location) then this is an attempt at initialization
17421742
// of the union - we should error in that case.
17431743
let tcx = this.infcx.tcx;
1744-
if let ty::TyKind::Adt(def, _) = base.ty(this.mir, tcx).ty.sty {
1744+
if let ty::Adt(def, _) = base.ty(this.mir, tcx).ty.sty {
17451745
if def.is_union() {
17461746
if this.move_data.path_map[mpi].iter().any(|moi| {
17471747
this.move_data.moves[*moi].source.is_predecessor_of(

src/librustc_mir/borrow_check/move_errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
532532
if let StatementKind::Assign(_, box Rvalue::Ref(_, _, source)) = &stmt.kind {
533533
let ty = source.ty(self.mir, self.infcx.tcx).ty;
534534
let ty = match ty.sty {
535-
ty::TyKind::Ref(_, ty, _) => ty,
535+
ty::Ref(_, ty, _) => ty,
536536
_ => ty,
537537
};
538538
debug!("borrowed_content_source: ty={:?}", ty);
@@ -557,7 +557,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
557557

558558
let ty = source.ty(self.mir, self.infcx.tcx).ty;
559559
let ty = match ty.sty {
560-
ty::TyKind::Ref(_, ty, _) => ty,
560+
ty::Ref(_, ty, _) => ty,
561561
_ => ty,
562562
};
563563
debug!("borrowed_content_source: ty={:?}", ty);

src/librustc_mir/borrow_check/mutability_errors.rs

Lines changed: 5 additions & 5 deletions
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, TyKind, TyCtxt};
8+
use rustc::ty::{self, Const, DefIdTree, TyS, TyCtxt};
99
use rustc_data_structures::indexed_vec::Idx;
1010
use syntax_pos::Span;
1111
use syntax_pos::symbol::keywords;
@@ -261,7 +261,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
261261
// Otherwise, check if the name is the self kewyord - in which case
262262
// we have an explicit self. Do the same thing in this case and check
263263
// for a `self: &mut Self` to suggest removing the `&mut`.
264-
if let ty::TyKind::Ref(
264+
if let ty::Ref(
265265
_, _, hir::Mutability::MutMutable
266266
) = local_decl.ty.sty {
267267
true
@@ -476,7 +476,7 @@ impl<'a, 'gcx, 'tcx> MirBorrowckCtxt<'a, 'gcx, 'tcx> {
476476
func: Operand::Constant(box Constant {
477477
literal: Const {
478478
ty: &TyS {
479-
sty: TyKind::FnDef(id, substs),
479+
sty: ty::FnDef(id, substs),
480480
..
481481
},
482482
..
@@ -633,8 +633,8 @@ fn annotate_struct_field(
633633
field: &mir::Field,
634634
) -> Option<(Span, String)> {
635635
// Expect our local to be a reference to a struct of some kind.
636-
if let ty::TyKind::Ref(_, ty, _) = ty.sty {
637-
if let ty::TyKind::Adt(def, _) = ty.sty {
636+
if let ty::Ref(_, ty, _) = ty.sty {
637+
if let ty::Adt(def, _) = ty.sty {
638638
let field = def.all_fields().nth(field.index())?;
639639
// Use the HIR types to construct the diagnostic message.
640640
let hir_id = tcx.hir().as_local_hir_id(field.did)?;

src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
589589
// Check the type for a trait object.
590590
return match ty.sty {
591591
// `&dyn Trait`
592-
ty::TyKind::Ref(_, ty, _) if ty.is_trait() => true,
592+
ty::Ref(_, ty, _) if ty.is_trait() => true,
593593
// `Box<dyn Trait>`
594594
_ if ty.is_box() && ty.boxed_ty().is_trait() => true,
595595
// `dyn Trait`

src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
583583
(self.to_error_region(fr), self.to_error_region(outlived_fr))
584584
{
585585
if let Some(ty::TyS {
586-
sty: ty::TyKind::Opaque(did, substs),
586+
sty: ty::Opaque(did, substs),
587587
..
588588
}) = infcx
589589
.tcx

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use rustc::traits::{ObligationCause, PredicateObligations};
3939
use rustc::ty::fold::TypeFoldable;
4040
use rustc::ty::subst::{Subst, SubstsRef, UnpackedKind, UserSubsts};
4141
use rustc::ty::{
42-
self, RegionVid, ToPolyTraitRef, Ty, TyCtxt, TyKind, UserType,
42+
self, RegionVid, ToPolyTraitRef, Ty, TyCtxt, UserType,
4343
CanonicalUserTypeAnnotation, CanonicalUserTypeAnnotations,
4444
UserTypeAnnotationIndex,
4545
};
@@ -746,7 +746,7 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> {
746746
let (variant, substs) = match base_ty {
747747
PlaceTy { ty, variant_index: Some(variant_index) } => {
748748
match ty.sty {
749-
ty::TyKind::Adt(adt_def, substs) => (&adt_def.variants[variant_index], substs),
749+
ty::Adt(adt_def, substs) => (&adt_def.variants[variant_index], substs),
750750
_ => bug!("can't have downcast of non-adt type"),
751751
}
752752
}
@@ -1136,7 +1136,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
11361136
category: ConstraintCategory,
11371137
) -> Fallible<()> {
11381138
if let Err(terr) = self.sub_types(sub, sup, locations, category) {
1139-
if let TyKind::Opaque(..) = sup.sty {
1139+
if let ty::Opaque(..) = sup.sty {
11401140
// When you have `let x: impl Foo = ...` in a closure,
11411141
// the resulting inferend values are stored with the
11421142
// def-id of the base function.
@@ -1389,7 +1389,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
13891389
} => {
13901390
let place_type = place.ty(mir, tcx).ty;
13911391
let adt = match place_type.sty {
1392-
TyKind::Adt(adt, _) if adt.is_enum() => adt,
1392+
ty::Adt(adt, _) if adt.is_enum() => adt,
13931393
_ => {
13941394
span_bug!(
13951395
stmt.source_info.span,

src/librustc_mir/dataflow/move_paths/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> {
425425
base,
426426
elem: ProjectionElem::Field(_, _),
427427
}) if match base.ty(self.builder.mir, self.builder.tcx).ty.sty {
428-
ty::TyKind::Adt(def, _) if def.is_union() => true,
428+
ty::Adt(def, _) if def.is_union() => true,
429429
_ => false,
430430
} => base,
431431
// Otherwise, lookup the place.

src/librustc_mir/hair/pattern/_match.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>(
17541754
// they should be pointing to memory is when they are subslices of nonzero
17551755
// slices
17561756
let (opt_ptr, n, ty) = match value.ty.sty {
1757-
ty::TyKind::Array(t, n) => {
1757+
ty::Array(t, n) => {
17581758
match value.val {
17591759
ConstValue::ByRef(ptr, alloc) => (
17601760
Some((ptr, alloc)),
@@ -1767,7 +1767,7 @@ fn specialize<'p, 'a: 'p, 'tcx: 'a>(
17671767
),
17681768
}
17691769
},
1770-
ty::TyKind::Slice(t) => {
1770+
ty::Slice(t) => {
17711771
match value.val {
17721772
ConstValue::Slice(ptr, n) => (
17731773
ptr.to_ptr().ok().map(|ptr| (

src/librustc_mir/hair/pattern/check_match.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc::middle::expr_use_visitor as euv;
1010
use rustc::middle::mem_categorization::cmt_;
1111
use rustc::middle::region;
1212
use rustc::session::Session;
13-
use rustc::ty::{self, Ty, TyCtxt, TyKind};
13+
use rustc::ty::{self, Ty, TyCtxt};
1414
use rustc::ty::subst::{InternalSubsts, SubstsRef};
1515
use rustc::lint;
1616
use rustc_errors::{Applicability, DiagnosticBuilder};
@@ -481,7 +481,7 @@ fn check_exhaustive<'p, 'a: 'p, 'tcx: 'a>(
481481
}
482482
let patterns = witnesses.iter().map(|p| (**p).clone()).collect::<Vec<Pattern<'_>>>();
483483
if patterns.len() < 4 {
484-
for sp in maybe_point_at_variant(cx, &scrut_ty.sty, patterns.as_slice()) {
484+
for sp in maybe_point_at_variant(cx, scrut_ty, patterns.as_slice()) {
485485
err.span_label(sp, "not covered");
486486
}
487487
}
@@ -498,11 +498,11 @@ fn check_exhaustive<'p, 'a: 'p, 'tcx: 'a>(
498498

499499
fn maybe_point_at_variant(
500500
cx: &mut MatchCheckCtxt<'a, 'tcx>,
501-
sty: &TyKind<'tcx>,
501+
ty: Ty<'tcx>,
502502
patterns: &[Pattern<'_>],
503503
) -> Vec<Span> {
504504
let mut covered = vec![];
505-
if let ty::Adt(def, _) = sty {
505+
if let ty::Adt(def, _) = ty.sty {
506506
// Don't point at variants that have already been covered due to other patterns to avoid
507507
// visual clutter
508508
for pattern in patterns {
@@ -518,15 +518,15 @@ fn maybe_point_at_variant(
518518
.map(|field_pattern| field_pattern.pattern.clone())
519519
.collect::<Vec<_>>();
520520
covered.extend(
521-
maybe_point_at_variant(cx, sty, subpatterns.as_slice()),
521+
maybe_point_at_variant(cx, ty, subpatterns.as_slice()),
522522
);
523523
}
524524
}
525525
if let PatternKind::Leaf { subpatterns } = pk {
526526
let subpatterns = subpatterns.iter()
527527
.map(|field_pattern| field_pattern.pattern.clone())
528528
.collect::<Vec<_>>();
529-
covered.extend(maybe_point_at_variant(cx, sty, subpatterns.as_slice()));
529+
covered.extend(maybe_point_at_variant(cx, ty, subpatterns.as_slice()));
530530
}
531531
}
532532
}

src/librustc_mir/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
2828
#![recursion_limit="256"]
2929

3030
#![deny(rust_2018_idioms)]
31+
#![cfg_attr(not(stage0), deny(internal))]
3132
#![allow(explicit_outlives_requirements)]
3233

3334
#[macro_use] extern crate log;

src/librustc_mir/lints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc::hir::intravisit::FnKind;
44
use rustc::hir::map::blocks::FnLikeNode;
55
use rustc::lint::builtin::UNCONDITIONAL_RECURSION;
66
use rustc::mir::{self, Mir, TerminatorKind};
7-
use rustc::ty::{AssociatedItem, AssociatedItemContainer, Instance, TyCtxt, TyKind};
7+
use rustc::ty::{self, AssociatedItem, AssociatedItemContainer, Instance, TyCtxt};
88
use rustc::ty::subst::InternalSubsts;
99

1010
pub fn check(tcx: TyCtxt<'a, 'tcx, 'tcx>,
@@ -86,7 +86,7 @@ fn check_fn_for_unconditional_recursion(tcx: TyCtxt<'a, 'tcx, 'tcx>,
8686
TerminatorKind::Call { ref func, .. } => {
8787
let func_ty = func.ty(mir, tcx);
8888

89-
if let TyKind::FnDef(fn_def_id, substs) = func_ty.sty {
89+
if let ty::FnDef(fn_def_id, substs) = func_ty.sty {
9090
let (call_fn_id, call_substs) =
9191
if let Some(instance) = Instance::resolve(tcx,
9292
param_env,

src/librustc_mir/transform/instcombine.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use rustc::mir::{Constant, Location, Place, PlaceBase, Mir, Operand, ProjectionElem, Rvalue, Local};
44
use rustc::mir::visit::{MutVisitor, Visitor};
5-
use rustc::ty::{TyCtxt, TyKind};
5+
use rustc::ty::{self, TyCtxt};
66
use rustc::util::nodemap::{FxHashMap, FxHashSet};
77
use rustc_data_structures::indexed_vec::Idx;
88
use std::mem;
@@ -90,7 +90,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for OptimizationFinder<'b, 'a, 'tcx> {
9090

9191
if let Rvalue::Len(ref place) = *rvalue {
9292
let place_ty = place.ty(&self.mir.local_decls, self.tcx).ty;
93-
if let TyKind::Array(_, len) = place_ty.sty {
93+
if let ty::Array(_, len) = place_ty.sty {
9494
let span = self.mir.source_info(location).span;
9595
let ty = self.tcx.types.usize;
9696
let constant = Constant { span, ty, literal: len, user_ty: None };

src/librustc_mir/transform/lower_128bit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use rustc::hir::def_id::DefId;
44
use rustc::middle::lang_items::LangItem;
55
use rustc::mir::*;
6-
use rustc::ty::{List, Ty, TyCtxt, TyKind};
6+
use rustc::ty::{self, List, Ty, TyCtxt};
77
use rustc_data_structures::indexed_vec::{Idx};
88
use crate::transform::{MirPass, MirSource};
99

@@ -183,8 +183,8 @@ impl RhsKind {
183183

184184
fn sign_of_128bit(ty: Ty<'_>) -> Option<bool> {
185185
match ty.sty {
186-
TyKind::Int(syntax::ast::IntTy::I128) => Some(true),
187-
TyKind::Uint(syntax::ast::UintTy::U128) => Some(false),
186+
ty::Int(syntax::ast::IntTy::I128) => Some(true),
187+
ty::Uint(syntax::ast::UintTy::U128) => Some(false),
188188
_ => None,
189189
}
190190
}

0 commit comments

Comments
 (0)