diff --git a/compiler/rustc_ast_lowering/src/asm.rs b/compiler/rustc_ast_lowering/src/asm.rs index 71bcdb0e27e8f..92b3f77ce4a56 100644 --- a/compiler/rustc_ast_lowering/src/asm.rs +++ b/compiler/rustc_ast_lowering/src/asm.rs @@ -261,24 +261,45 @@ impl<'hir> LoweringContext<'_, 'hir> { if class == asm::InlineAsmRegClass::Err { continue; } - let valid_modifiers = class.valid_modifiers(asm_arch.unwrap()); + let valid_modifiers = + class.valid_modifiers(asm_arch.unwrap(), allow_experimental_reg); if !valid_modifiers.contains(&modifier) { - let sub = if valid_modifiers.is_empty() { - InvalidAsmTemplateModifierRegClassSub::DoesNotSupportModifier { - class_name: class.name(), - } + // First check if the requested modifier is missing from the valid + // values because experimental registers are disabled. + let unstable_modifiers = class.valid_modifiers(asm_arch.unwrap(), true); + if !allow_experimental_reg && unstable_modifiers.contains(&modifier) { + self.tcx.sess.create_feature_err( + InvalidAsmTemplateModifierRegClass { + placeholder_span, + op_span: op_sp, + modifier: modifier.to_string(), + sub: InvalidAsmTemplateModifierRegClassSub::ModifierIsGated { + class_name: class.name(), + feature: sym::asm_experimental_reg, + stable_modifiers: valid_modifiers.to_vec().into(), + all_modifiers: unstable_modifiers.to_vec().into(), + }, + }, + sym::asm_experimental_reg, + ).emit(); } else { - InvalidAsmTemplateModifierRegClassSub::SupportModifier { - class_name: class.name(), - modifiers: valid_modifiers.to_vec().into(), - } - }; - self.dcx().emit_err(InvalidAsmTemplateModifierRegClass { - placeholder_span, - op_span: op_sp, - modifier: modifier.to_string(), - sub, - }); + let sub = if valid_modifiers.is_empty() { + InvalidAsmTemplateModifierRegClassSub::DoesNotSupportModifier { + class_name: class.name(), + } + } else { + InvalidAsmTemplateModifierRegClassSub::SupportModifier { + class_name: class.name(), + modifiers: valid_modifiers.to_vec().into(), + } + }; + self.dcx().emit_err(InvalidAsmTemplateModifierRegClass { + placeholder_span, + op_span: op_sp, + modifier: modifier.to_string(), + sub, + }); + } } } hir::InlineAsmOperand::Const { .. } => { diff --git a/compiler/rustc_ast_lowering/src/diagnostics.rs b/compiler/rustc_ast_lowering/src/diagnostics.rs index 8c298c57040e9..35a787f62858b 100644 --- a/compiler/rustc_ast_lowering/src/diagnostics.rs +++ b/compiler/rustc_ast_lowering/src/diagnostics.rs @@ -266,6 +266,18 @@ pub(crate) enum InvalidAsmTemplateModifierRegClassSub { SupportModifier { class_name: Symbol, modifiers: DiagSymbolList }, #[note("the `{$class_name}` register class does not support template modifiers")] DoesNotSupportModifier { class_name: Symbol }, + + /// Enabling a feature is needed to use the requested modifier. + #[note( + "the `{$class_name}` register class only supports the following template modifiers on stable: {$stable_modifiers}" + )] + #[note("enabling the `{$feature}` feature will allow using: {$all_modifiers}")] + ModifierIsGated { + class_name: Symbol, + feature: Symbol, + stable_modifiers: DiagSymbolList, + all_modifiers: DiagSymbolList, + }, } #[derive(Diagnostic)] diff --git a/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs b/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs index ed61d557385dd..009608d7eee31 100644 --- a/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs +++ b/compiler/rustc_hir_typeck/src/method/prelude_edition_lints.rs @@ -1,10 +1,10 @@ use std::fmt::Write; +use hir::HirId; use hir::def_id::DefId; -use hir::{HirId, ItemKind}; use rustc_ast::join_path_idents; use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, Level}; -use rustc_hir as hir; +use rustc_hir::{self as hir, Node}; use rustc_hir::attrs::lang_items::LangItem; use rustc_lint::{ARRAY_INTO_ITER, BOXED_SLICE_INTO_ITER}; use rustc_lint_defs::builtin::{RUST_2021_PRELUDE_COLLISIONS, RUST_2024_PRELUDE_COLLISIONS}; @@ -436,12 +436,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let import_items: Vec<_> = applicable_trait .import_ids .iter() - .map(|&import_id| self.tcx.hir_expect_item(import_id)) + .map(|&import_id| match self.tcx.hir_node_by_def_id(import_id) { + Node::NestedUseTree(tree) => *tree, + Node::Item(it) => it.expect_use(), + node => span_bug!(span, "expected use tree, found {node:#?}"), + }) .collect(); // Find an identifier with which this trait was imported (note that `_` doesn't count). for item in import_items.iter() { - match item.expect_use().kind { + match item.kind { hir::UseKind::Single(ident) => { if ident.name != kw::Underscore { return Some(format!("{}", ident.name)); @@ -454,14 +458,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // All that is left is `_`! We need to use the full path. It doesn't matter which one we // pick, so just take the first one. - match import_items[0].kind { - ItemKind::Use(tree) => { - Some(join_path_idents(tree.prefix.segments.iter().map(|seg| seg.ident))) - } - _ => { - span_bug!(span, "unexpected item kind, expected a use: {:?}", import_items[0].kind); - } - } + Some(join_path_idents(import_items[0].prefix.segments.iter().map(|seg| seg.ident))) } /// Creates a string version of the `expr` that includes explicit adjustments. diff --git a/compiler/rustc_target/src/asm/aarch64.rs b/compiler/rustc_target/src/asm/aarch64.rs index 83d249262c104..4136d1a624588 100644 --- a/compiler/rustc_target/src/asm/aarch64.rs +++ b/compiler/rustc_target/src/asm/aarch64.rs @@ -18,10 +18,21 @@ def_reg_class! { } impl AArch64InlineAsmRegClass { - pub fn valid_modifiers(self, _arch: super::InlineAsmArch) -> &'static [char] { + pub fn valid_modifiers( + self, + _arch: super::InlineAsmArch, + allow_experimental_reg: bool, + ) -> &'static [char] { match self { Self::reg => &['w', 'x'], - Self::vreg | Self::vreg_low16 => &['b', 'h', 's', 'd', 'q', 'v', 'z'], + Self::vreg | Self::vreg_low16 => { + if allow_experimental_reg { + &['b', 'h', 's', 'd', 'q', 'v', 'z'] + } else { + &['b', 'h', 's', 'd', 'q', 'v'] + } + } + Self::preg | Self::ffr => &[], } } diff --git a/compiler/rustc_target/src/asm/mod.rs b/compiler/rustc_target/src/asm/mod.rs index 6f9751e807490..500010dc426f4 100644 --- a/compiler/rustc_target/src/asm/mod.rs +++ b/compiler/rustc_target/src/asm/mod.rs @@ -711,13 +711,19 @@ impl InlineAsmRegClass { }) } - /// Returns the list of template modifiers that can be used with this - /// register class. - pub fn valid_modifiers(self, arch: InlineAsmArch) -> &'static [char] { + /// Returns the list of template modifiers that can be used with this register class, as well as + /// whether the `asm_experimental_reg` feature is enabled: there can be template modifiers that + /// apply to currently unstable registers, and we don't want to make these modifiers usable + /// without the feature gate. + pub fn valid_modifiers( + self, + arch: InlineAsmArch, + allow_experimental_reg: bool, + ) -> &'static [char] { match self { Self::X86(r) => r.valid_modifiers(arch), Self::Arm(r) => r.valid_modifiers(arch), - Self::AArch64(r) => r.valid_modifiers(arch), + Self::AArch64(r) => r.valid_modifiers(arch, allow_experimental_reg), Self::Amdgpu(r) => r.valid_modifiers(arch), Self::RiscV(r) => r.valid_modifiers(arch), Self::Nvptx(r) => r.valid_modifiers(arch), diff --git a/compiler/rustc_target/src/target_features.rs b/compiler/rustc_target/src/target_features.rs index 2ee7dea9f8af3..e8970ea57e822 100644 --- a/compiler/rustc_target/src/target_features.rs +++ b/compiler/rustc_target/src/target_features.rs @@ -680,9 +680,9 @@ static RISCV_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[ ("a", Stable, &["zaamo", "zalrsc"]), ("b", Stable, &["zba", "zbb", "zbs"]), ("c", Stable, &["zca"]), - ("d", Stable, &["f"]), - ("e", Unstable(sym::riscv_target_feature), &[]), // negative feature! needs special care. - ("f", Stable, &["zicsr"]), + ("d", Unstable(sym::riscv_target_feature), &["f"]), + ("e", Unstable(sym::riscv_target_feature), &[]), + ("f", Unstable(sym::riscv_target_feature), &["zicsr"]), ( "forced-atomics", // Not implied by any CPU model or other feature. diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 64c6d46cea355..6e01b60f60ac2 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -3219,7 +3219,7 @@ fn clean_use_statement<'tcx>( for (tree, hir_id, def_id) in items { let mut segments = path.segments.to_vec(); segments.extend(tree.prefix.segments.iter()); - if segments.last().unwrap().ident.name == kw::SelfLower { + if segments.last().is_some_and(|seg| seg.ident.name == kw::SelfLower) { segments.pop(); } let path = hir::UsePath { diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 0ecbc5927cf48..3ac1f3d944afb 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -582,7 +582,7 @@ pub(crate) struct RunnableDocTest<'a> { /// In a standalone test this is just the regular test code. full_test_code: String, full_test_line_offset: usize, - test_opts: &'a IndividualTestOptions, + test_opts: IndividualTestOptions, global_opts: &'a GlobalTestOptions, langstr: LangString, line: usize, @@ -1151,8 +1151,6 @@ fn generate_test_desc_and_fn( unused_externs: Arc>>, ) -> test::TestDescAndFn { let target_str = rustdoc_options.target.to_string(); - let rustdoc_test_options = - IndividualTestOptions::new(&rustdoc_options, &test.test_id, scraped_test.path()); debug!("creating test {}: {}", scraped_test.name, scraped_test.text); test::TestDescAndFn { @@ -1177,8 +1175,13 @@ fn generate_test_desc_and_fn( }, #[cfg(bootstrap)] testfn: test::DynTestFn(Box::new(move || { + let rustdoc_test_options = IndividualTestOptions::new( + &rustdoc_options, + &test.test_id, + scraped_test.path(), + ); doctest_run_fn( - &rustdoc_test_options, + rustdoc_test_options, &opts, &test, &scraped_test, @@ -1188,8 +1191,13 @@ fn generate_test_desc_and_fn( })), #[cfg(not(bootstrap))] testfn: test::DynTestFn(Arc::new(move || { + let rustdoc_test_options = IndividualTestOptions::new( + &rustdoc_options, + &test.test_id, + scraped_test.path(), + ); doctest_run_fn( - &rustdoc_test_options, + rustdoc_test_options, &opts, &test, &scraped_test, @@ -1201,7 +1209,7 @@ fn generate_test_desc_and_fn( } fn doctest_run_fn( - test_opts: &IndividualTestOptions, + test_opts: IndividualTestOptions, global_opts: &GlobalTestOptions, doctest: &DocTestBuilder, scraped_test: &ScrapedDocTest, diff --git a/src/librustdoc/doctest/runner.rs b/src/librustdoc/doctest/runner.rs index 43ed48aad95d4..2ec5061bb775d 100644 --- a/src/librustdoc/doctest/runner.rs +++ b/src/librustdoc/doctest/runner.rs @@ -197,7 +197,7 @@ test::test_main(test_args, tests) let runnable_test = RunnableDocTest { full_test_code: format!("{code_prefix}{code}", code = self.output), full_test_line_offset: 0, - test_opts: &test_options, + test_opts: test_options, global_opts: opts, langstr: LangString::default(), line: 0, diff --git a/src/llvm-project b/src/llvm-project index f738f3b0ed65c..0a5579eb649d3 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit f738f3b0ed65c01edcb44a504a77edc12a82c319 +Subproject commit 0a5579eb649d3634a9c30ac873300cc2944fa070 diff --git a/src/tools/rustfmt/src/config/config_type.rs b/src/tools/rustfmt/src/config/config_type.rs index 6611a387814ab..afac8d3fcf992 100644 --- a/src/tools/rustfmt/src/config/config_type.rs +++ b/src/tools/rustfmt/src/config/config_type.rs @@ -423,65 +423,6 @@ macro_rules! create_config { )+ } - /// Reduces the maximum width of the configuration. - /// - /// This method is intended to be used when creating a forked - /// configuration for a particular formatting context in which the - /// total available width needs to be reduced. This reduces the - /// size of max_width, and all other properties affected by small - /// heuristics, without treating those adjustments as overrides. - /// - /// As an example use case, this method is used when formatting - /// arms within a declarative macro. - #[allow(unreachable_pub)] - pub fn reduce_max_width(&mut self, delta: usize) { - self.adjust_max_width(-(delta.min(isize::MAX as usize) as isize)); - } - - /// Increases the maximum width of the configuration. - /// - /// This method is intended to be used when creating a forked - /// configuration for a particular formatting context in which the - /// total available width needs to be increased. This increases the - /// size of max_width, and all other properties affected by small - /// heuristics, without treating those adjustments as overrides. - /// - /// As an example use case, this method is used when formatting - /// arms within a declarative macro. - #[allow(unreachable_pub)] - pub fn increase_max_width(&mut self, delta: usize) { - self.adjust_max_width(delta.min(isize::MAX as usize) as isize); - } - - /// Adjusts the maximum width of the configuration. - /// - /// This method is intended to be used when creating a forked - /// configuration for a particular formatting context in which the - /// total available width needs to be reduced. This adjusts the - /// size of max_width, and all other properties affected by small - /// heuristics, without treating those adjustments as overrides. - /// - /// As an example use case, this method is used when formatting - /// arms within a declarative macro. - fn adjust_max_width(&mut self, delta: isize) { - // NB: we need to either saturate or report an error (or some kind of testable - // warning). I picked to saturate here. - let adjust = |value: usize| value.saturating_add_signed(delta); - - self.array_width.2 = adjust(self.array_width.2); - self.attr_fn_like_width.2 = adjust(self.attr_fn_like_width.2); - self.chain_width.2 = adjust(self.chain_width.2); - self.fn_call_width.2 = adjust(self.fn_call_width.2); - self.single_line_if_else_max_width.2 = adjust(self.single_line_if_else_max_width.2); - self.single_line_let_else_max_width.2 = - adjust(self.single_line_let_else_max_width.2); - self.struct_lit_width.2 = adjust(self.struct_lit_width.2); - self.struct_variant_width.2 = adjust(self.struct_variant_width.2); - - self.max_width.2 = adjust(self.max_width.2); - self.set_heuristics(); - } - fn set_width_heuristics(&mut self, heuristics: WidthHeuristics) { let max_width = self.max_width.2; let get_width_value = | diff --git a/src/tools/rustfmt/src/config/mod.rs b/src/tools/rustfmt/src/config/mod.rs index 1aab68ac52ab1..a3f9842cd4f7f 100644 --- a/src/tools/rustfmt/src/config/mod.rs +++ b/src/tools/rustfmt/src/config/mod.rs @@ -701,23 +701,6 @@ mod test { assert_eq!(config.verbose(), Verbosity::Normal); } - #[test] - fn test_adjust_max_width() { - // Regression tests for #7147, where we didn't handle overflows / integral cast outside of - // range properly. - - // Reduce with huge amount saturates to zero instead of wraparound. - let mut config = Config::default(); - config.reduce_max_width(usize::MAX); - assert_eq!(config.max_width(), 0); - - // Increase with huge amount saturates instead of wraparound. - let mut config = Config::default(); - config.set().max_width(usize::MAX - 1); - config.increase_max_width(2); - assert_eq!(config.max_width(), usize::MAX); - } - #[test] fn test_config_used_to_toml() { let config = Config::default(); diff --git a/src/tools/rustfmt/src/macros.rs b/src/tools/rustfmt/src/macros.rs index 9a88569b7909b..1f4a38db2d819 100644 --- a/src/tools/rustfmt/src/macros.rs +++ b/src/tools/rustfmt/src/macros.rs @@ -1361,13 +1361,15 @@ impl MacroBranch { } else { shape.indent.block_indent(&config) }; - config.reduce_max_width(body_indent.width()); + let new_width = config.max_width() - body_indent.width(); + config.set().max_width(new_width); // First try to format as items, then as statements. let new_body_snippet = match crate::format_snippet(&body_str, &config, true) { Some(new_body) => new_body, None => { - config.increase_max_width(config.tab_spaces()); + let new_width = new_width + config.tab_spaces(); + config.set().max_width(new_width); match crate::format_code_block(&body_str, &config, true) { Some(new_body) => new_body, None => { diff --git a/src/tools/rustfmt/tests/target/issue-6651/custom_width.rs b/src/tools/rustfmt/tests/target/issue-6651/custom_width.rs index b46bd5ef5ccab..b6bbe715290d3 100644 --- a/src/tools/rustfmt/tests/target/issue-6651/custom_width.rs +++ b/src/tools/rustfmt/tests/target/issue-6651/custom_width.rs @@ -16,11 +16,6 @@ macro_rules! medium { macro_rules! long { () => { - m!( - aaaaaaaaaaaaaaaa, - bbbbbbbbbbbbbbbb, - cccccccccccccccc, - ddddddddddddddd - ); + m!(aaaaaaaaaaaaaaaa, bbbbbbbbbbbbbbbb, cccccccccccccccc, ddddddddddddddd); }; } diff --git a/tests/assembly-llvm/asm/aarch64-modifiers.rs b/tests/assembly-llvm/asm/aarch64-modifiers.rs index 66be35de574f6..5c68c25a7b902 100644 --- a/tests/assembly-llvm/asm/aarch64-modifiers.rs +++ b/tests/assembly-llvm/asm/aarch64-modifiers.rs @@ -5,7 +5,7 @@ //@ compile-flags: -Zmerge-functions=disabled //@ needs-llvm-components: aarch64 -#![feature(no_core)] +#![feature(asm_experimental_reg, no_core)] #![crate_type = "rlib"] #![no_core] #![allow(asm_sub_register)] diff --git a/tests/run-make/rustdoc-doctest-tempdir-cleanup/lib.rs b/tests/run-make/rustdoc-doctest-tempdir-cleanup/lib.rs new file mode 100644 index 0000000000000..a8585bd0bd082 --- /dev/null +++ b/tests/run-make/rustdoc-doctest-tempdir-cleanup/lib.rs @@ -0,0 +1,18 @@ +/// ``` +/// assert!(true); +/// ``` +pub fn a() {} + +/// ``` +/// let count = std::fs::read_dir(std::env::temp_dir()) +/// .unwrap() +/// .filter(|entry| { +/// entry.as_ref().unwrap().file_name().to_str().unwrap().starts_with("rustdoctest") +/// }) +/// .count(); +/// // It's 2 and not one because rustdoc creates a temp dir where it puts the `rustdoc-cfgs` +/// // file which contains the list of flags to be passed down to the doctests. It lives +/// // until all doctests have been run. +/// assert_eq!(count, 2); +/// ``` +pub fn b() {} diff --git a/tests/run-make/rustdoc-doctest-tempdir-cleanup/rmake.rs b/tests/run-make/rustdoc-doctest-tempdir-cleanup/rmake.rs new file mode 100644 index 0000000000000..789002533833c --- /dev/null +++ b/tests/run-make/rustdoc-doctest-tempdir-cleanup/rmake.rs @@ -0,0 +1,23 @@ +// This test ensures that a temporary doctest directory is removed as soon as the doctest +// was run to prevent "No space left on device". To ensure it works, we use a file with two +// doctests, run without the "merged doctests" feature (hence the "2021" edition) with +// one thread to prevent potential concurrent cleanups. +// Regression test for . + +//@ ignore-cross-compile +//@ only-linux + +use run_make_support::{is_windows, path, rfs, rustdoc}; + +fn main() { + let tmp = path("tmp"); + rfs::create_dir(&tmp); + + let mut cmd = rustdoc() + .env("TMPDIR", &tmp) + .input("lib.rs") + .edition("2021") + .arg("--test") + .arg("--test-args=--test-threads=1") + .run(); +} diff --git a/tests/rustdoc-ui/ice-nested-use-without-prefix-164158-edition2015.rs b/tests/rustdoc-ui/ice-nested-use-without-prefix-164158-edition2015.rs new file mode 100644 index 0000000000000..a539d7998282b --- /dev/null +++ b/tests/rustdoc-ui/ice-nested-use-without-prefix-164158-edition2015.rs @@ -0,0 +1,9 @@ +//@ check-pass +//@ edition: 2015 + +// Regression test for . +// Nested glob use with no path prefix (edition 2015 form from review). + +mod what { + use {*}; +} diff --git a/tests/rustdoc-ui/ice-nested-use-without-prefix-164158.rs b/tests/rustdoc-ui/ice-nested-use-without-prefix-164158.rs new file mode 100644 index 0000000000000..c16af79f9b706 --- /dev/null +++ b/tests/rustdoc-ui/ice-nested-use-without-prefix-164158.rs @@ -0,0 +1,14 @@ +//@ check-pass +//@ edition: 2021 + +// Regression test for . +// A nested use group with no path in front of it made rustdoc panic. + +use {{}}; + +pub mod inner { + pub struct S; + pub struct T; +} + +pub use {inner::S, {inner::T}}; diff --git a/tests/rustdoc-ui/issues/issue-98690.rs b/tests/rustdoc-ui/issues/issue-98690.rs index 01708f3f64d3e..1c7eb844a272a 100644 --- a/tests/rustdoc-ui/issues/issue-98690.rs +++ b/tests/rustdoc-ui/issues/issue-98690.rs @@ -1,6 +1,8 @@ //@ compile-flags: --test --persist-doctests /../../ -Z unstable-options //@ failure-status: 101 //@ only-linux +//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" +//@ normalize-stdout: ".rs:\d+:\d+" -> ".rs:$$LINE:$$COL" #![crate_name = "foo"] diff --git a/tests/rustdoc-ui/issues/issue-98690.stderr b/tests/rustdoc-ui/issues/issue-98690.stderr deleted file mode 100644 index 47d94f99a4563..0000000000000 --- a/tests/rustdoc-ui/issues/issue-98690.stderr +++ /dev/null @@ -1 +0,0 @@ -Couldn't create directory for doctest executables: Permission denied (os error 13) diff --git a/tests/rustdoc-ui/issues/issue-98690.stdout b/tests/rustdoc-ui/issues/issue-98690.stdout new file mode 100644 index 0000000000000..970583175f18b --- /dev/null +++ b/tests/rustdoc-ui/issues/issue-98690.stdout @@ -0,0 +1,15 @@ + +running 1 test +test $DIR/issue-98690.rs - (line 9) ... FAILED + +failures: + +---- $DIR/issue-98690.rs - (line 9) stdout ---- +Couldn't create directory for doctest executables: Permission denied (os error 13) + + +failures: + $DIR/issue-98690.rs - (line 9) + +test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME + diff --git a/tests/ui/asm/aarch64/bad-reg.stderr b/tests/ui/asm/aarch64/bad-reg.stderr index 8937509763dec..14ffdb3e0059f 100644 --- a/tests/ui/asm/aarch64/bad-reg.stderr +++ b/tests/ui/asm/aarch64/bad-reg.stderr @@ -30,7 +30,7 @@ LL | asm!("{:r}", in(vreg) foo); | | | template modifier | - = note: the `vreg` register class supports the following template modifiers: `b`, `h`, `s`, `d`, `q`, `v`, and `z` + = note: the `vreg` register class supports the following template modifiers: `b`, `h`, `s`, `d`, `q`, and `v` error: invalid asm template modifier `r` for this register class --> $DIR/bad-reg.rs:26:15 @@ -40,7 +40,7 @@ LL | asm!("{:r}", in(vreg_low16) foo); | | | template modifier | - = note: the `vreg_low16` register class supports the following template modifiers: `b`, `h`, `s`, `d`, `q`, `v`, and `z` + = note: the `vreg_low16` register class supports the following template modifiers: `b`, `h`, `s`, `d`, `q`, and `v` error: asm template modifiers are not allowed for `const` arguments --> $DIR/bad-reg.rs:28:15 diff --git a/tests/ui/feature-gates/feature-gate-asm_experimental_reg.aarch64.stderr b/tests/ui/feature-gates/feature-gate-asm_experimental_reg.aarch64.stderr index f19cb17a04a29..e1ac256ab7a79 100644 --- a/tests/ui/feature-gates/feature-gate-asm_experimental_reg.aarch64.stderr +++ b/tests/ui/feature-gates/feature-gate-asm_experimental_reg.aarch64.stderr @@ -8,6 +8,32 @@ LL | asm!("/* {0} */", in(preg) p); = help: add `#![feature(asm_experimental_reg)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date +error[E0658]: invalid asm template modifier `z` for this register class + --> $DIR/feature-gate-asm_experimental_reg.rs:53:24 + | +LL | unsafe { asm!("mov {1:z}.d, {0:z}.d", in(vreg) x, out(vreg) y) }; + | ^^^^^ template modifier ----------- argument + | + = note: the `vreg` register class only supports the following template modifiers on stable: `b`, `h`, `s`, `d`, `q`, and `v` + = note: enabling the `asm_experimental_reg` feature will allow using: `b`, `h`, `s`, `d`, `q`, `v`, and `z` + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: invalid asm template modifier `z` for this register class + --> $DIR/feature-gate-asm_experimental_reg.rs:53:33 + | +LL | unsafe { asm!("mov {1:z}.d, {0:z}.d", in(vreg) x, out(vreg) y) }; + | ^^^^^ ---------- argument + | | + | template modifier + | + = note: the `vreg` register class only supports the following template modifiers on stable: `b`, `h`, `s`, `d`, `q`, and `v` + = note: enabling the `asm_experimental_reg` feature will allow using: `b`, `h`, `s`, `d`, `q`, `v`, and `z` + = note: see issue #133416 for more information + = help: add `#![feature(asm_experimental_reg)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + error[E0658]: type `svint32_t` cannot be used with this register class in stable --> $DIR/feature-gate-asm_experimental_reg.rs:33:32 | @@ -48,6 +74,6 @@ LL | asm!("/* {0} */", in(preg) p); = help: add `#![feature(asm_experimental_reg)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 5 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-asm_experimental_reg.loongarch.stderr b/tests/ui/feature-gates/feature-gate-asm_experimental_reg.loongarch.stderr index 0f829dd65cb47..0eee8e9af60af 100644 --- a/tests/ui/feature-gates/feature-gate-asm_experimental_reg.loongarch.stderr +++ b/tests/ui/feature-gates/feature-gate-asm_experimental_reg.loongarch.stderr @@ -1,5 +1,5 @@ error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/feature-gate-asm_experimental_reg.rs:60:41 + --> $DIR/feature-gate-asm_experimental_reg.rs:69:41 | LL | asm!("xvadd.h {1:u}, {0:u}, {0:u}", out(vreg) y, in(vreg) x); | ^^^^^^^^^^^ @@ -9,7 +9,7 @@ LL | asm!("xvadd.h {1:u}, {0:u}, {0:u}", out(vreg) y, in(vreg) x); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: register class `vreg` can only be used as a clobber in stable - --> $DIR/feature-gate-asm_experimental_reg.rs:60:54 + --> $DIR/feature-gate-asm_experimental_reg.rs:69:54 | LL | asm!("xvadd.h {1:u}, {0:u}, {0:u}", out(vreg) y, in(vreg) x); | ^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | asm!("xvadd.h {1:u}, {0:u}, {0:u}", out(vreg) y, in(vreg) x); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `i8x16` cannot be used with this register class in stable - --> $DIR/feature-gate-asm_experimental_reg.rs:60:51 + --> $DIR/feature-gate-asm_experimental_reg.rs:69:51 | LL | asm!("xvadd.h {1:u}, {0:u}, {0:u}", out(vreg) y, in(vreg) x); | ^ @@ -29,7 +29,7 @@ LL | asm!("xvadd.h {1:u}, {0:u}, {0:u}", out(vreg) y, in(vreg) x); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: type `i8x16` cannot be used with this register class in stable - --> $DIR/feature-gate-asm_experimental_reg.rs:60:63 + --> $DIR/feature-gate-asm_experimental_reg.rs:69:63 | LL | asm!("xvadd.h {1:u}, {0:u}, {0:u}", out(vreg) y, in(vreg) x); | ^ diff --git a/tests/ui/feature-gates/feature-gate-asm_experimental_reg.rs b/tests/ui/feature-gates/feature-gate-asm_experimental_reg.rs index c91036366a028..f6c03e246dc46 100644 --- a/tests/ui/feature-gates/feature-gate-asm_experimental_reg.rs +++ b/tests/ui/feature-gates/feature-gate-asm_experimental_reg.rs @@ -47,6 +47,15 @@ unsafe fn predicate(p: svbool_t) { //[aarch64]~| ERROR type `svbool_t` cannot be used with this register class in stable } +#[cfg(aarch64)] +unsafe fn modifier(x: f64) -> f64 { + let y: f64; + unsafe { asm!("mov {1:z}.d, {0:z}.d", in(vreg) x, out(vreg) y) }; + //[aarch64]~^ ERROR invalid asm template modifier `z` for this register class + //[aarch64]~| ERROR invalid asm template modifier `z` for this register class + y +} + #[cfg(loongarch)] #[repr(simd)] pub struct i8x16([i8; 16]); diff --git a/tests/ui/rust-2024/prelude-migration/nested-use-statement.rs b/tests/ui/rust-2024/prelude-migration/nested-use-statement.rs new file mode 100644 index 0000000000000..9f42d523ddea4 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/nested-use-statement.rs @@ -0,0 +1,19 @@ +//! This test used to ICE because the lint did not handle +//! nested use trees in the new HIR representation. + +//@ check-pass + +#[warn(rust_2024_prelude_collisions)] +fn main() { + ().into_future() + //~^ WARN: `into_future` will become ambiguous + //~| WARN: is a hard error in Rust 2024 +} +#[rustfmt::skip] +use future::{IntoFuture}; +mod future { + pub trait IntoFuture { + fn into_future(&self) {} + } + impl IntoFuture for () {} +} diff --git a/tests/ui/rust-2024/prelude-migration/nested-use-statement.stderr b/tests/ui/rust-2024/prelude-migration/nested-use-statement.stderr new file mode 100644 index 0000000000000..af720c2141d73 --- /dev/null +++ b/tests/ui/rust-2024/prelude-migration/nested-use-statement.stderr @@ -0,0 +1,16 @@ +warning: trait method `into_future` will become ambiguous in Rust 2024 + --> $DIR/nested-use-statement.rs:8:5 + | +LL | ().into_future() + | ^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `IntoFuture::into_future(&())` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2024! + = note: for more information, see +note: the lint level is defined here + --> $DIR/nested-use-statement.rs:6:8 + | +LL | #[warn(rust_2024_prelude_collisions)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr index bc40b139095a5..1995f9d993a63 100644 --- a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr +++ b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.riscv.stderr @@ -1,7 +1,13 @@ +warning: unstable feature specified for `-Ctarget-feature`: `d` + | + = note: this feature is not stably supported; its behavior can change in the future + = 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 #162235 + warning: target feature `d` 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 #162235 -warning: 1 warning emitted +warning: 2 warnings emitted diff --git a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs index c6b5e15599d8e..c6370f01c47d6 100644 --- a/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs +++ b/tests/ui/target-feature/abi-incompatible-target-feature-flag-enable.rs @@ -19,4 +19,5 @@ extern crate minicore; use minicore::*; //~? WARN must be disabled to ensure that the ABI of the current target can be implemented correctly +//[riscv]~? WARN unstable feature specified for `-Ctarget-feature` //[x86]~? WARN use a soft-float target instead diff --git a/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr b/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr index e8a5e98793d10..c4ce26bfef8d3 100644 --- a/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.riscv.stderr @@ -1,7 +1,13 @@ +warning: unstable feature specified for `-Ctarget-feature`: `d` + | + = note: this feature is not stably supported; its behavior can change in the future + = 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 #162235 + warning: target feature `d` must be enabled 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 #162235 -warning: 1 warning emitted +warning: 2 warnings emitted diff --git a/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs b/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs index 4faef8d02d673..47b7abd50debb 100644 --- a/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs +++ b/tests/ui/target-feature/abi-required-target-feature-flag-disable.rs @@ -26,4 +26,4 @@ extern crate minicore; use minicore::*; //~? WARN must be enabled to ensure that the ABI of the current target can be implemented correctly -//[x86]~? WARN unstable feature specified for `-Ctarget-feature` +//[x86,riscv]~? WARN unstable feature specified for `-Ctarget-feature`