Merge #3575
3575: Restore cargo-fmt gating r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
02b44006b8
@ -227,11 +227,9 @@ pub fn scope(
|
||||
Some((name, def))
|
||||
}
|
||||
})
|
||||
.flat_map(|(name, def)|
|
||||
ScopeDef::all_items(def)
|
||||
.into_iter()
|
||||
.map(move |item| (name.clone(), item))
|
||||
)
|
||||
.flat_map(|(name, def)| {
|
||||
ScopeDef::all_items(def).into_iter().map(move |item| (name.clone(), item))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
@ -1298,10 +1296,8 @@ impl ScopeDef {
|
||||
let mut items = ArrayVec::new();
|
||||
|
||||
match (def.take_types(), def.take_values()) {
|
||||
(Some(m1), None) =>
|
||||
items.push(ScopeDef::ModuleDef(m1.into())),
|
||||
(None, Some(m2)) =>
|
||||
items.push(ScopeDef::ModuleDef(m2.into())),
|
||||
(Some(m1), None) => items.push(ScopeDef::ModuleDef(m1.into())),
|
||||
(None, Some(m2)) => items.push(ScopeDef::ModuleDef(m2.into())),
|
||||
(Some(m1), Some(m2)) => {
|
||||
// Some items, like unit structs and enum variants, are
|
||||
// returned as both a type and a value. Here we want
|
||||
@ -1312,8 +1308,8 @@ impl ScopeDef {
|
||||
} else {
|
||||
items.push(ScopeDef::ModuleDef(m1.into()));
|
||||
}
|
||||
},
|
||||
(None, None) => {},
|
||||
}
|
||||
(None, None) => {}
|
||||
};
|
||||
|
||||
if let Some(macro_def_id) = def.take_macros() {
|
||||
|
@ -349,8 +349,8 @@ pub fn process_all_names(&self, f: &mut dyn FnMut(Name, ScopeDef)) {
|
||||
for item in items {
|
||||
f(name.clone(), item);
|
||||
}
|
||||
return
|
||||
},
|
||||
return;
|
||||
}
|
||||
resolver::ScopeDef::ImplSelfType(it) => ScopeDef::ImplSelfType(it.into()),
|
||||
resolver::ScopeDef::AdtSelfType(it) => ScopeDef::AdtSelfType(it.into()),
|
||||
resolver::ScopeDef::GenericParam(id) => ScopeDef::GenericParam(TypeParam { id }),
|
||||
|
@ -1005,5 +1005,4 @@ pub fn z() {}
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -82,26 +82,8 @@ fn list_(p: &mut Parser, flavor: Flavor) {
|
||||
fn value_parameter(p: &mut Parser, flavor: Flavor) {
|
||||
let m = p.start();
|
||||
match flavor {
|
||||
// test trait_fn_placeholder_parameter
|
||||
// trait Foo {
|
||||
// fn bar(_: u64, mut x: i32);
|
||||
// }
|
||||
|
||||
// test trait_fn_patterns
|
||||
// trait T {
|
||||
// fn f1((a, b): (usize, usize)) {}
|
||||
// fn f2(S { a, b }: S) {}
|
||||
// fn f3(NewType(a): NewType) {}
|
||||
// fn f4(&&a: &&usize) {}
|
||||
// }
|
||||
|
||||
// test fn_patterns
|
||||
// impl U {
|
||||
// fn f1((a, b): (usize, usize)) {}
|
||||
// fn f2(S { a, b }: S) {}
|
||||
// fn f3(NewType(a): NewType) {}
|
||||
// fn f4(&&a: &&usize) {}
|
||||
// }
|
||||
// test fn_def_param
|
||||
// fn foo((x, y): (i32, i32)) {}
|
||||
Flavor::FnDef => {
|
||||
patterns::pattern(p);
|
||||
types::ascription(p);
|
||||
|
@ -1,3 +0,0 @@
|
||||
trait Foo {
|
||||
fn bar(_: u64, mut x: i32);
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
SOURCE_FILE@[0; 46)
|
||||
TRAIT_DEF@[0; 45)
|
||||
TRAIT_KW@[0; 5) "trait"
|
||||
WHITESPACE@[5; 6) " "
|
||||
NAME@[6; 9)
|
||||
IDENT@[6; 9) "Foo"
|
||||
WHITESPACE@[9; 10) " "
|
||||
ITEM_LIST@[10; 45)
|
||||
L_CURLY@[10; 11) "{"
|
||||
WHITESPACE@[11; 16) "\n "
|
||||
FN_DEF@[16; 43)
|
||||
FN_KW@[16; 18) "fn"
|
||||
WHITESPACE@[18; 19) " "
|
||||
NAME@[19; 22)
|
||||
IDENT@[19; 22) "bar"
|
||||
PARAM_LIST@[22; 42)
|
||||
L_PAREN@[22; 23) "("
|
||||
PARAM@[23; 29)
|
||||
PLACEHOLDER_PAT@[23; 24)
|
||||
UNDERSCORE@[23; 24) "_"
|
||||
COLON@[24; 25) ":"
|
||||
WHITESPACE@[25; 26) " "
|
||||
PATH_TYPE@[26; 29)
|
||||
PATH@[26; 29)
|
||||
PATH_SEGMENT@[26; 29)
|
||||
NAME_REF@[26; 29)
|
||||
IDENT@[26; 29) "u64"
|
||||
COMMA@[29; 30) ","
|
||||
WHITESPACE@[30; 31) " "
|
||||
PARAM@[31; 41)
|
||||
BIND_PAT@[31; 36)
|
||||
MUT_KW@[31; 34) "mut"
|
||||
WHITESPACE@[34; 35) " "
|
||||
NAME@[35; 36)
|
||||
IDENT@[35; 36) "x"
|
||||
COLON@[36; 37) ":"
|
||||
WHITESPACE@[37; 38) " "
|
||||
PATH_TYPE@[38; 41)
|
||||
PATH@[38; 41)
|
||||
PATH_SEGMENT@[38; 41)
|
||||
NAME_REF@[38; 41)
|
||||
IDENT@[38; 41) "i32"
|
||||
R_PAREN@[41; 42) ")"
|
||||
SEMI@[42; 43) ";"
|
||||
WHITESPACE@[43; 44) "\n"
|
||||
R_CURLY@[44; 45) "}"
|
||||
WHITESPACE@[45; 46) "\n"
|
@ -0,0 +1 @@
|
||||
fn foo((x, y): (i32, i32)) {}
|
@ -0,0 +1,44 @@
|
||||
SOURCE_FILE@[0; 30)
|
||||
FN_DEF@[0; 29)
|
||||
FN_KW@[0; 2) "fn"
|
||||
WHITESPACE@[2; 3) " "
|
||||
NAME@[3; 6)
|
||||
IDENT@[3; 6) "foo"
|
||||
PARAM_LIST@[6; 26)
|
||||
L_PAREN@[6; 7) "("
|
||||
PARAM@[7; 25)
|
||||
TUPLE_PAT@[7; 13)
|
||||
L_PAREN@[7; 8) "("
|
||||
BIND_PAT@[8; 9)
|
||||
NAME@[8; 9)
|
||||
IDENT@[8; 9) "x"
|
||||
COMMA@[9; 10) ","
|
||||
WHITESPACE@[10; 11) " "
|
||||
BIND_PAT@[11; 12)
|
||||
NAME@[11; 12)
|
||||
IDENT@[11; 12) "y"
|
||||
R_PAREN@[12; 13) ")"
|
||||
COLON@[13; 14) ":"
|
||||
WHITESPACE@[14; 15) " "
|
||||
TUPLE_TYPE@[15; 25)
|
||||
L_PAREN@[15; 16) "("
|
||||
PATH_TYPE@[16; 19)
|
||||
PATH@[16; 19)
|
||||
PATH_SEGMENT@[16; 19)
|
||||
NAME_REF@[16; 19)
|
||||
IDENT@[16; 19) "i32"
|
||||
COMMA@[19; 20) ","
|
||||
WHITESPACE@[20; 21) " "
|
||||
PATH_TYPE@[21; 24)
|
||||
PATH@[21; 24)
|
||||
PATH_SEGMENT@[21; 24)
|
||||
NAME_REF@[21; 24)
|
||||
IDENT@[21; 24) "i32"
|
||||
R_PAREN@[24; 25) ")"
|
||||
R_PAREN@[25; 26) ")"
|
||||
WHITESPACE@[26; 27) " "
|
||||
BLOCK_EXPR@[27; 29)
|
||||
BLOCK@[27; 29)
|
||||
L_CURLY@[27; 28) "{"
|
||||
R_CURLY@[28; 29) "}"
|
||||
WHITESPACE@[29; 30) "\n"
|
@ -3,4 +3,5 @@ fn f1((a, b): (usize, usize)) {}
|
||||
fn f2(S { a, b }: S) {}
|
||||
fn f3(NewType(a): NewType) {}
|
||||
fn f4(&&a: &&usize) {}
|
||||
fn bar(_: u64, mut x: i32);
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
SOURCE_FILE@[0; 138)
|
||||
TRAIT_DEF@[0; 137)
|
||||
SOURCE_FILE@[0; 170)
|
||||
TRAIT_DEF@[0; 169)
|
||||
TRAIT_KW@[0; 5) "trait"
|
||||
WHITESPACE@[5; 6) " "
|
||||
NAME@[6; 7)
|
||||
IDENT@[6; 7) "T"
|
||||
WHITESPACE@[7; 8) " "
|
||||
ITEM_LIST@[8; 137)
|
||||
ITEM_LIST@[8; 169)
|
||||
L_CURLY@[8; 9) "{"
|
||||
WHITESPACE@[9; 14) "\n "
|
||||
FN_DEF@[14; 46)
|
||||
@ -156,6 +156,41 @@ SOURCE_FILE@[0; 138)
|
||||
BLOCK@[133; 135)
|
||||
L_CURLY@[133; 134) "{"
|
||||
R_CURLY@[134; 135) "}"
|
||||
WHITESPACE@[135; 136) "\n"
|
||||
R_CURLY@[136; 137) "}"
|
||||
WHITESPACE@[137; 138) "\n"
|
||||
WHITESPACE@[135; 140) "\n "
|
||||
FN_DEF@[140; 167)
|
||||
FN_KW@[140; 142) "fn"
|
||||
WHITESPACE@[142; 143) " "
|
||||
NAME@[143; 146)
|
||||
IDENT@[143; 146) "bar"
|
||||
PARAM_LIST@[146; 166)
|
||||
L_PAREN@[146; 147) "("
|
||||
PARAM@[147; 153)
|
||||
PLACEHOLDER_PAT@[147; 148)
|
||||
UNDERSCORE@[147; 148) "_"
|
||||
COLON@[148; 149) ":"
|
||||
WHITESPACE@[149; 150) " "
|
||||
PATH_TYPE@[150; 153)
|
||||
PATH@[150; 153)
|
||||
PATH_SEGMENT@[150; 153)
|
||||
NAME_REF@[150; 153)
|
||||
IDENT@[150; 153) "u64"
|
||||
COMMA@[153; 154) ","
|
||||
WHITESPACE@[154; 155) " "
|
||||
PARAM@[155; 165)
|
||||
BIND_PAT@[155; 160)
|
||||
MUT_KW@[155; 158) "mut"
|
||||
WHITESPACE@[158; 159) " "
|
||||
NAME@[159; 160)
|
||||
IDENT@[159; 160) "x"
|
||||
COLON@[160; 161) ":"
|
||||
WHITESPACE@[161; 162) " "
|
||||
PATH_TYPE@[162; 165)
|
||||
PATH@[162; 165)
|
||||
PATH_SEGMENT@[162; 165)
|
||||
NAME_REF@[162; 165)
|
||||
IDENT@[162; 165) "i32"
|
||||
R_PAREN@[165; 166) ")"
|
||||
SEMI@[166; 167) ";"
|
||||
WHITESPACE@[167; 168) "\n"
|
||||
R_CURLY@[168; 169) "}"
|
||||
WHITESPACE@[169; 170) "\n"
|
@ -397,6 +397,8 @@ pub fn skip_slow_tests() -> bool {
|
||||
should_skip
|
||||
}
|
||||
|
||||
const REWRITE: bool = false;
|
||||
|
||||
/// Asserts that `expected` and `actual` strings are equal. If they differ only
|
||||
/// in trailing or leading whitespace the test won't fail and
|
||||
/// the contents of `actual` will be written to the file located at `path`.
|
||||
@ -412,7 +414,6 @@ fn assert_equal_text(expected: &str, actual: &str, path: &Path) {
|
||||
fs::write(path, actual).unwrap();
|
||||
return;
|
||||
}
|
||||
const REWRITE: bool = false;
|
||||
if REWRITE {
|
||||
println!("rewriting {}", pretty_path.display());
|
||||
fs::write(path, actual).unwrap();
|
||||
|
@ -38,13 +38,11 @@ pub fn project_root() -> PathBuf {
|
||||
}
|
||||
|
||||
pub fn run_rustfmt(mode: Mode) -> Result<()> {
|
||||
let _dir = pushd(project_root());
|
||||
ensure_rustfmt()?;
|
||||
|
||||
if mode == Mode::Verify {
|
||||
run!("rustup run {} -- cargo fmt -- --check", TOOLCHAIN)?;
|
||||
} else {
|
||||
run!("rustup run {} -- cargo fmt", TOOLCHAIN)?;
|
||||
}
|
||||
let check = if mode == Mode::Verify { "--check" } else { "" };
|
||||
run!("rustup run {} -- cargo fmt -- {}", TOOLCHAIN, check)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user