diff --git a/Cargo.lock b/Cargo.lock index a6dca2048d4e8..0f770f3eadbea 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3762,7 +3762,6 @@ dependencies = [ "rustc", "rustc_codegen_utils", "rustc_data_structures", - "rustc_target", "serde_json", "syntax", "syntax_pos", @@ -4362,7 +4361,6 @@ dependencies = [ "rustc_errors", "rustc_index", "rustc_lexer", - "rustc_target", "scoped-tls", "serialize", "smallvec 1.0.0", @@ -4380,7 +4378,6 @@ dependencies = [ "rustc_errors", "rustc_index", "rustc_lexer", - "rustc_target", "scoped-tls", "serialize", "smallvec 1.0.0", diff --git a/src/librustc/error_codes.rs b/src/librustc/error_codes.rs index f5ff92e69bc7a..cf892127a3079 100644 --- a/src/librustc/error_codes.rs +++ b/src/librustc/error_codes.rs @@ -2336,6 +2336,7 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC. E0657, // `impl Trait` can only capture lifetimes bound at the fn level E0687, // in-band lifetimes cannot be used in `fn`/`Fn` syntax E0688, // in-band lifetimes cannot be mixed with explicit lifetime binders + E0703, // invalid ABI // E0707, // multiple elided lifetimes used in arguments of `async fn` E0708, // `async` non-`move` closures with parameters are not currently // supported diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 230fbb16b87bc..6344c7a233ca4 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -1216,7 +1216,7 @@ impl<'a> LoweringContext<'a> { ImplTraitContext::disallowed(), ), unsafety: this.lower_unsafety(f.unsafety), - abi: f.abi, + abi: this.lower_abi(f.abi), decl: this.lower_fn_decl(&f.decl, None, false, None), param_names: this.lower_fn_params_to_names(&f.decl), })) diff --git a/src/librustc/hir/lowering/item.rs b/src/librustc/hir/lowering/item.rs index f1b999cdd6f0f..5fe463d783f4b 100644 --- a/src/librustc/hir/lowering/item.rs +++ b/src/librustc/hir/lowering/item.rs @@ -12,6 +12,7 @@ use crate::hir::def::{Res, DefKind}; use crate::util::nodemap::NodeMap; use rustc_data_structures::thin_vec::ThinVec; +use rustc_target::spec::abi; use std::collections::BTreeSet; use smallvec::SmallVec; @@ -735,7 +736,7 @@ impl LoweringContext<'_> { fn lower_foreign_mod(&mut self, fm: &ForeignMod) -> hir::ForeignMod { hir::ForeignMod { - abi: fm.abi, + abi: self.lower_abi(fm.abi), items: fm.items .iter() .map(|x| self.lower_foreign_item(x)) @@ -1291,10 +1292,30 @@ impl LoweringContext<'_> { unsafety: self.lower_unsafety(h.unsafety), asyncness: self.lower_asyncness(h.asyncness.node), constness: self.lower_constness(h.constness), - abi: h.abi, + abi: self.lower_abi(h.abi), } } + pub(super) fn lower_abi(&mut self, abi: Abi) -> abi::Abi { + abi::lookup(&abi.symbol.as_str()).unwrap_or_else(|| { + self.error_on_invalid_abi(abi); + abi::Abi::Rust + }) + } + + fn error_on_invalid_abi(&self, abi: Abi) { + struct_span_err!( + self.sess, + abi.span, + E0703, + "invalid ABI: found `{}`", + abi.symbol + ) + .span_label(abi.span, "invalid ABI") + .help(&format!("valid ABIs: {}", abi::all_names().join(", "))) + .emit(); + } + pub(super) fn lower_unsafety(&mut self, u: Unsafety) -> hir::Unsafety { match u { Unsafety::Unsafe => hir::Unsafety::Unsafe, diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index aa147462e3d3b..2201c4b0980b3 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -124,7 +124,6 @@ for ::syntax::attr::StabilityLevel { impl_stable_hash_for!(struct ::syntax::attr::RustcDeprecation { since, reason, suggestion }); - impl_stable_hash_for!(enum ::syntax::attr::IntType { SignedInt(int_ty), UnsignedInt(uint_ty) @@ -136,6 +135,11 @@ impl_stable_hash_for!(enum ::syntax::ast::LitIntType { Unsuffixed }); +impl_stable_hash_for!(enum ::syntax::ast::LitFloatType { + Suffixed(float_ty), + Unsuffixed +}); + impl_stable_hash_for!(struct ::syntax::ast::Lit { kind, token, @@ -148,8 +152,7 @@ impl_stable_hash_for!(enum ::syntax::ast::LitKind { Byte(value), Char(value), Int(value, lit_int_type), - Float(value, float_ty), - FloatUnsuffixed(value), + Float(value, lit_float_type), Bool(value), Err(value) }); @@ -159,6 +162,7 @@ impl_stable_hash_for_spanned!(::syntax::ast::LitKind); impl_stable_hash_for!(enum ::syntax::ast::IntTy { Isize, I8, I16, I32, I64, I128 }); impl_stable_hash_for!(enum ::syntax::ast::UintTy { Usize, U8, U16, U32, U64, U128 }); impl_stable_hash_for!(enum ::syntax::ast::FloatTy { F32, F64 }); +impl_stable_hash_for!(enum ::rustc_target::abi::FloatTy { F32, F64 }); impl_stable_hash_for!(enum ::syntax::ast::Unsafety { Unsafe, Normal }); impl_stable_hash_for!(enum ::syntax::ast::Constness { Const, NotConst }); impl_stable_hash_for!(enum ::syntax::ast::Defaultness { Default, Final }); diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 95040135eb7d3..60aab6b6aa924 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -538,7 +538,10 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> { ty::Uint(ity) => { scalar(Int(Integer::from_attr(dl, attr::UnsignedInt(ity)), false)) } - ty::Float(fty) => scalar(Float(fty)), + ty::Float(fty) => scalar(Float(match fty { + ast::FloatTy::F32 => FloatTy::F32, + ast::FloatTy::F64 => FloatTy::F64, + })), ty::FnPtr(_) => { let mut ptr = scalar_unit(Pointer); ptr.valid_range = 1..=*ptr.valid_range.end(); diff --git a/src/librustc/ty/print/obsolete.rs b/src/librustc/ty/print/obsolete.rs index e72916de6a9c7..d25f302cf889e 100644 --- a/src/librustc/ty/print/obsolete.rs +++ b/src/librustc/ty/print/obsolete.rs @@ -12,7 +12,6 @@ use rustc::ty::{self, Const, Instance, Ty, TyCtxt}; use rustc::{bug, hir}; use std::fmt::Write; use std::iter; -use syntax::ast; /// Same as `unique_type_name()` but with the result pushed onto the given /// `output` parameter. @@ -39,20 +38,9 @@ impl DefPathBasedNames<'tcx> { ty::Char => output.push_str("char"), ty::Str => output.push_str("str"), ty::Never => output.push_str("!"), - ty::Int(ast::IntTy::Isize) => output.push_str("isize"), - ty::Int(ast::IntTy::I8) => output.push_str("i8"), - ty::Int(ast::IntTy::I16) => output.push_str("i16"), - ty::Int(ast::IntTy::I32) => output.push_str("i32"), - ty::Int(ast::IntTy::I64) => output.push_str("i64"), - ty::Int(ast::IntTy::I128) => output.push_str("i128"), - ty::Uint(ast::UintTy::Usize) => output.push_str("usize"), - ty::Uint(ast::UintTy::U8) => output.push_str("u8"), - ty::Uint(ast::UintTy::U16) => output.push_str("u16"), - ty::Uint(ast::UintTy::U32) => output.push_str("u32"), - ty::Uint(ast::UintTy::U64) => output.push_str("u64"), - ty::Uint(ast::UintTy::U128) => output.push_str("u128"), - ty::Float(ast::FloatTy::F32) => output.push_str("f32"), - ty::Float(ast::FloatTy::F64) => output.push_str("f64"), + ty::Int(ty) => output.push_str(ty.name_str()), + ty::Uint(ty) => output.push_str(ty.name_str()), + ty::Float(ty) => output.push_str(ty.name_str()), ty::Adt(adt_def, substs) => { self.push_def_path(adt_def.did, output); self.push_generic_params(substs, iter::empty(), output, debug); diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index 8a98a5d83615f..4d1fece2cb9c9 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -466,9 +466,9 @@ pub trait PrettyPrinter<'tcx>: match ty.kind { ty::Bool => p!(write("bool")), ty::Char => p!(write("char")), - ty::Int(t) => p!(write("{}", t.ty_to_string())), - ty::Uint(t) => p!(write("{}", t.ty_to_string())), - ty::Float(t) => p!(write("{}", t.ty_to_string())), + ty::Int(t) => p!(write("{}", t.name_str())), + ty::Uint(t) => p!(write("{}", t.name_str())), + ty::Float(t) => p!(write("{}", t.name_str())), ty::RawPtr(ref tm) => { p!(write("*{} ", match tm.mutbl { hir::MutMutable => "mut", @@ -895,10 +895,11 @@ pub trait PrettyPrinter<'tcx>: let bit_size = Integer::from_attr(&self.tcx(), UnsignedInt(*ui)).size(); let max = truncate(u128::max_value(), bit_size); + let ui_str = ui.name_str(); if data == max { - p!(write("std::{}::MAX", ui)) + p!(write("std::{}::MAX", ui_str)) } else { - p!(write("{}{}", data, ui)) + p!(write("{}{}", data, ui_str)) }; }, (ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Int(i)) => { @@ -911,10 +912,11 @@ pub trait PrettyPrinter<'tcx>: let size = self.tcx().layout_of(ty::ParamEnv::empty().and(ty)) .unwrap() .size; + let i_str = i.name_str(); match data { - d if d == min => p!(write("std::{}::MIN", i)), - d if d == max => p!(write("std::{}::MAX", i)), - _ => p!(write("{}{}", sign_extend(data, size) as i128, i)) + d if d == min => p!(write("std::{}::MIN", i_str)), + d if d == max => p!(write("std::{}::MAX", i_str)), + _ => p!(write("{}{}", sign_extend(data, size) as i128, i_str)) } }, (ConstValue::Scalar(Scalar::Raw { data, .. }), ty::Char) => diff --git a/src/librustc_codegen_llvm/debuginfo/metadata.rs b/src/librustc_codegen_llvm/debuginfo/metadata.rs index f0148a21ae670..5f18bb1700c14 100644 --- a/src/librustc_codegen_llvm/debuginfo/metadata.rs +++ b/src/librustc_codegen_llvm/debuginfo/metadata.rs @@ -843,13 +843,13 @@ fn basic_type_metadata(cx: &CodegenCx<'ll, 'tcx>, t: Ty<'tcx>) -> &'ll DIType { ty::Bool => ("bool", DW_ATE_boolean), ty::Char => ("char", DW_ATE_unsigned_char), ty::Int(int_ty) => { - (int_ty.ty_to_string(), DW_ATE_signed) + (int_ty.name_str(), DW_ATE_signed) }, ty::Uint(uint_ty) => { - (uint_ty.ty_to_string(), DW_ATE_unsigned) + (uint_ty.name_str(), DW_ATE_unsigned) }, ty::Float(float_ty) => { - (float_ty.ty_to_string(), DW_ATE_float) + (float_ty.name_str(), DW_ATE_float) }, _ => bug!("debuginfo::basic_type_metadata - t is invalid type") }; diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 1bce34abe5599..a4c3b42f51e9e 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -18,8 +18,8 @@ use rustc::ty::layout::{self, LayoutOf, HasTyCtxt, Primitive}; use rustc::mir::interpret::GlobalId; use rustc_codegen_ssa::common::{IntPredicate, TypeKind}; use rustc::hir; -use syntax::ast::{self, FloatTy}; -use rustc_target::abi::HasDataLayout; +use rustc_target::abi::{FloatTy, HasDataLayout}; +use syntax::ast; use rustc_codegen_ssa::common::span_invalid_monomorphization_error; use rustc_codegen_ssa::traits::*; @@ -1335,7 +1335,7 @@ fn generic_simd_intrinsic( }, ty::Float(f) => { return_error!("unsupported element type `{}` of floating-point vector `{}`", - f, in_ty); + f.name_str(), in_ty); }, _ => { return_error!("`{}` is not a floating-point type", in_ty); diff --git a/src/librustc_codegen_ssa/debuginfo/type_names.rs b/src/librustc_codegen_ssa/debuginfo/type_names.rs index 166a74fe48795..372aefacb95f2 100644 --- a/src/librustc_codegen_ssa/debuginfo/type_names.rs +++ b/src/librustc_codegen_ssa/debuginfo/type_names.rs @@ -37,9 +37,9 @@ pub fn push_debuginfo_type_name<'tcx>( ty::Char => output.push_str("char"), ty::Str => output.push_str("str"), ty::Never => output.push_str("!"), - ty::Int(int_ty) => output.push_str(int_ty.ty_to_string()), - ty::Uint(uint_ty) => output.push_str(uint_ty.ty_to_string()), - ty::Float(float_ty) => output.push_str(float_ty.ty_to_string()), + ty::Int(int_ty) => output.push_str(int_ty.name_str()), + ty::Uint(uint_ty) => output.push_str(uint_ty.name_str()), + ty::Float(float_ty) => output.push_str(float_ty.name_str()), ty::Foreign(def_id) => push_item_name(tcx, def_id, qualified, output), ty::Adt(def, substs) => { push_item_name(tcx, def.did, qualified, output); diff --git a/src/librustc_interface/Cargo.toml b/src/librustc_interface/Cargo.toml index 98e4f974a9f23..35b93db1d6590 100644 --- a/src/librustc_interface/Cargo.toml +++ b/src/librustc_interface/Cargo.toml @@ -27,7 +27,6 @@ rustc_codegen_utils = { path = "../librustc_codegen_utils" } rustc_metadata = { path = "../librustc_metadata" } rustc_mir = { path = "../librustc_mir" } rustc_passes = { path = "../librustc_passes" } -rustc_target = { path = "../librustc_target" } rustc_typeck = { path = "../librustc_typeck" } rustc_lint = { path = "../librustc_lint" } rustc_errors = { path = "../librustc_errors" } @@ -36,3 +35,6 @@ rustc_privacy = { path = "../librustc_privacy" } rustc_resolve = { path = "../librustc_resolve" } tempfile = "3.0.5" once_cell = "1" + +[dev-dependencies] +rustc_target = { path = "../librustc_target" } diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index f2ad400d5dd37..65e0940920bd7 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -68,7 +68,7 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>( max: u128, expr: &'tcx hir::Expr, parent_expr: &'tcx hir::Expr, - ty: impl std::fmt::Debug, + ty: &str, ) -> bool { // We only want to handle exclusive (`..`) ranges, // which are represented as `ExprKind::Struct`. @@ -83,15 +83,15 @@ fn lint_overflowing_range_endpoint<'a, 'tcx>( let mut err = cx.struct_span_lint( OVERFLOWING_LITERALS, parent_expr.span, - &format!("range endpoint is out of range for `{:?}`", ty), + &format!("range endpoint is out of range for `{}`", ty), ); if let Ok(start) = cx.sess().source_map().span_to_snippet(eps[0].span) { use ast::{LitKind, LitIntType}; // We need to preserve the literal's suffix, // as it may determine typing information. let suffix = match lit.node { - LitKind::Int(_, LitIntType::Signed(s)) => format!("{}", s), - LitKind::Int(_, LitIntType::Unsigned(s)) => format!("{}", s), + LitKind::Int(_, LitIntType::Signed(s)) => format!("{}", s.name_str()), + LitKind::Int(_, LitIntType::Unsigned(s)) => format!("{}", s.name_str()), LitKind::Int(_, LitIntType::Unsuffixed) => "".to_owned(), _ => bug!(), }; @@ -161,11 +161,11 @@ fn report_bin_hex_error( let (t, actually) = match ty { attr::IntType::SignedInt(t) => { let actually = sign_extend(val, size) as i128; - (format!("{:?}", t), actually.to_string()) + (t.name_str(), actually.to_string()) } attr::IntType::UnsignedInt(t) => { let actually = truncate(val, size); - (format!("{:?}", t), actually.to_string()) + (t.name_str(), actually.to_string()) } }; let mut err = cx.struct_span_lint( @@ -204,7 +204,7 @@ fn report_bin_hex_error( // - `uX` => `uY` // // No suggestion for: `isize`, `usize`. -fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option { +fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option<&'static str> { use syntax::ast::IntTy::*; use syntax::ast::UintTy::*; macro_rules! find_fit { @@ -215,10 +215,10 @@ fn get_type_suggestion(t: Ty<'_>, val: u128, negative: bool) -> Option { match $ty { $($type => { $(if !negative && val <= uint_ty_range($utypes).1 { - return Some(format!("{:?}", $utypes)) + return Some($utypes.name_str()) })* $(if val <= int_ty_range($itypes).1 as u128 + _neg { - return Some(format!("{:?}", $itypes)) + return Some($itypes.name_str()) })* None },)+ @@ -281,7 +281,7 @@ fn lint_int_literal<'a, 'tcx>( if let Node::Expr(par_e) = cx.tcx.hir().get(par_id) { if let hir::ExprKind::Struct(..) = par_e.kind { if is_range_literal(cx.sess(), par_e) - && lint_overflowing_range_endpoint(cx, lit, v, max, e, par_e, t) + && lint_overflowing_range_endpoint(cx, lit, v, max, e, par_e, t.name_str()) { // The overflowing literal lint was overridden. return; @@ -292,7 +292,7 @@ fn lint_int_literal<'a, 'tcx>( cx.span_lint( OVERFLOWING_LITERALS, e.span, - &format!("literal out of range for `{:?}`", t), + &format!("literal out of range for `{}`", t.name_str()), ); } } @@ -338,6 +338,7 @@ fn lint_uint_literal<'a, 'tcx>( } hir::ExprKind::Struct(..) if is_range_literal(cx.sess(), par_e) => { + let t = t.name_str(); if lint_overflowing_range_endpoint(cx, lit, lit_val, max, e, par_e, t) { // The overflowing literal lint was overridden. return; @@ -353,7 +354,7 @@ fn lint_uint_literal<'a, 'tcx>( cx.span_lint( OVERFLOWING_LITERALS, e.span, - &format!("literal out of range for `{:?}`", t), + &format!("literal out of range for `{}`", t.name_str()), ); } } @@ -379,8 +380,7 @@ fn lint_literal<'a, 'tcx>( } ty::Float(t) => { let is_infinite = match lit.node { - ast::LitKind::Float(v, _) | - ast::LitKind::FloatUnsuffixed(v) => { + ast::LitKind::Float(v, _) => { match t { ast::FloatTy::F32 => v.as_str().parse().map(f32::is_infinite), ast::FloatTy::F64 => v.as_str().parse().map(f64::is_infinite), @@ -389,9 +389,11 @@ fn lint_literal<'a, 'tcx>( _ => bug!(), }; if is_infinite == Ok(true) { - cx.span_lint(OVERFLOWING_LITERALS, - e.span, - &format!("literal out of range for `{:?}`", t)); + cx.span_lint( + OVERFLOWING_LITERALS, + e.span, + &format!("literal out of range for `{}`", t.name_str()), + ); } } _ => {} diff --git a/src/librustc_mir/hair/constant.rs b/src/librustc_mir/hair/constant.rs index 956716f8ceaf7..b9e75a576cad8 100644 --- a/src/librustc_mir/hair/constant.rs +++ b/src/librustc_mir/hair/constant.rs @@ -45,10 +45,7 @@ crate fn lit_to_const<'tcx>( trunc(n as u128)? }, LitKind::Int(n, _) => trunc(n)?, - LitKind::Float(n, fty) => { - parse_float(n, fty, neg).map_err(|_| LitToConstError::UnparseableFloat)? - } - LitKind::FloatUnsuffixed(n) => { + LitKind::Float(n, _) => { let fty = match ty.kind { ty::Float(fty) => fty, _ => bug!() diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml index b89c83d630b7d..2d93585e50ee4 100644 --- a/src/librustc_save_analysis/Cargo.toml +++ b/src/librustc_save_analysis/Cargo.toml @@ -13,7 +13,6 @@ log = "0.4" rustc = { path = "../librustc" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_codegen_utils = { path = "../librustc_codegen_utils" } -rustc_target = { path = "../librustc_target" } serde_json = "1" syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } diff --git a/src/librustc_save_analysis/sig.rs b/src/librustc_save_analysis/sig.rs index 203bd4d4167e2..019e92717b5d6 100644 --- a/src/librustc_save_analysis/sig.rs +++ b/src/librustc_save_analysis/sig.rs @@ -32,7 +32,7 @@ use rls_data::{SigElement, Signature}; use rustc::hir::def::{Res, DefKind}; use syntax::ast::{self, NodeId}; use syntax::print::pprust; - +use syntax_pos::sym; pub fn item_signature(item: &ast::Item, scx: &SaveContext<'_, '_>) -> Option { if !scx.config.signatures { @@ -157,6 +157,12 @@ fn text_sig(text: String) -> Signature { } } +fn push_abi(text: &mut String, abi: ast::Abi) { + if abi.symbol != sym::Rust { + text.push_str(&format!("extern \"{}\" ", abi.symbol)); + } +} + impl Sig for ast::Ty { fn make(&self, offset: usize, _parent_id: Option, scx: &SaveContext<'_, '_>) -> Result { let id = Some(self.id); @@ -231,11 +237,7 @@ impl Sig for ast::Ty { if f.unsafety == ast::Unsafety::Unsafe { text.push_str("unsafe "); } - if f.abi != rustc_target::spec::abi::Abi::Rust { - text.push_str("extern"); - text.push_str(&f.abi.to_string()); - text.push(' '); - } + push_abi(&mut text, f.abi); text.push_str("fn("); let mut defs = vec![]; @@ -385,11 +387,7 @@ impl Sig for ast::Item { if header.unsafety == ast::Unsafety::Unsafe { text.push_str("unsafe "); } - if header.abi != rustc_target::spec::abi::Abi::Rust { - text.push_str("extern"); - text.push_str(&header.abi.to_string()); - text.push(' '); - } + push_abi(&mut text, header.abi); text.push_str("fn "); let mut sig = name_and_generics(text, offset, generics, self.id, self.ident, scx)?; @@ -948,11 +946,7 @@ fn make_method_signature( if m.header.unsafety == ast::Unsafety::Unsafe { text.push_str("unsafe "); } - if m.header.abi != rustc_target::spec::abi::Abi::Rust { - text.push_str("extern"); - text.push_str(&m.header.abi.to_string()); - text.push(' '); - } + push_abi(&mut text, m.header.abi); text.push_str("fn "); let mut sig = name_and_generics(text, 0, generics, id, ident, scx)?; diff --git a/src/librustc_target/abi/mod.rs b/src/librustc_target/abi/mod.rs index fde5c5bed4d91..e58caed0c99dd 100644 --- a/src/librustc_target/abi/mod.rs +++ b/src/librustc_target/abi/mod.rs @@ -3,11 +3,9 @@ pub use Primitive::*; use crate::spec::Target; -use std::fmt; use std::ops::{Add, Deref, Sub, Mul, AddAssign, Range, RangeInclusive}; use rustc_index::vec::{Idx, IndexVec}; -use syntax_pos::symbol::{sym, Symbol}; use syntax_pos::Span; pub mod call; @@ -534,49 +532,13 @@ impl Integer { } } - #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy, - PartialOrd, Ord)] + PartialOrd, Ord, Debug)] pub enum FloatTy { F32, F64, } -impl fmt::Debug for FloatTy { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(self, f) - } -} - -impl fmt::Display for FloatTy { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.ty_to_string()) - } -} - -impl FloatTy { - pub fn ty_to_string(self) -> &'static str { - match self { - FloatTy::F32 => "f32", - FloatTy::F64 => "f64", - } - } - - pub fn to_symbol(self) -> Symbol { - match self { - FloatTy::F32 => sym::f32, - FloatTy::F64 => sym::f64, - } - } - - pub fn bit_width(self) -> usize { - match self { - FloatTy::F32 => 32, - FloatTy::F64 => 64, - } - } -} - /// Fundamental unit of memory access and layout. #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)] pub enum Primitive { diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 26f040810462f..a297a0b014f61 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -3660,8 +3660,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { }); opt_ty.unwrap_or_else(|| self.next_int_var()) } - ast::LitKind::Float(_, t) => tcx.mk_mach_float(t), - ast::LitKind::FloatUnsuffixed(_) => { + ast::LitKind::Float(_, ast::LitFloatType::Suffixed(t)) => tcx.mk_mach_float(t), + ast::LitKind::Float(_, ast::LitFloatType::Unsuffixed) => { let opt_ty = expected.to_option(self).and_then(|ty| { match ty.kind { ty::Float(_) => Some(ty), diff --git a/src/libsyntax/Cargo.toml b/src/libsyntax/Cargo.toml index b1839cc05cd1f..3e17e7949ea99 100644 --- a/src/libsyntax/Cargo.toml +++ b/src/libsyntax/Cargo.toml @@ -20,5 +20,4 @@ errors = { path = "../librustc_errors", package = "rustc_errors" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_index = { path = "../librustc_index" } rustc_lexer = { path = "../librustc_lexer" } -rustc_target = { path = "../librustc_target" } smallvec = { version = "1.0", features = ["union", "may_dangle"] } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 2392b809150d4..67d1acbccfbe5 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -22,7 +22,6 @@ pub use GenericArgs::*; pub use UnsafeSource::*; pub use crate::util::parser::ExprPrecedence; -pub use rustc_target::abi::FloatTy; pub use syntax_pos::symbol::{Ident, Symbol as Name}; use crate::parse::token::{self, DelimToken}; @@ -38,7 +37,6 @@ use rustc_data_structures::sync::Lrc; use rustc_data_structures::thin_vec::ThinVec; use rustc_index::vec::Idx; use rustc_serialize::{self, Decoder, Encoder}; -use rustc_target::spec::abi::Abi; #[cfg(target_arch = "x86_64")] use rustc_data_structures::static_assert_size; @@ -1401,7 +1399,7 @@ pub struct Lit { // Clippy uses Hash and PartialEq /// Type of the integer literal based on provided suffix. -#[derive(Clone, RustcEncodable, RustcDecodable, Debug, Copy, Hash, PartialEq)] +#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)] pub enum LitIntType { /// e.g. `42_i32`. Signed(IntTy), @@ -1411,6 +1409,15 @@ pub enum LitIntType { Unsuffixed, } +/// Type of the float literal based on provided suffix. +#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, Hash, PartialEq)] +pub enum LitFloatType { + /// A float literal with a suffix (`1f32` or `1E10f32`). + Suffixed(FloatTy), + /// A float literal without a suffix (`1.0 or 1.0E10`). + Unsuffixed, +} + /// Literal kind. /// /// E.g., `"foo"`, `42`, `12.34`, or `bool`. @@ -1428,9 +1435,7 @@ pub enum LitKind { /// An integer literal (`1`). Int(u128, LitIntType), /// A float literal (`1f64` or `1E10f64`). - Float(Symbol, FloatTy), - /// A float literal without a suffix (`1.0 or 1.0E10`). - FloatUnsuffixed(Symbol), + Float(Symbol, LitFloatType), /// A boolean literal. Bool(bool), /// Placeholder for a literal that wasn't well-formed in some way. @@ -1457,7 +1462,7 @@ impl LitKind { /// Returns `true` if this is a numeric literal. pub fn is_numeric(&self) -> bool { match *self { - LitKind::Int(..) | LitKind::Float(..) | LitKind::FloatUnsuffixed(..) => true, + LitKind::Int(..) | LitKind::Float(..) => true, _ => false, } } @@ -1474,14 +1479,14 @@ impl LitKind { // suffixed variants LitKind::Int(_, LitIntType::Signed(..)) | LitKind::Int(_, LitIntType::Unsigned(..)) - | LitKind::Float(..) => true, + | LitKind::Float(_, LitFloatType::Suffixed(..)) => true, // unsuffixed variants LitKind::Str(..) | LitKind::ByteStr(..) | LitKind::Byte(..) | LitKind::Char(..) | LitKind::Int(_, LitIntType::Unsuffixed) - | LitKind::FloatUnsuffixed(..) + | LitKind::Float(_, LitFloatType::Unsuffixed) | LitKind::Bool(..) | LitKind::Err(..) => false, } @@ -1553,7 +1558,36 @@ pub enum ImplItemKind { Macro(Mac), } -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Copy)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)] +pub enum FloatTy { + F32, + F64, +} + +impl FloatTy { + pub fn name_str(self) -> &'static str { + match self { + FloatTy::F32 => "f32", + FloatTy::F64 => "f64", + } + } + + pub fn name(self) -> Symbol { + match self { + FloatTy::F32 => sym::f32, + FloatTy::F64 => sym::f64, + } + } + + pub fn bit_width(self) -> usize { + match self { + FloatTy::F32 => 32, + FloatTy::F64 => 64, + } + } +} + +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Debug)] pub enum IntTy { Isize, I8, @@ -1563,20 +1597,8 @@ pub enum IntTy { I128, } -impl fmt::Debug for IntTy { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(self, f) - } -} - -impl fmt::Display for IntTy { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.ty_to_string()) - } -} - impl IntTy { - pub fn ty_to_string(&self) -> &'static str { + pub fn name_str(&self) -> &'static str { match *self { IntTy::Isize => "isize", IntTy::I8 => "i8", @@ -1587,7 +1609,7 @@ impl IntTy { } } - pub fn to_symbol(&self) -> Symbol { + pub fn name(&self) -> Symbol { match *self { IntTy::Isize => sym::isize, IntTy::I8 => sym::i8, @@ -1602,7 +1624,7 @@ impl IntTy { // Cast to a `u128` so we can correctly print `INT128_MIN`. All integral types // are parsed as `u128`, so we wouldn't want to print an extra negative // sign. - format!("{}{}", val as u128, self.ty_to_string()) + format!("{}{}", val as u128, self.name_str()) } pub fn bit_width(&self) -> Option { @@ -1617,7 +1639,7 @@ impl IntTy { } } -#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Copy)] +#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, RustcEncodable, RustcDecodable, Copy, Debug)] pub enum UintTy { Usize, U8, @@ -1628,7 +1650,7 @@ pub enum UintTy { } impl UintTy { - pub fn ty_to_string(&self) -> &'static str { + pub fn name_str(&self) -> &'static str { match *self { UintTy::Usize => "usize", UintTy::U8 => "u8", @@ -1639,7 +1661,7 @@ impl UintTy { } } - pub fn to_symbol(&self) -> Symbol { + pub fn name(&self) -> Symbol { match *self { UintTy::Usize => sym::usize, UintTy::U8 => sym::u8, @@ -1651,7 +1673,7 @@ impl UintTy { } pub fn val_to_string(&self, val: u128) -> String { - format!("{}{}", val, self.ty_to_string()) + format!("{}{}", val, self.name_str()) } pub fn bit_width(&self) -> Option { @@ -1666,18 +1688,6 @@ impl UintTy { } } -impl fmt::Debug for UintTy { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt::Display::fmt(self, f) - } -} - -impl fmt::Display for UintTy { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{}", self.ty_to_string()) - } -} - /// A constraint on an associated type (e.g., `A = Bar` in `Foo` or /// `A: TraitA + TraitB` in `Foo`). #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] @@ -2358,6 +2368,27 @@ impl Item { } } +/// A reference to an ABI. +/// +/// In AST our notion of an ABI is still syntactic unlike in `rustc_target::spec::abi::Abi`. +#[derive(Clone, Copy, RustcEncodable, RustcDecodable, Debug, PartialEq)] +pub struct Abi { + pub symbol: Symbol, + pub span: Span, +} + +impl Abi { + pub fn new(symbol: Symbol, span: Span) -> Self { + Self { symbol, span } + } +} + +impl Default for Abi { + fn default() -> Self { + Self::new(sym::Rust, DUMMY_SP) + } +} + /// A function header. /// /// All the information between the visibility and the name of the function is @@ -2376,7 +2407,7 @@ impl Default for FnHeader { unsafety: Unsafety::Normal, asyncness: dummy_spanned(IsAsync::NotAsync), constness: dummy_spanned(Constness::NotConst), - abi: Abi::Rust, + abi: Abi::default(), } } } diff --git a/src/libsyntax/error_codes.rs b/src/libsyntax/error_codes.rs index 941df5ea57087..c23c8d65a7f23 100644 --- a/src/libsyntax/error_codes.rs +++ b/src/libsyntax/error_codes.rs @@ -540,6 +540,5 @@ equivalent in Rust would be to use macros directly. E0630, E0693, // incorrect `repr(align)` attribute format // E0694, // an unknown tool name found in scoped attributes - E0703, // invalid ABI E0717, // rustc_promotable without stability attribute } diff --git a/src/libsyntax/feature_gate/check.rs b/src/libsyntax/feature_gate/check.rs index b7e75ff3a7e38..213e96805246c 100644 --- a/src/libsyntax/feature_gate/check.rs +++ b/src/libsyntax/feature_gate/check.rs @@ -18,7 +18,6 @@ use crate::tokenstream::TokenTree; use errors::{Applicability, DiagnosticBuilder, Handler}; use rustc_data_structures::fx::FxHashMap; -use rustc_target::spec::abi::Abi; use syntax_pos::{Span, DUMMY_SP, MultiSpan}; use log::debug; @@ -192,62 +191,70 @@ macro_rules! gate_feature_post { } impl<'a> PostExpansionVisitor<'a> { - fn check_abi(&self, abi: Abi, span: Span) { - match abi { - Abi::RustIntrinsic => { + fn check_abi(&self, abi: ast::Abi) { + let ast::Abi { symbol, span } = abi; + + match &*symbol.as_str() { + // Stable + "Rust" | + "C" | + "cdecl" | + "stdcall" | + "fastcall" | + "aapcs" | + "win64" | + "sysv64" | + "system" => {} + "rust-intrinsic" => { gate_feature_post!(&self, intrinsics, span, "intrinsics are subject to change"); }, - Abi::PlatformIntrinsic => { + "platform-intrinsic" => { gate_feature_post!(&self, platform_intrinsics, span, "platform intrinsics are experimental and possibly buggy"); }, - Abi::Vectorcall => { + "vectorcall" => { gate_feature_post!(&self, abi_vectorcall, span, "vectorcall is experimental and subject to change"); }, - Abi::Thiscall => { + "thiscall" => { gate_feature_post!(&self, abi_thiscall, span, "thiscall is experimental and subject to change"); }, - Abi::RustCall => { + "rust-call" => { gate_feature_post!(&self, unboxed_closures, span, "rust-call ABI is subject to change"); }, - Abi::PtxKernel => { + "ptx-kernel" => { gate_feature_post!(&self, abi_ptx, span, "PTX ABIs are experimental and subject to change"); }, - Abi::Unadjusted => { + "unadjusted" => { gate_feature_post!(&self, abi_unadjusted, span, "unadjusted ABI is an implementation detail and perma-unstable"); }, - Abi::Msp430Interrupt => { + "msp430-interrupt" => { gate_feature_post!(&self, abi_msp430_interrupt, span, "msp430-interrupt ABI is experimental and subject to change"); }, - Abi::X86Interrupt => { + "x86-interrupt" => { gate_feature_post!(&self, abi_x86_interrupt, span, "x86-interrupt ABI is experimental and subject to change"); }, - Abi::AmdGpuKernel => { + "amdgpu-kernel" => { gate_feature_post!(&self, abi_amdgpu_kernel, span, "amdgpu-kernel ABI is experimental and subject to change"); }, - Abi::EfiApi => { + "efiapi" => { gate_feature_post!(&self, abi_efiapi, span, "efiapi ABI is experimental and subject to change"); }, - // Stable - Abi::Cdecl | - Abi::Stdcall | - Abi::Fastcall | - Abi::Aapcs | - Abi::Win64 | - Abi::SysV64 | - Abi::Rust | - Abi::C | - Abi::System => {} + abi => { + self.parse_sess.span_diagnostic.delay_span_bug( + span, + &format!("unrecognized ABI not caught in lowering: {}", abi), + ) + } } } @@ -373,7 +380,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { fn visit_item(&mut self, i: &'a ast::Item) { match i.kind { ast::ItemKind::ForeignMod(ref foreign_module) => { - self.check_abi(foreign_module.abi, i.span); + self.check_abi(foreign_module.abi); } ast::ItemKind::Fn(..) => { @@ -503,7 +510,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { fn visit_ty(&mut self, ty: &'a ast::Ty) { match ty.kind { ast::TyKind::BareFn(ref bare_fn_ty) => { - self.check_abi(bare_fn_ty.abi, ty.span); + self.check_abi(bare_fn_ty.abi); } ast::TyKind::Never => { gate_feature_post!(&self, never_type, ty.span, @@ -597,7 +604,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { // Stability of const fn methods are covered in // `visit_trait_item` and `visit_impl_item` below; this is // because default methods don't pass through this point. - self.check_abi(header.abi, span); + self.check_abi(header.abi); } if fn_decl.c_variadic() { @@ -631,7 +638,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { match ti.kind { ast::TraitItemKind::Method(ref sig, ref block) => { if block.is_none() { - self.check_abi(sig.header.abi, ti.span); + self.check_abi(sig.header.abi); } if sig.decl.c_variadic() { gate_feature_post!(&self, c_variadic, ti.span, diff --git a/src/libsyntax/parse/literal.rs b/src/libsyntax/parse/literal.rs index c42f4aa25cc96..a8eeac59954f1 100644 --- a/src/libsyntax/parse/literal.rs +++ b/src/libsyntax/parse/literal.rs @@ -157,17 +157,18 @@ impl LitKind { } LitKind::Int(n, ty) => { let suffix = match ty { - ast::LitIntType::Unsigned(ty) => Some(ty.to_symbol()), - ast::LitIntType::Signed(ty) => Some(ty.to_symbol()), + ast::LitIntType::Unsigned(ty) => Some(ty.name()), + ast::LitIntType::Signed(ty) => Some(ty.name()), ast::LitIntType::Unsuffixed => None, }; (token::Integer, sym::integer(n), suffix) } LitKind::Float(symbol, ty) => { - (token::Float, symbol, Some(ty.to_symbol())) - } - LitKind::FloatUnsuffixed(symbol) => { - (token::Float, symbol, None) + let suffix = match ty { + ast::LitFloatType::Suffixed(ty) => Some(ty.name()), + ast::LitFloatType::Unsuffixed => None, + }; + (token::Float, symbol, suffix) } LitKind::Bool(value) => { let symbol = if value { kw::True } else { kw::False }; @@ -244,12 +245,12 @@ fn filtered_float_lit(symbol: Symbol, suffix: Option, base: u32) return Err(LitError::NonDecimalFloat(base)); } Ok(match suffix { - Some(suf) => match suf { - sym::f32 => LitKind::Float(symbol, ast::FloatTy::F32), - sym::f64 => LitKind::Float(symbol, ast::FloatTy::F64), + Some(suf) => LitKind::Float(symbol, ast::LitFloatType::Suffixed(match suf { + sym::f32 => ast::FloatTy::F32, + sym::f64 => ast::FloatTy::F64, _ => return Err(LitError::InvalidFloatSuffix), - } - None => LitKind::FloatUnsuffixed(symbol) + })), + None => LitKind::Float(symbol, ast::LitFloatType::Unsuffixed) }) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7652c730e51b6..0c358b1caaf71 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -12,7 +12,7 @@ mod diagnostics; use diagnostics::Error; use crate::ast::{ - self, DUMMY_NODE_ID, AttrStyle, Attribute, CrateSugar, Ident, + self, Abi, DUMMY_NODE_ID, AttrStyle, Attribute, CrateSugar, Ident, IsAsync, MacDelimiter, Mutability, StrStyle, Visibility, VisibilityKind, Unsafety, }; use crate::parse::{PResult, Directory, DirectoryOwnership}; @@ -28,7 +28,6 @@ use crate::tokenstream::{self, DelimSpan, TokenTree, TokenStream, TreeAndJoint}; use crate::ThinVec; use errors::{Applicability, DiagnosticBuilder, DiagnosticId, FatalError}; -use rustc_target::spec::abi::{self, Abi}; use syntax_pos::{Span, BytePos, DUMMY_SP, FileName}; use log::debug; @@ -1206,48 +1205,41 @@ impl<'a> Parser<'a> { Ok(()) } - /// Parses `extern` followed by an optional ABI string, or nothing. + /// Parses `extern string_literal?`. + /// If `extern` is not found, the Rust ABI is used. + /// If `extern` is found and a `string_literal` does not follow, the C ABI is used. fn parse_extern_abi(&mut self) -> PResult<'a, Abi> { - if self.eat_keyword(kw::Extern) { - Ok(self.parse_opt_abi()?.unwrap_or(Abi::C)) + Ok(if self.eat_keyword(kw::Extern) { + self.parse_opt_abi()? } else { - Ok(Abi::Rust) - } + Abi::default() + }) } - /// Parses a string as an ABI spec on an extern type or module. Consumes - /// the `extern` keyword, if one is found. - fn parse_opt_abi(&mut self) -> PResult<'a, Option> { - match self.token.kind { - token::Literal(token::Lit { kind: token::Str, symbol, suffix }) | - token::Literal(token::Lit { kind: token::StrRaw(..), symbol, suffix }) => { - self.expect_no_suffix(self.token.span, "an ABI spec", suffix); - self.bump(); - match abi::lookup(&symbol.as_str()) { - Some(abi) => Ok(Some(abi)), - None => { - self.error_on_invalid_abi(symbol); - Ok(None) - } + /// Parses a string literal as an ABI spec. + /// If one is not found, the "C" ABI is used. + fn parse_opt_abi(&mut self) -> PResult<'a, Abi> { + let span = if self.token.can_begin_literal_or_bool() { + let ast::Lit { span, kind, .. } = self.parse_lit()?; + match kind { + ast::LitKind::Str(symbol, _) => return Ok(Abi::new(symbol, span)), + ast::LitKind::Err(_) => {} + _ => { + self.struct_span_err(span, "non-string ABI literal") + .span_suggestion( + span, + "specify the ABI with a string literal", + "\"C\"".to_string(), + Applicability::MaybeIncorrect, + ) + .emit(); } } - _ => Ok(None), - } - } - - /// Emit an error where `symbol` is an invalid ABI. - fn error_on_invalid_abi(&self, symbol: Symbol) { - let prev_span = self.prev_span; - struct_span_err!( - self.sess.span_diagnostic, - prev_span, - E0703, - "invalid ABI: found `{}`", - symbol - ) - .span_label(prev_span, "invalid ABI") - .help(&format!("valid ABIs: {}", abi::all_names().join(", "))) - .emit(); + span + } else { + self.prev_span + }; + Ok(Abi::new(sym::C, span)) } /// We are parsing `async fn`. If we are on Rust 2015, emit an error. diff --git a/src/libsyntax/parse/parser/expr.rs b/src/libsyntax/parse/parser/expr.rs index 97b1092452aaf..80ea8f380fbad 100644 --- a/src/libsyntax/parse/parser/expr.rs +++ b/src/libsyntax/parse/parser/expr.rs @@ -1116,7 +1116,11 @@ impl<'a> Parser<'a> { Err(self.span_fatal(token.span, &msg)) } Err(err) => { - let (lit, span) = (token.expect_lit(), token.span); + let span = token.span; + let lit = match token.kind { + token::Literal(lit) => lit, + _ => unreachable!(), + }; self.bump(); self.error_literal_from_token(err, lit, span); // Pack possible quotes and prefixes from the original literal into diff --git a/src/libsyntax/parse/parser/item.rs b/src/libsyntax/parse/parser/item.rs index cc6235c6fc772..ebb1cf129965e 100644 --- a/src/libsyntax/parse/parser/item.rs +++ b/src/libsyntax/parse/parser/item.rs @@ -3,7 +3,7 @@ use super::diagnostics::{Error, dummy_arg, ConsumeClosingDelim}; use crate::maybe_whole; use crate::ptr::P; -use crate::ast::{self, DUMMY_NODE_ID, Ident, Attribute, AttrKind, AttrStyle, AnonConst, Item}; +use crate::ast::{self, Abi, DUMMY_NODE_ID, Ident, Attribute, AttrKind, AttrStyle, AnonConst, Item}; use crate::ast::{ItemKind, ImplItem, ImplItemKind, TraitItem, TraitItemKind, UseTree, UseTreeKind}; use crate::ast::{PathSegment, IsAuto, Constness, IsAsync, Unsafety, Defaultness}; use crate::ast::{Visibility, VisibilityKind, Mutability, FnHeader, ForeignItem, ForeignItemKind}; @@ -17,7 +17,6 @@ use crate::ThinVec; use log::debug; use std::mem; -use rustc_target::spec::abi::Abi; use errors::{Applicability, DiagnosticBuilder, DiagnosticId, StashKey}; use syntax_pos::BytePos; @@ -111,7 +110,7 @@ impl<'a> Parser<'a> { return Ok(Some(self.parse_item_extern_crate(lo, vis, attrs)?)); } - let opt_abi = self.parse_opt_abi()?; + let abi = self.parse_opt_abi()?; if self.eat_keyword(kw::Fn) { // EXTERN FUNCTION ITEM @@ -120,12 +119,12 @@ impl<'a> Parser<'a> { unsafety: Unsafety::Normal, asyncness: respan(fn_span, IsAsync::NotAsync), constness: respan(fn_span, Constness::NotConst), - abi: opt_abi.unwrap_or(Abi::C), + abi, }; return self.parse_item_fn(lo, vis, attrs, header); } else if self.check(&token::OpenDelim(token::Brace)) { return Ok(Some( - self.parse_item_foreign_mod(lo, opt_abi, vis, attrs, extern_sp)?, + self.parse_item_foreign_mod(lo, abi, vis, attrs, extern_sp)?, )); } @@ -201,7 +200,7 @@ impl<'a> Parser<'a> { unsafety, asyncness, constness: respan(fn_span, Constness::NotConst), - abi: Abi::Rust, + abi: Abi::new(sym::Rust, fn_span), }; return self.parse_item_fn(lo, vis, attrs, header); } @@ -238,7 +237,7 @@ impl<'a> Parser<'a> { unsafety: Unsafety::Normal, asyncness: respan(fn_span, IsAsync::NotAsync), constness: respan(fn_span, Constness::NotConst), - abi: Abi::Rust, + abi: Abi::new(sym::Rust, fn_span), }; return self.parse_item_fn(lo, vis, attrs, header); } @@ -1115,15 +1114,13 @@ impl<'a> Parser<'a> { fn parse_item_foreign_mod( &mut self, lo: Span, - opt_abi: Option, + abi: Abi, visibility: Visibility, mut attrs: Vec, extern_sp: Span, ) -> PResult<'a, P> { self.expect(&token::OpenDelim(token::Brace))?; - let abi = opt_abi.unwrap_or(Abi::C); - attrs.extend(self.parse_inner_attributes()?); let mut foreign_items = vec![]; @@ -1801,7 +1798,7 @@ impl<'a> Parser<'a> { ) -> PResult<'a, Option>> { let (ident, decl, generics) = self.parse_fn_sig(ParamCfg { is_self_allowed: false, - allow_c_variadic: header.abi == Abi::C && header.unsafety == Unsafety::Unsafe, + allow_c_variadic: header.abi.symbol == sym::C && header.unsafety == Unsafety::Unsafe, is_name_required: |_| true, })?; let (inner_attrs, body) = self.parse_inner_attrs_and_block()?; @@ -1930,7 +1927,7 @@ impl<'a> Parser<'a> { let asyncness = respan(self.prev_span, asyncness); let unsafety = self.parse_unsafety(); let (constness, unsafety, abi) = if is_const_fn { - (respan(const_span, Constness::Const), unsafety, Abi::Rust) + (respan(const_span, Constness::Const), unsafety, Abi::default()) } else { let abi = self.parse_extern_abi()?; (respan(self.prev_span, Constness::NotConst), unsafety, abi) diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 03e77b199cc3b..6f3da344ccf88 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -381,9 +381,7 @@ impl Token { match self.kind { OpenDelim(Brace) => true, Interpolated(ref nt) => match **nt { - NtExpr(..) => true, - NtBlock(..) => true, - NtLiteral(..) => true, + NtExpr(..) | NtBlock(..) | NtLiteral(..) => true, _ => false, } _ => self.can_begin_literal_or_bool(), @@ -404,13 +402,6 @@ impl Token { } } - crate fn expect_lit(&self) -> Lit { - match self.kind { - Literal(lit) => lit, - _ => panic!("`expect_lit` called on non-literal"), - } - } - /// Returns `true` if the token is any literal, a minus (which can prefix a literal, /// for example a '-42', or one of the boolean idents). pub fn can_begin_literal_or_bool(&self) -> bool { diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index c8afe8a1ff459..1d59c13a9d081 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -14,7 +14,6 @@ use crate::sess::ParseSess; use crate::symbol::{kw, sym}; use crate::tokenstream::{self, TokenStream, TokenTree}; -use rustc_target::spec::abi::{self, Abi}; use syntax_pos::{self, BytePos}; use syntax_pos::{FileName, Span}; @@ -1230,7 +1229,7 @@ impl<'a> State<'a> { } ast::ItemKind::ForeignMod(ref nmod) => { self.head("extern"); - self.word_nbsp(nmod.abi.to_string()); + self.print_abi(nmod.abi); self.bopen(); self.print_foreign_mod(nmod, &item.attrs); self.bclose(item.span); @@ -2823,7 +2822,7 @@ impl<'a> State<'a> { } crate fn print_ty_fn(&mut self, - abi: abi::Abi, + abi: ast::Abi, unsafety: ast::Unsafety, decl: &ast::FnDecl, name: Option, @@ -2884,14 +2883,18 @@ impl<'a> State<'a> { self.print_asyncness(header.asyncness.node); self.print_unsafety(header.unsafety); - if header.abi != Abi::Rust { + if header.abi.symbol != sym::Rust { self.word_nbsp("extern"); - self.word_nbsp(header.abi.to_string()); + self.print_abi(header.abi); } self.s.word("fn") } + fn print_abi(&mut self, abi: ast::Abi) { + self.word_nbsp(format!("\"{}\"", abi.symbol)); + } + crate fn print_unsafety(&mut self, s: ast::Unsafety) { match s { ast::Unsafety::Normal => {}, diff --git a/src/libsyntax/print/pprust/tests.rs b/src/libsyntax/print/pprust/tests.rs index faa70edbfa29b..2c6dd0fb1c6dc 100644 --- a/src/libsyntax/print/pprust/tests.rs +++ b/src/libsyntax/print/pprust/tests.rs @@ -34,12 +34,7 @@ fn test_fun_to_string() { assert_eq!( fun_to_string( &decl, - ast::FnHeader { - unsafety: ast::Unsafety::Normal, - constness: source_map::dummy_spanned(ast::Constness::NotConst), - asyncness: source_map::dummy_spanned(ast::IsAsync::NotAsync), - abi: Abi::Rust, - }, + ast::FnHeader::default(), abba_ident, &generics ), diff --git a/src/libsyntax_expand/Cargo.toml b/src/libsyntax_expand/Cargo.toml index d98b9457a625f..02c711bc387e3 100644 --- a/src/libsyntax_expand/Cargo.toml +++ b/src/libsyntax_expand/Cargo.toml @@ -21,6 +21,5 @@ errors = { path = "../librustc_errors", package = "rustc_errors" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_index = { path = "../librustc_index" } rustc_lexer = { path = "../librustc_lexer" } -rustc_target = { path = "../librustc_target" } smallvec = { version = "1.0", features = ["union", "may_dangle"] } syntax = { path = "../libsyntax" } diff --git a/src/libsyntax_ext/concat.rs b/src/libsyntax_ext/concat.rs index 47bade698a80a..4bf13f3771102 100644 --- a/src/libsyntax_ext/concat.rs +++ b/src/libsyntax_ext/concat.rs @@ -21,8 +21,7 @@ pub fn expand_concat( match e.kind { ast::ExprKind::Lit(ref lit) => match lit.kind { ast::LitKind::Str(ref s, _) - | ast::LitKind::Float(ref s, _) - | ast::LitKind::FloatUnsuffixed(ref s) => { + | ast::LitKind::Float(ref s, _) => { accumulator.push_str(&s.as_str()); } ast::LitKind::Char(c) => { diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 2e5ae235893cb..b18fd50ae7605 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -182,8 +182,7 @@ use std::iter; use std::vec; use rustc_data_structures::thin_vec::ThinVec; -use rustc_target::spec::abi::Abi; -use syntax::ast::{self, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind}; +use syntax::ast::{self, Abi, BinOpKind, EnumDef, Expr, Generics, Ident, PatKind}; use syntax::ast::{VariantData, GenericParamKind, GenericArg}; use syntax::attr; use syntax::source_map::respan; @@ -738,7 +737,7 @@ impl<'a> TraitDef<'a> { self, type_ident, generics, - Abi::Rust, + sym::Rust, explicit_self, tys, body) @@ -793,7 +792,7 @@ impl<'a> TraitDef<'a> { self, type_ident, generics, - Abi::Rust, + sym::Rust, explicit_self, tys, body) @@ -919,7 +918,7 @@ impl<'a> MethodDef<'a> { trait_: &TraitDef<'_>, type_ident: Ident, generics: &Generics, - abi: Abi, + abi: Symbol, explicit_self: Option, arg_types: Vec<(Ident, P)>, body: P) @@ -949,23 +948,27 @@ impl<'a> MethodDef<'a> { ast::Unsafety::Normal }; + let trait_lo_sp = trait_.span.shrink_to_lo(); + + let sig = ast::MethodSig { + header: ast::FnHeader { + unsafety, + abi: Abi::new(abi, trait_lo_sp), + ..ast::FnHeader::default() + }, + decl: fn_decl, + }; + // Create the method. ast::ImplItem { id: ast::DUMMY_NODE_ID, attrs: self.attributes.clone(), generics: fn_generics, span: trait_.span, - vis: respan(trait_.span.shrink_to_lo(), ast::VisibilityKind::Inherited), + vis: respan(trait_lo_sp, ast::VisibilityKind::Inherited), defaultness: ast::Defaultness::Final, ident: method_ident, - kind: ast::ImplItemKind::Method(ast::MethodSig { - header: ast::FnHeader { - unsafety, abi, - ..ast::FnHeader::default() - }, - decl: fn_decl, - }, - body_block), + kind: ast::ImplItemKind::Method(sig, body_block), tokens: None, } } diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs index 3f7b3e5b3d82a..2bdd8eacd1175 100644 --- a/src/libsyntax_pos/symbol.rs +++ b/src/libsyntax_pos/symbol.rs @@ -563,6 +563,7 @@ symbols! { rust_2018_preview, rust_begin_unwind, rustc, + Rust, RustcDecodable, RustcEncodable, rustc_allocator, diff --git a/src/test/ui/feature-gated-feature-in-macro-arg.stderr b/src/test/ui/feature-gated-feature-in-macro-arg.stderr index 5ee05154c3a2a..218e0292776d0 100644 --- a/src/test/ui/feature-gated-feature-in-macro-arg.stderr +++ b/src/test/ui/feature-gated-feature-in-macro-arg.stderr @@ -1,10 +1,8 @@ error[E0658]: intrinsics are subject to change - --> $DIR/feature-gated-feature-in-macro-arg.rs:8:9 + --> $DIR/feature-gated-feature-in-macro-arg.rs:8:16 | -LL | / extern "rust-intrinsic" { -LL | | fn atomic_fence(); -LL | | } - | |_________^ +LL | extern "rust-intrinsic" { + | ^^^^^^^^^^^^^^^^ | = help: add `#![feature(intrinsics)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr b/src/test/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr index 0d2e355535dee..d58a2d91b2b7f 100644 --- a/src/test/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr +++ b/src/test/ui/feature-gates/feature-gate-abi-msp430-interrupt.stderr @@ -1,8 +1,8 @@ error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi-msp430-interrupt.rs:4:1 + --> $DIR/feature-gate-abi-msp430-interrupt.rs:4:8 | LL | extern "msp430-interrupt" fn foo() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38487 = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-abi.stderr b/src/test/ui/feature-gates/feature-gate-abi.stderr index 0f2622f106595..6db6cb49cef14 100644 --- a/src/test/ui/feature-gates/feature-gate-abi.stderr +++ b/src/test/ui/feature-gates/feature-gate-abi.stderr @@ -1,591 +1,591 @@ error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:13:1 + --> $DIR/feature-gate-abi.rs:13:8 | LL | extern "rust-intrinsic" fn f1() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:15:1 + --> $DIR/feature-gate-abi.rs:15:8 | LL | extern "platform-intrinsic" fn f2() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/27731 = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:17:1 + --> $DIR/feature-gate-abi.rs:17:8 | LL | extern "vectorcall" fn f3() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:18:1 + --> $DIR/feature-gate-abi.rs:18:8 | LL | extern "rust-call" fn f4() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:19:1 + --> $DIR/feature-gate-abi.rs:19:8 | LL | extern "msp430-interrupt" fn f5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38487 = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:20:1 + --> $DIR/feature-gate-abi.rs:20:8 | LL | extern "ptx-kernel" fn f6() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38788 = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:21:1 + --> $DIR/feature-gate-abi.rs:21:8 | LL | extern "x86-interrupt" fn f7() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/40180 = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:22:1 + --> $DIR/feature-gate-abi.rs:22:8 | LL | extern "thiscall" fn f8() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ | = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:23:1 + --> $DIR/feature-gate-abi.rs:23:8 | LL | extern "amdgpu-kernel" fn f9() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:24:1 + --> $DIR/feature-gate-abi.rs:24:8 | LL | extern "efiapi" fn f10() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:28:5 + --> $DIR/feature-gate-abi.rs:28:12 | LL | extern "rust-intrinsic" fn m1(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:30:5 + --> $DIR/feature-gate-abi.rs:30:12 | LL | extern "platform-intrinsic" fn m2(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/27731 = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:32:5 + --> $DIR/feature-gate-abi.rs:32:12 | LL | extern "vectorcall" fn m3(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:33:5 + --> $DIR/feature-gate-abi.rs:33:12 | LL | extern "rust-call" fn m4(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:34:5 + --> $DIR/feature-gate-abi.rs:34:12 | LL | extern "msp430-interrupt" fn m5(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38487 = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:35:5 + --> $DIR/feature-gate-abi.rs:35:12 | LL | extern "ptx-kernel" fn m6(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38788 = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:36:5 + --> $DIR/feature-gate-abi.rs:36:12 | LL | extern "x86-interrupt" fn m7(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/40180 = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:37:5 + --> $DIR/feature-gate-abi.rs:37:12 | LL | extern "thiscall" fn m8(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ | = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:38:5 + --> $DIR/feature-gate-abi.rs:38:12 | LL | extern "amdgpu-kernel" fn m9(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:39:5 + --> $DIR/feature-gate-abi.rs:39:12 | LL | extern "efiapi" fn m10(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:41:5 + --> $DIR/feature-gate-abi.rs:41:12 | LL | extern "vectorcall" fn dm3() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:42:5 + --> $DIR/feature-gate-abi.rs:42:12 | LL | extern "rust-call" fn dm4() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:43:5 + --> $DIR/feature-gate-abi.rs:43:12 | LL | extern "msp430-interrupt" fn dm5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38487 = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:44:5 + --> $DIR/feature-gate-abi.rs:44:12 | LL | extern "ptx-kernel" fn dm6() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38788 = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:45:5 + --> $DIR/feature-gate-abi.rs:45:12 | LL | extern "x86-interrupt" fn dm7() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/40180 = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:46:5 + --> $DIR/feature-gate-abi.rs:46:12 | LL | extern "thiscall" fn dm8() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ | = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:47:5 + --> $DIR/feature-gate-abi.rs:47:12 | LL | extern "amdgpu-kernel" fn dm9() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:48:5 + --> $DIR/feature-gate-abi.rs:48:12 | LL | extern "efiapi" fn dm10() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:55:5 + --> $DIR/feature-gate-abi.rs:55:12 | LL | extern "rust-intrinsic" fn m1() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:57:5 + --> $DIR/feature-gate-abi.rs:57:12 | LL | extern "platform-intrinsic" fn m2() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/27731 = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:59:5 + --> $DIR/feature-gate-abi.rs:59:12 | LL | extern "vectorcall" fn m3() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:60:5 + --> $DIR/feature-gate-abi.rs:60:12 | LL | extern "rust-call" fn m4() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:61:5 + --> $DIR/feature-gate-abi.rs:61:12 | LL | extern "msp430-interrupt" fn m5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38487 = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:62:5 + --> $DIR/feature-gate-abi.rs:62:12 | LL | extern "ptx-kernel" fn m6() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38788 = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:63:5 + --> $DIR/feature-gate-abi.rs:63:12 | LL | extern "x86-interrupt" fn m7() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/40180 = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:64:5 + --> $DIR/feature-gate-abi.rs:64:12 | LL | extern "thiscall" fn m8() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ | = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:65:5 + --> $DIR/feature-gate-abi.rs:65:12 | LL | extern "amdgpu-kernel" fn m9() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:66:5 + --> $DIR/feature-gate-abi.rs:66:12 | LL | extern "efiapi" fn m10() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:71:5 + --> $DIR/feature-gate-abi.rs:71:12 | LL | extern "rust-intrinsic" fn im1() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:73:5 + --> $DIR/feature-gate-abi.rs:73:12 | LL | extern "platform-intrinsic" fn im2() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/27731 = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:75:5 + --> $DIR/feature-gate-abi.rs:75:12 | LL | extern "vectorcall" fn im3() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:76:5 + --> $DIR/feature-gate-abi.rs:76:12 | LL | extern "rust-call" fn im4() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:77:5 + --> $DIR/feature-gate-abi.rs:77:12 | LL | extern "msp430-interrupt" fn im5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38487 = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:78:5 + --> $DIR/feature-gate-abi.rs:78:12 | LL | extern "ptx-kernel" fn im6() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38788 = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:79:5 + --> $DIR/feature-gate-abi.rs:79:12 | LL | extern "x86-interrupt" fn im7() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/40180 = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:80:5 + --> $DIR/feature-gate-abi.rs:80:12 | LL | extern "thiscall" fn im8() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ | = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:81:5 + --> $DIR/feature-gate-abi.rs:81:12 | LL | extern "amdgpu-kernel" fn im9() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:82:5 + --> $DIR/feature-gate-abi.rs:82:12 | LL | extern "efiapi" fn im10() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:86:11 + --> $DIR/feature-gate-abi.rs:86:18 | LL | type A1 = extern "rust-intrinsic" fn(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:87:11 + --> $DIR/feature-gate-abi.rs:87:18 | LL | type A2 = extern "platform-intrinsic" fn(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/27731 = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:88:11 + --> $DIR/feature-gate-abi.rs:88:18 | LL | type A3 = extern "vectorcall" fn(); - | ^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:89:11 + --> $DIR/feature-gate-abi.rs:89:18 | LL | type A4 = extern "rust-call" fn(); - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:90:11 + --> $DIR/feature-gate-abi.rs:90:18 | LL | type A5 = extern "msp430-interrupt" fn(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38487 = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:91:11 + --> $DIR/feature-gate-abi.rs:91:18 | LL | type A6 = extern "ptx-kernel" fn (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38788 = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:92:11 + --> $DIR/feature-gate-abi.rs:92:18 | LL | type A7 = extern "x86-interrupt" fn(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/40180 = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:93:11 + --> $DIR/feature-gate-abi.rs:93:18 | LL | type A8 = extern "thiscall" fn(); - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ | = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:94:11 + --> $DIR/feature-gate-abi.rs:94:18 | LL | type A9 = extern "amdgpu-kernel" fn(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:95:12 + --> $DIR/feature-gate-abi.rs:95:19 | LL | type A10 = extern "efiapi" fn(); - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-abi.rs:98:1 + --> $DIR/feature-gate-abi.rs:98:8 | LL | extern "rust-intrinsic" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: platform intrinsics are experimental and possibly buggy - --> $DIR/feature-gate-abi.rs:99:1 + --> $DIR/feature-gate-abi.rs:99:8 | LL | extern "platform-intrinsic" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/27731 = help: add `#![feature(platform_intrinsics)]` to the crate attributes to enable error[E0658]: vectorcall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:100:1 + --> $DIR/feature-gate-abi.rs:100:8 | LL | extern "vectorcall" {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = help: add `#![feature(abi_vectorcall)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-abi.rs:101:1 + --> $DIR/feature-gate-abi.rs:101:8 | LL | extern "rust-call" {} - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: msp430-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:102:1 + --> $DIR/feature-gate-abi.rs:102:8 | LL | extern "msp430-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38487 = help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable error[E0658]: PTX ABIs are experimental and subject to change - --> $DIR/feature-gate-abi.rs:103:1 + --> $DIR/feature-gate-abi.rs:103:8 | LL | extern "ptx-kernel" {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/38788 = help: add `#![feature(abi_ptx)]` to the crate attributes to enable error[E0658]: x86-interrupt ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:104:1 + --> $DIR/feature-gate-abi.rs:104:8 | LL | extern "x86-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/40180 = help: add `#![feature(abi_x86_interrupt)]` to the crate attributes to enable error[E0658]: thiscall is experimental and subject to change - --> $DIR/feature-gate-abi.rs:105:1 + --> $DIR/feature-gate-abi.rs:105:8 | LL | extern "thiscall" {} - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ | = help: add `#![feature(abi_thiscall)]` to the crate attributes to enable error[E0658]: amdgpu-kernel ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:106:1 + --> $DIR/feature-gate-abi.rs:106:8 | LL | extern "amdgpu-kernel" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/51575 = help: add `#![feature(abi_amdgpu_kernel)]` to the crate attributes to enable error[E0658]: efiapi ABI is experimental and subject to change - --> $DIR/feature-gate-abi.rs:107:1 + --> $DIR/feature-gate-abi.rs:107:8 | LL | extern "efiapi" {} - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/65815 = help: add `#![feature(abi_efiapi)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-abi_unadjusted.stderr b/src/test/ui/feature-gates/feature-gate-abi_unadjusted.stderr index 4954a7d1f71f6..1757befec35c0 100644 --- a/src/test/ui/feature-gates/feature-gate-abi_unadjusted.stderr +++ b/src/test/ui/feature-gates/feature-gate-abi_unadjusted.stderr @@ -1,10 +1,8 @@ error[E0658]: unadjusted ABI is an implementation detail and perma-unstable - --> $DIR/feature-gate-abi_unadjusted.rs:1:1 + --> $DIR/feature-gate-abi_unadjusted.rs:1:8 | -LL | / extern "unadjusted" fn foo() { -LL | | -LL | | } - | |_^ +LL | extern "unadjusted" fn foo() { + | ^^^^^^^^^^^^ | = help: add `#![feature(abi_unadjusted)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-intrinsics.stderr b/src/test/ui/feature-gates/feature-gate-intrinsics.stderr index 101a10e8df71f..8f943d357ce02 100644 --- a/src/test/ui/feature-gates/feature-gate-intrinsics.stderr +++ b/src/test/ui/feature-gates/feature-gate-intrinsics.stderr @@ -1,18 +1,16 @@ error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-intrinsics.rs:1:1 + --> $DIR/feature-gate-intrinsics.rs:1:8 | -LL | / extern "rust-intrinsic" { -LL | | fn bar(); -LL | | } - | |_^ +LL | extern "rust-intrinsic" { + | ^^^^^^^^^^^^^^^^ | = help: add `#![feature(intrinsics)]` to the crate attributes to enable error[E0658]: intrinsics are subject to change - --> $DIR/feature-gate-intrinsics.rs:5:1 + --> $DIR/feature-gate-intrinsics.rs:5:8 | LL | extern "rust-intrinsic" fn baz() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: add `#![feature(intrinsics)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr index c05379c71eeaf..657bf13c8739e 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -1,35 +1,35 @@ error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:11:5 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:11:12 | LL | extern "rust-call" fn call(self, args: ()) -> () {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:17:5 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:17:12 | LL | extern "rust-call" fn call_once(self, args: ()) -> () {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:23:5 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:23:12 | LL | extern "rust-call" fn call_mut(&self, args: ()) -> () {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:29:5 + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:29:12 | LL | extern "rust-call" fn call_once(&self, args: ()) -> () {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable diff --git a/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr b/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr index 723c6619887aa..f343a42eb8fa9 100644 --- a/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr +++ b/src/test/ui/feature-gates/feature-gate-unboxed-closures.stderr @@ -1,10 +1,8 @@ error[E0658]: rust-call ABI is subject to change - --> $DIR/feature-gate-unboxed-closures.rs:9:5 + --> $DIR/feature-gate-unboxed-closures.rs:9:12 | -LL | / extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { -LL | | a + b -LL | | } - | |_____^ +LL | extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { + | ^^^^^^^^^^^ | = note: for more information, see https://github.com/rust-lang/rust/issues/29625 = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable diff --git a/src/test/ui/parser/bad-lit-suffixes.rs b/src/test/ui/parser/bad-lit-suffixes.rs index 9f301db09956e..7db83674efc60 100644 --- a/src/test/ui/parser/bad-lit-suffixes.rs +++ b/src/test/ui/parser/bad-lit-suffixes.rs @@ -1,9 +1,9 @@ extern - "C"suffix //~ ERROR suffixes on an ABI spec are invalid + "C"suffix //~ ERROR suffixes on a string literal are invalid fn foo() {} extern - "C"suffix //~ ERROR suffixes on an ABI spec are invalid + "C"suffix //~ ERROR suffixes on a string literal are invalid {} fn main() { diff --git a/src/test/ui/parser/bad-lit-suffixes.stderr b/src/test/ui/parser/bad-lit-suffixes.stderr index 208fcf43d9177..6b0049298ffd2 100644 --- a/src/test/ui/parser/bad-lit-suffixes.stderr +++ b/src/test/ui/parser/bad-lit-suffixes.stderr @@ -1,10 +1,10 @@ -error: suffixes on an ABI spec are invalid +error: suffixes on a string literal are invalid --> $DIR/bad-lit-suffixes.rs:2:5 | LL | "C"suffix | ^^^^^^^^^ invalid suffix `suffix` -error: suffixes on an ABI spec are invalid +error: suffixes on a string literal are invalid --> $DIR/bad-lit-suffixes.rs:6:5 | LL | "C"suffix diff --git a/src/test/ui/parser/extern-abi-from-mac-literal-frag.rs b/src/test/ui/parser/extern-abi-from-mac-literal-frag.rs new file mode 100644 index 0000000000000..cb23f2c808c34 --- /dev/null +++ b/src/test/ui/parser/extern-abi-from-mac-literal-frag.rs @@ -0,0 +1,26 @@ +// check-pass + +// In this test we check that the parser accepts an ABI string when it +// comes from a macro `literal` fragment as opposed to a hardcoded string. + +fn main() {} + +macro_rules! abi_from_lit_frag { + ($abi:literal) => { + extern $abi { + fn _import(); + } + + extern $abi fn _export() {} + + type _PTR = extern $abi fn(); + } +} + +mod rust { + abi_from_lit_frag!("Rust"); +} + +mod c { + abi_from_lit_frag!("C"); +} diff --git a/src/test/ui/parser/extern-abi-raw-strings.rs b/src/test/ui/parser/extern-abi-raw-strings.rs new file mode 100644 index 0000000000000..fad855a21f6b1 --- /dev/null +++ b/src/test/ui/parser/extern-abi-raw-strings.rs @@ -0,0 +1,13 @@ +// check-pass + +// Check that the string literal in `extern lit` will accept raw strings. + +fn main() {} + +extern r#"C"# fn foo() {} + +extern r#"C"# { + fn bar(); +} + +type T = extern r#"C"# fn(); diff --git a/src/test/ui/parser/extern-abi-string-escaping.rs b/src/test/ui/parser/extern-abi-string-escaping.rs new file mode 100644 index 0000000000000..87bd31aabb67d --- /dev/null +++ b/src/test/ui/parser/extern-abi-string-escaping.rs @@ -0,0 +1,13 @@ +// check-pass + +// Check that the string literal in `extern lit` will escapes. + +fn main() {} + +extern "\x43" fn foo() {} + +extern "\x43" { + fn bar(); +} + +type T = extern "\x43" fn(); diff --git a/src/test/ui/parser/extern-abi-syntactic.rs b/src/test/ui/parser/extern-abi-syntactic.rs new file mode 100644 index 0000000000000..7d2bbfe8a0163 --- /dev/null +++ b/src/test/ui/parser/extern-abi-syntactic.rs @@ -0,0 +1,17 @@ +// check-pass + +// Check that from the grammar's point of view, +// the specific set of ABIs is not part of it. + +fn main() {} + +#[cfg(FALSE)] +extern "some_abi_that_we_are_sure_does_not_exist_semantically" fn foo() {} + +#[cfg(FALSE)] +extern "some_abi_that_we_are_sure_does_not_exist_semantically" { + fn foo(); +} + +#[cfg(FALSE)] +type T = extern "some_abi_that_we_are_sure_does_not_exist_semantically" fn();