Skip to content

raw_pointer_deriving lint name should be raw_pointer_derive #20498

@huonw

Description

@huonw

Due to the #[deriving] -> #[derive] switch.

Relevant bits of code:

  • 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);
    }
    _ => {}
    }
    }
    }
    for the actual code
  • // Insert temporary renamings for a one-time deprecation (#16545)
    should have this renaming added

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: 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.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions