forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#86424 - calebcartwright:rustfmt-mod-resolut…
…ion, r=Mark-Simulacrum rustfmt: load nested out-of-line mods correctly This should address rust-lang/rustfmt#4874 r? `@Mark-Simulacrum` Decided to make the change directly in tree here for expediency/to minimize any potential backporting issues, and because there's some subtree sync items I need to get resolved before pulling from r-l/rustfmt
- Loading branch information
Showing
7 changed files
with
46 additions
and
1 deletion.
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
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,25 @@ | ||
use std::io; | ||
use std::path::PathBuf; | ||
|
||
use super::read_config; | ||
|
||
use crate::{FileName, Input, Session}; | ||
|
||
#[test] | ||
fn nested_out_of_line_mods_loaded() { | ||
// See also https://github.com/rust-lang/rustfmt/issues/4874 | ||
let filename = "tests/mod-resolver/issue-4874/main.rs"; | ||
let input_file = PathBuf::from(filename); | ||
let config = read_config(&input_file); | ||
let mut session = Session::<io::Stdout>::new(config, None); | ||
let report = session | ||
.format(Input::File(filename.into())) | ||
.expect("Should not have had any execution errors"); | ||
let errors_by_file = &report.internal.borrow().0; | ||
assert!(errors_by_file.contains_key(&FileName::Real(PathBuf::from( | ||
"tests/mod-resolver/issue-4874/bar/baz.rs", | ||
)))); | ||
assert!(errors_by_file.contains_key(&FileName::Real(PathBuf::from( | ||
"tests/mod-resolver/issue-4874/foo/qux.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,5 @@ | ||
fn | ||
fail_fmt_check | ||
( | ||
|
||
) {} |
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 @@ | ||
mod qux; |
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,5 @@ | ||
fn | ||
badly_formatted | ||
( | ||
|
||
) {} |
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 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} | ||
|
||
mod foo; | ||
mod bar { | ||
mod baz; | ||
} |