about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCaleb Cartwright <calebcartwright@users.noreply.github.com>2022-06-08 19:58:15 -0500
committerGitHub <noreply@github.com>2022-06-08 19:58:15 -0500
commit75786fb0b707a9a4938ee31b916762c1a3eae09d (patch)
tree8c16e611ce019ae0151081558c350d0215275cf3
parent64f1f57a4837694cb2449d6bc1f614e60c6ff42c (diff)
parentaedb396063e2cd166e3cc0bfd762bf382996cd03 (diff)
downloadrust-75786fb0b707a9a4938ee31b916762c1a3eae09d.tar.gz
rust-75786fb0b707a9a4938ee31b916762c1a3eae09d.zip
Merge pull request #5374 from calebcartwright/subtree-sync-2022-06-07
Subtree sync
-rw-r--r--rust-toolchain2
-rw-r--r--src/attr.rs2
-rw-r--r--src/bin/main.rs1
-rw-r--r--src/config/options.rs5
-rw-r--r--src/expr.rs10
-rw-r--r--src/formatting.rs1
-rw-r--r--src/items.rs15
-rw-r--r--src/macros.rs74
-rw-r--r--src/modules.rs12
-rw-r--r--src/overflow.rs8
-rw-r--r--src/parse/macros/cfg_if.rs8
-rw-r--r--src/parse/macros/mod.rs10
-rw-r--r--src/parse/session.rs27
-rw-r--r--src/utils.rs17
-rw-r--r--src/visitor.rs22
-rw-r--r--tests/source/cfg_if/detect/arch/x86.rs2
-rw-r--r--tests/source/fn-simple.rs2
-rw-r--r--tests/source/pub-restricted.rs13
-rw-r--r--tests/target/cfg_if/detect/arch/x86.rs2
-rw-r--r--tests/target/fn-simple.rs2
-rw-r--r--tests/target/pub-restricted.rs13
21 files changed, 122 insertions, 126 deletions
diff --git a/rust-toolchain b/rust-toolchain
index 94b57d506c2..813e5e2c10f 100644
--- a/rust-toolchain
+++ b/rust-toolchain
@@ -1,3 +1,3 @@
 [toolchain]
-channel = "nightly-2022-03-27"
+channel = "nightly-2022-06-06"
 components = ["rustc-dev"]
diff --git a/src/attr.rs b/src/attr.rs
index befe12ae2c4..41ba9a847e6 100644
--- a/src/attr.rs
+++ b/src/attr.rs
@@ -1,7 +1,7 @@
 //! Format attributes and meta items.
 
 use rustc_ast::ast;
-use rustc_ast::AstLike;
+use rustc_ast::HasAttrs;
 use rustc_span::{symbol::sym, Span, Symbol};
 
 use self::doc_comment::DocCommentFormatter;
diff --git a/src/bin/main.rs b/src/bin/main.rs
index ad10b9ede60..8e871e61f26 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -693,6 +693,7 @@ fn edition_from_edition_str(edition_str: &str) -> Result<Edition> {
         "2015" => Ok(Edition::Edition2015),
         "2018" => Ok(Edition::Edition2018),
         "2021" => Ok(Edition::Edition2021),
+        "2024" => Ok(Edition::Edition2024),
         _ => Err(format_err!("Invalid value for `--edition`")),
     }
 }
diff --git a/src/config/options.rs b/src/config/options.rs
index d857c29be29..257a17b2703 100644
--- a/src/config/options.rs
+++ b/src/config/options.rs
@@ -423,6 +423,10 @@ pub enum Edition {
     #[doc_hint = "2021"]
     /// Edition 2021.
     Edition2021,
+    #[value = "2024"]
+    #[doc_hint = "2024"]
+    /// Edition 2024.
+    Edition2024,
 }
 
 impl Default for Edition {
@@ -437,6 +441,7 @@ impl From<Edition> for rustc_span::edition::Edition {
             Edition::Edition2015 => Self::Edition2015,
             Edition::Edition2018 => Self::Edition2018,
             Edition::Edition2021 => Self::Edition2021,
+            Edition::Edition2024 => Self::Edition2024,
         }
     }
 }
diff --git a/src/expr.rs b/src/expr.rs
index cfecc9b9d89..4ccf1ca70c9 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -3,7 +3,7 @@ use std::cmp::min;
 use std::collections::HashMap;
 
 use itertools::Itertools;
-use rustc_ast::token::{DelimToken, LitKind};
+use rustc_ast::token::{Delimiter, LitKind};
 use rustc_ast::{ast, ptr};
 use rustc_span::{BytePos, Span};
 
