Skip to content

raw_pointer_deriving lint name should be raw_pointer_derive #20498

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

Closed
huonw opened this issue Jan 4, 2015 · 1 comment · Fixed by #20511
Closed

raw_pointer_deriving lint name should be raw_pointer_derive #20498

huonw opened this issue Jan 4, 2015 · 1 comment · Fixed by #20511
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@huonw
Copy link
Member

huonw commented Jan 4, 2015

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
@huonw huonw added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. labels Jan 4, 2015
@csouth3
Copy link
Contributor

csouth3 commented Jan 4, 2015

Looks easy enough. I could take care of this if you would like/are not doing it already.

Edit: I've prepared a patch, make checking now

alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 5, 2015
`#[deriving]` has been changed to `#[derive]`, so we should update this lint accordingly so that it remains consistent with the language.

Also register the rename with the LintStore.

I've changed the one reference to `raw_pointer_deriving` that occurs in the tests (as well as renamed the file appropriately), but the rest of the `raw_pointer_deriving`s in the Rust codebase will need to wait for a snapshot to be changed because stage0 doesn't know about the new lint name.  I'll take care of the remaining renaming after the next snapshot.

Closes rust-lang#20498.
alexcrichton added a commit to alexcrichton/rust that referenced this issue Jan 6, 2015
`#[deriving]` has been changed to `#[derive]`, so we should update this lint accordingly so that it remains consistent with the language.

Also register the rename with the LintStore.

I've changed the one reference to `raw_pointer_deriving` that occurs in the tests (as well as renamed the file appropriately), but the rest of the `raw_pointer_deriving`s in the Rust codebase will need to wait for a snapshot to be changed because stage0 doesn't know about the new lint name.  I'll take care of the remaining renaming after the next snapshot.

Closes rust-lang#20498.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants