-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #130246 - dianne:issue-97589-fix, r=petrochenkov
rustc_expand: remember module `#[path]`s during expansion During invocation collection, if a module item parsed from a `#[path]` attribute needed a second pass after parsing, its path wouldn't get added to the file path stack, so cycle detection broke. This checks the `#[path]` in such cases, so that it gets added appropriately. I think it should work identically to the case for external modules that don't need a second pass, but I'm not 100% sure. Fixes #97589
- Loading branch information
Showing
5 changed files
with
31 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...cular-module-with-doc-comment-issue-97589/circular-module-with-doc-comment-issue-97589.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//@ error-pattern: circular modules | ||
// Regression test for #97589: a doc-comment on a circular module bypassed cycle detection | ||
|
||
#![crate_type = "lib"] | ||
|
||
pub mod recursive; |
8 changes: 8 additions & 0 deletions
8
...r-module-with-doc-comment-issue-97589/circular-module-with-doc-comment-issue-97589.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
error: circular modules: $DIR/recursive.rs -> $DIR/recursive.rs | ||
--> $DIR/recursive.rs:6:1 | ||
| | ||
LL | mod recursive; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 1 previous error | ||
|
6 changes: 6 additions & 0 deletions
6
tests/ui/parser/issues/circular-module-with-doc-comment-issue-97589/recursive.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
//@ ignore-test: this is an auxiliary file for circular-module-with-doc-comment-issue-97589.rs | ||
|
||
//! this comment caused the circular dependency checker to break | ||
#[path = "recursive.rs"] | ||
mod recursive; |