@@ -274,6 +274,10 @@ fn format_expr_inner(
         ast::ExprKind::Ret(Some(ref expr)) => {
             rewrite_unary_prefix(context, "return ", &**expr, shape)
         }
+        ast::ExprKind::Yeet(None) => Some("do yeet".to_owned()),
+        ast::ExprKind::Yeet(Some(ref expr)) => {
+            rewrite_unary_prefix(context, "do yeet ", &**expr, shape)
+        }
         ast::ExprKind::Box(ref expr) => rewrite_unary_prefix(context, "box ", &**expr, shape),
         ast::ExprKind::AddrOf(borrow_kind, mutability, ref expr) => {
             rewrite_expr_addrof(context, borrow_kind, mutability, expr, shape)
@@ -461,7 +465,7 @@ pub(crate) fn rewrite_array<'a, T: 'a + IntoOverflowableItem<'a>>(
     context: &'a RewriteContext<'_>,
     shape: Shape,
     force_separator_tactic: Option<SeparatorTactic>,
-    delim_token: Option<DelimToken>,
+    delim_token: Option<Delimiter>,
 ) -> Option<String> {
     overflow::rewrite_with_square_brackets(
         context,
@@ -1374,7 +1378,7 @@ pub(crate) fn can_be_overflowed_expr(
         }
         ast::ExprKind::MacCall(ref mac) => {
             match (
-                rustc_ast::ast::MacDelimiter::from_token(mac.args.delim()),
+                rustc_ast::ast::MacDelimiter::from_token(mac.args.delim().unwrap()),
                 context.config.overflow_delimited_expr(),
             ) {
                 (Some(ast::MacDelimiter::Bracket), true)
diff --git a/src/formatting.rs b/src/formatting.rs
index 23d90d9e2e0..e644ea50eff 100644
--- a/src/formatting.rs
+++ b/src/formatting.rs
@@ -6,7 +6,6 @@ use std::rc::Rc;
 use std::time::{Duration, Instant};
 
 use rustc_ast::ast;
-use rustc_ast::AstLike;
 use rustc_span::Span;
 
 use self::newline_style::apply_newline_style;
diff --git a/src/items.rs b/src/items.rs
index 79f6ff69aa9..bab881f4b4e 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -204,12 +204,11 @@ impl<'a> FnSig<'a> {
 
     pub(crate) fn from_fn_kind(
         fn_kind: &'a visit::FnKind<'_>,
-        generics: &'a ast::Generics,
         decl: &'a ast::FnDecl,
         defaultness: ast::Defaultness,
     ) -> FnSig<'a> {
         match *fn_kind {
-            visit::FnKind::Fn(fn_ctxt, _, fn_sig, vis, _) => match fn_ctxt {
+            visit::FnKind::Fn(fn_ctxt, _, fn_sig, vis, generics, _) => match fn_ctxt {
                 visit::FnCtxt::Assoc(..) => {
                     let mut fn_sig = FnSig::from_method_sig(fn_sig, generics, vis);
                     fn_sig.defaultness = defaultness;
@@ -1362,7 +1361,7 @@ pub(crate) fn format_struct_struct(
 
 fn get_bytepos_after_visibility(vis: &ast::Visibility, default_span: Span) -> BytePos {
     match vis.kind {
-        ast::VisibilityKind::Crate(..) | ast::VisibilityKind::Restricted { .. } => vis.span.hi(),
+        ast::VisibilityKind::Restricted { .. } => vis.span.hi(),
         _ => default_span.lo(),
     }
 }
@@ -3180,8 +3179,14 @@ impl Rewrite for ast::ForeignItem {
                     let inner_attrs = inner_attributes(&self.attrs);
                     let fn_ctxt = visit::FnCtxt::Foreign;
                     visitor.visit_fn(
-                        visit::FnKind::Fn(fn_ctxt, self.ident, sig, &self.vis, Some(body)),
-                        generics,
+                        visit::FnKind::Fn(
+                            fn_ctxt,
+                            self.ident,
+                            sig,
+                            &self.vis,
+                            generics,
+                            Some(body),
+                        ),
                         &sig.decl,
                         self.span,
                         defaultness,
diff --git a/src/macros.rs b/src/macros.rs
index 664f152e8be..f4b2bcf2815 100644
--- a/src/macros.rs
+++ b/src/macros.rs
@@ -12,7 +12,7 @@
 use std::collections::HashMap;
 use std::panic::{catch_unwind, AssertUnwindSafe};
 
-use rustc_ast::token::{BinOpToken, DelimToken, Token, TokenKind};
+use rustc_ast::token::{BinOpToken, Delimiter, Token, TokenKind};
 use rustc_ast::tokenstream::{Cursor, Spacing, TokenStream, TokenTree};
 use rustc_ast::{ast, ptr};
 use rustc_ast_pretty::pprust;
@@ -203,7 +203,7 @@ fn rewrite_macro_inner(
     let is_forced_bracket = FORCED_BRACKET_MACROS.contains(&&macro_name[..]);
 
     let style = if is_forced_bracket && !is_nested_macro {
-        DelimToken::Bracket
+        Delimiter::Bracket
     } else {
         original_style
     };
@@ -212,21 +212,21 @@ fn rewrite_macro_inner(
     let has_comment = contains_comment(context.snippet(mac.span()));
     if ts.is_empty() && !has_comment {
         return match style {
-            DelimToken::Paren if position == MacroPosition::Item => {
+            Delimiter::Parenthesis if position == MacroPosition::Item => {
                 Some(format!("{}();", macro_name))
             }
-            DelimToken::Bracket if position == MacroPosition::Item => {
+            Delimiter::Bracket if position == MacroPosition::Item => {
                 Some(format!("{}[];", macro_name))
             }
-            DelimToken::Paren => Some(format!("{}()", macro_name)),
-            DelimToken::Bracket => Some(format!("{}[]", macro_name)),
-            DelimToken::Brace => Some(format!("{} {{}}", macro_name)),
+            Delimiter::Parenthesis => Some(format!("{}()", macro_name)),
+            Delimiter::Bracket => Some(format!("{}[]", macro_name)),
+            Delimiter::Brace => Some(format!("{} {{}}", macro_name)),
             _ => unreachable!(),
         };
     }
     // Format well-known macros which cannot be parsed as a valid AST.
     if macro_name == "lazy_static!" && !has_comment {
-        if let success @ Some(..) = format_lazy_static(context, shape, ts.trees().collect()) {
+        if let success @ Some(..) = format_lazy_static(context, shape, ts.clone()) {
             return success;
         }
     }
@@ -260,7 +260,7 @@ fn rewrite_macro_inner(
     }
 
     match style {
-        DelimToken::Paren => {
+        Delimiter::Parenthesis => {
             // Handle special case: `vec!(expr; expr)`
             if vec_with_semi {
                 handle_vec_semi(context, shape, arg_vec, macro_name, style)
@@ -286,7 +286,7 @@ fn rewrite_macro_inner(
                 })
             }
         }
-        DelimToken::Bracket => {
+        Delimiter::Bracket => {
             // Handle special case: `vec![expr; expr]`
             if vec_with_semi {
                 handle_vec_semi(context, shape, arg_vec, macro_name, style)
@@ -323,7 +323,7 @@ fn rewrite_macro_inner(
                 Some(format!("{}{}", rewrite, comma))
             }
         }
-        DelimToken::Brace => {
+        Delimiter::Brace => {
             // For macro invocations with braces, always put a space between
             // the `macro_name!` and `{ /* macro_body */ }` but skip modifying
             // anything in between the braces (for now).
@@ -342,11 +342,11 @@ fn handle_vec_semi(
     shape: Shape,
     arg_vec: Vec<MacroArg>,
     macro_name: String,
-    delim_token: DelimToken,
+    delim_token: Delimiter,
 ) -> Option<String> {
     let (left, right) = match delim_token {
-        DelimToken::Paren => ("(", ")"),
-        DelimToken::Bracket => ("[", "]"),
+        Delimiter::Parenthesis => ("(", ")"),
+        Delimiter::Bracket => ("[", "]"),
         _ => unreachable!(),
     };
 
@@ -528,7 +528,7 @@ enum MacroArgKind {
     /// e.g., `$($foo: expr),*`
     Repeat(
         /// `()`, `[]` or `{}`.
-        DelimToken,
+        Delimiter,
         /// Inner arguments inside delimiters.
         Vec<ParsedMacroArg>,
         /// Something after the closing delimiter and the repeat token, if available.
@@ -537,7 +537,7 @@ enum MacroArgKind {
         Token,
     ),
     /// e.g., `[derive(Debug)]`
-    Delimited(DelimToken, Vec<ParsedMacroArg>),
+    Delimited(Delimiter, Vec<ParsedMacroArg>),
     /// A possible separator. e.g., `,` or `;`.
     Separator(String, String),
     /// Other random stuff that does not fit to other kinds.
@@ -547,22 +547,22 @@ enum MacroArgKind {
 
 fn delim_token_to_str(
     context: &RewriteContext<'_>,
-    delim_token: DelimToken,
+    delim_token: Delimiter,
     shape: Shape,
     use_multiple_lines: bool,
     inner_is_empty: bool,
 ) -> (String, String) {
     let (lhs, rhs) = match delim_token {
-        DelimToken::Paren => ("(", ")"),
-        DelimToken::Bracket => ("[", "]"),
-        DelimToken::Brace => {
+        Delimiter::Parenthesis => ("(", ")"),
+        Delimiter::Bracket => ("[", "]"),
+        Delimiter::Brace => {
             if inner_is_empty || use_multiple_lines {
                 ("{", "}")
             } else {
                 ("{ ", " }")
             }
         }
-        DelimToken::NoDelim => ("", ""),
+        Delimiter::Invisible => unreachable!(),
     };
     if use_multiple_lines {
         let indent_str = shape.indent.to_string_with_newline(context.config);
@@ -583,8 +583,8 @@ impl MacroArgKind {
     fn starts_with_brace(&self) -> bool {
         matches!(
             *self,
-            MacroArgKind::Repeat(DelimToken::Brace, _, _, _)
-                | MacroArgKind::Delimited(DelimToken::Brace, _)
+            MacroArgKind::Repeat(Delimiter::Brace, _, _, _)
+                | MacroArgKind::Delimited(Delimiter::Brace, _)
         )
     }
 
@@ -753,7 +753,7 @@ impl MacroArgParser {
         }
     }
 
-    fn add_delimited(&mut self, inner: Vec<ParsedMacroArg>, delim: DelimToken) {
+    fn add_delimited(&mut self, inner: Vec<ParsedMacroArg>, delim: Delimiter) {
         self.result.push(ParsedMacroArg {
             kind: MacroArgKind::Delimited(delim, inner),
         });
@@ -763,7 +763,7 @@ impl MacroArgParser {
     fn add_repeat(
         &mut self,
         inner: Vec<ParsedMacroArg>,
-        delim: DelimToken,
+        delim: Delimiter,
         iter: &mut Cursor,
     ) -> Option<()> {
         let mut buffer = String::new();
@@ -855,7 +855,7 @@ impl MacroArgParser {
 
     /// Returns a collection of parsed macro def's arguments.
     fn parse(mut self, tokens: TokenStream) -> Option<Vec<ParsedMacroArg>> {
-        let mut iter = tokens.trees();
+        let mut iter = tokens.into_trees();
 
         while let Some(tok) = iter.next() {
             match tok {
@@ -1083,18 +1083,18 @@ pub(crate) fn convert_try_mac(
     }
 }
 
-pub(crate) fn macro_style(mac: &ast::MacCall, context: &RewriteContext<'_>) -> DelimToken {
+pub(crate) fn macro_style(mac: &ast::MacCall, context: &RewriteContext<'_>) -> Delimiter {
     let snippet = context.snippet(mac.span());
     let paren_pos = snippet.find_uncommented("(").unwrap_or(usize::max_value());
     let bracket_pos = snippet.find_uncommented("[").unwrap_or(usize::max_value());
     let brace_pos = snippet.find_uncommented("{").unwrap_or(usize::max_value());
 
     if paren_pos < bracket_pos && paren_pos < brace_pos {
-        DelimToken::Paren
+        Delimiter::Parenthesis
     } else if bracket_pos < brace_pos {
-        DelimToken::Bracket
+        Delimiter::Bracket
     } else {
-        DelimToken::Brace
+        Delimiter::Brace
     }
 }
 
@@ -1174,7 +1174,7 @@ struct Macro {
 // rather than clone them, if we can make the borrowing work out.
 struct MacroBranch {
     span: Span,
-    args_paren_kind: DelimToken,
+    args_paren_kind: Delimiter,
     args: TokenStream,
     body: Span,
     whole_body: Span,
@@ -1188,7 +1188,7 @@ impl MacroBranch {
         multi_branch_style: bool,
     ) -> Option<String> {
         // Only attempt to format function-like macros.
-        if self.args_paren_kind != DelimToken::Paren {
+        if self.args_paren_kind != Delimiter::Parenthesis {
             // FIXME(#1539): implement for non-sugared macros.
             return None;
         }
@@ -1350,18 +1350,18 @@ fn rewrite_macro_with_items(
     items: &[MacroArg],
     macro_name: &str,
     shape: Shape,
-    style: DelimToken,
+    style: Delimiter,
     position: MacroPosition,
     span: Span,
 ) -> Option<String> {
     let (opener, closer) = match style {
-        DelimToken::Paren => ("(", ")"),
-        DelimToken::Bracket => ("[", "]"),
-        DelimToken::Brace => (" {", "}"),
+        Delimiter::Parenthesis => ("(", ")"),
+        Delimiter::Bracket => ("[", "]"),
+        Delimiter::Brace => (" {", "}"),
         _ => return None,
     };
     let trailing_semicolon = match style {
-        DelimToken::Paren | DelimToken::Bracket if position == MacroPosition::Item => ";",
+        Delimiter::Parenthesis | Delimiter::Bracket if position == MacroPosition::Item => ";",
         _ => "",
     };
 
diff --git a/src/modules.rs b/src/modules.rs
index a65dc66f797..81da724329f 100644
--- a/src/modules.rs
+++ b/src/modules.rs
@@ -4,7 +4,6 @@ use std::path::{Path, PathBuf};
 
 use rustc_ast::ast;
 use rustc_ast::visit::Visitor;
-use rustc_ast::AstLike;
 use rustc_span::symbol::{self, sym, Symbol};
 use rustc_span::Span;
 use thiserror::Error;
@@ -50,19 +49,10 @@ impl<'a> Module<'a> {
             ast_mod_kind,
         }
     }
-}
 
-impl<'a> AstLike for Module<'a> {
-    const SUPPORTS_CUSTOM_INNER_ATTRS: bool = true;
-    fn attrs(&self) -> &[ast::Attribute] {
+    pub(crate) fn attrs(&self) -> &[ast::Attribute] {
         &self.inner_attr
     }
-    fn visit_attrs(&mut self, f: impl FnOnce(&mut Vec<ast::Attribute>)) {
-        f(&mut self.inner_attr)
-    }
-    fn tokens_mut(&mut self) -> Option<&mut Option<rustc_ast::tokenstream::LazyTokenStream>> {
-        unimplemented!()
-    }
 }
 
 /// Maps each module to the corresponding file.
diff --git a/src/overflow.rs b/src/overflow.rs
index c296961d1f0..6bf8cd0c70b 100644
--- a/src/overflow.rs
+++ b/src/overflow.rs
@@ -3,7 +3,7 @@
 use std::cmp::min;
 
 use itertools::Itertools;
-use rustc_ast::token::DelimToken;
+use rustc_ast::token::Delimiter;
 use rustc_ast::{ast, ptr};
 use rustc_span::Span;
 
@@ -297,11 +297,11 @@ pub(crate) fn rewrite_with_square_brackets<'a, T: 'a + IntoOverflowableItem<'a>>
     shape: Shape,
     span: Span,
     force_separator_tactic: Option<SeparatorTactic>,
-    delim_token: Option<DelimToken>,
+    delim_token: Option<Delimiter>,
 ) -> Option<String> {
     let (lhs, rhs) = match delim_token {
-        Some(DelimToken::Paren) => ("(", ")"),
-        Some(DelimToken::Brace) => ("{", "}"),
+        Some(Delimiter::Parenthesis) => ("(", ")"),
+        Some(Delimiter::Brace) => ("{", "}"),
         _ => ("[", "]"),
     };
     Context::new(
diff --git a/src/parse/macros/cfg_if.rs b/src/parse/macros/cfg_if.rs
index 306b6bb745e..09b3e32df31 100644
--- a/src/parse/macros/cfg_if.rs
+++ b/src/parse/macros/cfg_if.rs
@@ -1,7 +1,7 @@
 use std::panic::{catch_unwind, AssertUnwindSafe};
 
 use rustc_ast::ast;
-use rustc_ast::token::{DelimToken, TokenKind};
+use rustc_ast::token::{Delimiter, TokenKind};
 use rustc_parse::parser::ForceCollect;
 use rustc_span::symbol::kw;
 
@@ -47,11 +47,11 @@ fn parse_cfg_if_inner<'a>(
                 .map_err(|_| "Failed to parse attributes")?;
         }
 
-        if !parser.eat(&TokenKind::OpenDelim(DelimToken::Brace)) {
+        if !parser.eat(&TokenKind::OpenDelim(Delimiter::Brace)) {
             return Err("Expected an opening brace");
         }
 
-        while parser.token != TokenKind::CloseDelim(DelimToken::Brace)
+        while parser.token != TokenKind::CloseDelim(Delimiter::Brace)
             && parser.token.kind != TokenKind::Eof
         {
             let item = match parser.parse_item(ForceCollect::No) {
@@ -70,7 +70,7 @@ fn parse_cfg_if_inner<'a>(
             }
         }
 
-        if !parser.eat(&TokenKind::CloseDelim(DelimToken::Brace)) {
+        if !parser.eat(&TokenKind::CloseDelim(Delimiter::Brace)) {
             return Err("Expected a closing brace");
         }
 
diff --git a/src/parse/macros/mod.rs b/src/parse/macros/mod.rs
index 3728f3a19b4..67f3985926e 100644
--- a/src/parse/macros/mod.rs
+++ b/src/parse/macros/mod.rs
@@ -1,4 +1,4 @@
-use rustc_ast::token::{DelimToken, TokenKind};
+use rustc_ast::token::{Delimiter, TokenKind};
 use rustc_ast::tokenstream::TokenStream;
 use rustc_ast::{ast, ptr};
 use rustc_parse::parser::{ForceCollect, Parser};
@@ -79,9 +79,7 @@ fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
     for &keyword in RUST_KW.iter() {
         if parser.token.is_keyword(keyword)
             && parser.look_ahead(1, |t| {
-                t.kind == TokenKind::Eof
-                    || t.kind == TokenKind::Comma
-                    || t.kind == TokenKind::CloseDelim(DelimToken::NoDelim)
+                t.kind == TokenKind::Eof || t.kind == TokenKind::Comma
             })
         {
             parser.bump();
@@ -97,7 +95,7 @@ fn check_keyword<'a, 'b: 'a>(parser: &'a mut Parser<'b>) -> Option<MacroArg> {
 pub(crate) fn parse_macro_args(
     context: &RewriteContext<'_>,
     tokens: TokenStream,
-    style: DelimToken,
+    style: Delimiter,
     forced_bracket: bool,
 ) -> Option<ParsedMacroArgs> {
     let mut parser = build_parser(context, tokens);
@@ -105,7 +103,7 @@ pub(crate) fn parse_macro_args(
     let mut vec_with_semi = false;
     let mut trailing_comma = false;
 
-    if DelimToken::Brace != style {
+    if Delimiter::Brace != style {
         loop {
             if let Some(arg) = check_keyword(&mut parser) {
                 args.push(arg);
diff --git a/src/parse/session.rs b/src/parse/session.rs
index 55050571db7..a0f71c2b8ba 100644
--- a/src/parse/session.rs
+++ b/src/parse/session.rs
@@ -33,6 +33,12 @@ impl Emitter for SilentEmitter {
         None
     }
     fn emit_diagnostic(&mut self, _db: &Diagnostic) {}
+    fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
+        None
+    }
+    fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
+        panic!("silent emitter attempted to translate a diagnostic");
+    }
 }
 
 fn silent_emitter() -> Box<dyn Emitter + Send> {
@@ -82,6 +88,14 @@ impl Emitter for SilentOnIgnoredFilesEmitter {
         }
         self.handle_non_ignoreable_error(db);
     }
+
+    fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
+        self.emitter.fluent_bundle()
+    }
+
+    fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
+        self.emitter.fallback_fluent_bundle()
+    }
 }
 
 fn default_handler(
@@ -100,9 +114,13 @@ fn default_handler(
     let emitter = if hide_parse_errors {
         silent_emitter()
     } else {
+        let fallback_bundle =
+            rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
         Box::new(EmitterWriter::stderr(
             color_cfg,
             Some(source_map.clone()),
+            None,
+            fallback_bundle,
             false,
             false,
             None,
@@ -313,7 +331,8 @@ mod tests {
         use super::*;
         use crate::config::IgnoreList;
         use crate::utils::mk_sp;
-        use rustc_span::{FileName as SourceMapFileName, MultiSpan, RealFileName};
+        use rustc_errors::MultiSpan;
+        use rustc_span::{FileName as SourceMapFileName, RealFileName};
         use std::path::PathBuf;
         use std::sync::atomic::AtomicU32;
 
@@ -328,6 +347,12 @@ mod tests {
             fn emit_diagnostic(&mut self, _db: &Diagnostic) {
                 self.num_emitted_errors.fetch_add(1, Ordering::Release);
             }
+            fn fluent_bundle(&self) -> Option<&Lrc<rustc_errors::FluentBundle>> {
+                None
+            }
+            fn fallback_fluent_bundle(&self) -> &rustc_errors::FluentBundle {
+                panic!("test emitter attempted to translate a diagnostic");
+            }
         }
 
         fn build_diagnostic(level: DiagnosticLevel, span: Option<MultiSpan>) -> Diagnostic {
diff --git a/src/utils.rs b/src/utils.rs
index 35512e78fa6..58fd95c656e 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -1,7 +1,7 @@
 use std::borrow::Cow;
 
 use rustc_ast::ast::{
-    self, Attribute, CrateSugar, MetaItem, MetaItemKind, NestedMetaItem, NodeId, Path, Visibility,
+    self, Attribute, MetaItem, MetaItemKind, NestedMetaItem, NodeId, Path, Visibility,
     VisibilityKind,
 };
 use rustc_ast::ptr;
@@ -44,15 +44,7 @@ pub(crate) fn is_same_visibility(a: &Visibility, b: &Visibility) -> bool {
             VisibilityKind::Restricted { path: q, .. },
         ) => pprust::path_to_string(p) == pprust::path_to_string(q),
         (VisibilityKind::Public, VisibilityKind::Public)
-        | (VisibilityKind::Inherited, VisibilityKind::Inherited)
-        | (
-            VisibilityKind::Crate(CrateSugar::PubCrate),
-            VisibilityKind::Crate(CrateSugar::PubCrate),
-        )
-        | (
-            VisibilityKind::Crate(CrateSugar::JustCrate),
-            VisibilityKind::Crate(CrateSugar::JustCrate),
-        ) => true,
+        | (VisibilityKind::Inherited, VisibilityKind::Inherited) => true,
         _ => false,
     }
 }
@@ -65,8 +57,6 @@ pub(crate) fn format_visibility(
     match vis.kind {
         VisibilityKind::Public => Cow::from("pub "),
         VisibilityKind::Inherited => Cow::from(""),
-        VisibilityKind::Crate(CrateSugar::PubCrate) => Cow::from("pub(crate) "),
-        VisibilityKind::Crate(CrateSugar::JustCrate) => Cow::from("crate "),
         VisibilityKind::Restricted { ref path, .. } => {
             let Path { ref segments, .. } = **path;
             let mut segments_iter = segments.iter().map(|seg| rewrite_ident(context, seg.ident));
@@ -75,7 +65,7 @@ pub(crate) fn format_visibility(
                     .next()
                     .expect("Non-global path in pub(restricted)?");
             }
-            let is_keyword = |s: &str| s == "self" || s == "super";
+            let is_keyword = |s: &str| s == "crate" || s == "self" || s == "super";
             let path = segments_iter.collect::<Vec<_>>().join("::");
             let in_str = if is_keyword(&path) { "" } else { "in " };
 
@@ -512,6 +502,7 @@ pub(crate) fn is_block_expr(context: &RewriteContext<'_>, expr: &ast::Expr, repr
         | ast::ExprKind::Range(..)
         | ast::ExprKind::Repeat(..)
         | ast::ExprKind::Ret(..)
+        | ast::ExprKind::Yeet(..)
         | ast::ExprKind::Tup(..)
         | ast::ExprKind::Type(..)
         | ast::ExprKind::Yield(None)
diff --git a/src/visitor.rs b/src/visitor.rs
index 06736e3079a..3ff56d52f92 100644
--- a/src/visitor.rs
+++ b/src/visitor.rs
@@ -1,7 +1,7 @@
 use std::cell::{Cell, RefCell};
 use std::rc::Rc;
 
-use rustc_ast::{ast, token::DelimToken, visit, AstLike};
+use rustc_ast::{ast, token::Delimiter, visit};
 use rustc_data_structures::sync::Lrc;
 use rustc_span::{symbol, BytePos, Pos, Span};
 
@@ -383,7 +383,6 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
     pub(crate) fn visit_fn(
         &mut self,
         fk: visit::FnKind<'_>,
-        generics: &ast::Generics,
         fd: &ast::FnDecl,
         s: Span,
         defaultness: ast::Defaultness,
@@ -392,12 +391,12 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
         let indent = self.block_indent;
         let block;
         let rewrite = match fk {
-            visit::FnKind::Fn(_, ident, _, _, Some(ref b)) => {
+            visit::FnKind::Fn(_, ident, _, _, _, Some(ref b)) => {
                 block = b;
                 self.rewrite_fn_before_block(
                     indent,
                     ident,
-                    &FnSig::from_fn_kind(&fk, generics, fd, defaultness),
+                    &FnSig::from_fn_kind(&fk, fd, defaultness),
                     mk_sp(s.lo(), b.span.lo()),
                 )
             }
@@ -553,8 +552,14 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
                             _ => visit::FnCtxt::Foreign,
                         };
                         self.visit_fn(
-                            visit::FnKind::Fn(fn_ctxt, item.ident, sig, &item.vis, Some(body)),
-                            generics,
+                            visit::FnKind::Fn(
+                                fn_ctxt,
+                                item.ident,
+                                sig,
+                                &item.vis,
+                                generics,
+                                Some(body),
+                            ),
                             &sig.decl,
                             item.span,
                             defaultness,
@@ -643,8 +648,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
                     let inner_attrs = inner_attributes(&ai.attrs);
                     let fn_ctxt = visit::FnCtxt::Assoc(assoc_ctxt);
                     self.visit_fn(
-                        visit::FnKind::Fn(fn_ctxt, ai.ident, sig, &ai.vis, Some(body)),
-                        generics,
+                        visit::FnKind::Fn(fn_ctxt, ai.ident, sig, &ai.vis, generics, Some(body)),
                         &sig.decl,
                         ai.span,
                         defaultness,
@@ -686,7 +690,7 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
         // with whitespace between the delimiters and trailing semi (i.e. `foo!(abc)     ;`)
         // are formatted correctly.
         let (span, rewrite) = match macro_style(mac, &self.get_context()) {
-            DelimToken::Bracket | DelimToken::Paren if MacroPosition::Item == pos => {
+            Delimiter::Bracket | Delimiter::Parenthesis if MacroPosition::Item == pos => {
                 let search_span = mk_sp(mac.span().hi(), self.snippet_provider.end_pos());
                 let hi = self.snippet_provider.span_before(search_span, ";");
                 let target_span = mk_sp(mac.span().lo(), hi + BytePos(1));
diff --git a/tests/source/cfg_if/detect/arch/x86.rs b/tests/source/cfg_if/detect/arch/x86.rs
index 4c71a2c6ab9..d26f4ee894f 100644
--- a/tests/source/cfg_if/detect/arch/x86.rs
+++ b/tests/source/cfg_if/detect/arch/x86.rs
@@ -3,7 +3,7 @@
 //! The features are detected using the `detect_features` function below.
 //! This function uses the CPUID instruction to read the feature flags from the
 //! CPU and encodes them in a `usize` where each bit position represents
-//! whether a feature is available (bit is set) or unavaiable (bit is cleared).
+//! whether a feature is available (bit is set) or unavailable (bit is cleared).
 //!
 //! The enum `Feature` is used to map bit positions to feature names, and the
 //! the `__crate::detect::check_for!` macro is used to map string literals (e.g.,
diff --git a/tests/source/fn-simple.rs b/tests/source/fn-simple.rs
index 528b9a0292a..12a50c013a9 100644
--- a/tests/source/fn-simple.rs
+++ b/tests/source/fn-simple.rs
@@ -63,7 +63,7 @@ mod foo {
 // #2082
 pub(crate) fn init() {}
 
-crate fn init() {}
+pub(crate) fn init() {}
 
 // #2630
 fn make_map<T, F: (Fn(&T) -> String)>(records: &Vec<T>, key_fn: F) -> HashMap<String, usize> {}
diff --git a/tests/source/pub-restricted.rs b/tests/source/pub-restricted.rs
index 30051fa72ee..5683acbf3aa 100644
--- a/tests/source/pub-restricted.rs
+++ b/tests/source/pub-restricted.rs
@@ -24,19 +24,6 @@ pub(  crate  ) enum WriteState<D> {
     WriteData(Writer<D>),
 }
 
-  crate   enum WriteState<D> {
-    WriteId {
-        id: U64Writer,
-        size: U64Writer,
-        payload: Option<Writer<D>>,
-    },
-    WriteSize {
-        size: U64Writer,
-        payload: Option<Writer<D>>,
-    },
-    WriteData(Writer<D>),
-}
-
 pub(in  ::global::  path :: to::some_mod  ) enum WriteState<D> {
     WriteId {
         id: U64Writer,
diff --git a/tests/target/cfg_if/detect/arch/x86.rs b/tests/target/cfg_if/detect/arch/x86.rs
index b985dd8caa1..02d5eed1c29 100644
--- a/tests/target/cfg_if/detect/arch/x86.rs
+++ b/tests/target/cfg_if/detect/arch/x86.rs
@@ -3,7 +3,7 @@
 //! The features are detected using the `detect_features` function below.
 //! This function uses the CPUID instruction to read the feature flags from the
 //! CPU and encodes them in a `usize` where each bit position represents
-//! whether a feature is available (bit is set) or unavaiable (bit is cleared).
+//! whether a feature is available (bit is set) or unavailable (bit is cleared).
 //!
 //! The enum `Feature` is used to map bit positions to feature names, and the
 //! the `__crate::detect::check_for!` macro is used to map string literals (e.g.,
diff --git a/tests/target/fn-simple.rs b/tests/target/fn-simple.rs
index 692739fa6a9..e725269360d 100644
--- a/tests/target/fn-simple.rs
+++ b/tests/target/fn-simple.rs
@@ -105,7 +105,7 @@ mod foo {
 // #2082
 pub(crate) fn init() {}
 
-crate fn init() {}
+pub(crate) fn init() {}
 
 // #2630
 fn make_map<T, F: (Fn(&T) -> String)>(records: &Vec<T>, key_fn: F) -> HashMap<String, usize> {}
diff --git a/tests/target/pub-restricted.rs b/tests/target/pub-restricted.rs
index 8cc2ade612a..0e178ef1013 100644
--- a/tests/target/pub-restricted.rs
+++ b/tests/target/pub-restricted.rs
@@ -24,19 +24,6 @@ pub(crate) enum WriteState<D> {
     WriteData(Writer<D>),
 }
 
-crate enum WriteState<D> {
-    WriteId {
-        id: U64Writer,
-        size: U64Writer,
-        payload: Option<Writer<D>>,
-    },
-    WriteSize {
-        size: U64Writer,
-        payload: Option<Writer<D>>,
-    },
-    WriteData(Writer<D>),
-}
-
 pub(in global::path::to::some_mod) enum WriteState<D> {
     WriteId {
         id: U64Writer,