Skip to content
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

cfg attribute should remove the entire item from type checking, including its annotations #6931

Open
ironcev opened this issue Feb 14, 2025 · 0 comments
Assignees
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: parser Everything to do with the parser compiler General compiler. Should eventually become more specific as the issue is triaged team:compiler Compiler Team

Comments

@ironcev
Copy link
Member

ironcev commented Feb 14, 2025

By definition, a cfg attribute that cfg-evals to false effectively removes its annotated item from the AST and further type checking. E.g., this compiles when new_encoding is active, because the whole function gets removed from the type checking:

#[cfg(experimental_new_encoding = false)]
fn not_type_checked() -> bool {
    non_existing + non_existing
}

Since the item is removed, its annotations must be removed as well. E.g., we shouldn't get warnings or errors for invalid annotations. This is currently not the case. E.g., this code:

#[allow(something)]        // <<<<---- Emits warning here, although `not_type_checked` does not exist.
#[cfg(experimental_new_encoding = false)]
fn not_type_checked() -> bool {
    non_existing + non_existing
}

will emit a warning, although the not_type_checked does not exist in the further compilation.

@ironcev ironcev self-assigned this Feb 14, 2025
@ironcev ironcev added compiler General compiler. Should eventually become more specific as the issue is triaged compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: parser Everything to do with the parser team:compiler Compiler Team labels Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: parser Everything to do with the parser compiler General compiler. Should eventually become more specific as the issue is triaged team:compiler Compiler Team
Projects
None yet
Development

No branches or pull requests

1 participant