-
-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Fix nonsensical #[path] attributes being silently allowed
#157903
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // ERROR: #[path] on inline module with NO external submodules | ||
| #[path = "foo.rs"] | ||
| mod inline_module {} //~ ERROR attribute `#[path]` is useless on inline modules | ||
|
|
||
| // ERROR: #[path] on inline module with only inline submodules | ||
| #[path = "foo.rs"] | ||
| mod inline_with_inline_sub { //~ ERROR attribute `#[path]` is useless on inline modules | ||
| mod inner {} // inline, not external | ||
| } | ||
|
|
||
| // ERROR: #![path] inside module with no external submodules | ||
| mod useless_inner { //~ ERROR attribute `#[path]` is useless here as there are no nested external modules | ||
| #![path = "some_dir"] | ||
| // no external submodules | ||
| } | ||
|
|
||
| // ERROR: #![path] inside module where submodule is inline (has body) | ||
| mod thread_inline_sub { //~ ERROR attribute `#[path]` is useless here as there are no nested external modules | ||
| #![path = "thread_files"] | ||
| #[path = "tls.rs"] | ||
| mod local_data {} //~ ERROR attribute `#[path]` is useless on inline modules | ||
| } | ||
|
Comment on lines
+17
to
+22
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You claim at #157260 (comment) that this code will not produce a warning. This test shows that the code produces a hard error instead. Could you explain?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mod thread_inline_sub { //~ ERROR attribute |
||
|
|
||
| fn main() {} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| error: attribute `#[path]` is useless on inline modules | ||
| --> $DIR/path-inline-module.rs:3:1 | ||
| | | ||
| LL | mod inline_module {} | ||
| | ^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: attribute `#[path]` is useless on inline modules | ||
| --> $DIR/path-inline-module.rs:7:1 | ||
| | | ||
| LL | / mod inline_with_inline_sub { | ||
| LL | | mod inner {} // inline, not external | ||
| LL | | } | ||
| | |_^ | ||
|
|
||
| error: attribute `#[path]` is useless here as there are no nested external modules | ||
| --> $DIR/path-inline-module.rs:12:1 | ||
| | | ||
| LL | / mod useless_inner { | ||
| LL | | #![path = "some_dir"] | ||
| LL | | // no external submodules | ||
| LL | | } | ||
| | |_^ | ||
|
|
||
| error: attribute `#[path]` is useless here as there are no nested external modules | ||
| --> $DIR/path-inline-module.rs:18:1 | ||
| | | ||
| LL | / mod thread_inline_sub { | ||
| LL | | #![path = "thread_files"] | ||
| LL | | #[path = "tls.rs"] | ||
| LL | | mod local_data {} | ||
| LL | | } | ||
| | |_^ | ||
|
|
||
| error: attribute `#[path]` is useless on inline modules | ||
| --> $DIR/path-inline-module.rs:21:5 | ||
| | | ||
| LL | mod local_data {} | ||
| | ^^^^^^^^^^^^^^^^^ | ||
|
|
||
| error: aborting due to 5 previous errors | ||
|
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: please edit your PR description to more meaningfully reflect what is being changed about the language (reviewers do not need a list of files being changed; they can see that through the diff already). Please describe e.g.:
#[path]attributes were being silently allowed, but are now loudly rejected?For an example, seee #145463 (comment)
View changes since the review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes @jieyouxu i have updated the PR description as suggested by you
thanks for the suggestion ,I will take care of it in future