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

Emit compiler errors for unknown field attributes #729

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sharkdp
Copy link

@sharkdp sharkdp commented Feb 25, 2025

Emit an error if an unknown field attribute is used on a salsa::tracked struct. For example, when changing the attribute in ParsedFile inside the examples/lazy-input/main.rs example from return_ref to returns_ref, the compiler emits:

error: unrecognized field attribute
   --> examples/lazy-input/main.rs:164:5
    |
164 |     #[returns_ref]
    |     ^^^^^^^^^^^^^^

I'm opening this as a draft for two reasons:

  • It's unclear to me if this is actually desired behavior. Could non-salsa attributes be mixed with salsa attributes?
  • The error message above seems fine, but there are actually a lot more downstream compiler errors if that change is made to the example. Maybe there is a way to get rid of those downstream errors?

closes #728

Emit an error if an unknown field attribute is used on a
`salsa::tracked` struct. For example, when changing the `return_ref`
attribute in `ParsedFile` to `returns_ref`, the compiler emits:

    error: unrecognized field attribute
       --> examples/lazy-input/main.rs:164:5
        |
    164 |     #[returns_ref]
        |     ^^^^^^^^^^^^^^
Copy link

netlify bot commented Feb 25, 2025

Deploy Preview for salsa-rs canceled.

Name Link
🔨 Latest commit 1b1bd2d
🔍 Latest deploy log https://app.netlify.com/sites/salsa-rs/deploys/67bdc0b6e78c6d0008eecd18

@MichaReiser
Copy link
Contributor

I'm not sure if possible but it would be nice if we could carry along unknown attributes. I would have found that useful in the past, e.g. to suppress a clippy warning (allow a reference to some deprecated code).

It would also be great to have a test for this. You can add a compilation test by adding a new file in tests/compile-fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unknown annotations in salsa::tracked structs do not lead to an error
2 participants