Skip to content

Renaming builtin attributes does not work, but name resolution thinks it does #79798

Closed
@jonas-schievink

Description

@jonas-schievink
Contributor

Forgive my sins, but:

use allow as deny;

#[deny(unused)]
fn f() {}

The #[deny] still acts as a #[deny], but the import should make it behave like #[allow]. No "unused import" lint is emitted, so name resolution thinks that the import has an effect.

Activity

added
A-attributesArea: Attributes (`#[…]`, `#![…]`)
A-resolveArea: Name/path resolution done by `rustc_resolve` specifically
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
on Dec 7, 2020
petrochenkov

petrochenkov commented on Dec 7, 2020

@petrochenkov
Contributor

This should be an error, we have a special check for this in resolve.
I'll check why the error is not reported.

self-assigned this
on Dec 7, 2020
petrochenkov

petrochenkov commented on Dec 7, 2020

@petrochenkov
Contributor

Compare with

use global_allocator as allow;

#[allow(unused)]
fn f() {}
error[E0659]: `allow` is ambiguous (built-in attribute vs any other name)
 --> src/lib.rs:3:3
  |
3 | #[allow(unused)]
  |   ^^^^^ ambiguous name
  |
  = note: `allow` could refer to a built-in attribute
note: `allow` could also refer to the attribute macro imported here
 --> src/lib.rs:1:5
  |
1 | use global_allocator as allow;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^
  = help: use `crate::allow` to refer to this attribute macro unambiguously

Looks like we just consider all (inert) built-in attributes same during this check.

petrochenkov

petrochenkov commented on Dec 14, 2020

@petrochenkov
Contributor

Fixed in #80031.

added 3 commits that reference this issue on Jan 16, 2021

Rollup merge of rust-lang#80031 - petrochenkov:builtina, r=estebank

c06ff92

Rollup merge of rust-lang#80031 - petrochenkov:builtina, r=estebank

ea81a28

Rollup merge of rust-lang#80031 - petrochenkov:builtina, r=estebank

3d5e7e0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @jonas-schievink@petrochenkov

    Issue actions

      Renaming builtin attributes does not work, but name resolution thinks it does · Issue #79798 · rust-lang/rust