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

ast: Revert a breaking attribute visiting order change #125734

Merged
merged 2 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -852,10 +852,10 @@ pub fn walk_assoc_item<'a, V: Visitor<'a>>(
ctxt: AssocCtxt,
) -> V::Result {
let &Item { id: _, span: _, ident, ref vis, ref attrs, ref kind, tokens: _ } = item;
walk_list!(visitor, visit_attribute, attrs);
try_visit!(visitor.visit_vis(vis));
try_visit!(visitor.visit_ident(ident));
try_visit!(kind.walk(item, ctxt, visitor));
walk_list!(visitor, visit_attribute, attrs);
V::Result::output()
}

Expand Down
48 changes: 24 additions & 24 deletions src/tools/clippy/tests/ui/tabs_in_doc_comments.stderr
Original file line number Diff line number Diff line change
@@ -1,53 +1,53 @@
error: using tabs in doc comments is not recommended
--> tests/ui/tabs_in_doc_comments.rs:6:5
--> tests/ui/tabs_in_doc_comments.rs:10:9
|
LL | /// - first one
| ^^^^ help: consider using four spaces per tab
LL | /// - First String:
| ^^^^ help: consider using four spaces per tab
|
= note: `-D clippy::tabs-in-doc-comments` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::tabs_in_doc_comments)]`

error: using tabs in doc comments is not recommended
--> tests/ui/tabs_in_doc_comments.rs:6:13
--> tests/ui/tabs_in_doc_comments.rs:11:9
|
LL | /// - first one
| ^^^^^^^^ help: consider using four spaces per tab
LL | /// - needs to be inside here
| ^^^^^^^^ help: consider using four spaces per tab

error: using tabs in doc comments is not recommended
--> tests/ui/tabs_in_doc_comments.rs:7:5
--> tests/ui/tabs_in_doc_comments.rs:14:9
|
LL | /// - second one
| ^^^^ help: consider using four spaces per tab
LL | /// - Second String:
| ^^^^ help: consider using four spaces per tab

error: using tabs in doc comments is not recommended
--> tests/ui/tabs_in_doc_comments.rs:7:14
--> tests/ui/tabs_in_doc_comments.rs:15:9
|
LL | /// - second one
| ^^^^ help: consider using four spaces per tab
LL | /// - needs to be inside here
| ^^^^^^^^ help: consider using four spaces per tab

error: using tabs in doc comments is not recommended
--> tests/ui/tabs_in_doc_comments.rs:10:9
--> tests/ui/tabs_in_doc_comments.rs:6:5
|
LL | /// - First String:
| ^^^^ help: consider using four spaces per tab
LL | /// - first one
| ^^^^ help: consider using four spaces per tab

error: using tabs in doc comments is not recommended
--> tests/ui/tabs_in_doc_comments.rs:11:9
--> tests/ui/tabs_in_doc_comments.rs:6:13
|
LL | /// - needs to be inside here
| ^^^^^^^^ help: consider using four spaces per tab
LL | /// - first one
| ^^^^^^^^ help: consider using four spaces per tab

error: using tabs in doc comments is not recommended
--> tests/ui/tabs_in_doc_comments.rs:14:9
--> tests/ui/tabs_in_doc_comments.rs:7:5
|
LL | /// - Second String:
| ^^^^ help: consider using four spaces per tab
LL | /// - second one
| ^^^^ help: consider using four spaces per tab

error: using tabs in doc comments is not recommended
--> tests/ui/tabs_in_doc_comments.rs:15:9
--> tests/ui/tabs_in_doc_comments.rs:7:14
|
LL | /// - needs to be inside here
| ^^^^^^^^ help: consider using four spaces per tab
LL | /// - second one
| ^^^^ help: consider using four spaces per tab

error: aborting due to 8 previous errors

64 changes: 64 additions & 0 deletions tests/ui/attributes/key-value-expansion-scope.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#![doc = in_root!()] // FIXME, this is a bug
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
#![doc = in_mod_escape!()] // FIXME, this is a bug
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope

#[doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope
#[doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
#[doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope
#[doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
fn before() {
#![doc = in_root!()] //~ ERROR cannot find macro `in_root` in this scope
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
#![doc = in_mod_escape!()] //~ ERROR cannot find macro `in_mod_escape` in this scope
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
}

macro_rules! in_root { () => { "" } }

mod macros_stay {
#![doc = in_mod!()] // FIXME, this is a bug

macro_rules! in_mod { () => { "" } }

#[doc = in_mod!()] // OK
fn f() {
#![doc = in_mod!()] // OK
}
}

#[macro_use]
mod macros_escape {
#![doc = in_mod_escape!()] // FIXME, this is a bug

macro_rules! in_mod_escape { () => { "" } }

#[doc = in_mod_escape!()] // OK
fn f() {
#![doc = in_mod_escape!()] // OK
}
}

fn block() {
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope

macro_rules! in_block { () => { "" } }

#[doc = in_block!()] // OK
fn f() {
#![doc = in_block!()] // OK
}
}

#[doc = in_root!()] // OK
#[doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
#[doc = in_mod_escape!()] // OK
#[doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
fn after() {
#![doc = in_root!()] // OK
#![doc = in_mod!()] //~ ERROR cannot find macro `in_mod` in this scope
#![doc = in_mod_escape!()] // OK
#![doc = in_block!()] //~ ERROR cannot find macro `in_block` in this scope
}

fn main() {}
122 changes: 122 additions & 0 deletions tests/ui/attributes/key-value-expansion-scope.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
error: cannot find macro `in_mod` in this scope
--> $DIR/key-value-expansion-scope.rs:2:10
|
LL | #![doc = in_mod!()]
| ^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_block` in this scope
--> $DIR/key-value-expansion-scope.rs:4:10
|
LL | #![doc = in_block!()]
| ^^^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_root` in this scope
--> $DIR/key-value-expansion-scope.rs:6:9
|
LL | #[doc = in_root!()]
| ^^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_mod` in this scope
--> $DIR/key-value-expansion-scope.rs:7:9
|
LL | #[doc = in_mod!()]
| ^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_mod_escape` in this scope
--> $DIR/key-value-expansion-scope.rs:8:9
|
LL | #[doc = in_mod_escape!()]
| ^^^^^^^^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_block` in this scope
--> $DIR/key-value-expansion-scope.rs:9:9
|
LL | #[doc = in_block!()]
| ^^^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_root` in this scope
--> $DIR/key-value-expansion-scope.rs:11:14
|
LL | #![doc = in_root!()]
| ^^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_mod` in this scope
--> $DIR/key-value-expansion-scope.rs:12:14
|
LL | #![doc = in_mod!()]
| ^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_mod_escape` in this scope
--> $DIR/key-value-expansion-scope.rs:13:14
|
LL | #![doc = in_mod_escape!()]
| ^^^^^^^^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_block` in this scope
--> $DIR/key-value-expansion-scope.rs:14:14
|
LL | #![doc = in_block!()]
| ^^^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_block` in this scope
--> $DIR/key-value-expansion-scope.rs:43:14
|
LL | #![doc = in_block!()]
| ^^^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_mod` in this scope
--> $DIR/key-value-expansion-scope.rs:54:9
|
LL | #[doc = in_mod!()]
| ^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_block` in this scope
--> $DIR/key-value-expansion-scope.rs:56:9
|
LL | #[doc = in_block!()]
| ^^^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_mod` in this scope
--> $DIR/key-value-expansion-scope.rs:59:14
|
LL | #![doc = in_mod!()]
| ^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: cannot find macro `in_block` in this scope
--> $DIR/key-value-expansion-scope.rs:61:14
|
LL | #![doc = in_block!()]
| ^^^^^^^^
|
= help: have you added the `#[macro_use]` on the module/import?

