Skip to content

expected unsuffixed literal or identifier, found IN_ISDIR #122796

Closed as not planned

Description

@Thomasdezeeuw

I have the following (open source) code: https://github.com/Thomasdezeeuw/heph/blob/1c7ee4af37627fcfb11749389973fa5e4a34a0bf/rt/src/fs/watch.rs#L354-L466. It's over a 100 lines and I'm not sure what is causing the issue.

This compiled fine since it was added to the repository, latest nightly compiler that is know to work is from rustc 1.78.0-nightly (c67326b06 2024-03-15).

However using the currently nightly compiler, 1.79.0-nightly (a7e4de13c 2024-03-19), fails to compile it giving the following errors:

Details
error: expected unsuffixed literal or identifier, found `IN_ISDIR`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_ACCESS`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_MODIFY`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_ATTRIB`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_CLOSE_WRITE`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_CLOSE_NOWRITE`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_CLOSE`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_OPEN`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_DELETE_SELF`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_MOVE_SELF`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_UNMOUNT`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_MOVED_FROM`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_MOVED_TO`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_MOVE`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_CREATE`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: expected unsuffixed literal or identifier, found `IN_DELETE`
   --> rt/src/fs/watch.rs:454:23
    |
354 |     bit_checks!(self.event.mask);
    |     ---------------------------- in this macro invocation
...
454 |         #[doc(alias = $bit)]
    |                       ^^^^
    |
    = note: this error originates in the macro `bit_checks` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `heph-rt` (lib) due to 16 previous errors
make: *** [Makefile.include:21: test] Error 101

Also available on the CI:

There are two problems. First, the regression from the previous nightly. Second, the error message is rather confusing, I have would have no idea what the actual problem is.

Meta

rustc --version --verbose:

rustc 1.79.0-nightly (a7e4de13c 2024-03-19)
binary: rustc
commit-hash: a7e4de13c1785819f4d61da41f6704ed69d5f203
commit-date: 2024-03-19
host: x86_64-unknown-linux-gnu
release: 1.79.0-nightly
LLVM version: 18.1.2

Activity

  1. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Mar 20, 2024
  2. Thomasdezeeuw commented on Mar 20, 2024

    @Thomasdezeeuw
    ContributorAuthor

    The code works with nightly-2024-03-16:

    rustc 1.78.0-nightly (766bdce74 2024-03-16)
    binary: rustc
    commit-hash: 766bdce744d531267d53ba2a3f9ffcda69fb9b17
    commit-date: 2024-03-16
    host: x86_64-unknown-linux-gnu
    release: 1.78.0-nightly
    LLVM version: 18.1.2
    
  3. added
    A-attributesArea: Attributes (`#[…]`, `#![…]`)
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    C-discussionCategory: Discussion or questions that doesn't represent real issues.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    C-bugCategory: This is a bug.
    on Mar 20, 2024
  4. jieyouxu commented on Mar 20, 2024

    @jieyouxu
    Member

    Exhibit A:

    #![crate_type = "lib"]
    #![allow(dead_code)]
    
    pub const IN_ISDIR: usize = 0;
    
    macro_rules! m {
        ($bit: ident) => {
            #[doc(alias = $bit)]
            pub const fn foo() {}
        };
    }
    
    struct Bar;
    
    impl Bar {
        m!(IN_ISDIR);
    }

    OK on stable, ERROR on nightly 2024-03-19.


    Exhibit B:

    #![crate_type = "lib"]
    #![allow(dead_code)]
    
    pub const IN_ISDIR: usize = 0;
    
    macro_rules! m {
        ($bit: ident) => {
            #[doc(alias = $bit)]
            pub const fn foo() {}
        };
    }
    
    struct Bar;
    
    m!(IN_ISDIR);

    ERROR on both.


    Exhibit C:

    #![crate_type = "lib"]
    #![allow(dead_code)]
    
    pub const IN_ISDIR: usize = 0;
    
    macro_rules! m {
        ($bit: ident) => {
            #[doc(alias = $bit)]
            pub fn foo() {}            // <- notice not `const` like Exhibit A
        };
    }
    
    struct Bar;
    
    impl Bar {
        m!(IN_ISDIR);
    }

    ERROR on both.

  5. fmease commented on Mar 20, 2024

    @fmease
    Member

    First and foremost, sorry for breaking your crate! However this was an intentional breaking change. We used to not validate attributes on certain kinds of associated functions. We did a crater run and found only a single regression. Therefore I decided to roll with it.

  6. fmease commented on Mar 20, 2024

    @fmease
    Member

    Intentionally regressed in #121545.

  7. jieyouxu commented on Mar 20, 2024

    @jieyouxu
    Member

    Makes a lot of sense, was about to say the stable behavior is the surprising one lol

  8. fmease commented on Mar 20, 2024

    @fmease
    Member

    @Thomasdezeeuw Your #[doc(alias = $bit)] attribute is malformed, the latest rustc is correct here. The doc-alias takes a string literal IIRC. To fix this, you can do #[doc(alias = stringify!($bit))].

    See also: https://doc.rust-lang.org/rustdoc/advanced-features.html#add-aliases-for-an-item-in-documentation-search

  9. jieyouxu commented on Mar 20, 2024

    @jieyouxu
    Member

    Intentionally regressed in #121545.

    If this is an intentional regression, we can probably close this issue?

  10. fmease commented on Mar 20, 2024

    @fmease
    Member

    The diagnostic isn't great tho lol, we should open an issue if there isn't one already. We are not expecting an identifier.

  11. Thomasdezeeuw commented on Mar 21, 2024

    @Thomasdezeeuw
    ContributorAuthor

    @jieyouxu @fmease thanks for the responses.

    Any chance we can reopen (or create another issue) to improve the diagnostic message though? Because I won't have guessed from the error message that the problem was in the doc attributed.

  12. jieyouxu commented on Mar 21, 2024

    @jieyouxu
    Member

    Any chance we can reopen (or create another issue) to improve the diagnostic message though? Because I won't have guessed from the error message that the problem was in the doc attributed.

    Feel free to create an issue for the diagnostic (which is actionable)

  13. fmease commented on Mar 22, 2024

    @fmease
    Member

    Any chance we can reopen (or create another issue) to improve the diagnostic message though? Because I won't have guessed from the error message that the problem was in the doc attributed.

    I will look into that later.

  14. added 2 commits that reference this issue on May 10, 2024
  15. added a commit that references this issue on May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)C-discussionCategory: Discussion or questions that doesn't represent real issues.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

      No branches or pull requests

      Issue actions