From b516a8c5cbcde670e509182592547072a723875a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 1 Dec 2021 11:45:14 -0800 Subject: [PATCH 1/6] Pretty print empty blocks as {} --- compiler/rustc_ast_pretty/src/pprust/state.rs | 68 ++++++++++++------- compiler/rustc_hir_pretty/src/lib.rs | 4 +- src/test/pretty/ast-stmt-expr-attr.rs | 8 +-- src/test/pretty/attr-derive.rs | 2 +- src/test/pretty/auto-trait.rs | 6 +- .../block-comment-trailing-whitespace2.rs | 9 ++- src/test/pretty/closure-reform-pretty.rs | 12 ++-- src/test/pretty/disamb-stmt-expr.rs | 2 +- src/test/pretty/enum-variant-vis.rs | 2 +- src/test/pretty/example1.rs | 2 +- src/test/pretty/example2.pp | 2 +- src/test/pretty/example2.rs | 2 +- .../pretty/expanded-and-path-remap-80832.pp | 2 +- src/test/pretty/fn-return.rs | 6 +- src/test/pretty/fn-types.rs | 6 +- src/test/pretty/fn-variadic.rs | 2 +- src/test/pretty/if-attr.rs | 18 ++--- src/test/pretty/issue-12590-a.rs | 2 +- src/test/pretty/issue-12590-c.pp | 6 +- src/test/pretty/issue-12590-c.rs | 2 +- src/test/pretty/issue-19077.rs | 4 +- src/test/pretty/issue-30731.rs | 2 +- .../issue-68710-field-attr-proc-mac-lost.rs | 2 +- src/test/pretty/lifetime.rs | 4 +- src/test/pretty/macro.rs | 2 +- src/test/pretty/macro_rules.rs | 12 ++-- .../pretty/nested-item-vis-defaultness.rs | 2 +- src/test/pretty/path-type-bounds.rs | 4 +- .../pretty/qpath-associated-type-bound.rs | 4 +- src/test/pretty/stmt_expr_attributes.rs | 18 ++--- src/test/pretty/tag-blank-lines.rs | 2 +- src/test/pretty/trait-inner-attr.rs | 2 +- src/test/pretty/trait-polarity.rs | 4 +- src/test/pretty/trait-safety.rs | 4 +- src/test/pretty/where-clauses.rs | 2 +- .../ui/async-await/issues/issue-60674.stdout | 6 +- src/test/ui/attributes/issue-90873.stderr | 2 +- .../defaults/pretty-printing-ast.stdout | 4 +- src/test/ui/hygiene/unpretty-debug.stdout | 2 +- src/test/ui/lint/issue-87308.stdout | 2 +- src/test/ui/macros/nonterminal-matching.rs | 2 +- .../ui/macros/nonterminal-matching.stderr | 2 +- .../proc-macro/allowed-attr-stmt-expr.stdout | 8 +-- src/test/ui/proc-macro/attr-complex-fn.stdout | 2 +- src/test/ui/proc-macro/attr-stmt-expr.stdout | 8 +-- .../proc-macro/attribute-after-derive.stdout | 4 +- src/test/ui/proc-macro/auxiliary/attr-args.rs | 2 +- .../ui/proc-macro/auxiliary/attr-on-trait.rs | 2 +- src/test/ui/proc-macro/cfg-eval-inner.stdout | 2 +- .../ui/proc-macro/derive-expand-order.stdout | 10 +-- .../expr-stmt-nonterminal-tokens.stdout | 2 +- src/test/ui/proc-macro/inner-attrs.stdout | 6 +- .../ui/proc-macro/input-interpolated.stdout | 2 +- .../ui/proc-macro/issue-75734-pp-paren.stdout | 2 +- .../proc-macro/issue-75930-derive-cfg.stdout | 6 +- .../proc-macro/issue-81007-item-attrs.stdout | 4 +- .../ui/proc-macro/nested-macro-rules.stdout | 4 +- .../nonterminal-token-hygiene.stdout | 2 +- src/test/ui/proc-macro/trailing-plus.stdout | 2 +- src/test/ui/proc-macro/weird-braces.stdout | 2 +- .../ui/repr/issue-83921-pretty.pretty.stdout | 5 +- .../ast-pretty-check.stdout | 2 +- .../auxiliary/param-attrs.rs | 18 ++--- 63 files changed, 182 insertions(+), 164 deletions(-) diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs index f1f2387866d0d..63e41bb8dcf6b 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state.rs @@ -263,14 +263,17 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere self.strsep(",", false, b, elts, op) } - fn maybe_print_comment(&mut self, pos: BytePos) { + fn maybe_print_comment(&mut self, pos: BytePos) -> bool { + let mut has_comment = false; while let Some(ref cmnt) = self.next_comment() { if cmnt.pos < pos { + has_comment = true; self.print_comment(cmnt); } else { break; } } + has_comment } fn print_comment(&mut self, cmnt: &Comment) { @@ -570,7 +573,10 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere self.print_tts(tts, convert_dollar_crate); self.end(); match delim { - DelimToken::Brace => self.bclose(span), + DelimToken::Brace => { + let empty = tts.is_empty(); + self.bclose(span, empty); + } _ => { let token_str = self.token_kind_to_string(&token::CloseDelim(delim)); self.word(token_str) @@ -642,17 +648,20 @@ pub trait PrintState<'a>: std::ops::Deref + std::ops::Dere self.end(); // Close the head-box. } - fn bclose_maybe_open(&mut self, span: rustc_span::Span, close_box: bool) { - self.maybe_print_comment(span.hi()); - self.break_offset_if_not_bol(1, -(INDENT_UNIT as isize)); + fn bclose_maybe_open(&mut self, span: rustc_span::Span, empty: bool, close_box: bool) { + let has_comment = self.maybe_print_comment(span.hi()); + if !empty || has_comment { + self.break_offset_if_not_bol(1, -(INDENT_UNIT as isize)); + } self.word("}"); if close_box { self.end(); // Close the outer-box. } } - fn bclose(&mut self, span: rustc_span::Span) { - self.bclose_maybe_open(span, true) + fn bclose(&mut self, span: rustc_span::Span, empty: bool) { + let close_box = true; + self.bclose_maybe_open(span, empty, close_box) } fn break_offset_if_not_bol(&mut self, n: usize, off: isize) { @@ -1196,7 +1205,8 @@ impl<'a> State<'a> { for item in items { self.print_item(item); } - self.bclose(item.span); + let empty = item.attrs.is_empty() && items.is_empty(); + self.bclose(item.span, empty); } ModKind::Unloaded => { self.s.word(";"); @@ -1216,7 +1226,8 @@ impl<'a> State<'a> { } self.bopen(); self.print_foreign_mod(nmod, &item.attrs); - self.bclose(item.span); + let empty = item.attrs.is_empty() && nmod.items.is_empty(); + self.bclose(item.span, empty); } ast::ItemKind::GlobalAsm(ref asm) => { self.head(visibility_qualified(&item.vis, "global_asm!")); @@ -1291,7 +1302,8 @@ impl<'a> State<'a> { for impl_item in items { self.print_assoc_item(impl_item); } - self.bclose(item.span); + let empty = item.attrs.is_empty() && items.is_empty(); + self.bclose(item.span, empty); } ast::ItemKind::Trait(box ast::Trait { is_auto, @@ -1326,7 +1338,8 @@ impl<'a> State<'a> { for trait_item in items { self.print_assoc_item(trait_item); } - self.bclose(item.span); + let empty = item.attrs.is_empty() && items.is_empty(); + self.bclose(item.span, empty); } ast::ItemKind::TraitAlias(ref generics, ref bounds) => { self.head(""); @@ -1410,7 +1423,8 @@ impl<'a> State<'a> { self.end(); self.maybe_print_trailing_comment(v.span, None); } - self.bclose(span) + let empty = variants.is_empty(); + self.bclose(span, empty) } crate fn print_visibility(&mut self, vis: &ast::Visibility) { @@ -1441,20 +1455,24 @@ impl<'a> State<'a> { crate fn print_record_struct_body(&mut self, fields: &[ast::FieldDef], span: rustc_span::Span) { self.nbsp(); self.bopen(); - self.hardbreak_if_not_bol(); - for field in fields { + let empty = fields.is_empty(); + if !empty { self.hardbreak_if_not_bol(); - self.maybe_print_comment(field.span.lo()); - self.print_outer_attributes(&field.attrs); - self.print_visibility(&field.vis); - self.print_ident(field.ident.unwrap()); - self.word_nbsp(":"); - self.print_type(&field.ty); - self.s.word(","); + + for field in fields { + self.hardbreak_if_not_bol(); + self.maybe_print_comment(field.span.lo()); + self.print_outer_attributes(&field.attrs); + self.print_visibility(&field.vis); + self.print_ident(field.ident.unwrap()); + self.word_nbsp(":"); + self.print_type(&field.ty); + self.s.word(","); + } } - self.bclose(span) + self.bclose(span, empty); } crate fn print_struct( @@ -1633,7 +1651,8 @@ impl<'a> State<'a> { } } - self.bclose_maybe_open(blk.span, close_box); + let empty = attrs.is_empty() && blk.stmts.is_empty(); + self.bclose_maybe_open(blk.span, empty, close_box); self.ann.post(self, AnnNode::Block(blk)) } @@ -2010,7 +2029,8 @@ impl<'a> State<'a> { for arm in arms { self.print_arm(arm); } - self.bclose(expr.span); + let empty = attrs.is_empty() && arms.is_empty(); + self.bclose(expr.span, empty); } ast::ExprKind::Closure( capture_clause, diff --git a/compiler/rustc_hir_pretty/src/lib.rs b/compiler/rustc_hir_pretty/src/lib.rs index 9c2927111a66c..1cb2737a5ad89 100644 --- a/compiler/rustc_hir_pretty/src/lib.rs +++ b/compiler/rustc_hir_pretty/src/lib.rs @@ -2171,7 +2171,7 @@ impl<'a> State<'a> { match decl.output { hir::FnRetTy::Return(ref ty) => { self.print_type(&ty); - self.maybe_print_comment(ty.span.lo()) + self.maybe_print_comment(ty.span.lo()); } hir::FnRetTy::DefaultReturn(..) => unreachable!(), } @@ -2365,7 +2365,7 @@ impl<'a> State<'a> { self.end(); if let hir::FnRetTy::Return(ref output) = decl.output { - self.maybe_print_comment(output.span.lo()) + self.maybe_print_comment(output.span.lo()); } } diff --git a/src/test/pretty/ast-stmt-expr-attr.rs b/src/test/pretty/ast-stmt-expr-attr.rs index 32d1da390c547..c80bce2d140b9 100644 --- a/src/test/pretty/ast-stmt-expr-attr.rs +++ b/src/test/pretty/ast-stmt-expr-attr.rs @@ -1,6 +1,6 @@ // pp-exact -fn main() { } +fn main() {} #[cfg(FALSE)] fn syntax() { @@ -117,7 +117,7 @@ fn syntax() { let _ = #[attr] foo!(#! [attr]); let _ = #[attr] foo![]; let _ = #[attr] foo![#! [attr]]; - let _ = #[attr] foo! { }; + let _ = #[attr] foo! {}; let _ = #[attr] foo! { #! [attr] }; let _ = #[attr] Foo{bar: baz,}; let _ = #[attr] Foo{..foo}; @@ -135,7 +135,7 @@ fn syntax() { foo!(); #[attr] - foo! { } + foo! {} #[attr] foo![]; @@ -170,6 +170,6 @@ fn syntax() { { #[attr] - foo! { } + foo! {} } } diff --git a/src/test/pretty/attr-derive.rs b/src/test/pretty/attr-derive.rs index 4ce6d2fbf17b9..0eb403c6bc843 100644 --- a/src/test/pretty/attr-derive.rs +++ b/src/test/pretty/attr-derive.rs @@ -29,4 +29,4 @@ enum Enum { Qwerty, } -fn main() { } +fn main() {} diff --git a/src/test/pretty/auto-trait.rs b/src/test/pretty/auto-trait.rs index 61644e7df09ae..c3c47cff5eda9 100644 --- a/src/test/pretty/auto-trait.rs +++ b/src/test/pretty/auto-trait.rs @@ -2,8 +2,8 @@ // pp-exact -auto trait MyTrait { } +auto trait MyTrait {} -unsafe auto trait UnsafeMyTrait { } +unsafe auto trait UnsafeMyTrait {} -pub fn main() { } +pub fn main() {} diff --git a/src/test/pretty/block-comment-trailing-whitespace2.rs b/src/test/pretty/block-comment-trailing-whitespace2.rs index b7c42e39557c9..e53d51e34cefa 100644 --- a/src/test/pretty/block-comment-trailing-whitespace2.rs +++ b/src/test/pretty/block-comment-trailing-whitespace2.rs @@ -1,9 +1,8 @@ // compile-flags: --crate-type=lib // pp-exact -fn f() { -} /* - The next line should not be indented. +fn f() {} /* + The next line should not be indented. - That one. It shouldn't have been indented. - */ + That one. It shouldn't have been indented. + */ diff --git a/src/test/pretty/closure-reform-pretty.rs b/src/test/pretty/closure-reform-pretty.rs index ef5189fa13ee1..1eba1e6bdec3f 100644 --- a/src/test/pretty/closure-reform-pretty.rs +++ b/src/test/pretty/closure-reform-pretty.rs @@ -3,14 +3,14 @@ // pp-exact -fn call_it(f: Box String>) { } +fn call_it(f: Box String>) {} -fn call_this(f: F) where F: Fn(&str) + Send { } +fn call_this(f: F) where F: Fn(&str) + Send {} -fn call_that(f: F) where F: for<'a> Fn(&'a isize, &'a isize) -> isize { } +fn call_that(f: F) where F: for<'a> Fn(&'a isize, &'a isize) -> isize {} -fn call_extern(f: fn() -> isize) { } +fn call_extern(f: fn() -> isize) {} -fn call_abid_extern(f: extern "C" fn() -> isize) { } +fn call_abid_extern(f: extern "C" fn() -> isize) {} -pub fn main() { } +pub fn main() {} diff --git a/src/test/pretty/disamb-stmt-expr.rs b/src/test/pretty/disamb-stmt-expr.rs index 601ca7bb6de1c..734f9fa123eea 100644 --- a/src/test/pretty/disamb-stmt-expr.rs +++ b/src/test/pretty/disamb-stmt-expr.rs @@ -7,4 +7,4 @@ fn id(f: F) -> isize where F: Fn() -> isize { f() } fn wsucc(_n: isize) -> isize { id(|| { 1 }) - 0 } -fn main() { } +fn main() {} diff --git a/src/test/pretty/enum-variant-vis.rs b/src/test/pretty/enum-variant-vis.rs index a3e8178aeb3de..fc646c2956c4f 100644 --- a/src/test/pretty/enum-variant-vis.rs +++ b/src/test/pretty/enum-variant-vis.rs @@ -2,7 +2,7 @@ // Check that the visibility is printed on an enum variant. -fn main() { } +fn main() {} #[cfg(FALSE)] enum Foo { pub V, } diff --git a/src/test/pretty/example1.rs b/src/test/pretty/example1.rs index 4f7d5e7e71e17..8df74e8e1f9c8 100644 --- a/src/test/pretty/example1.rs +++ b/src/test/pretty/example1.rs @@ -1,3 +1,3 @@ // pp-exact -fn main() { } +fn main() {} diff --git a/src/test/pretty/example2.pp b/src/test/pretty/example2.pp index 852b9f316ce0f..3f7129afde26d 100644 --- a/src/test/pretty/example2.pp +++ b/src/test/pretty/example2.pp @@ -1,3 +1,3 @@ // pp-exact:example2.pp -fn main() { } +fn main() {} diff --git a/src/test/pretty/example2.rs b/src/test/pretty/example2.rs index 852b9f316ce0f..3f7129afde26d 100644 --- a/src/test/pretty/example2.rs +++ b/src/test/pretty/example2.rs @@ -1,3 +1,3 @@ // pp-exact:example2.pp -fn main() { } +fn main() {} diff --git a/src/test/pretty/expanded-and-path-remap-80832.pp b/src/test/pretty/expanded-and-path-remap-80832.pp index 1579ea41cfdf1..8385c5fa8c91a 100644 --- a/src/test/pretty/expanded-and-path-remap-80832.pp +++ b/src/test/pretty/expanded-and-path-remap-80832.pp @@ -10,4 +10,4 @@ // pp-exact:expanded-and-path-remap-80832.pp // compile-flags: --remap-path-prefix {{src-base}}=the/src -fn main() { } +fn main() {} diff --git a/src/test/pretty/fn-return.rs b/src/test/pretty/fn-return.rs index 142d852cd6a13..b932e83aaf10f 100644 --- a/src/test/pretty/fn-return.rs +++ b/src/test/pretty/fn-return.rs @@ -1,7 +1,7 @@ // pp-exact -// Check that `fn f() -> () { }` does not print as `fn f() { }`. +// Check that `fn f() -> () {}` does not print as `fn f() {}`. -fn f() -> () { } +fn f() -> () {} -fn main() { } +fn main() {} diff --git a/src/test/pretty/fn-types.rs b/src/test/pretty/fn-types.rs index 842138e28c353..f012763c3f606 100644 --- a/src/test/pretty/fn-types.rs +++ b/src/test/pretty/fn-types.rs @@ -1,5 +1,5 @@ // pp-exact -fn from_foreign_fn(_x: fn()) { } -fn from_stack_closure(_x: F) where F: Fn() { } -fn main() { } +fn from_foreign_fn(_x: fn()) {} +fn from_stack_closure(_x: F) where F: Fn() {} +fn main() {} diff --git a/src/test/pretty/fn-variadic.rs b/src/test/pretty/fn-variadic.rs index d499be424603b..59e477cfa8ecb 100644 --- a/src/test/pretty/fn-variadic.rs +++ b/src/test/pretty/fn-variadic.rs @@ -12,4 +12,4 @@ pub unsafe extern "C" fn bar(_: i32, mut ap: ...) -> usize { ap.arg::() } -fn main() { } +fn main() {} diff --git a/src/test/pretty/if-attr.rs b/src/test/pretty/if-attr.rs index 652604fc7f34b..7b90b0becacba 100644 --- a/src/test/pretty/if-attr.rs +++ b/src/test/pretty/if-attr.rs @@ -4,34 +4,34 @@ fn simple_attr() { #[attr] - if true { } + if true {} #[allow_warnings] - if true { } + if true {} } #[cfg(FALSE)] fn if_else_chain() { #[first_attr] - if true { } else if false { } else { } + if true {} else if false {} else {} } #[cfg(FALSE)] fn if_let() { #[attr] - if let Some(_) = Some(true) { } + if let Some(_) = Some(true) {} } #[cfg(FALSE)] fn let_attr_if() { - let _ = #[attr] if let _ = 0 { }; - let _ = #[attr] if true { }; + let _ = #[attr] if let _ = 0 {}; + let _ = #[attr] if true {}; - let _ = #[attr] if let _ = 0 { } else { }; - let _ = #[attr] if true { } else { }; + let _ = #[attr] if let _ = 0 {} else {}; + let _ = #[attr] if true {} else {}; } -fn main() { } +fn main() {} diff --git a/src/test/pretty/issue-12590-a.rs b/src/test/pretty/issue-12590-a.rs index ca1fef83cffc5..3c88f5cb8a41c 100644 --- a/src/test/pretty/issue-12590-a.rs +++ b/src/test/pretty/issue-12590-a.rs @@ -6,4 +6,4 @@ #[path = "issue-12590-b.rs"] mod issue_12590_b; -fn main() { } +fn main() {} diff --git a/src/test/pretty/issue-12590-c.pp b/src/test/pretty/issue-12590-c.pp index dd0b8899b2d9d..07b3f5653d36b 100644 --- a/src/test/pretty/issue-12590-c.pp +++ b/src/test/pretty/issue-12590-c.pp @@ -13,7 +13,7 @@ #[path = "issue-12590-b.rs"] mod issue_12590_b { - fn b() { } - fn main() { } + fn b() {} + fn main() {} } -fn main() { } +fn main() {} diff --git a/src/test/pretty/issue-12590-c.rs b/src/test/pretty/issue-12590-c.rs index 2cc444edda3d7..0ec05f9a8051b 100644 --- a/src/test/pretty/issue-12590-c.rs +++ b/src/test/pretty/issue-12590-c.rs @@ -7,4 +7,4 @@ #[path = "issue-12590-b.rs"] mod issue_12590_b; -fn main() { } +fn main() {} diff --git a/src/test/pretty/issue-19077.rs b/src/test/pretty/issue-19077.rs index b42791113056e..0d2702804d12d 100644 --- a/src/test/pretty/issue-19077.rs +++ b/src/test/pretty/issue-19077.rs @@ -4,8 +4,8 @@ fn main() { match true { true if true => (), - false if false => unsafe { }, - true => { } + false if false => unsafe {}, + true => {} false => (), } } diff --git a/src/test/pretty/issue-30731.rs b/src/test/pretty/issue-30731.rs index 02951395e70b4..607cbebee170c 100644 --- a/src/test/pretty/issue-30731.rs +++ b/src/test/pretty/issue-30731.rs @@ -5,4 +5,4 @@ // pretty-compare-only // pp-exact -fn main() { b! { } c } +fn main() { b! {} c } diff --git a/src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs b/src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs index 031a482595932..ed7879001d559 100644 --- a/src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs +++ b/src/test/pretty/issue-68710-field-attr-proc-mac-lost.rs @@ -1,6 +1,6 @@ // pp-exact -fn main() { } +fn main() {} struct C { field: u8, diff --git a/src/test/pretty/lifetime.rs b/src/test/pretty/lifetime.rs index bfef51202dbe1..34eae849be45e 100644 --- a/src/test/pretty/lifetime.rs +++ b/src/test/pretty/lifetime.rs @@ -1,5 +1,5 @@ // pp-exact -fn f1<'a, 'b, 'c>(_x: &'a u32, _y: &'b u32, _z: &'c u32) where 'c: 'a + 'b { } +fn f1<'a, 'b, 'c>(_x: &'a u32, _y: &'b u32, _z: &'c u32) where 'c: 'a + 'b {} -fn main() { } +fn main() {} diff --git a/src/test/pretty/macro.rs b/src/test/pretty/macro.rs index d3865d93a30d8..b88ae703950ba 100644 --- a/src/test/pretty/macro.rs +++ b/src/test/pretty/macro.rs @@ -4,4 +4,4 @@ pub(crate) macro mac { ($arg : expr) => { $arg + $arg } } -fn main() { } +fn main() {} diff --git a/src/test/pretty/macro_rules.rs b/src/test/pretty/macro_rules.rs index 3b13f2530dd92..fb66e4a775842 100644 --- a/src/test/pretty/macro_rules.rs +++ b/src/test/pretty/macro_rules.rs @@ -1,19 +1,19 @@ // pp-exact -macro_rules! brace { () => { } ; } +macro_rules! brace { () => {} ; } -macro_rules! bracket[() => { } ;]; +macro_rules! bracket[() => {} ;]; -macro_rules! paren(() => { } ;); +macro_rules! paren(() => {} ;); macro_rules! matcher_brackets { - (paren) => { } ; (bracket) => { } ; (brace) => { } ; + (paren) => {} ; (bracket) => {} ; (brace) => {} ; } macro_rules! all_fragments { ($b : block, $e : expr, $i : ident, $it : item, $l : lifetime, $lit : literal, $m : meta, $p : pat, $pth : path, $s : stmt, $tt : tt, $ty : ty, - $vis : vis) => { } ; + $vis : vis) => {} ; } -fn main() { } +fn main() {} diff --git a/src/test/pretty/nested-item-vis-defaultness.rs b/src/test/pretty/nested-item-vis-defaultness.rs index 0a3f2a10c8549..f46c0e3f1bc62 100644 --- a/src/test/pretty/nested-item-vis-defaultness.rs +++ b/src/test/pretty/nested-item-vis-defaultness.rs @@ -2,7 +2,7 @@ // pp-exact -fn main() { } +fn main() {} #[cfg(FALSE)] extern "C" { diff --git a/src/test/pretty/path-type-bounds.rs b/src/test/pretty/path-type-bounds.rs index 3072e416cbeef..f1970de6feb4b 100644 --- a/src/test/pretty/path-type-bounds.rs +++ b/src/test/pretty/path-type-bounds.rs @@ -2,9 +2,9 @@ trait Tr { - fn dummy(&self) { } + fn dummy(&self) {} } -impl Tr for isize { } +impl Tr for isize {} fn foo<'a>(x: Box) -> Box { x } diff --git a/src/test/pretty/qpath-associated-type-bound.rs b/src/test/pretty/qpath-associated-type-bound.rs index e06885e03882b..67a5d1dd8ec66 100644 --- a/src/test/pretty/qpath-associated-type-bound.rs +++ b/src/test/pretty/qpath-associated-type-bound.rs @@ -8,9 +8,9 @@ mod m { } trait Tu { - fn dummy() { } + fn dummy() {} } fn foo() { ::Ts::dummy(); } -fn main() { } +fn main() {} diff --git a/src/test/pretty/stmt_expr_attributes.rs b/src/test/pretty/stmt_expr_attributes.rs index e4a3acade871b..12204c8cd30ed 100644 --- a/src/test/pretty/stmt_expr_attributes.rs +++ b/src/test/pretty/stmt_expr_attributes.rs @@ -4,7 +4,7 @@ #![feature(rustc_attrs)] #![feature(stmt_expr_attributes)] -fn main() { } +fn main() {} fn _0() { @@ -35,7 +35,7 @@ fn _2() { fn _3() { #[rustc_dummy] - match () { _ => { } } + match () { _ => {} } } fn _4() { @@ -117,13 +117,13 @@ fn _9() { stmt_mac!(); #[rustc_dummy] - stmt_mac! { }; + stmt_mac! {}; #[rustc_dummy] stmt_mac![]; #[rustc_dummy] - stmt_mac! { } + stmt_mac! {} let _ = (); } @@ -133,7 +133,7 @@ macro_rules! expr_mac { () => { () } } fn _10() { let _ = #[rustc_dummy] expr_mac!(); let _ = #[rustc_dummy] expr_mac![]; - let _ = #[rustc_dummy] expr_mac! { }; + let _ = #[rustc_dummy] expr_mac! {}; } fn _11() { @@ -235,7 +235,7 @@ fn _11() { || #[rustc_dummy] return; let _ = #[rustc_dummy] expr_mac!(); let _ = #[rustc_dummy] expr_mac![]; - let _ = #[rustc_dummy] expr_mac! { }; + let _ = #[rustc_dummy] expr_mac! {}; let _ = #[rustc_dummy] Foo{data: (),}; let _ = #[rustc_dummy] Foo{..s}; let _ = #[rustc_dummy] Foo{data: (), ..s}; @@ -258,6 +258,6 @@ fn _12() { } } -fn foo() { } -fn foo3(_: i32, _: (), _: ()) { } -fn qux(_: i32) { } +fn foo() {} +fn foo3(_: i32, _: (), _: ()) {} +fn qux(_: i32) {} diff --git a/src/test/pretty/tag-blank-lines.rs b/src/test/pretty/tag-blank-lines.rs index 28ed4fccaf26b..d53f6e4b52850 100644 --- a/src/test/pretty/tag-blank-lines.rs +++ b/src/test/pretty/tag-blank-lines.rs @@ -5,4 +5,4 @@ enum foo { baz, } -fn main() { } +fn main() {} diff --git a/src/test/pretty/trait-inner-attr.rs b/src/test/pretty/trait-inner-attr.rs index bb4fb1459bd64..6cb0e4136b62c 100644 --- a/src/test/pretty/trait-inner-attr.rs +++ b/src/test/pretty/trait-inner-attr.rs @@ -4,4 +4,4 @@ trait Foo { #![allow(bar)] } -fn main() { } +fn main() {} diff --git a/src/test/pretty/trait-polarity.rs b/src/test/pretty/trait-polarity.rs index df1a7946afb11..310506eabca17 100644 --- a/src/test/pretty/trait-polarity.rs +++ b/src/test/pretty/trait-polarity.rs @@ -4,6 +4,6 @@ struct Test; -impl !Send for Test { } +impl !Send for Test {} -pub fn main() { } +pub fn main() {} diff --git a/src/test/pretty/trait-safety.rs b/src/test/pretty/trait-safety.rs index b2f2d610c3122..c4ae7606946ba 100644 --- a/src/test/pretty/trait-safety.rs +++ b/src/test/pretty/trait-safety.rs @@ -5,11 +5,11 @@ unsafe trait UnsafeTrait { } unsafe impl UnsafeTrait for isize { - fn foo(&self) { } + fn foo(&self) {} } pub unsafe trait PubUnsafeTrait { fn foo(&self); } -fn main() { } +fn main() {} diff --git a/src/test/pretty/where-clauses.rs b/src/test/pretty/where-clauses.rs index 3d6e431a11a9a..5614a81b0eb41 100644 --- a/src/test/pretty/where-clauses.rs +++ b/src/test/pretty/where-clauses.rs @@ -2,4 +2,4 @@ fn f<'a, 'b, T>(t: T) -> isize where T: 'a, 'a: 'b, T: Eq { 0 } -fn main() { } +fn main() {} diff --git a/src/test/ui/async-await/issues/issue-60674.stdout b/src/test/ui/async-await/issues/issue-60674.stdout index 395d9e21b3848..6f980e6066451 100644 --- a/src/test/ui/async-await/issues/issue-60674.stdout +++ b/src/test/ui/async-await/issues/issue-60674.stdout @@ -1,3 +1,3 @@ -async fn f(mut x : u8) { } -async fn g((mut x, y, mut z) : (u8, u8, u8)) { } -async fn g(mut x : u8, (a, mut b, c) : (u8, u8, u8), y : u8) { } +async fn f(mut x : u8) {} +async fn g((mut x, y, mut z) : (u8, u8, u8)) {} +async fn g(mut x : u8, (a, mut b, c) : (u8, u8, u8), y : u8) {} diff --git a/src/test/ui/attributes/issue-90873.stderr b/src/test/ui/attributes/issue-90873.stderr index d466157f04e0c..2718b65108cdd 100644 --- a/src/test/ui/attributes/issue-90873.stderr +++ b/src/test/ui/attributes/issue-90873.stderr @@ -8,7 +8,7 @@ LL | #![u=||{static d=||1;}] | ^^^^^^^^^^^^^^^^^ error: unexpected token: `{ - impl std::ops::Neg for i8 { } + impl std::ops::Neg for i8 {} }` --> $DIR/issue-90873.rs:7:6 | diff --git a/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout b/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout index 1bceb8cbb94dd..9f65b8f25baaf 100644 --- a/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout +++ b/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout @@ -11,9 +11,9 @@ use ::std::prelude::rust_2015::*; #[macro_use] extern crate std; -trait Foo { } +trait Foo {} -fn foo() { } +fn foo() {} struct Range; diff --git a/src/test/ui/hygiene/unpretty-debug.stdout b/src/test/ui/hygiene/unpretty-debug.stdout index ffb9f9eed41fb..51c21043db888 100644 --- a/src/test/ui/hygiene/unpretty-debug.stdout +++ b/src/test/ui/hygiene/unpretty-debug.stdout @@ -15,7 +15,7 @@ fn bar /* 0#0 */() { y /* 0#1 */ + x /* 0#0 */ } -fn y /* 0#0 */() { } +fn y /* 0#0 */() {} /* Expansions: diff --git a/src/test/ui/lint/issue-87308.stdout b/src/test/ui/lint/issue-87308.stdout index 68a076c93be61..4f81ee8b7e6bb 100644 --- a/src/test/ui/lint/issue-87308.stdout +++ b/src/test/ui/lint/issue-87308.stdout @@ -11,4 +11,4 @@ extern crate std; macro_rules! foo { () => { break 'x ; } } -pub fn main() { loop { } } +pub fn main() { loop {} } diff --git a/src/test/ui/macros/nonterminal-matching.rs b/src/test/ui/macros/nonterminal-matching.rs index 0ccdf6e5f2e74..84fffe44d6a55 100644 --- a/src/test/ui/macros/nonterminal-matching.rs +++ b/src/test/ui/macros/nonterminal-matching.rs @@ -16,7 +16,7 @@ macro complex_nonterminal($nt_item: item) { struct S; } - n!(a $nt_item b); //~ ERROR no rules expected the token `enum E { }` + n!(a $nt_item b); //~ ERROR no rules expected the token `enum E {}` } simple_nonterminal!(a, 'a, (x, y, z)); // OK diff --git a/src/test/ui/macros/nonterminal-matching.stderr b/src/test/ui/macros/nonterminal-matching.stderr index 155a94251312c..585f2355321f5 100644 --- a/src/test/ui/macros/nonterminal-matching.stderr +++ b/src/test/ui/macros/nonterminal-matching.stderr @@ -1,4 +1,4 @@ -error: no rules expected the token `enum E { }` +error: no rules expected the token `enum E {}` --> $DIR/nonterminal-matching.rs:19:10 | LL | macro n(a $nt_item b) { diff --git a/src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout b/src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout index eae169b162f4d..091862de30f7f 100644 --- a/src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout +++ b/src/test/ui/proc-macro/allowed-attr-stmt-expr.stdout @@ -14,7 +14,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/allowed-attr-stmt-expr.rs:49:20: 49:21 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Foo { } +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Foo {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', @@ -140,7 +140,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/allowed-attr-stmt-expr.rs:61:28: 61:29 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): second_make_stmt! (#[allow(dead_code)] struct Bar { }) ; +PRINT-ATTR INPUT (DISPLAY): second_make_stmt! (#[allow(dead_code)] struct Bar {}) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "second_make_stmt", @@ -201,7 +201,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/allowed-attr-stmt-expr.rs:64:57: 64:58 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] #[allow(dead_code)] struct Bar { } +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] #[allow(dead_code)] struct Bar {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', @@ -257,7 +257,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/allowed-attr-stmt-expr.rs:64:54: 64:56 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Other { } +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Other {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', diff --git a/src/test/ui/proc-macro/attr-complex-fn.stdout b/src/test/ui/proc-macro/attr-complex-fn.stdout index fbefa3923ee22..fc69a13ddb9b4 100644 --- a/src/test/ui/proc-macro/attr-complex-fn.stdout +++ b/src/test/ui/proc-macro/attr-complex-fn.stdout @@ -1,4 +1,4 @@ -PRINT-ATTR INPUT (DISPLAY): fn foo < T : MyTrait < MyStruct < { true } >> > () { } +PRINT-ATTR INPUT (DISPLAY): fn foo < T : MyTrait < MyStruct < { true } >> > () {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "fn", diff --git a/src/test/ui/proc-macro/attr-stmt-expr.stdout b/src/test/ui/proc-macro/attr-stmt-expr.stdout index edb9fbab342e2..f9b2305c7359b 100644 --- a/src/test/ui/proc-macro/attr-stmt-expr.stdout +++ b/src/test/ui/proc-macro/attr-stmt-expr.stdout @@ -1,4 +1,4 @@ -PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Foo { } +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Foo {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', @@ -124,7 +124,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/attr-stmt-expr.rs:53:28: 53:29 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): second_make_stmt! (#[allow(dead_code)] struct Bar { }) ; +PRINT-ATTR INPUT (DISPLAY): second_make_stmt! (#[allow(dead_code)] struct Bar {}) ; PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "second_make_stmt", @@ -185,7 +185,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/attr-stmt-expr.rs:56:57: 56:58 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] #[allow(dead_code)] struct Bar { } +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] #[allow(dead_code)] struct Bar {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', @@ -241,7 +241,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/attr-stmt-expr.rs:56:54: 56:56 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Other { } +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] struct Other {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', diff --git a/src/test/ui/proc-macro/attribute-after-derive.stdout b/src/test/ui/proc-macro/attribute-after-derive.stdout index c5b84b0367c8f..1b17d60476a84 100644 --- a/src/test/ui/proc-macro/attribute-after-derive.stdout +++ b/src/test/ui/proc-macro/attribute-after-derive.stdout @@ -83,7 +83,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/attribute-after-derive.rs:16:24: 19:2 (#0), }, ] -PRINT-DERIVE INPUT (DISPLAY): struct AttributeDerive { } +PRINT-DERIVE INPUT (DISPLAY): struct AttributeDerive {} PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "struct", @@ -99,7 +99,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: $DIR/attribute-after-derive.rs:16:24: 19:2 (#0), }, ] -PRINT-DERIVE INPUT (DISPLAY): #[print_attr] struct DeriveAttribute { } +PRINT-DERIVE INPUT (DISPLAY): #[print_attr] struct DeriveAttribute {} PRINT-DERIVE INPUT (DEBUG): TokenStream [ Punct { ch: '#', diff --git a/src/test/ui/proc-macro/auxiliary/attr-args.rs b/src/test/ui/proc-macro/auxiliary/attr-args.rs index 8dd2a5ac7866f..5f76a4484e1a4 100644 --- a/src/test/ui/proc-macro/auxiliary/attr-args.rs +++ b/src/test/ui/proc-macro/auxiliary/attr-args.rs @@ -15,7 +15,7 @@ pub fn attr_with_args(args: TokenStream, input: TokenStream) -> TokenStream { let input = input.to_string(); - assert_eq!(input, "fn foo() { }"); + assert_eq!(input, "fn foo() {}"); r#" fn foo() -> &'static str { "Hello, world!" } diff --git a/src/test/ui/proc-macro/auxiliary/attr-on-trait.rs b/src/test/ui/proc-macro/auxiliary/attr-on-trait.rs index d89aaac59f6bd..3787b8eeccc40 100644 --- a/src/test/ui/proc-macro/auxiliary/attr-on-trait.rs +++ b/src/test/ui/proc-macro/auxiliary/attr-on-trait.rs @@ -10,6 +10,6 @@ use proc_macro::TokenStream; #[proc_macro_attribute] pub fn foo(attr: TokenStream, item: TokenStream) -> TokenStream { drop(attr); - assert_eq!(item.to_string(), "fn foo() { }"); + assert_eq!(item.to_string(), "fn foo() {}"); "fn foo(&self);".parse().unwrap() } diff --git a/src/test/ui/proc-macro/cfg-eval-inner.stdout b/src/test/ui/proc-macro/cfg-eval-inner.stdout index 08ead5aaeee84..debbad57a8699 100644 --- a/src/test/ui/proc-macro/cfg-eval-inner.stdout +++ b/src/test/ui/proc-macro/cfg-eval-inner.stdout @@ -3,7 +3,7 @@ PRINT-ATTR INPUT (DISPLAY): impl Foo < { #! [rustc_dummy(cursed_inner)] #! [allow(unused)] struct Inner { field : [u8 ; { #! [rustc_dummy(another_cursed_inner)] 1 }] } 0 - }] > { #! [rustc_dummy(evaluated_attr)] fn bar() { } } + }] > { #! [rustc_dummy(evaluated_attr)] fn bar() {} } PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "impl", diff --git a/src/test/ui/proc-macro/derive-expand-order.stdout b/src/test/ui/proc-macro/derive-expand-order.stdout index 3ac1adf92c24f..dffbbf1494b9a 100644 --- a/src/test/ui/proc-macro/derive-expand-order.stdout +++ b/src/test/ui/proc-macro/derive-expand-order.stdout @@ -1,5 +1,5 @@ -Derive First: #[derive(Second)] #[derive(Third, Fourth)] #[derive(Fifth)] pub struct Foo { } -Derive Second: #[derive(Third, Fourth)] #[derive(Fifth)] pub struct Foo { } -Derive Third: #[derive(Fifth)] pub struct Foo { } -Derive Fourth: #[derive(Fifth)] pub struct Foo { } -Derive Fifth: pub struct Foo { } +Derive First: #[derive(Second)] #[derive(Third, Fourth)] #[derive(Fifth)] pub struct Foo {} +Derive Second: #[derive(Third, Fourth)] #[derive(Fifth)] pub struct Foo {} +Derive Third: #[derive(Fifth)] pub struct Foo {} +Derive Fourth: #[derive(Fifth)] pub struct Foo {} +Derive Fifth: pub struct Foo {} diff --git a/src/test/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout b/src/test/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout index e37a483cb87bc..686d53e887660 100644 --- a/src/test/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout +++ b/src/test/ui/proc-macro/expr-stmt-nonterminal-tokens.stdout @@ -202,7 +202,7 @@ PRINT-DERIVE INPUT (DEBUG): TokenStream [ span: #8 bytes(430..483), }, ] -PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { { } } ; 0 }, } +PRINT-DERIVE INPUT (DISPLAY): enum E { V = { let _ = { {} } ; 0 }, } PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "enum", diff --git a/src/test/ui/proc-macro/inner-attrs.stdout b/src/test/ui/proc-macro/inner-attrs.stdout index 9b7865be6220e..eaa8882d6a6cb 100644 --- a/src/test/ui/proc-macro/inner-attrs.stdout +++ b/src/test/ui/proc-macro/inner-attrs.stdout @@ -269,7 +269,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/inner-attrs.rs:20:30: 20:36 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): fn foo() { } +PRINT-ATTR INPUT (DISPLAY): fn foo() {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "fn", @@ -552,7 +552,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/inner-attrs.rs:27:30: 27:40 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): mod inline_mod { } +PRINT-ATTR INPUT (DISPLAY): mod inline_mod {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "mod", @@ -933,7 +933,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/inner-attrs.rs:82:42: 82:47 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): fn weird_extern() { } +PRINT-ATTR INPUT (DISPLAY): fn weird_extern() {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "fn", diff --git a/src/test/ui/proc-macro/input-interpolated.stdout b/src/test/ui/proc-macro/input-interpolated.stdout index 866608e4d8e1d..44baa37577cfa 100644 --- a/src/test/ui/proc-macro/input-interpolated.stdout +++ b/src/test/ui/proc-macro/input-interpolated.stdout @@ -53,7 +53,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: #4 bytes(432..433), }, ] -PRINT-DERIVE INPUT (DISPLAY): struct A { } +PRINT-DERIVE INPUT (DISPLAY): struct A {} PRINT-DERIVE INPUT (DEBUG): TokenStream [ Ident { ident: "struct", diff --git a/src/test/ui/proc-macro/issue-75734-pp-paren.stdout b/src/test/ui/proc-macro/issue-75734-pp-paren.stdout index ea03653c52f83..0fda6654ff370 100644 --- a/src/test/ui/proc-macro/issue-75734-pp-paren.stdout +++ b/src/test/ui/proc-macro/issue-75734-pp-paren.stdout @@ -1,4 +1,4 @@ -PRINT-ATTR INPUT (DISPLAY): fn main() { & | _ : u8 | { } ; mul_2! (1 + 1) ; } +PRINT-ATTR INPUT (DISPLAY): fn main() { & | _ : u8 | {} ; mul_2! (1 + 1) ; } PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "fn", diff --git a/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout b/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout index 81b2b219c4368..fdd178a52292f 100644 --- a/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout +++ b/src/test/ui/proc-macro/issue-75930-derive-cfg.stdout @@ -8,8 +8,8 @@ struct Foo < #[cfg(FALSE)] A, B > #[cfg(FALSE)] struct Bar ; #[cfg(not(FALSE))] struct Inner ; #[cfg(FALSE)] let a = 25 ; match true { - #[cfg(FALSE)] true => { }, - #[cfg_attr(not(FALSE), allow(warnings))] false => { }, _ => { } + #[cfg(FALSE)] true => {}, + #[cfg_attr(not(FALSE), allow(warnings))] false => {}, _ => {} } ; #[print_helper(should_be_removed)] fn removed_fn() { #! [cfg(FALSE)] } #[print_helper(c)] #[cfg(not(FALSE))] fn kept_fn() { #! [cfg(not(FALSE))] let my_val = true ; } enum TupleEnum @@ -1278,7 +1278,7 @@ PRINT-DERIVE INPUT (DISPLAY): #[print_helper(a)] #[allow(dead_code)] #[print_hel [u8 ; { #[cfg(not(FALSE))] struct Inner ; match true - { #[allow(warnings)] false => { }, _ => { } } ; #[print_helper(c)] + { #[allow(warnings)] false => {}, _ => {} } ; #[print_helper(c)] #[cfg(not(FALSE))] fn kept_fn() { #! [cfg(not(FALSE))] let my_val = true ; } enum TupleEnum { Foo(#[cfg(not(FALSE))] i32, u8) } struct diff --git a/src/test/ui/proc-macro/issue-81007-item-attrs.stdout b/src/test/ui/proc-macro/issue-81007-item-attrs.stdout index 6f880a1202170..3c001e9954b5e 100644 --- a/src/test/ui/proc-macro/issue-81007-item-attrs.stdout +++ b/src/test/ui/proc-macro/issue-81007-item-attrs.stdout @@ -1,4 +1,4 @@ -PRINT-ATTR INPUT (DISPLAY): #[doc = r" A doc comment"] struct Foo { } +PRINT-ATTR INPUT (DISPLAY): #[doc = r" A doc comment"] struct Foo {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', @@ -40,7 +40,7 @@ PRINT-ATTR INPUT (DEBUG): TokenStream [ span: $DIR/issue-81007-item-attrs.rs:22:16: 22:18 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] #[doc = r" Another comment comment"] struct Bar { } +PRINT-ATTR INPUT (DISPLAY): #[rustc_dummy] #[doc = r" Another comment comment"] struct Bar {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Punct { ch: '#', diff --git a/src/test/ui/proc-macro/nested-macro-rules.stdout b/src/test/ui/proc-macro/nested-macro-rules.stdout index 8292617fc1675..68f30c23a8d28 100644 --- a/src/test/ui/proc-macro/nested-macro-rules.stdout +++ b/src/test/ui/proc-macro/nested-macro-rules.stdout @@ -11,7 +11,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/auxiliary/nested-macro-rules.rs:9:30: 9:35 (#6), }, ] -PRINT-ATTR INPUT (DISPLAY): struct FirstAttrStruct { } +PRINT-ATTR INPUT (DISPLAY): struct FirstAttrStruct {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", @@ -46,7 +46,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [ span: $DIR/auxiliary/nested-macro-rules.rs:9:30: 9:35 (#15), }, ] -PRINT-ATTR INPUT (DISPLAY): struct SecondAttrStruct { } +PRINT-ATTR INPUT (DISPLAY): struct SecondAttrStruct {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "struct", diff --git a/src/test/ui/proc-macro/nonterminal-token-hygiene.stdout b/src/test/ui/proc-macro/nonterminal-token-hygiene.stdout index 709b2a2169e08..c08e5308138c9 100644 --- a/src/test/ui/proc-macro/nonterminal-token-hygiene.stdout +++ b/src/test/ui/proc-macro/nonterminal-token-hygiene.stdout @@ -64,7 +64,7 @@ macro inner /* 0#4 */ { () => { print_bang! { struct S; } } } struct S /* 0#5 */; // OK, not a duplicate definition of `S` -fn main /* 0#0 */() { } +fn main /* 0#0 */() {} /* Expansions: diff --git a/src/test/ui/proc-macro/trailing-plus.stdout b/src/test/ui/proc-macro/trailing-plus.stdout index d60f400af2bb9..b90057cd6d520 100644 --- a/src/test/ui/proc-macro/trailing-plus.stdout +++ b/src/test/ui/proc-macro/trailing-plus.stdout @@ -1,4 +1,4 @@ -PRINT-ATTR INPUT (DISPLAY): fn foo < T > () where T : Copy + { } +PRINT-ATTR INPUT (DISPLAY): fn foo < T > () where T : Copy + {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "fn", diff --git a/src/test/ui/proc-macro/weird-braces.stdout b/src/test/ui/proc-macro/weird-braces.stdout index dc35df1159f88..9bf5622173458 100644 --- a/src/test/ui/proc-macro/weird-braces.stdout +++ b/src/test/ui/proc-macro/weird-braces.stdout @@ -445,7 +445,7 @@ PRINT-ATTR_ARGS INPUT (DEBUG): TokenStream [ span: $DIR/weird-braces.rs:20:30: 20:42 (#0), }, ] -PRINT-ATTR INPUT (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > { } +PRINT-ATTR INPUT (DISPLAY): impl Bar < { 1 > 0 } > for Foo < { true } > {} PRINT-ATTR INPUT (DEBUG): TokenStream [ Ident { ident: "impl", diff --git a/src/test/ui/repr/issue-83921-pretty.pretty.stdout b/src/test/ui/repr/issue-83921-pretty.pretty.stdout index dad3641f0f5af..aaf3993538acf 100644 --- a/src/test/ui/repr/issue-83921-pretty.pretty.stdout +++ b/src/test/ui/repr/issue-83921-pretty.pretty.stdout @@ -13,7 +13,6 @@ extern crate std; // [pretty]compile-flags: -Zunpretty=everybody_loops // [pretty]check-pass #[repr("C")] -struct A { -} +struct A {} -fn main() { loop { } } +fn main() { loop {} } diff --git a/src/test/ui/rfc-2497-if-let-chains/ast-pretty-check.stdout b/src/test/ui/rfc-2497-if-let-chains/ast-pretty-check.stdout index aeee43b01cc02..6052ea95d0f85 100644 --- a/src/test/ui/rfc-2497-if-let-chains/ast-pretty-check.stdout +++ b/src/test/ui/rfc-2497-if-let-chains/ast-pretty-check.stdout @@ -7,4 +7,4 @@ extern crate std; // build-pass (FIXME(62277): could be check-pass?) // compile-flags: -Z unpretty=expanded -fn main() { if let 0 = 1 { } } +fn main() { if let 0 = 1 {} } diff --git a/src/test/ui/rfc-2565-param-attrs/auxiliary/param-attrs.rs b/src/test/ui/rfc-2565-param-attrs/auxiliary/param-attrs.rs index 2a172c8458d71..8800d3e66f9e4 100644 --- a/src/test/ui/rfc-2565-param-attrs/auxiliary/param-attrs.rs +++ b/src/test/ui/rfc-2565-param-attrs/auxiliary/param-attrs.rs @@ -18,14 +18,14 @@ macro_rules! checker { } checker!(attr_extern, r#"extern "C" { fn ffi(#[a1] arg1 : i32, #[a2] ...) ; }"#); -checker!(attr_extern_cvar, r#"unsafe extern "C" fn cvar(arg1 : i32, #[a1] mut args : ...) { }"#); +checker!(attr_extern_cvar, r#"unsafe extern "C" fn cvar(arg1 : i32, #[a1] mut args : ...) {}"#); checker!(attr_alias, "type Alias = fn(#[a1] u8, #[a2] ...) ;"); checker!(attr_free, "fn free(#[a1] arg1 : u8) { let lam = | #[a2] W(x), #[a3] y | () ; }"); -checker!(attr_inherent_1, "fn inherent1(#[a1] self, #[a2] arg1 : u8) { }"); -checker!(attr_inherent_2, "fn inherent2(#[a1] & self, #[a2] arg1 : u8) { }"); -checker!(attr_inherent_3, "fn inherent3 < 'a > (#[a1] & 'a mut self, #[a2] arg1 : u8) { }"); -checker!(attr_inherent_4, "fn inherent4 < 'a > (#[a1] self : Box < Self >, #[a2] arg1 : u8) { }"); -checker!(attr_inherent_issue_64682, "fn inherent5(#[a1] #[a2] arg1 : u8, #[a3] arg2 : u8) { }"); +checker!(attr_inherent_1, "fn inherent1(#[a1] self, #[a2] arg1 : u8) {}"); +checker!(attr_inherent_2, "fn inherent2(#[a1] & self, #[a2] arg1 : u8) {}"); +checker!(attr_inherent_3, "fn inherent3 < 'a > (#[a1] & 'a mut self, #[a2] arg1 : u8) {}"); +checker!(attr_inherent_4, "fn inherent4 < 'a > (#[a1] self : Box < Self >, #[a2] arg1 : u8) {}"); +checker!(attr_inherent_issue_64682, "fn inherent5(#[a1] #[a2] arg1 : u8, #[a3] arg2 : u8) {}"); checker!(attr_trait_1, "fn trait1(#[a1] self, #[a2] arg1 : u8) ;"); checker!(attr_trait_2, "fn trait2(#[a1] & self, #[a2] arg1 : u8) ;"); checker!(attr_trait_3, "fn trait3 < 'a > (#[a1] & 'a mut self, #[a2] arg1 : u8) ;"); @@ -35,9 +35,9 @@ checker!(attr_trait_issue_64682, "fn trait5(#[a1] #[a2] arg1 : u8, #[a3] arg2 : checker!(rename_params, r#"impl Foo { fn hello(#[angery(true)] a : i32, #[a2] b : i32, #[what = "how"] c : u32) - { } fn + {} fn hello2(#[a1] #[a2] a : i32, #[what = "how"] b : i32, #[angery(true)] c : - u32) { } fn + u32) {} fn hello_self(#[a1] #[a2] & self, #[a1] #[a2] a : i32, #[what = "how"] b : - i32, #[angery(true)] c : u32) { } + i32, #[angery(true)] c : u32) {} }"#); From 9b77a1e571041716ad0c446afd87949d40ed4de6 Mon Sep 17 00:00:00 2001 From: Hirochika Matsumoto Date: Thu, 2 Dec 2021 19:22:46 +0900 Subject: [PATCH 2/6] Don't suggest types whose inner type is erroneous Currently, we check if the returned type equals to `tcx.ty_error()` not to emit erroneous types, but this has a pitfall; for example, `Option<[type error]> != tcx.ty_error()` holds. --- compiler/rustc_typeck/src/collect.rs | 4 ++-- .../ui/typeck/issue-91450-inner-ty-error.rs | 7 +++++++ .../typeck/issue-91450-inner-ty-error.stderr | 21 +++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/typeck/issue-91450-inner-ty-error.rs create mode 100644 src/test/ui/typeck/issue-91450-inner-ty-error.stderr diff --git a/compiler/rustc_typeck/src/collect.rs b/compiler/rustc_typeck/src/collect.rs index 4b41730ffd50b..f88260c0a8bf5 100644 --- a/compiler/rustc_typeck/src/collect.rs +++ b/compiler/rustc_typeck/src/collect.rs @@ -41,7 +41,7 @@ use rustc_middle::ty::subst::InternalSubsts; use rustc_middle::ty::util::Discr; use rustc_middle::ty::util::IntTypeExt; use rustc_middle::ty::{self, AdtKind, Const, DefIdTree, Ty, TyCtxt}; -use rustc_middle::ty::{ReprOptions, ToPredicate, WithConstness}; +use rustc_middle::ty::{ReprOptions, ToPredicate, TypeFoldable, WithConstness}; use rustc_session::lint; use rustc_session::parse::feature_err; use rustc_span::symbol::{kw, sym, Ident, Symbol}; @@ -1779,7 +1779,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> { visitor.visit_ty(ty); let mut diag = bad_placeholder_type(tcx, visitor.0, "return type"); let ret_ty = fn_sig.skip_binder().output(); - if ret_ty != tcx.ty_error() { + if !ret_ty.references_error() { if !ret_ty.is_closure() { let ret_ty_str = match ret_ty.kind() { // Suggest a function pointer return type instead of a unique function definition diff --git a/src/test/ui/typeck/issue-91450-inner-ty-error.rs b/src/test/ui/typeck/issue-91450-inner-ty-error.rs new file mode 100644 index 0000000000000..0b942d6d94f84 --- /dev/null +++ b/src/test/ui/typeck/issue-91450-inner-ty-error.rs @@ -0,0 +1,7 @@ +// Regression test for #91450. +// This test ensures that the compiler does not suggest `Foo<[type error]>` in diagnostic messages. + +fn foo() -> Option<_> {} //~ ERROR: [E0308] +//~^ ERROR: the type placeholder `_` is not allowed + +fn main() {} diff --git a/src/test/ui/typeck/issue-91450-inner-ty-error.stderr b/src/test/ui/typeck/issue-91450-inner-ty-error.stderr new file mode 100644 index 0000000000000..314fe56180368 --- /dev/null +++ b/src/test/ui/typeck/issue-91450-inner-ty-error.stderr @@ -0,0 +1,21 @@ +error[E0308]: mismatched types + --> $DIR/issue-91450-inner-ty-error.rs:4:13 + | +LL | fn foo() -> Option<_> {} + | --- ^^^^^^^^^ expected enum `Option`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + | + = note: expected enum `Option<_>` + found unit type `()` + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures for return types + --> $DIR/issue-91450-inner-ty-error.rs:4:20 + | +LL | fn foo() -> Option<_> {} + | ^ not allowed in type signatures + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0121, E0308. +For more information about an error, try `rustc --explain E0121`. From 63523e4d1c2fe6683b035c6818cafa9f77614711 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sat, 4 Dec 2021 14:34:20 -0500 Subject: [PATCH 3/6] Stabilize `-Z emit-future-incompat` as `--json future-incompat` --- compiler/rustc_interface/src/tests.rs | 1 - compiler/rustc_session/src/config.rs | 14 ++++++++++++-- compiler/rustc_session/src/options.rs | 5 +++-- compiler/rustc_session/src/session.rs | 2 +- src/test/ui/lint/future-incompat-test.rs | 2 +- src/tools/compiletest/src/runtest.rs | 3 ++- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 6147311af6159..c651feaaa66f6 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -651,7 +651,6 @@ fn test_debugging_options_tracking_hash() { untracked!(dump_mir_dir, String::from("abc")); untracked!(dump_mir_exclude_pass_number, true); untracked!(dump_mir_graphviz, true); - untracked!(emit_future_incompat_report, true); untracked!(emit_stack_sizes, true); untracked!(future_incompat_test, true); untracked!(hir_stats, true); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 16b68d95858b8..87e8e57611765 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -746,6 +746,7 @@ impl Default for Options { edition: DEFAULT_EDITION, json_artifact_notifications: false, json_unused_externs: false, + json_future_incompat: false, pretty: None, working_dir: RealFileName::LocalPath(std::env::current_dir().unwrap()), } @@ -1257,6 +1258,7 @@ pub struct JsonConfig { pub json_rendered: HumanReadableErrorType, pub json_artifact_notifications: bool, pub json_unused_externs: bool, + pub json_future_incompat: bool, } /// Parse the `--json` flag. @@ -1269,6 +1271,7 @@ pub fn parse_json(matches: &getopts::Matches) -> JsonConfig { let mut json_color = ColorConfig::Never; let mut json_artifact_notifications = false; let mut json_unused_externs = false; + let mut json_future_incompat = false; for option in matches.opt_strs("json") { // For now conservatively forbid `--color` with `--json` since `--json` // won't actually be emitting any colors and anything colorized is @@ -1286,6 +1289,7 @@ pub fn parse_json(matches: &getopts::Matches) -> JsonConfig { "diagnostic-rendered-ansi" => json_color = ColorConfig::Always, "artifacts" => json_artifact_notifications = true, "unused-externs" => json_unused_externs = true, + "future-incompat" => json_future_incompat = true, s => early_error( ErrorOutputType::default(), &format!("unknown `--json` option `{}`", s), @@ -1298,6 +1302,7 @@ pub fn parse_json(matches: &getopts::Matches) -> JsonConfig { json_rendered: json_rendered(json_color), json_artifact_notifications, json_unused_externs, + json_future_incompat, } } @@ -2011,8 +2016,12 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { let edition = parse_crate_edition(matches); - let JsonConfig { json_rendered, json_artifact_notifications, json_unused_externs } = - parse_json(matches); + let JsonConfig { + json_rendered, + json_artifact_notifications, + json_unused_externs, + json_future_incompat, + } = parse_json(matches); let error_format = parse_error_format(matches, color, json_rendered); @@ -2248,6 +2257,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { edition, json_artifact_notifications, json_unused_externs, + json_future_incompat, pretty, working_dir, } diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 779f29e3dfedf..8610d8c64bd2e 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -205,6 +205,9 @@ top_level_options!( /// `true` if we're emitting a JSON blob containing the unused externs json_unused_externs: bool [UNTRACKED], + /// `true` if we're emitting a JSON job containg a future-incompat report for lints + json_future_incompat: bool [TRACKED], + pretty: Option [UNTRACKED], /// The (potentially remapped) working directory @@ -1124,8 +1127,6 @@ options! { computed `block` spans (one span encompassing a block's terminator and \ all statements). If `-Z instrument-coverage` is also enabled, create \ an additional `.html` file showing the computed coverage spans."), - emit_future_incompat_report: bool = (false, parse_bool, [UNTRACKED], - "emits a future-incompatibility report for lints (RFC 2834)"), emit_stack_sizes: bool = (false, parse_bool, [UNTRACKED], "emit a section containing stack size metadata (default: no)"), fewer_names: Option = (None, parse_opt_bool, [TRACKED], diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 54109559a3bb2..3f15de3ba6931 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -280,7 +280,7 @@ impl Session { } fn emit_future_breakage(&self) { - if !self.opts.debugging_opts.emit_future_incompat_report { + if !self.opts.json_future_incompat { return; } diff --git a/src/test/ui/lint/future-incompat-test.rs b/src/test/ui/lint/future-incompat-test.rs index ce8c118dab242..c5f477cc4500e 100644 --- a/src/test/ui/lint/future-incompat-test.rs +++ b/src/test/ui/lint/future-incompat-test.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zfuture-incompat-test -Zemit-future-incompat-report +// compile-flags: -Zfuture-incompat-test // check-pass // The `-Zfuture-incompat-test flag causes any normal warning to be included diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 727eecbb73256..f1f285ace173b 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1802,6 +1802,7 @@ impl<'test> TestCx<'test> { // patterns still match the raw compiler output. if self.props.error_patterns.is_empty() { rustc.args(&["--error-format", "json"]); + rustc.args(&["--json", "future-incompat"]); } rustc.arg("-Zui-testing"); rustc.arg("-Zdeduplicate-diagnostics=no"); @@ -1809,11 +1810,11 @@ impl<'test> TestCx<'test> { Ui => { if !self.props.compile_flags.iter().any(|s| s.starts_with("--error-format")) { rustc.args(&["--error-format", "json"]); + rustc.args(&["--json", "future-incompat"]); } rustc.arg("-Ccodegen-units=1"); rustc.arg("-Zui-testing"); rustc.arg("-Zdeduplicate-diagnostics=no"); - rustc.arg("-Zemit-future-incompat-report"); } MirOpt => { rustc.args(&[ From 95209252f534ccb5bd15766234a992f53737fccf Mon Sep 17 00:00:00 2001 From: b-naber Date: Wed, 3 Nov 2021 15:36:38 +0100 Subject: [PATCH 4/6] add test --- src/test/ui/const-generics/issues/issue-90455.rs | 12 ++++++++++++ src/test/ui/const-generics/issues/issue-90455.stderr | 10 ++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/test/ui/const-generics/issues/issue-90455.rs create mode 100644 src/test/ui/const-generics/issues/issue-90455.stderr diff --git a/src/test/ui/const-generics/issues/issue-90455.rs b/src/test/ui/const-generics/issues/issue-90455.rs new file mode 100644 index 0000000000000..a580410cf37ef --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-90455.rs @@ -0,0 +1,12 @@ +#![feature(generic_const_exprs, adt_const_params)] +#![allow(incomplete_features)] + +struct FieldElement { + n: [u64; num_limbs(N)], + //~^ ERROR unconstrained generic constant +} +const fn num_limbs(_: &str) -> usize { + 0 +} + +fn main() {} diff --git a/src/test/ui/const-generics/issues/issue-90455.stderr b/src/test/ui/const-generics/issues/issue-90455.stderr new file mode 100644 index 0000000000000..724d7f42e69d1 --- /dev/null +++ b/src/test/ui/const-generics/issues/issue-90455.stderr @@ -0,0 +1,10 @@ +error: unconstrained generic constant + --> $DIR/issue-90455.rs:5:8 + | +LL | n: [u64; num_limbs(N)], + | ^^^^^^^^^^^^^^^^^^^ + | + = help: try adding a `where` bound using this expression: `where [(); num_limbs(N)]:` + +error: aborting due to previous error + From 8ff50fe2736d8d33e2c51105cbabf023eff93218 Mon Sep 17 00:00:00 2001 From: b-naber Date: Thu, 2 Dec 2021 12:43:36 +0100 Subject: [PATCH 5/6] skip reborrows during AbstractConst building --- .../src/traits/const_evaluatable.rs | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs index 8edb7069fc45f..be09434771235 100644 --- a/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs +++ b/compiler/rustc_trait_selection/src/traits/const_evaluatable.rs @@ -399,13 +399,25 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> { let arg = self.recurse_build(source)?; self.nodes.push(Node::Cast(abstract_const::CastKind::As, arg, node.ty)) } - + ExprKind::Borrow{ arg, ..} => { + let arg_node = &self.body.exprs[*arg]; + + // Skip reborrows for now until we allow Deref/Borrow/AddressOf + // expressions. + // FIXME(generic_const_exprs): Verify/explain why this is sound + if let ExprKind::Deref {arg} = arg_node.kind { + self.recurse_build(arg)? + } else { + self.maybe_supported_error( + node.span, + "borrowing is not supported in generic constants", + )? + } + } // FIXME(generic_const_exprs): We may want to support these. - ExprKind::AddressOf { .. } - | ExprKind::Borrow { .. } - | ExprKind::Deref { .. } => self.maybe_supported_error( + ExprKind::AddressOf { .. } | ExprKind::Deref {..}=> self.maybe_supported_error( node.span, - "dereferencing is not supported in generic constants", + "dereferencing or taking the address is not supported in generic constants", )?, ExprKind::Repeat { .. } | ExprKind::Array { .. } => self.maybe_supported_error( node.span, From 1777f431ad3afa1c19ceed8b11b211dbe18b558c Mon Sep 17 00:00:00 2001 From: b-naber Date: Sun, 5 Dec 2021 11:47:07 +0100 Subject: [PATCH 6/6] bless tests --- src/test/ui/const-generics/generic_const_exprs/closures.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/const-generics/generic_const_exprs/closures.stderr b/src/test/ui/const-generics/generic_const_exprs/closures.stderr index 0dfd804be41b4..18010413b9394 100644 --- a/src/test/ui/const-generics/generic_const_exprs/closures.stderr +++ b/src/test/ui/const-generics/generic_const_exprs/closures.stderr @@ -4,7 +4,7 @@ error: overly complex generic constant LL | fn test() -> [u8; N + (|| 42)()] {} | ^^^^-------^^ | | - | dereferencing is not supported in generic constants + | borrowing is not supported in generic constants | = help: consider moving this anonymous constant into a `const` function = note: this operation may be supported in the future