error: aborting due to 15 previous errors

20 changes: 10 additions & 10 deletions tests/ui/feature-gates/feature-gate-optimize_attribute.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
error[E0658]: the `#[optimize]` attribute is an experimental feature
--> $DIR/feature-gate-optimize_attribute.rs:4:1
|
LL | #[optimize(size)]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information
= help: add `#![feature(optimize_attribute)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the `#[optimize]` attribute is an experimental feature
--> $DIR/feature-gate-optimize_attribute.rs:7:1
|
Expand Down Expand Up @@ -38,6 +28,16 @@ LL | #[optimize(banana)]
= help: add `#![feature(optimize_attribute)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the `#[optimize]` attribute is an experimental feature
--> $DIR/feature-gate-optimize_attribute.rs:4:1
|
LL | #[optimize(size)]
| ^^^^^^^^^^^^^^^^^
|
= note: see issue #54882 <https://github.com/rust-lang/rust/issues/54882> for more information
= help: add `#![feature(optimize_attribute)]` to the crate attributes to enable
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date

error[E0658]: the `#[optimize]` attribute is an experimental feature
--> $DIR/feature-gate-optimize_attribute.rs:2:1
|
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/feature-gates/issue-43106-gating-of-stable.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
error[E0734]: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:10:1
|
LL | #[stable()]
| ^^^^^^^^^^^

error[E0734]: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:14:9
|
Expand Down Expand Up @@ -34,6 +28,12 @@ error[E0734]: stability attributes may not be used outside of the standard libra
LL | #[stable()]
| ^^^^^^^^^^^

error[E0734]: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:10:1
|
LL | #[stable()]
| ^^^^^^^^^^^

error[E0734]: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-stable.rs:7:1
|
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/feature-gates/issue-43106-gating-of-unstable.stderr
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
error[E0734]: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:10:1
|
LL | #[unstable()]
| ^^^^^^^^^^^^^

error[E0734]: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:14:9
|
Expand Down Expand Up @@ -34,6 +28,12 @@ error[E0734]: stability attributes may not be used outside of the standard libra
LL | #[unstable()]
| ^^^^^^^^^^^^^

error[E0734]: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:10:1
|
LL | #[unstable()]
| ^^^^^^^^^^^^^

error[E0734]: stability attributes may not be used outside of the standard library
--> $DIR/issue-43106-gating-of-unstable.rs:7:1
|
Expand Down
Loading