-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Description
Due to the #[deriving]
-> #[derive]
switch.
Relevant bits of code:
rust/src/librustc/lint/builtin.rs
Lines 552 to 620 in 496dc4e
declare_lint! { RAW_POINTER_DERIVING, Warn, "uses of #[derive] with raw pointers are rarely correct" } struct RawPtrDerivingVisitor<'a, 'tcx: 'a> { cx: &'a Context<'a, 'tcx> } impl<'a, 'tcx, 'v> Visitor<'v> for RawPtrDerivingVisitor<'a, 'tcx> { fn visit_ty(&mut self, ty: &ast::Ty) { static MSG: &'static str = "use of `#[derive]` with a raw pointer"; if let ast::TyPtr(..) = ty.node { self.cx.span_lint(RAW_POINTER_DERIVING, ty.span, MSG); } visit::walk_ty(self, ty); } // explicit override to a no-op to reduce code bloat fn visit_expr(&mut self, _: &ast::Expr) {} fn visit_block(&mut self, _: &ast::Block) {} } pub struct RawPointerDeriving { checked_raw_pointers: NodeSet, } impl RawPointerDeriving { pub fn new() -> RawPointerDeriving { RawPointerDeriving { checked_raw_pointers: NodeSet::new(), } } } impl LintPass for RawPointerDeriving { fn get_lints(&self) -> LintArray { lint_array!(RAW_POINTER_DERIVING) } fn check_item(&mut self, cx: &Context, item: &ast::Item) { if !attr::contains_name(item.attrs[], "automatically_derived") { return } let did = match item.node { ast::ItemImpl(..) => { match ty::node_id_to_type(cx.tcx, item.id).sty { ty::ty_enum(did, _) => did, ty::ty_struct(did, _) => did, _ => return, } } _ => return, }; if !ast_util::is_local(did) { return } let item = match cx.tcx.map.find(did.node) { Some(ast_map::NodeItem(item)) => item, _ => return, }; if !self.checked_raw_pointers.insert(item.id) { return } match item.node { ast::ItemStruct(..) | ast::ItemEnum(..) => { let mut visitor = RawPtrDerivingVisitor { cx: cx }; visit::walk_item(&mut visitor, &*item); } _ => {} } } } rust/src/librustc/lint/context.rs
Line 226 in 496dc4e
// Insert temporary renamings for a one-time deprecation (#16545)
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.