-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rustfmt): load nested out-of-line mods correctly
- Loading branch information
1 parent
a6bc43e
commit d2f2237
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; | ||
} |