Skip to content

Commit 50b969d

Browse files
committed
Auto merge of #29882 - devonhollowood:master, r=Manishearth
Implement #14615
2 parents 277416e + 0823ee6 commit 50b969d

File tree

7 files changed

+2
-148
lines changed

7 files changed

+2
-148
lines changed

src/libcore/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
#![doc(test(no_crate_inject, attr(allow(unused_variables), deny(warnings))))]
6767

6868
#![no_core]
69-
#![allow(raw_pointer_derive)]
7069
#![deny(missing_docs)]
7170

7271
#![feature(allow_internal_unstable)]

src/librustc_lint/builtin.rs

+1-87
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use syntax::attr::{self, AttrMetaMethods};
4646
use syntax::codemap::{self, Span};
4747

4848
use rustc_front::hir;
49-
use rustc_front::visit::{self, FnKind, Visitor};
49+
use rustc_front::visit::FnKind;
5050

5151
use bad_style::{MethodLateContext, method_context};
5252

@@ -138,92 +138,6 @@ impl LateLintPass for BoxPointers {
138138
}
139139
}
140140

141-
declare_lint! {
142-
RAW_POINTER_DERIVE,
143-
Warn,
144-
"uses of #[derive] with raw pointers are rarely correct"
145-
}
146-
147-
struct RawPtrDeriveVisitor<'a, 'tcx: 'a> {
148-
cx: &'a LateContext<'a, 'tcx>
149-
}
150-
151-
impl<'a, 'tcx, 'v> Visitor<'v> for RawPtrDeriveVisitor<'a, 'tcx> {
152-
fn visit_ty(&mut self, ty: &hir::Ty) {
153-
const MSG: &'static str = "use of `#[derive]` with a raw pointer";
154-
if let hir::TyPtr(..) = ty.node {
155-
self.cx.span_lint(RAW_POINTER_DERIVE, ty.span, MSG);
156-
}
157-
visit::walk_ty(self, ty);
158-
}
159-
// explicit override to a no-op to reduce code bloat
160-
fn visit_expr(&mut self, _: &hir::Expr) {}
161-
fn visit_block(&mut self, _: &hir::Block) {}
162-
}
163-
164-
pub struct RawPointerDerive {
165-
checked_raw_pointers: NodeSet,
166-
}
167-
168-
impl RawPointerDerive {
169-
pub fn new() -> RawPointerDerive {
170-
RawPointerDerive {
171-
checked_raw_pointers: NodeSet(),
172-
}
173-
}
174-
}
175-
176-
impl LintPass for RawPointerDerive {
177-
fn get_lints(&self) -> LintArray {
178-
lint_array!(RAW_POINTER_DERIVE)
179-
}
180-
}
181-
182-
impl LateLintPass for RawPointerDerive {
183-
fn check_item(&mut self, cx: &LateContext, item: &hir::Item) {
184-
if !attr::contains_name(&item.attrs, "automatically_derived") {
185-
return;
186-
}
187-
let did = match item.node {
188-
hir::ItemImpl(_, _, _, ref t_ref_opt, _, _) => {
189-
// Deriving the Copy trait does not cause a warning
190-
if let &Some(ref trait_ref) = t_ref_opt {
191-
let def_id = cx.tcx.trait_ref_to_def_id(trait_ref);
192-
if Some(def_id) == cx.tcx.lang_items.copy_trait() {
193-
return;
194-
}
195-
}
196-
197-
match cx.tcx.node_id_to_type(item.id).sty {
198-
ty::TyEnum(def, _) => def.did,
199-
ty::TyStruct(def, _) => def.did,
200-
_ => return,
201-
}
202-
}
203-
_ => return,
204-
};
205-
let node_id = if let Some(node_id) = cx.tcx.map.as_local_node_id(did) {
206-
node_id
207-
} else {
208-
return;
209-
};
210-
let item = match cx.tcx.map.find(node_id) {
211-
Some(hir_map::NodeItem(item)) => item,
212-
_ => return,
213-
};
214-
if !self.checked_raw_pointers.insert(item.id) {
215-
return;
216-
}
217-
match item.node {
218-
hir::ItemStruct(..) | hir::ItemEnum(..) => {
219-
let mut visitor = RawPtrDeriveVisitor { cx: cx };
220-
visit::walk_item(&mut visitor, &item);
221-
}
222-
_ => {}
223-
}
224-
}
225-
}
226-
227141
declare_lint! {
228142
NON_SHORTHAND_FIELD_PATTERNS,
229143
Warn,

src/librustc_lint/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
135135

136136
add_builtin_with_new!(sess,
137137
TypeLimits,
138-
RawPointerDerive,
139138
MissingDoc,
140139
MissingDebugImplementations,
141140
);
@@ -152,8 +151,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
152151
store.register_late_pass(sess, false, box lint::GatherNodeLevels);
153152

154153
// Insert temporary renamings for a one-time deprecation
155-
store.register_renamed("raw_pointer_deriving", "raw_pointer_derive");
156-
157154
store.register_renamed("unknown_features", "unused_features");
158155

159156
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");

src/librustc_llvm/diagnostic.rs

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ impl OptimizationDiagnosticKind {
3737
}
3838
}
3939

40-
#[allow(raw_pointer_derive)]
4140
#[derive(Copy, Clone)]
4241
pub struct OptimizationDiagnostic {
4342
pub kind: OptimizationDiagnosticKind,

src/test/compile-fail/lint-raw-ptr-derive.rs

-34
This file was deleted.

src/test/run-pass/issue-21296.rs

-21
This file was deleted.

0 commit comments

Comments
 (0)