]> git.lizzy.rs Git - rust.git/commitdiff
Deny internal lints on librustc_lint
authorflip1995 <hello@philkrones.com>
Sun, 31 Mar 2019 21:48:48 +0000 (23:48 +0200)
committerflip1995 <hello@philkrones.com>
Wed, 3 Apr 2019 16:24:22 +0000 (18:24 +0200)
src/librustc_lint/builtin.rs
src/librustc_lint/lib.rs
src/librustc_lint/types.rs

index 1fae931e9f1fd531d35fa949820aac1df32001ac..541d779c477fc4ba55fb9f4616929d3b5c273ac5 100644 (file)
@@ -1036,7 +1036,7 @@ fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &hir::Expr) {
 
         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 @@ fn check_expr(&mut self, cx: &LateContext<'_, '_>, expr: &hir::Expr) {
         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 @@ fn get_transmute_from_to<'a, 'tcx>
                 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
         }
index f741f37594ec3daf73f9e6072a0cfa45f27fe6fe..7e77962a16e0bda1f154cc03135c4c4e582de9ac 100644 (file)
@@ -20,6 +20,7 @@
 #![recursion_limit="256"]
 
 #![deny(rust_2018_idioms)]
+#![cfg_attr(not(stage0), deny(internal))]
 
 #[macro_use]
 extern crate rustc;
index 494a9bb73ed4b578f0eb25828a44dd54a4b34df9..fa106532662d18d2fbcffd17a356a409056ef060 100644 (file)
@@ -321,7 +321,7 @@ fn get_bin_hex_repr(cx: &LateContext<'_, '_>, lit: &ast::Lit) -> Option<String>
         //
         // 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 @@ macro_rules! find_fit {
                     }
                 }
             }
-            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 @@ macro_rules! find_fit {
             }
         }
 
+        #[cfg_attr(not(stage0), allow(usage_of_ty_tykind))]
         fn report_bin_hex_error(
             cx: &LateContext<'_, '_>,
             expr: &hir::Expr,
@@ -398,7 +399,7 @@ fn report_bin_hex_error(
                 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);