]> git.lizzy.rs Git - rust.git/blobdiff - src/utils.rs
Update rustc-ap-* crates to 659.0.0 for rustfmt-1.4.15 (#4184)
[rust.git] / src / utils.rs
index 41400399ddd6509c0b02293474330d55de71515c..f82bdd501cf9ab01a8c2386bec3faa956fb91ebc 100644 (file)
@@ -6,8 +6,7 @@
 };
 use rustc_ast::ptr;
 use rustc_ast_pretty::pprust;
-use rustc_span::{sym, BytePos, ExpnId, Span, Symbol, SyntaxContext};
-use rustc_target::spec::abi;
+use rustc_span::{sym, symbol, BytePos, ExpnId, Span, Symbol, SyntaxContext};
 use unicode_width::UnicodeWidthStr;
 
 use crate::comment::{filter_normal_code, CharClasses, FullCodeCharKind, LineClasses};
@@ -25,7 +24,7 @@ pub(crate) fn skip_annotation() -> Symbol {
     Symbol::intern("rustfmt::skip")
 }
 
-pub(crate) fn rewrite_ident<'a>(context: &'a RewriteContext<'_>, ident: ast::Ident) -> &'a str {
+pub(crate) fn rewrite_ident<'a>(context: &'a RewriteContext<'_>, ident: symbol::Ident) -> &'a str {
     context.snippet(ident.span)
 }
 
@@ -140,19 +139,17 @@ pub(crate) fn format_extern(
     is_mod: bool,
 ) -> Cow<'static, str> {
     let abi = match ext {
-        ast::Extern::None => abi::Abi::Rust,
-        ast::Extern::Implicit => abi::Abi::C,
-        ast::Extern::Explicit(abi) => {
-            abi::lookup(&abi.symbol_unescaped.as_str()).unwrap_or(abi::Abi::Rust)
-        }
+        ast::Extern::None => "Rust".to_owned(),
+        ast::Extern::Implicit => "C".to_owned(),
+        ast::Extern::Explicit(abi) => abi.symbol_unescaped.to_string(),
     };
 
-    if abi == abi::Abi::Rust && !is_mod {
+    if abi == "Rust" && !is_mod {
         Cow::from("")
-    } else if abi == abi::Abi::C && !explicit_abi {
+    } else if abi == "C" && !explicit_abi {
         Cow::from("extern ")
     } else {
-        Cow::from(format!("extern {} ", abi))
+        Cow::from(format!(r#"extern "{}" "#, abi))
     }
 }