Skip to content

Remove raw_pointer_deriving lint #29882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 18, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
#![doc(test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]

#![no_core]
#![allow(raw_pointer_derive)]
#![deny(missing_docs)]

#![feature(allow_internal_unstable)]
Expand Down
88 changes: 1 addition & 87 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ use syntax::attr::{self, AttrMetaMethods};
use syntax::codemap::{self, Span};

use rustc_front::hir;
use rustc_front::visit::{self, FnKind, Visitor};
use rustc_front::visit::FnKind;

use bad_style::{MethodLateContext, method_context};

Expand Down Expand Up @@ -138,92 +138,6 @@ impl LateLintPass for BoxPointers {
}
}

declare_lint! {
RAW_POINTER_DERIVE,
Warn,
"uses of #[derive] with raw pointers are rarely correct"
}

struct RawPtrDeriveVisitor<'a, 'tcx: 'a> {
cx: &'a LateContext<'a, 'tcx>
}

impl<'a, 'tcx, 'v> Visitor<'v> for RawPtrDeriveVisitor<'a, 'tcx> {
fn visit_ty(&mut self, ty: &hir::Ty) {
const MSG: &'static str = "use of `#[derive]` with a raw pointer";
if let hir::TyPtr(..) = ty.node {
self.cx.span_lint(RAW_POINTER_DERIVE, ty.span, MSG);
}
visit::walk_ty(self, ty);
}
// explicit override to a no-op to reduce code bloat
fn visit_expr(&mut self, _: &hir::Expr) {}
fn visit_block(&mut self, _: &hir::Block) {}
}

pub struct RawPointerDerive {
checked_raw_pointers: NodeSet,
}

impl RawPointerDerive {
pub fn new() -> RawPointerDerive {
RawPointerDerive {
checked_raw_pointers: NodeSet(),
}
}
}

impl LintPass for RawPointerDerive {
fn get_lints(&self) -> LintArray {
lint_array!(RAW_POINTER_DERIVE)
}
}

impl LateLintPass for RawPointerDerive {
fn check_item(&mut self, cx: &LateContext, item: &hir::Item) {
if !attr::contains_name(&item.attrs, "automatically_derived") {
return;
}
let did = match item.node {
hir::ItemImpl(_, _, _, ref t_ref_opt, _, _) => {
// Deriving the Copy trait does not cause a warning
if let &Some(ref trait_ref) = t_ref_opt {
let def_id = cx.tcx.trait_ref_to_def_id(trait_ref);
if Some(def_id) == cx.tcx.lang_items.copy_trait() {
return;
}
}

match cx.tcx.node_id_to_type(item.id).sty {
ty::TyEnum(def, _) => def.did,
ty::TyStruct(def, _) => def.did,
_ => return,
}
}
_ => return,
};
let node_id = if let Some(node_id) = cx.tcx.map.as_local_node_id(did) {
node_id
} else {
return;
};
let item = match cx.tcx.map.find(node_id) {
Some(hir_map::NodeItem(item)) => item,
_ => return,
};
if !self.checked_raw_pointers.insert(item.id) {
return;
}
match item.node {
hir::ItemStruct(..) | hir::ItemEnum(..) => {
let mut visitor = RawPtrDeriveVisitor { cx: cx };
visit::walk_item(&mut visitor, &item);
}
_ => {}
}
}
}

declare_lint! {
NON_SHORTHAND_FIELD_PATTERNS,
Warn,
Expand Down
3 changes: 0 additions & 3 deletions src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {

add_builtin_with_new!(sess,
TypeLimits,
RawPointerDerive,
MissingDoc,
MissingDebugImplementations,
);
Expand All @@ -152,8 +151,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
store.register_late_pass(sess, false, box lint::GatherNodeLevels);

// Insert temporary renamings for a one-time deprecation
store.register_renamed("raw_pointer_deriving", "raw_pointer_derive");

store.register_renamed("unknown_features", "unused_features");

store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
Expand Down
1 change: 0 additions & 1 deletion src/librustc_llvm/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ impl OptimizationDiagnosticKind {
}
}

#[allow(raw_pointer_derive)]
#[derive(Copy, Clone)]
pub struct OptimizationDiagnostic {
pub kind: OptimizationDiagnosticKind,
Expand Down
34 changes: 0 additions & 34 deletions src/test/compile-fail/lint-raw-ptr-derive.rs

This file was deleted.

21 changes: 0 additions & 21 deletions src/test/run-pass/issue-21296.rs

This file was deleted.