mirror of
https://github.com/servo/servo.git
synced 2025-07-14 19:03:40 +01:00
Kill transmute-type-lint
This commit is contained in:
parent
f3bacf84f4
commit
19c645ff68
4 changed files with 0 additions and 66 deletions
|
@ -46,7 +46,6 @@ pub fn plugin_registrar(reg: &mut Registry) {
|
||||||
reg.register_late_lint_pass(box lints::unrooted_must_root::UnrootedPass::new());
|
reg.register_late_lint_pass(box lints::unrooted_must_root::UnrootedPass::new());
|
||||||
reg.register_late_lint_pass(box lints::privatize::PrivatizePass);
|
reg.register_late_lint_pass(box lints::privatize::PrivatizePass);
|
||||||
reg.register_late_lint_pass(box lints::inheritance_integrity::InheritancePass);
|
reg.register_late_lint_pass(box lints::inheritance_integrity::InheritancePass);
|
||||||
reg.register_late_lint_pass(box lints::transmute_type::TransmutePass);
|
|
||||||
reg.register_early_lint_pass(box lints::ban::BanPass);
|
reg.register_early_lint_pass(box lints::ban::BanPass);
|
||||||
reg.register_attribute("_dom_struct_marker".to_string(), Whitelisted);
|
reg.register_attribute("_dom_struct_marker".to_string(), Whitelisted);
|
||||||
reg.register_attribute("allow_unrooted_interior".to_string(), Whitelisted);
|
reg.register_attribute("allow_unrooted_interior".to_string(), Whitelisted);
|
||||||
|
|
|
@ -5,5 +5,4 @@
|
||||||
pub mod ban;
|
pub mod ban;
|
||||||
pub mod inheritance_integrity;
|
pub mod inheritance_integrity;
|
||||||
pub mod privatize;
|
pub mod privatize;
|
||||||
pub mod transmute_type;
|
|
||||||
pub mod unrooted_must_root;
|
pub mod unrooted_must_root;
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
use rustc::hir;
|
|
||||||
use rustc::lint::{LateContext, LintPass, LintArray, LateLintPass, LintContext};
|
|
||||||
|
|
||||||
declare_lint!(TRANSMUTE_TYPE_LINT, Allow,
|
|
||||||
"Warn and report types being transmuted");
|
|
||||||
|
|
||||||
/// Lint for auditing transmutes
|
|
||||||
///
|
|
||||||
/// This lint (off by default, enable with `-W transmute-type-lint`) warns about all the transmutes
|
|
||||||
/// being used, along with the types they transmute to/from.
|
|
||||||
pub struct TransmutePass;
|
|
||||||
|
|
||||||
impl LintPass for TransmutePass {
|
|
||||||
fn get_lints(&self) -> LintArray {
|
|
||||||
lint_array!(TRANSMUTE_TYPE_LINT)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for TransmutePass {
|
|
||||||
fn check_expr(&mut self, cx: &LateContext, ex: &hir::Expr) {
|
|
||||||
match ex.node {
|
|
||||||
hir::ExprCall(ref expr, ref args) => {
|
|
||||||
match expr.node {
|
|
||||||
hir::ExprPath(hir::QPath::Resolved(_, ref path)) => {
|
|
||||||
if path.segments.last()
|
|
||||||
.map_or(false, |ref segment| &*segment.name.as_str() == "transmute") &&
|
|
||||||
args.len() == 1 {
|
|
||||||
cx.span_lint(TRANSMUTE_TYPE_LINT, ex.span,
|
|
||||||
&format!("Transmute to {:?} from {:?} detected",
|
|
||||||
cx.tables.expr_ty(ex),
|
|
||||||
cx.tables.expr_ty(&args.get(0).unwrap())
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
#![feature(plugin)]
|
|
||||||
#![plugin(plugins)]
|
|
||||||
#![allow(dead_code)]
|
|
||||||
#![deny(transmute_type_lint)]
|
|
||||||
|
|
||||||
use std::mem::{self, transmute};
|
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _: &[u8] = unsafe { transmute("Rust") };
|
|
||||||
//~^ ERROR Transmute to &[u8] from &'static str detected
|
|
||||||
|
|
||||||
let _: &[u8] = unsafe { mem::transmute("Rust") };
|
|
||||||
//~^ ERROR Transmute to &[u8] from &'static str detected
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue