Skip to content

regression: ambiguous outer attributes #125199

Description

@BoxyUwU
[INFO] [stdout] error: ambiguous outer attributes
[INFO] [stdout]    --> src/main.rs:284:17
[INFO] [stdout]     |
[INFO] [stdout] 284 | /                 #[cfg(feature = "rustls")]
[INFO] [stdout] 285 | |                 server = server.listen_rustls(listener, ssl_builder)?;
[INFO] [stdout]     | |_____________________________________________________________________^
[INFO] [stdout]     |

Probably #124099 cc @davidtwco

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 17, 2024
  2. added
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 17, 2024
  3. added this to the 1.79.0 milestone on May 17, 2024
  4. added
    A-attributesArea: Attributes (`#[…]`, `#![…]`)
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on May 18, 2024
  5. davidtwco commented on May 20, 2024

    @davidtwco
    Member

    cc @voidc as author of #124099

  6. apiraino commented on May 21, 2024

    @apiraino
    Contributor

    WG-prioritization assigning priority (Zulip discussion).

    My question here is how do we want to handle the changes in #124099. I don't see a mention of it being aware about breaking changes (PR was even rolled up).

    @rustbot label -I-prioritize +P-critical

  7. added and removed
    I-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
    on May 21, 2024
  8. voidc commented on May 30, 2024

    @voidc
    Contributor

    I looked into each regression. Most are caused by a dependency on rustrict (versions 0.3.13..0.5.14) which contains the following code (source):

        /// TODO: This is untested.
        #[cfg(feature = "reset_censor")]
        pub fn reset(&mut self, text: I) {
            // ...
            #[cfg(any(feature = "find_false_positives", feature = "trace"))]
            self.total_matches = 0;
            // ...
        }

    I assume the author meant to apply the attribute to the whole assignment statement but here it only applies to the expression self.total_matches. Applying the attribute to the statement would have required wrapping it in braces. Since the stmt_expr_attributes feature is still unstable, the above code would normally trigger an error. However, because the reset function is conditional on the (untested) reset_censor feature, the unstable feature error was never triggered during normal compilation. In a later commit the reset function was removed.

    Besides rustrict there are three more problematic crates: thoughts_server, leptos_router, and varies.
    In all of them, the regression boils down to a pattern similar to rustrict.

    To summarize, in each case, an attribute is applied to the left-hand side of an assignment, which most likely does not match the authors' intention. This is exactly the kind of mistake that the error introduced in #124099 is meant to prevent.

  9. riking commented on May 30, 2024

    @riking

    I'm unclear whether this requires nightly to trigger?

    This should probably be reverted and changed to a future compat warning.

  10. apiraino commented on May 30, 2024

    @apiraino
    Contributor

    Issue was briefly mentioned today in the t-compiler triage meeting (on Zulip).

    Seems that given the timeframe leading to the next stable (2024-06-13, in 13 days), a revert would be more appropriate.

  11. wesleywiser commented on Jun 6, 2024

    @wesleywiser
    Member

    Yeah, since #[something] let foo = bar; is already accepted syntax on stable, we can't change it to be an error even if most of the places in this crater are not using it correctly. I think @riking is correct and this first needs to be made into a future compatibility warning and then a hard error over an edition boundary to preserve backwards compatibility.

  12. added a commit that references this issue on Jun 7, 2024
  13. added 2 commits that reference this issue on Jun 7, 2024
  14. added a commit that references this issue on Jun 7, 2024
  15. Mark-Simulacrum commented on Jun 7, 2024

    @Mark-Simulacrum
    Member

    Closing since fixes landed on beta/nightly: #126093

  16. lqd commented on Jun 7, 2024

    @lqd
    Member

    This was fixed by reverting #124099 on nightly (in #126101) and beta (in #126093).

  17. added a commit that references this issue on Jun 13, 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 (`#[…]`, `#![…]`)P-criticalCritical priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions