Skip to content

Broken build after updating: coverage is ambiguous; ambiguous because of a name conflict with a builtin attribute #121157

Open
@NicholasGorski

Description

@NicholasGorski

Code

I have an internal macro for domain-specific coverage tracking:

macro_rules! coverage {
    () => {
        /* .. */
    };
}

pub(crate) use coverage;

On version 1.73.0, this compiles without error (godbolt).
On version 1.74.0 and above, this results in an error (godbolt):

error[E0659]: `coverage` is ambiguous
 --> <source>:7:16
  |
7 | pub(crate) use coverage;
  |                ^^^^^^^^ ambiguous name
  |
  = note: ambiguous because of a name conflict with a builtin attribute
  = note: `coverage` could refer to a built-in attribute

My understanding is that this is an acceptable breakage in general. (Though, perhaps should be in the 1.74.0 compatibility notes).

However, what might make this unacceptable is that this attribute is not actually stable:

#[coverage(off)]
pub fn foo() {}

gives (godbolt):

error[E0658]: the `#[coverage]` attribute is an experimental feature
 --> <source>:1:1
  |
1 | #[coverage(off)]
  | ^^^^^^^^^^^^^^^^
  |
  = note: see issue #84605 <https://github.com/rust-lang/rust/issues/84605> for more information
  = help: add `#![feature(coverage_attribute)]` to the crate

Is it expected that an inactive experimental attribute can cause name ambiguity on stable Rust?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-code-coverageArea: Source-based code coverage (-Cinstrument-coverage)A-resolveArea: Name/path resolution done by `rustc_resolve` specificallyC-bugCategory: This is a bug.P-mediumMedium priorityS-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language team, which will review and decide on the PR/issue.regression-untriagedUntriaged performance or correctness regression.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions