diff --git a/compiler/rustc_builtin_macros/src/asm.rs b/compiler/rustc_builtin_macros/src/asm.rs index 2958686f86cd5..62a39d957b9c4 100644 --- a/compiler/rustc_builtin_macros/src/asm.rs +++ b/compiler/rustc_builtin_macros/src/asm.rs @@ -288,6 +288,18 @@ fn expand_preparsed_asm( let msg = "asm template must be a string literal"; let template_sp = template_expr.span; let template_is_mac_call = matches!(template_expr.kind, ast::ExprKind::MacCall(_)); + + // Gets the span inside `template_sp` corresponding to the given range + let span_in_template = |range: std::ops::Range| -> Span { + if template_is_mac_call { + // When the template is a macro call we can't reliably get inner spans + // so just use the entire template span (see ICEs #129503, #131292) + template_sp + } else { + template_sp.from_inner(InnerSpan::new(range.start, range.end)) + } + }; + let ExprToSpannedString { symbol: template_str, style: template_style, @@ -382,13 +394,8 @@ fn expand_preparsed_asm( if !parser.errors.is_empty() { let err = parser.errors.remove(0); - let err_sp = if template_is_mac_call { - // If the template is a macro call we can't reliably point to the error's - // span so just use the template's span as the error span (fixes #129503) - template_span - } else { - template_span.from_inner(InnerSpan::new(err.span.start, err.span.end)) - }; + + let err_sp = span_in_template(err.span); let msg = format!("invalid asm template string: {}", err.description); let mut e = ecx.dcx().struct_span_err(err_sp, msg); @@ -397,8 +404,7 @@ fn expand_preparsed_asm( e.note(note); } if let Some((label, span)) = err.secondary_label { - let err_sp = template_span.from_inner(InnerSpan::new(span.start, span.end)); - e.span_label(err_sp, label); + e.span_label(span_in_template(span), label); } let guar = e.emit(); return ExpandResult::Ready(Err(guar)); @@ -477,8 +483,7 @@ fn expand_preparsed_asm( ecx.dcx() .create_err(errors::AsmNoMatchedArgumentName { name: name.to_owned(), - span: template_span - .from_inner(InnerSpan::new(span.start, span.end)), + span: span_in_template(span), }) .emit(); None @@ -490,11 +495,7 @@ fn expand_preparsed_asm( let mut chars = arg.format.ty.chars(); let mut modifier = chars.next(); if chars.next().is_some() { - let span = arg - .format - .ty_span - .map(|sp| template_sp.from_inner(InnerSpan::new(sp.start, sp.end))) - .unwrap_or(template_sp); + let span = arg.format.ty_span.map(span_in_template).unwrap_or(template_sp); ecx.dcx().emit_err(errors::AsmModifierInvalid { span }); modifier = None; } diff --git a/compiler/rustc_builtin_macros/src/errors.rs b/compiler/rustc_builtin_macros/src/errors.rs index 43bade3c43ac1..1343c8ccf4a59 100644 --- a/compiler/rustc_builtin_macros/src/errors.rs +++ b/compiler/rustc_builtin_macros/src/errors.rs @@ -678,6 +678,18 @@ pub(crate) enum InvalidFormatStringSuggestion { #[primary_span] span: Span, }, + + #[suggestion( + "use rust debug printing macro", + code = "{replacement}", + style = "verbose", + applicability = "machine-applicable" + )] + UseRustDebugPrintingMacro { + #[primary_span] + macro_span: Span, + replacement: String, + }, } #[derive(Diagnostic)] diff --git a/compiler/rustc_builtin_macros/src/format.rs b/compiler/rustc_builtin_macros/src/format.rs index 12cb2cd00694d..f47dae5eba00a 100644 --- a/compiler/rustc_builtin_macros/src/format.rs +++ b/compiler/rustc_builtin_macros/src/format.rs @@ -160,6 +160,7 @@ fn make_format_args( ecx: &mut ExtCtxt<'_>, input: MacroInput, append_newline: bool, + macro_span: Span, ) -> ExpandResult, ()> { let msg = "format argument must be a string literal"; let unexpanded_fmt_span = input.fmtstr.span; @@ -333,6 +334,23 @@ fn make_format_args( let span = fmt_span.from_inner(InnerSpan::new(span.start, span.end)); e.sugg_ = Some(errors::InvalidFormatStringSuggestion::AddMissingColon { span }); } + parse::Suggestion::UseRustDebugPrintingMacro => { + // This targets `println!("{=}", x);` and `println!("{0=}", x);` + if let [arg] = args.all_args() { + let expr_span = arg.expr.span; + if let Ok(expr_snippet) = ecx.source_map().span_to_snippet(expr_span) { + let replacement = format!("{}!({})", "dbg", expr_snippet); + + let call_span = macro_span.source_callsite(); + e.sugg_ = Some( + errors::InvalidFormatStringSuggestion::UseRustDebugPrintingMacro { + macro_span: call_span, + replacement, + }, + ); + } + } + } } let guar = ecx.dcx().emit_err(e); return ExpandResult::Ready(Err(guar)); @@ -1048,7 +1066,7 @@ fn expand_format_args_impl<'cx>( sp = ecx.with_def_site_ctxt(sp); ExpandResult::Ready(match parse_args(ecx, sp, tts) { Ok(input) => { - let ExpandResult::Ready(mac) = make_format_args(ecx, input, nl) else { + let ExpandResult::Ready(mac) = make_format_args(ecx, input, nl, sp) else { return ExpandResult::Retry(()); }; match mac { diff --git a/compiler/rustc_parse/src/errors.rs b/compiler/rustc_parse/src/errors.rs index fb77af1c19485..6499f31bb935b 100644 --- a/compiler/rustc_parse/src/errors.rs +++ b/compiler/rustc_parse/src/errors.rs @@ -573,6 +573,24 @@ pub(crate) struct ExpectedExpressionFoundLet { pub comparison: Option, } +#[derive(Diagnostic)] +#[diag("let-chain with missing `let`")] +pub(crate) struct LetChainMissingLet { + #[primary_span] + pub span: Span, + #[label("expected `let` expression, found assignment")] + pub label_span: Span, + #[label("let expression later in the condition")] + pub rhs_span: Span, + #[suggestion( + "add `let` before the expression", + applicability = "maybe-incorrect", + code = "let ", + style = "verbose" + )] + pub sug_span: Span, +} + #[derive(Diagnostic)] #[diag("`||` operators are not supported in let chain conditions")] pub(crate) struct OrInLetChain { diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 8bb22c2a831bf..05216be06ff56 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -4282,7 +4282,52 @@ impl MutVisitor for CondChecker<'_> { mut_visit::walk_expr(self, e); self.forbid_let_reason = forbid_let_reason; } - ExprKind::Assign(ref lhs, _, span) => { + ExprKind::Assign(ref lhs, ref rhs, span) => { + if let ExprKind::Call(_, _) = &lhs.kind { + fn get_path_from_rhs(e: &Expr) -> Option<(u32, &Path)> { + fn inner(e: &Expr, depth: u32) -> Option<(u32, &Path)> { + match &e.kind { + ExprKind::Binary(_, lhs, _) => inner(lhs, depth + 1), + ExprKind::Path(_, path) => Some((depth, path)), + _ => None, + } + } + + inner(e, 0) + } + + if let Some((depth, path)) = get_path_from_rhs(rhs) { + // For cases like if Some(_) = x && let Some(_) = y && let Some(_) = z + // This return let Some(_) = y expression + fn find_let_some(expr: &Expr) -> Option<&Expr> { + match &expr.kind { + ExprKind::Let(..) => Some(expr), + + ExprKind::Binary(op, lhs, rhs) if op.node == BinOpKind::And => { + find_let_some(lhs).or_else(|| find_let_some(rhs)) + } + + _ => None, + } + } + + let expr_span = lhs.span.to(path.span); + + if let Some(later_rhs) = find_let_some(rhs) + && depth > 0 + { + let guar = self.parser.dcx().emit_err(errors::LetChainMissingLet { + span: lhs.span, + label_span: expr_span, + rhs_span: later_rhs.span, + sug_span: lhs.span.shrink_to_lo(), + }); + + self.found_incorrect_let_chain = Some(guar); + } + } + } + let forbid_let_reason = self.forbid_let_reason; self.forbid_let_reason = Some(errors::ForbiddenLetReason::OtherForbidden); let missing_let = self.missing_let; diff --git a/compiler/rustc_parse_format/src/lib.rs b/compiler/rustc_parse_format/src/lib.rs index 3d8b97b2fde38..2338268a874f0 100644 --- a/compiler/rustc_parse_format/src/lib.rs +++ b/compiler/rustc_parse_format/src/lib.rs @@ -187,6 +187,9 @@ pub enum Suggestion { /// Add missing colon: /// `format!("{foo?}")` -> `format!("{foo:?}")` AddMissingColon(Range), + /// Use Rust format string: + /// `format!("{x=}")` -> `dbg!(x)` + UseRustDebugPrintingMacro, } /// The parser structure for interpreting the input format string. This is @@ -462,6 +465,7 @@ impl<'input> Parser<'input> { ('?', _) => self.suggest_format_debug(), ('<' | '^' | '>', _) => self.suggest_format_align(c), (',', _) => self.suggest_unsupported_python_numeric_grouping(), + ('=', '}') => self.suggest_rust_debug_printing_macro(), _ => self.suggest_positional_arg_instead_of_captured_arg(arg), } } @@ -871,6 +875,27 @@ impl<'input> Parser<'input> { } } + fn suggest_rust_debug_printing_macro(&mut self) { + if let Some((range, _)) = self.consume_pos('=') { + self.errors.insert( + 0, + ParseError { + description: + "python's f-string debug `=` is not supported in rust, use `dbg(x)` instead" + .to_owned(), + note: Some(format!("to print `{{`, you can escape it using `{{{{`",)), + label: "expected `}`".to_owned(), + span: range, + secondary_label: self + .last_open_brace + .clone() + .map(|sp| ("because of this opening brace".to_owned(), sp)), + suggestion: Suggestion::UseRustDebugPrintingMacro, + }, + ); + } + } + fn suggest_format_align(&mut self, alignment: char) { if let Some((range, _)) = self.consume_pos(alignment) { self.errors.insert( diff --git a/compiler/rustc_target/src/callconv/x86_win64.rs b/compiler/rustc_target/src/callconv/x86_win64.rs index 48f7700a86d52..4026c4f471a7e 100644 --- a/compiler/rustc_target/src/callconv/x86_win64.rs +++ b/compiler/rustc_target/src/callconv/x86_win64.rs @@ -28,7 +28,7 @@ where BackendRepr::ScalableVector { .. } => panic!("scalable vectors are unsupported"), BackendRepr::Scalar(scalar) => { if is_ret && matches!(scalar.primitive(), Primitive::Int(Integer::I128, _)) { - if cx.target_spec().rustc_abi == Some(RustcAbi::X86Softfloat) { + if cx.target_spec().rustc_abi == Some(RustcAbi::Softfloat) { // Use the native `i128` LLVM type for the softfloat ABI -- in other words, adjust nothing. } else { // `i128` is returned in xmm0 by Clang and GCC diff --git a/compiler/rustc_target/src/lib.rs b/compiler/rustc_target/src/lib.rs index dfa1b23207189..1dc62cb3659cc 100644 --- a/compiler/rustc_target/src/lib.rs +++ b/compiler/rustc_target/src/lib.rs @@ -76,7 +76,7 @@ macro_rules! target_spec_enum { pub enum $Name:ident { $( $( #[$variant_attr:meta] )* - $Variant:ident = $string:literal, + $Variant:ident = $string:literal $(,$alias:literal)* , )* } parse_error_type = $parse_error_type:literal; @@ -88,6 +88,7 @@ macro_rules! target_spec_enum { $( $( #[$variant_attr] )* #[serde(rename = $string)] // for JSON schema generation only + $( #[serde(alias = $alias)] )* $Variant, )* } @@ -97,7 +98,10 @@ macro_rules! target_spec_enum { fn from_str(s: &str) -> Result { Ok(match s { - $( $string => Self::$Variant, )* + $( + $string => Self::$Variant, + $($alias => Self::$Variant,)* + )* _ => { let all = [$( concat!("'", $string, "'") ),*].join(", "); return Err(format!("invalid {}: '{s}'. allowed values: {all}", $parse_error_type)); @@ -123,7 +127,7 @@ macro_rules! target_spec_enum { pub enum $Name:ident { $( $( #[$variant_attr:meta] )* - $Variant:ident = $string:literal, + $Variant:ident = $string:literal $(,$alias:literal)* , )* } $( #[$other_variant_attr:meta] )* @@ -134,6 +138,7 @@ macro_rules! target_spec_enum { pub enum $Name { $( $( #[$variant_attr:meta] )* + $( #[serde(alias = $alias)] )* $Variant, )* /// The vast majority of the time, the compiler deals with a fixed @@ -165,7 +170,10 @@ macro_rules! target_spec_enum { fn from_str(s: &str) -> Result { Ok(match s { - $( $string => Self::$Variant, )* + $( + $string => Self::$Variant, + $($alias => Self::$Variant,)* + )* _ => Self::$OtherVariant(s.to_owned().into()), }) } diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 9799f3e50ae24..537185f536ab1 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1005,8 +1005,8 @@ crate::target_spec_enum! { pub enum RustcAbi { /// On x86-32 only: make use of SSE and SSE2 for ABI purposes. X86Sse2 = "x86-sse2", - /// On x86-32/64 only: do not use any FPU or SIMD registers for the ABI. - X86Softfloat = "x86-softfloat", + /// On x86-32/64 and S390x: do not use any FPU or SIMD registers for the ABI. + Softfloat = "softfloat", "x86-softfloat", } parse_error_type = "rustc abi"; @@ -1460,6 +1460,7 @@ supported_targets! { ("powerpc64le-unknown-linux-gnu", powerpc64le_unknown_linux_gnu), ("powerpc64le-unknown-linux-musl", powerpc64le_unknown_linux_musl), ("s390x-unknown-linux-gnu", s390x_unknown_linux_gnu), + ("s390x-unknown-none-softfloat", s390x_unknown_none_softfloat), ("s390x-unknown-linux-musl", s390x_unknown_linux_musl), ("sparc-unknown-linux-gnu", sparc_unknown_linux_gnu), ("sparc64-unknown-linux-gnu", sparc64_unknown_linux_gnu), @@ -3204,10 +3205,10 @@ impl Target { Arch::X86, "`x86-sse2` ABI is only valid for x86-32 targets" ), - RustcAbi::X86Softfloat => check_matches!( + RustcAbi::Softfloat => check_matches!( self.arch, - Arch::X86 | Arch::X86_64, - "`x86-softfloat` ABI is only valid for x86 targets" + Arch::X86 | Arch::X86_64 | Arch::S390x, + "`softfloat` ABI is only valid for x86 and s390x targets" ), } } diff --git a/compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs b/compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs index 37b202097b467..7696edd5ba719 100644 --- a/compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs +++ b/compiler/rustc_target/src/spec/targets/i686_unknown_uefi.rs @@ -22,7 +22,7 @@ pub(crate) fn target() -> Target { // If you initialize FP units yourself, you can override these flags with custom linker // arguments, thus giving you access to full MMX/SSE acceleration. base.features = "-mmx,-sse,+soft-float".into(); - base.rustc_abi = Some(RustcAbi::X86Softfloat); + base.rustc_abi = Some(RustcAbi::Softfloat); // Turn off DWARF. This fixes an lld warning, "section name .debug_frame is longer than 8 // characters and will use a non-standard string table". That section will not be created if diff --git a/compiler/rustc_target/src/spec/targets/s390x_unknown_none_softfloat.rs b/compiler/rustc_target/src/spec/targets/s390x_unknown_none_softfloat.rs new file mode 100644 index 0000000000000..7d42c1fd92440 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/s390x_unknown_none_softfloat.rs @@ -0,0 +1,39 @@ +use rustc_abi::{Align, Endian}; + +use crate::spec::{ + Abi, Arch, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, RustcAbi, SanitizerSet, + StackProbeType, Target, TargetMetadata, TargetOptions, +}; + +pub(crate) fn target() -> Target { + let opts = TargetOptions { + abi: Abi::SoftFloat, + cpu: "z10".into(), + endian: Endian::Big, + features: "+soft-float,-vector".into(), + linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), + linker: Some("rust-lld".into()), + max_atomic_width: Some(128), + min_global_align: Some(Align::from_bits(16).unwrap()), + panic_strategy: PanicStrategy::Abort, + relocation_model: RelocModel::Static, + rustc_abi: Some(RustcAbi::Softfloat), + stack_probes: StackProbeType::Inline, + supported_sanitizers: SanitizerSet::KERNELADDRESS, + ..Default::default() + }; + + Target { + llvm_target: "s390x-unknown-linux-gnu".into(), + metadata: TargetMetadata { + description: Some("S390x Linux".into()), + host_tools: Some(false), + std: Some(false), + tier: Some(2), + }, + arch: Arch::S390x, + data_layout: "E-S64-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64".into(), + options: opts, + pointer_width: 64, + } +} diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs index 520a59d6a6f6c..0afe7a0b68b0d 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_none.rs @@ -20,7 +20,7 @@ pub(crate) fn target() -> Target { relro_level: RelroLevel::Full, linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), linker: Some("rust-lld".into()), - rustc_abi: Some(RustcAbi::X86Softfloat), + rustc_abi: Some(RustcAbi::Softfloat), features: "-mmx,-sse,-sse2,-sse3,-ssse3,-sse4.1,-sse4.2,-avx,-avx2,+soft-float".into(), supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS, disable_redzone: true, diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs index 8a494d0e56dd3..333e20bd0ac19 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_uefi.rs @@ -27,7 +27,7 @@ pub(crate) fn target() -> Target { // If you initialize FP units yourself, you can override these flags with custom linker // arguments, thus giving you access to full MMX/SSE acceleration. base.features = "-mmx,-sse,+soft-float".into(); - base.rustc_abi = Some(RustcAbi::X86Softfloat); + base.rustc_abi = Some(RustcAbi::Softfloat); Target { llvm_target: "x86_64-unknown-windows".into(), diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index a8e9d2e9dcaab..36bf89ed4f35b 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -863,7 +863,7 @@ const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("miscellaneous-extensions-3", Stable, &[]), ("miscellaneous-extensions-4", Stable, &[]), ("nnp-assist", Stable, &["vector"]), - ("soft-float", Forbidden { reason: "currently unsupported ABI-configuration feature" }, &[]), + ("soft-float", Forbidden { reason: "unsupported ABI-configuration feature" }, &[]), ("transactional-execution", Unstable(sym::s390x_target_feature), &[]), ("vector", Stable, &[]), ("vector-enhancements-1", Stable, &["vector"]), @@ -1117,7 +1117,7 @@ impl Target { incompatible: &["soft-float"], } } - Some(RustcAbi::X86Softfloat) => { + Some(RustcAbi::Softfloat) => { // Softfloat ABI, requires corresponding target feature. That feature trumps // `x87` and all other FPU features so those do not matter. // Note that this one requirement is the entire implementation of the ABI! @@ -1137,7 +1137,7 @@ impl Target { incompatible: &["soft-float"], } } - Some(RustcAbi::X86Softfloat) => { + Some(RustcAbi::Softfloat) => { // Softfloat ABI, requires corresponding target feature. That feature trumps // `x87` and all other FPU features so those do not matter. // Note that this one requirement is the entire implementation of the ABI! @@ -1237,11 +1237,27 @@ impl Target { } } Arch::S390x => { - // We don't currently support a softfloat target on this architecture. - // As usual, we have to reject swapping the `soft-float` target feature. - // The "vector" target feature does not affect the ABI for floats - // because the vector and float registers overlap. - FeatureConstraints { required: &[], incompatible: &["soft-float"] } + // Same as x86, We use our own ABI indicator here; + // LLVM does not have anything native and will switch ABI based + // on the soft-float target feature. + // Every case should require or forbid `soft-float`! + // The "vector" target feature may only be used without soft-float + // because the float and vector registers overlap and the + // standard s390x C ABI may pass vectors via these registers. + match self.rustc_abi { + None => { + // Default hardfloat ABI. + FeatureConstraints { required: &[], incompatible: &["soft-float"] } + } + Some(RustcAbi::Softfloat) => { + // Softfloat ABI, requires corresponding target feature. + // llvm will switch to soft-float ABI just based on this feature. + FeatureConstraints { required: &["soft-float"], incompatible: &["vector"] } + } + Some(r) => { + panic!("invalid Rust ABI for s390x: {r:?}"); + } + } } Arch::Avr => { // SRAM is minimum requirement for C/C++ in both avr-gcc and Clang, diff --git a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs index d15fb40dd1cb0..81cca3dd67ac6 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/infer/region.rs @@ -1020,7 +1020,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { && let Some((sup_expected, sup_found)) = self.values_str(sup_trace.values, &sup_trace.cause, err.long_ty_path()) && let Some((sub_expected, sub_found)) = - self.values_str(sub_trace.values, &sup_trace.cause, err.long_ty_path()) + self.values_str(sub_trace.values, &sub_trace.cause, err.long_ty_path()) && sub_expected == sup_expected && sub_found == sup_found { diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index 8b6405afa8929..e5327ab79ee23 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -48,6 +48,7 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[ "thumbv6-none-eabi", "aarch64v8r-unknown-none", "aarch64v8r-unknown-none-softfloat", + "s390x-unknown-none-softfloat", ]; /// Minimum version threshold for libstdc++ required when using prebuilt LLVM diff --git a/src/ci/citool/tests/jobs.rs b/src/ci/citool/tests/jobs.rs index 33fdb3f67b9be..247871de60255 100644 --- a/src/ci/citool/tests/jobs.rs +++ b/src/ci/citool/tests/jobs.rs @@ -6,7 +6,7 @@ const TEST_JOBS_YML_PATH: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/tes fn auto_jobs() { let stdout = get_matrix("push", "commit", "refs/heads/automation/bors/auto"); insta::assert_snapshot!(stdout, @r#" - jobs=[{"name":"aarch64-gnu","full_name":"auto - aarch64-gnu","os":"ubuntu-22.04-arm","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"x86_64-gnu-llvm-18-1","full_name":"auto - x86_64-gnu-llvm-18-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DOCKER_SCRIPT":"stage_2_test_set1.sh","IMAGE":"x86_64-gnu-llvm-18","READ_ONLY_SRC":"0","RUST_BACKTRACE":1,"TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"aarch64-apple","full_name":"auto - aarch64-apple","os":"macos-14","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DEVELOPER_DIR":"/Applications/Xcode_15.4.app/Contents/Developer","MACOSX_DEPLOYMENT_TARGET":11.0,"MACOSX_STD_DEPLOYMENT_TARGET":11.0,"NO_DEBUG_ASSERTIONS":1,"NO_LLVM_ASSERTIONS":1,"NO_OVERFLOW_CHECKS":1,"RUSTC_RETRY_LINKER_ON_SEGFAULT":1,"RUST_CONFIGURE_ARGS":"--enable-sanitizers --enable-profiler --set rust.jemalloc","SCRIPT":"./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin","TOOLSTATE_PUBLISH":1}},{"name":"dist-i686-msvc","full_name":"auto - dist-i686-msvc","os":"windows-2022","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","CODEGEN_BACKENDS":"llvm,cranelift","DEPLOY_BUCKET":"rust-lang-ci2","DIST_REQUIRE_ALL_TOOLS":1,"RUST_CONFIGURE_ARGS":"--build=i686-pc-windows-msvc --host=i686-pc-windows-msvc --target=i686-pc-windows-msvc,i586-pc-windows-msvc --enable-full-tools --enable-profiler","SCRIPT":"python x.py dist bootstrap --include-default-paths","TOOLSTATE_PUBLISH":1}},{"name":"pr-check-1","full_name":"auto - pr-check-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"pr-check-2","full_name":"auto - pr-check-2","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"tidy","full_name":"auto - tidy","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true,"doc_url":"https://foo.bar"}] + jobs=[{"name":"aarch64-gnu","full_name":"auto - aarch64-gnu","os":"ubuntu-22.04-arm","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"x86_64-gnu-llvm-18-1","full_name":"auto - x86_64-gnu-llvm-18-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DOCKER_SCRIPT":"stage_2_test_set1.sh","IMAGE":"x86_64-gnu-llvm-18","READ_ONLY_SRC":"0","RUST_BACKTRACE":1,"TOOLSTATE_PUBLISH":1},"free_disk":true},{"name":"aarch64-apple","full_name":"auto - aarch64-apple","os":"macos-15","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","DEVELOPER_DIR":"/Applications/Xcode_26.2.app/Contents/Developer","MACOSX_DEPLOYMENT_TARGET":11.0,"MACOSX_STD_DEPLOYMENT_TARGET":11.0,"NO_DEBUG_ASSERTIONS":1,"NO_LLVM_ASSERTIONS":1,"NO_OVERFLOW_CHECKS":1,"RUSTC_RETRY_LINKER_ON_SEGFAULT":1,"RUST_CONFIGURE_ARGS":"--enable-sanitizers --enable-profiler --set rust.jemalloc","SCRIPT":"./x.py --stage 2 test --host=aarch64-apple-darwin --target=aarch64-apple-darwin","TOOLSTATE_PUBLISH":1}},{"name":"dist-i686-msvc","full_name":"auto - dist-i686-msvc","os":"windows-2022","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","CODEGEN_BACKENDS":"llvm,cranelift","DEPLOY_BUCKET":"rust-lang-ci2","DIST_REQUIRE_ALL_TOOLS":1,"RUST_CONFIGURE_ARGS":"--build=i686-pc-windows-msvc --host=i686-pc-windows-msvc --target=i686-pc-windows-msvc,i586-pc-windows-msvc --enable-full-tools --enable-profiler","SCRIPT":"python x.py dist bootstrap --include-default-paths","TOOLSTATE_PUBLISH":1}},{"name":"pr-check-1","full_name":"auto - pr-check-1","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"pr-check-2","full_name":"auto - pr-check-2","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true},{"name":"tidy","full_name":"auto - tidy","os":"ubuntu-24.04","env":{"ARTIFACTS_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZN24CBO55","AWS_REGION":"us-west-1","CACHES_AWS_ACCESS_KEY_ID":"AKIA46X5W6CZI5DHEBFL","DEPLOY_BUCKET":"rust-lang-ci2","TOOLSTATE_PUBLISH":1},"continue_on_error":false,"free_disk":true,"doc_url":"https://foo.bar"}] run_type=auto "#); } diff --git a/src/ci/citool/tests/test-jobs.yml b/src/ci/citool/tests/test-jobs.yml index b2dded6a98e2f..3bad1fe1b4271 100644 --- a/src/ci/citool/tests/test-jobs.yml +++ b/src/ci/citool/tests/test-jobs.yml @@ -13,7 +13,7 @@ runners: <<: *base-job - &job-macos-m1 - os: macos-14 + os: macos-15 <<: *base-job - &job-windows @@ -33,7 +33,7 @@ envs: # Ensure that host tooling is tested on our minimum supported macOS version. MACOSX_DEPLOYMENT_TARGET: 10.12 MACOSX_STD_DEPLOYMENT_TARGET: 10.12 - DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer NO_LLVM_ASSERTIONS: 1 NO_DEBUG_ASSERTIONS: 1 NO_OVERFLOW_CHECKS: 1 @@ -112,7 +112,7 @@ auto: --enable-profiler --set rust.jemalloc RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 - DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer # Aarch64 tooling only needs to support macOS 11.0 and up as nothing else # supports the hardware, so only need to test it there. MACOSX_DEPLOYMENT_TARGET: 11.0 diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index dec8876519ed6..fafac482206e5 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -23,7 +23,7 @@ runners: <<: *base-job - &job-macos - os: macos-14 + os: macos-15 # macOS 15 Arm64 <<: *base-job - &job-windows @@ -459,7 +459,7 @@ auto: # Ensure that host tooling is built to support our minimum support macOS version. MACOSX_DEPLOYMENT_TARGET: 10.12 MACOSX_STD_DEPLOYMENT_TARGET: 10.12 - DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer DIST_REQUIRE_ALL_TOOLS: 1 CODEGEN_BACKENDS: llvm,cranelift <<: *job-macos @@ -474,7 +474,7 @@ auto: # FIXME(madsmtm): This might be redundant, as we're not building host tooling here (?) MACOSX_DEPLOYMENT_TARGET: 10.12 MACOSX_STD_DEPLOYMENT_TARGET: 10.12 - DEVELOPER_DIR: /Applications/Xcode_15.2.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer <<: *job-macos - name: dist-aarch64-apple @@ -495,7 +495,7 @@ auto: # supports the hardware. MACOSX_DEPLOYMENT_TARGET: 11.0 MACOSX_STD_DEPLOYMENT_TARGET: 11.0 - DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer DIST_REQUIRE_ALL_TOOLS: 1 CODEGEN_BACKENDS: llvm,cranelift <<: *job-macos @@ -509,7 +509,7 @@ auto: --enable-sanitizers --enable-profiler --set rust.jemalloc - DEVELOPER_DIR: /Applications/Xcode_15.4.app/Contents/Developer + DEVELOPER_DIR: /Applications/Xcode_26.2.app/Contents/Developer # Aarch64 tooling only needs to support macOS 11.0 and up as nothing else # supports the hardware, so only need to test it there. MACOSX_DEPLOYMENT_TARGET: 11.0 diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index 2ec0c3648bdf7..9049828c8b121 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -120,6 +120,7 @@ - [riscv64a23-unknown-linux-gnu](platform-support/riscv64a23-unknown-linux-gnu.md) - [s390x-unknown-linux-gnu](platform-support/s390x-unknown-linux-gnu.md) - [s390x-unknown-linux-musl](platform-support/s390x-unknown-linux-musl.md) + - [s390x-unknown-none-softfloat](platform-support/s390x-unknown-none-softfloat.md) - [sparc-unknown-none-elf](./platform-support/sparc-unknown-none-elf.md) - [solaris](platform-support/solaris.md) - [\*-nto-qnx-\*](platform-support/nto-qnx.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 114f66282afd9..29553f9c2a002 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -188,6 +188,7 @@ target | std | notes [`riscv64im-unknown-none-elf`](platform-support/riscv64im-unknown-none-elf.md) | * | Bare RISC-V (RV64IM ISA) `riscv64imac-unknown-none-elf` | * | Bare RISC-V (RV64IMAC ISA) `sparc64-unknown-linux-gnu` | ✓ | SPARC Linux (kernel 4.4+, glibc 2.23) +[`s390x-unknown-none-softfloat`](platform-support/s390x-unknown-none-softfloat.md) | * | Bare S390x (softfloat ABI) [`thumbv6m-none-eabi`](platform-support/thumbv6m-none-eabi.md) | * | Bare Armv6-M [`thumbv7em-none-eabi`](platform-support/thumbv7em-none-eabi.md) | * | Bare Armv7E-M [`thumbv7em-none-eabihf`](platform-support/thumbv7em-none-eabi.md) | * | Bare Armv7E-M, hardfloat diff --git a/src/doc/rustc/src/platform-support/s390x-unknown-none-softfloat.md b/src/doc/rustc/src/platform-support/s390x-unknown-none-softfloat.md new file mode 100644 index 0000000000000..39a1a7c52c394 --- /dev/null +++ b/src/doc/rustc/src/platform-support/s390x-unknown-none-softfloat.md @@ -0,0 +1,77 @@ +# `s390x-unknown-none-softfloat` + +**Tier: 2** + +IBM z/Architecture (s390x) code in ELF format for kernels, etc. + +## Target maintainers + +[@uweigand](https://github.com/uweigand) +[@cuviper](https://github.com/cuviper) + +## Requirements + +This target is intended for kernel development on s390x only. This target is +cross-compiled. There is no support for `std`.There is no default allocator, +but it's possible to use `alloc` by supplying an allocator. + +The target does not assume existence of a FPU and does not make use of any +non-GPR register. This allows the generated code to run in environments, such +as kernels, which may need to avoid the use of such registers or which may have +special considerations about the use of such registers (e.g. saving and +restoring them to avoid breaking userspace code using the same registers). You +can change code generation to use additional CPU features via the +`-C target-feature=` codegen options to rustc, or via the `#[target_feature]` +mechanism within Rust code. + +By default, code generated with the soft-float target should run on any Z System +starting at [Z10][s390x-isa]. Enabling additional target features or changing the +`-Ctarget-cpu` may raise the ISA required from the `z10` baseline. + +`extern "C"` does not use a stable ABI and is subject to change between compiler +or codegen backend versions. + +The target only generates object files in the ELF format. Any alternate formats +or special considerations for binary layout will require linker options or linker +scripts. + +* [z/Architecture Principles of Operation][s390x-isa] + +[s390x-isa]: https://publibfp.dhe.ibm.com/epubs/pdf/a227832d.pdf +[s390x-abi]: https://github.com/IBM/s390x-abi + +## Building the target + +You can build Rust with support for the target by adding it to the `target` +list in `bootstrap.toml`: + +```toml +[build] +target = ["s390x-unknown-none-softfloat"] +``` + +## Building Rust programs + +This target is not intended to build stand-alone binaries. You should only use +it in conjunction with the kernel build toolchain. + +## Testing + +As code generated by this target is intended to always be part of the kernel, +there are no additional requirements for testing. + +If you want to do native testing but do not have your own s390x +machine, there are several options how to get access to one: + +* The [IBM LinuxONE Community Cloud][cloud-community] provides a + self-service portal where you can create s390x virtual machine + instances. These are intended for temporary use (limited to 120 days). + +* The [IBM LinuxONE Open Source Cloud][cloud-opensource] provides + permanent access to s390x machines. This requires approval by IBM, + which will normally be granted if you're planning to use the machine + to work on an open-source project that is relevant to the IBM Z + ecosystem - the Rust compiler would certainly qualify. + +[cloud-community]: https://linuxone.cloud.marist.edu/ +[cloud-opensource]: https://community.ibm.com/zsystems/form/l1cc-oss-vm-request/ diff --git a/tests/assembly-llvm/s390x-softfloat-abi.rs b/tests/assembly-llvm/s390x-softfloat-abi.rs new file mode 100644 index 0000000000000..e2d9d013d201c --- /dev/null +++ b/tests/assembly-llvm/s390x-softfloat-abi.rs @@ -0,0 +1,64 @@ +//@ add-minicore +//@ revisions: enable-softfloat disable-softfloat +//@ assembly-output: emit-asm +//@ compile-flags: -Copt-level=3 --crate-type=lib +//@[enable-softfloat] compile-flags: --target=s390x-unknown-none-softfloat +//@[enable-softfloat] needs-llvm-components: systemz +//@[disable-softfloat] compile-flags: --target=s390x-unknown-linux-gnu +//@[disable-softfloat] needs-llvm-components: systemz +//@ ignore-backends: gcc + +#![feature(no_core, lang_items)] +#![no_std] +#![no_core] + +extern crate minicore; +use minicore::*; + +extern "C" { + fn extern_func(value: f64) -> f64; +} + +// CHECK-LABEL: test_softfloat +#[no_mangle] +extern "C" fn test_softfloat() -> f64 { + let value = 3.141_f64; + + // without softfloat we load the value direct to the first float register + // we do NOT construct a softfloat in r2 (first non-float arg register) + // disable-softfloat: ld %f{{.*}}, 0(%r{{.*}}) + // disable-softfloat-NOT: llihf %r{{.*}}, 1074340036 + // disable-softfloat-NOT: oilf %r{{.*}}, 2611340116 + + // with softfloat we construct the softfloat arg in r2 + // we do NOT pass anything by f0 (first float arg register) + // float registers can not be accessed + // enable-softfloat: llihf %r{{.*}}, 1074340036 + // enable-softfloat-NEXT: oilf %r{{.*}}, 2611340116 + // enable-softfloat-NOT: ld %f{{.*}}, 0(%r{{.*}}) + + unsafe { extern_func(value) }; + // disable-softfloat-NEXT: brasl %r{{.*}}, extern_func@PLT + // enable-softfloat-NEXT: brasl %r{{.*}}, extern_func@PLT + + // for return we check that without softfloat we write to float register + // disable-softfloat: ld %f{{.*}}, 0(%r{{.*}}) + // disable-softfloat-NOT: llihf %r{{.*}}, 1072841097 + // disable-softfloat-NOT: oilf %r{{.*}}, 927712936 + + #[cfg(not(target_feature = "soft-float"))] + { + 1.141_f64 + } + + // for return we check that WITH softfloat we write to genral purpose register + // enable-softfloat: llihf %r{{.*}}, 1072841097 + // enable-softfloat-NEXT: oilf %r{{.*}}, 927712936 + // enable-softfloat-NOT: ld %f{{.*}}, 0(%r{{.*}}) + #[cfg(target_feature = "soft-float")] + { + 2.718_f64 + } + // enable-softfloat: br %r{{.*}} + // disable-softfloat: br %r{{.*}} +} diff --git a/tests/assembly-llvm/targets/targets-elf.rs b/tests/assembly-llvm/targets/targets-elf.rs index c38e86315b272..b7deb6686cfe1 100644 --- a/tests/assembly-llvm/targets/targets-elf.rs +++ b/tests/assembly-llvm/targets/targets-elf.rs @@ -544,6 +544,9 @@ //@ revisions: s390x_unknown_linux_musl //@ [s390x_unknown_linux_musl] compile-flags: --target s390x-unknown-linux-musl //@ [s390x_unknown_linux_musl] needs-llvm-components: systemz +//@ revisions: s390x_unknown_none_softfloat +//@ [s390x_unknown_none_softfloat] compile-flags: --target s390x-unknown-none-softfloat +//@ [s390x_unknown_none_softfloat] needs-llvm-components: systemz //@ revisions: sparc64_unknown_helenos //@ [sparc64_unknown_helenos] compile-flags: --target sparc64-unknown-helenos //@ [sparc64_unknown_helenos] needs-llvm-components: sparc diff --git a/tests/crashes/131292.rs b/tests/crashes/131292.rs deleted file mode 100644 index 05b93d06b0553..0000000000000 --- a/tests/crashes/131292.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ known-bug: #131292 -//@ needs-asm-support -use std::arch::asm; - -unsafe fn f6() { - asm!(concat!(r#"lJ𐏿Æ�.𐏿�"#, "{}/day{:02}.txt")); -} diff --git a/tests/ui/abi/s390x-softfloat-gate.disable-softfloat.stderr b/tests/ui/abi/s390x-softfloat-gate.disable-softfloat.stderr new file mode 100644 index 0000000000000..e82d5b744a266 --- /dev/null +++ b/tests/ui/abi/s390x-softfloat-gate.disable-softfloat.stderr @@ -0,0 +1,12 @@ +warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: unsupported ABI-configuration feature + | + = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116344 + +warning: target feature `soft-float` must be disabled to ensure that the ABI of the current target can be implemented correctly + | + = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116344 + +warning: 2 warnings emitted + diff --git a/tests/ui/abi/s390x-softfloat-gate.enable-softfloat.stderr b/tests/ui/abi/s390x-softfloat-gate.enable-softfloat.stderr new file mode 100644 index 0000000000000..ecc96e448dcfb --- /dev/null +++ b/tests/ui/abi/s390x-softfloat-gate.enable-softfloat.stderr @@ -0,0 +1,7 @@ +warning: target feature `vector` must be disabled to ensure that the ABI of the current target can be implemented correctly + | + = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #116344 + +warning: 1 warning emitted + diff --git a/tests/ui/abi/s390x-softfloat-gate.rs b/tests/ui/abi/s390x-softfloat-gate.rs new file mode 100644 index 0000000000000..496929eb09551 --- /dev/null +++ b/tests/ui/abi/s390x-softfloat-gate.rs @@ -0,0 +1,38 @@ +//@ add-minicore +//@ revisions: disable-softfloat enable-softfloat +//@ assembly-output: emit-asm +//@ compile-flags: -Copt-level=3 --crate-type=lib + +// we expect the build to fail in the feature +//@ build-pass +//@ [enable-softfloat] compile-flags: --target=s390x-unknown-none-softfloat +//@ [enable-softfloat] compile-flags: -C target-feature=+vector +//@ [enable-softfloat] needs-llvm-components: systemz +//@ [disable-softfloat] compile-flags: --target=s390x-unknown-linux-gnu +//@ [disable-softfloat] compile-flags: -C target-feature=+soft-float +//@ [disable-softfloat] needs-llvm-components: systemz +//@ ignore-backends: gcc + +//[disable-softfloat]~? WARN target feature `soft-float` must be disabled to ensure that the ABI of the current target can be implemented correctly +//[disable-softfloat]~? WARN target feature `soft-float` cannot be enabled with `-Ctarget-feature` +//[enable-softfloat]~? WARN target feature `vector` must be disabled to ensure that the ABI of the current target can be implemented correctly + +#![feature(no_core, lang_items)] +#![no_std] +#![no_core] + +extern crate minicore; +use minicore::*; + +extern "C" { + fn extern_func(value: f64) -> f64; +} + +#[no_mangle] +extern "C" fn test_softfloat() -> f64 { + let value = 3.141_f64; + + unsafe { extern_func(value) } ; + + 2.718_f64 +} diff --git a/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr b/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr index 0e8e6637507d5..cda51a211324e 100644 --- a/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr +++ b/tests/ui/abi/simd-abi-checks-s390x.z13_soft_float.stderr @@ -1,4 +1,4 @@ -warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: currently unsupported ABI-configuration feature +warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: unsupported ABI-configuration feature | = note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #116344 diff --git a/tests/ui/asm/ice-bad-err-span-in-template-129503.rs b/tests/ui/asm/ice-bad-err-span-in-template-129503.rs index 3b4390f881a7e..0a7d0d405d17d 100644 --- a/tests/ui/asm/ice-bad-err-span-in-template-129503.rs +++ b/tests/ui/asm/ice-bad-err-span-in-template-129503.rs @@ -1,17 +1,22 @@ -// Regression test for ICE #129503 - - +// Regression test for ICEs #129503 and #131292 +// // Tests that we come up with decent error spans // when the template fed to `asm!()` is itself a // macro call like `concat!()` and should not ICE +//@ needs-asm-support + use std::arch::asm; fn main() { - // Should not ICE + // Should not ICE (test case for #129503) asm!(concat!(r#"lJ𐏿Æ�.𐏿�"#, "r} {}")); //~^ ERROR invalid asm template string: unmatched `}` found + // Should not ICE (test case for #131292) + asm!(concat!(r#"lJ𐏿Æ�.𐏿�"#, "{}/day{:02}.txt")); + //~^ ERROR invalid asm template string: expected `}`, found `0` + // Macro call template: should point to // everything within `asm!()` as error span diff --git a/tests/ui/asm/ice-bad-err-span-in-template-129503.stderr b/tests/ui/asm/ice-bad-err-span-in-template-129503.stderr index 066959a052d99..980338138c66f 100644 --- a/tests/ui/asm/ice-bad-err-span-in-template-129503.stderr +++ b/tests/ui/asm/ice-bad-err-span-in-template-129503.stderr @@ -1,13 +1,24 @@ error: invalid asm template string: unmatched `}` found - --> $DIR/ice-bad-err-span-in-template-129503.rs:12:10 + --> $DIR/ice-bad-err-span-in-template-129503.rs:13:10 | LL | asm!(concat!(r#"lJ𐏿Æ�.𐏿�"#, "r} {}")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unmatched `}` in asm template string | = note: if you intended to print `}`, you can escape it using `}}` +error: invalid asm template string: expected `}`, found `0` + --> $DIR/ice-bad-err-span-in-template-129503.rs:17:10 + | +LL | asm!(concat!(r#"lJ𐏿Æ�.𐏿�"#, "{}/day{:02}.txt")); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected `}` in asm template string + | because of this opening brace + | + = note: if you intended to print `{`, you can escape it using `{{` + error: invalid asm template string: unmatched `}` found - --> $DIR/ice-bad-err-span-in-template-129503.rs:18:10 + --> $DIR/ice-bad-err-span-in-template-129503.rs:23:10 | LL | asm!(concat!("abc", "r} {}")); | ^^^^^^^^^^^^^^^^^^^^^^^ unmatched `}` in asm template string @@ -15,12 +26,12 @@ LL | asm!(concat!("abc", "r} {}")); = note: if you intended to print `}`, you can escape it using `}}` error: invalid asm template string: unmatched `}` found - --> $DIR/ice-bad-err-span-in-template-129503.rs:24:19 + --> $DIR/ice-bad-err-span-in-template-129503.rs:29:19 | LL | asm!("abc", "r} {}"); | ^ unmatched `}` in asm template string | = note: if you intended to print `}`, you can escape it using `}}` -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/fmt/format-string-error-2.rs b/tests/ui/fmt/format-string-error-2.rs index 63d65023eb78b..c1d228bfbc9c4 100644 --- a/tests/ui/fmt/format-string-error-2.rs +++ b/tests/ui/fmt/format-string-error-2.rs @@ -88,4 +88,7 @@ raw { \n //~^ ERROR invalid format string: expected `}`, found `?` println!("{x,}, world!",); //~^ ERROR invalid format string: python's numeric grouping `,` is not supported in rust format strings + + println!("{x=}"); + //~^ ERROR invalid format string: python's f-string debug `=` is not supported in rust, use `dbg(x)` instead } diff --git a/tests/ui/fmt/format-string-error-2.stderr b/tests/ui/fmt/format-string-error-2.stderr index e7fbc2e81fc6b..b12e827853f80 100644 --- a/tests/ui/fmt/format-string-error-2.stderr +++ b/tests/ui/fmt/format-string-error-2.stderr @@ -198,5 +198,15 @@ LL | println!("{x,}, world!",); | = note: to print `{`, you can escape it using `{{` -error: aborting due to 20 previous errors +error: invalid format string: python's f-string debug `=` is not supported in rust, use `dbg(x)` instead + --> $DIR/format-string-error-2.rs:92:17 + | +LL | println!("{x=}"); + | - ^ expected `}` in format string + | | + | because of this opening brace + | + = note: to print `{`, you can escape it using `{{` + +error: aborting due to 21 previous errors diff --git a/tests/ui/fmt/format-string-error-3.fixed b/tests/ui/fmt/format-string-error-3.fixed new file mode 100644 index 0000000000000..16a169db11472 --- /dev/null +++ b/tests/ui/fmt/format-string-error-3.fixed @@ -0,0 +1,5 @@ +//@ run-rustfix +fn main() { + let x = 32; + dbg!(x); //~ ERROR invalid format string: python's f-string debug +} diff --git a/tests/ui/fmt/format-string-error-3.rs b/tests/ui/fmt/format-string-error-3.rs new file mode 100644 index 0000000000000..bd61233a475e3 --- /dev/null +++ b/tests/ui/fmt/format-string-error-3.rs @@ -0,0 +1,5 @@ +//@ run-rustfix +fn main() { + let x = 32; + println!("{=}", x); //~ ERROR invalid format string: python's f-string debug +} diff --git a/tests/ui/fmt/format-string-error-3.stderr b/tests/ui/fmt/format-string-error-3.stderr new file mode 100644 index 0000000000000..e07f47cff5a6f --- /dev/null +++ b/tests/ui/fmt/format-string-error-3.stderr @@ -0,0 +1,17 @@ +error: invalid format string: python's f-string debug `=` is not supported in rust, use `dbg(x)` instead + --> $DIR/format-string-error-3.rs:4:16 + | +LL | println!("{=}", x); + | -^ expected `}` in format string + | | + | because of this opening brace + | + = note: to print `{`, you can escape it using `{{` +help: use rust debug printing macro + | +LL - println!("{=}", x); +LL + dbg!(x); + | + +error: aborting due to 1 previous error + diff --git a/tests/ui/missing/missing-let.rs b/tests/ui/missing/missing-let.rs index 36db7bc95826b..595de640470b6 100644 --- a/tests/ui/missing/missing-let.rs +++ b/tests/ui/missing/missing-let.rs @@ -1,6 +1,18 @@ fn main() { let x = Some(42); + let y = Some(42); + let z = Some(42); if let Some(_) = x && Some(x) = x //~^ ERROR expected expression, found `let` statement + //~| NOTE: only supported directly in conditions of `if` and `while` expressions + {} + + if Some(_) = y && + //~^ NOTE expected `let` expression, found assignment + //~| ERROR let-chain with missing `let` + let Some(_) = z + //~^ ERROR: expected expression, found `let` statement + //~| NOTE: let expression later in the condition + //~| NOTE: only supported directly in conditions of `if` and `while` expressions {} } diff --git a/tests/ui/missing/missing-let.stderr b/tests/ui/missing/missing-let.stderr index 897ff6329d593..0a6e76b154f78 100644 --- a/tests/ui/missing/missing-let.stderr +++ b/tests/ui/missing/missing-let.stderr @@ -1,5 +1,5 @@ error: expected expression, found `let` statement - --> $DIR/missing-let.rs:3:8 + --> $DIR/missing-let.rs:5:8 | LL | if let Some(_) = x | ^^^^^^^^^^^^^^^ @@ -14,5 +14,29 @@ help: you might have meant to compare for equality LL | && Some(x) == x | + -error: aborting due to 1 previous error +error: expected expression, found `let` statement + --> $DIR/missing-let.rs:13:9 + | +LL | let Some(_) = z + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: let-chain with missing `let` + --> $DIR/missing-let.rs:10:8 + | +LL | if Some(_) = y && + | ^^^^^^^---- + | | + | expected `let` expression, found assignment +... +LL | let Some(_) = z + | --------------- let expression later in the condition + | +help: add `let` before the expression + | +LL | if let Some(_) = y && + | +++ + +error: aborting due to 3 previous errors diff --git a/tests/ui/target_modifiers/auxiliary/disabled_softfloat.rs b/tests/ui/target_modifiers/auxiliary/disabled_softfloat.rs new file mode 100644 index 0000000000000..0063d925deca2 --- /dev/null +++ b/tests/ui/target_modifiers/auxiliary/disabled_softfloat.rs @@ -0,0 +1,8 @@ +//@ add-minicore +//@ no-prefer-dynamic +//@ compile-flags: --target=s390x-unknown-linux-gnu +//@ needs-llvm-components: systemz + +#![feature(no_core)] +#![crate_type = "rlib"] +#![no_core] diff --git a/tests/ui/target_modifiers/auxiliary/enabled_softfloat.rs b/tests/ui/target_modifiers/auxiliary/enabled_softfloat.rs new file mode 100644 index 0000000000000..7439a1eb69b5f --- /dev/null +++ b/tests/ui/target_modifiers/auxiliary/enabled_softfloat.rs @@ -0,0 +1,8 @@ +//@ add-minicore +//@ no-prefer-dynamic +//@ compile-flags: --target=s390x-unknown-none-softfloat +//@ needs-llvm-components: systemz + +#![feature(no_core)] +#![crate_type = "rlib"] +#![no_core] diff --git a/tests/ui/target_modifiers/incompatible_softfloat_targets.disable-softfloat.stderr b/tests/ui/target_modifiers/incompatible_softfloat_targets.disable-softfloat.stderr new file mode 100644 index 0000000000000..090ebe6ca14c1 --- /dev/null +++ b/tests/ui/target_modifiers/incompatible_softfloat_targets.disable-softfloat.stderr @@ -0,0 +1,12 @@ +error[E0461]: couldn't find crate `enabled_softfloat` with expected target triple s390x-unknown-linux-gnu + --> $DIR/incompatible_softfloat_targets.rs:17:1 + | +LL | extern crate enabled_softfloat; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the following crate versions were found: + crate `enabled_softfloat`, target triple s390x-unknown-none-softfloat: $TEST_BUILD_DIR/auxiliary/libenabled_softfloat.rlib + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0461`. diff --git a/tests/ui/target_modifiers/incompatible_softfloat_targets.enable-softfloat.stderr b/tests/ui/target_modifiers/incompatible_softfloat_targets.enable-softfloat.stderr new file mode 100644 index 0000000000000..9adb6d265651a --- /dev/null +++ b/tests/ui/target_modifiers/incompatible_softfloat_targets.enable-softfloat.stderr @@ -0,0 +1,12 @@ +error[E0461]: couldn't find crate `disabled_softfloat` with expected target triple s390x-unknown-none-softfloat + --> $DIR/incompatible_softfloat_targets.rs:19:1 + | +LL | extern crate disabled_softfloat; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the following crate versions were found: + crate `disabled_softfloat`, target triple s390x-unknown-linux-gnu: $TEST_BUILD_DIR/auxiliary/libdisabled_softfloat.rlib + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0461`. diff --git a/tests/ui/target_modifiers/incompatible_softfloat_targets.rs b/tests/ui/target_modifiers/incompatible_softfloat_targets.rs new file mode 100644 index 0000000000000..3d253c5f0c78b --- /dev/null +++ b/tests/ui/target_modifiers/incompatible_softfloat_targets.rs @@ -0,0 +1,20 @@ +//@ add-minicore +//@ aux-build: disabled_softfloat.rs +//@ aux-build: enabled_softfloat.rs +//@ revisions: disable-softfloat enable-softfloat +//@ check-fail +//@ [enable-softfloat] compile-flags: --target=s390x-unknown-none-softfloat +//@ [enable-softfloat] needs-llvm-components: systemz +//@ [disable-softfloat] compile-flags: --target=s390x-unknown-linux-gnu +//@ [disable-softfloat] needs-llvm-components: systemz +//@ ignore-backends: gcc + + +#![feature(no_core)] +#![crate_type = "rlib"] +#![no_core] + +extern crate enabled_softfloat; +//[disable-softfloat]~^ ERROR couldn't find crate `enabled_softfloat` with expected target triple s390x-unknown-linux-gnu +extern crate disabled_softfloat; +//[enable-softfloat]~^ ERROR couldn't find crate `disabled_softfloat` with expected target triple s390x-unknown-none-softfloat diff --git a/triagebot.toml b/triagebot.toml index 98e88f4e2e9b6..2a98b1d43b99e 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -1449,29 +1449,6 @@ compiler_leads = [ "@davidtwco", "@wesleywiser", ] -compiler = [ - "@BoxyUwU", - "@chenyukang", - "@davidtwco", - "@eholk", - "@fee1-dead", - "@fmease", - "@jackh726", - "@jieyouxu", - "@jdonszelmann", - "@JonathanBrouwer", - "@madsmtm", - "@mati865", - "@Nadrieril", - "@nnethercote", - "@oli-obk", - "@petrochenkov", - "@SparrowLii", - "@TaKO8Ki", - "@tiif", - "@WaffleLapkin", - "@wesleywiser", -] libs = [ "@Mark-Simulacrum", "@workingjubilee",