Deny internal lints on librustc_lint

This commit is contained in:
flip1995 2019-03-31 23:48:48 +02:00
parent 818d300451
commit d2bc99135f
No known key found for this signature in database
GPG Key ID: 693086869D506637
3 changed files with 10 additions and 8 deletions

View File

@ -1036,7 +1036,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
let msg = "mutating transmuted &mut T from &T may cause undefined behavior, \
consider instead using an UnsafeCell";
match get_transmute_from_to(cx, expr) {
match get_transmute_from_to(cx, expr).map(|(ty1, ty2)| (&ty1.sty, &ty2.sty)) {
Some((&ty::Ref(_, _, from_mt), &ty::Ref(_, _, to_mt))) => {
if to_mt == hir::Mutability::MutMutable &&
from_mt == hir::Mutability::MutImmutable {
@ -1049,7 +1049,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
fn get_transmute_from_to<'a, 'tcx>
(cx: &LateContext<'a, 'tcx>,
expr: &hir::Expr)
-> Option<(&'tcx ty::TyKind<'tcx>, &'tcx ty::TyKind<'tcx>)> {
-> Option<(Ty<'tcx>, Ty<'tcx>)> {
let def = if let hir::ExprKind::Path(ref qpath) = expr.node {
cx.tables.qpath_def(qpath, expr.hir_id)
} else {
@ -1062,7 +1062,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MutableTransmutes {
let sig = cx.tables.node_type(expr.hir_id).fn_sig(cx.tcx);
let from = sig.inputs().skip_binder()[0];
let to = *sig.output().skip_binder();
return Some((&from.sty, &to.sty));
return Some((from, to));
}
None
}

View File

@ -20,6 +20,7 @@
#![recursion_limit="256"]
#![deny(rust_2018_idioms)]
#![cfg_attr(not(stage0), deny(internal))]
#[macro_use]
extern crate rustc;

View File

@ -321,7 +321,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
//
// No suggestion for: `isize`, `usize`.
fn get_type_suggestion<'a>(
t: &ty::TyKind<'_>,
t: Ty<'_>,
val: u128,
negative: bool,
) -> Option<String> {
@ -347,14 +347,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
}
}
}
match t {
&ty::Int(i) => find_fit!(i, val, negative,
match t.sty {
ty::Int(i) => find_fit!(i, val, negative,
I8 => [U8] => [I16, I32, I64, I128],
I16 => [U16] => [I32, I64, I128],
I32 => [U32] => [I64, I128],
I64 => [U64] => [I128],
I128 => [U128] => []),
&ty::Uint(u) => find_fit!(u, val, negative,
ty::Uint(u) => find_fit!(u, val, negative,
U8 => [U8, U16, U32, U64, U128] => [],
U16 => [U16, U32, U64, U128] => [],
U32 => [U32, U64, U128] => [],
@ -364,6 +364,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
}
}
#[cfg_attr(not(stage0), allow(usage_of_ty_tykind))]
fn report_bin_hex_error(
cx: &LateContext<'_, '_>,
expr: &hir::Expr,
@ -398,7 +399,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TypeLimits {
repr_str, val, t, actually, t
));
if let Some(sugg_ty) =
get_type_suggestion(&cx.tables.node_type(expr.hir_id).sty, val, negative)
get_type_suggestion(&cx.tables.node_type(expr.hir_id), val, negative)
{
if let Some(pos) = repr_str.chars().position(|c| c == 'i' || c == 'u') {
let (sans_suffix, _) = repr_str.split_at(pos);