From e4194c7075ae35d45bdec1b779a2b57c400af60b Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sun, 12 Oct 2025 16:51:28 +0900 Subject: [PATCH 01/21] Deduplicate higher-ranked lifetime capture errors in impl Trait Previously, when an `impl Trait` captured multiple higher-ranked lifetimes from an outer `impl Trait`, the compiler would emit a separate error for each captured lifetime. This resulted in verbose and confusing diagnostics, especially in edition 2024 where implicit captures caused duplicate errors. This commit introduces error accumulation that collects all capture spans and lifetime declaration spans, then emits a single consolidated diagnostic using MultiSpan. The new error shows all captured lifetimes with visual indicators and lists all declarations in a single note. --- .../src/collect/resolve_bound_vars.rs | 69 ++++++++++++++++--- compiler/rustc_hir_analysis/src/errors.rs | 4 +- tests/ui/error-codes/E0657.stderr | 8 +-- ...e-capture-deduplication.edition2015.stderr | 17 +++++ ...e-capture-deduplication.edition2024.stderr | 17 +++++ ...r-ranked-lifetime-capture-deduplication.rs | 26 +++++++ .../ui/impl-trait/impl-fn-hrtb-bounds.stderr | 18 +++-- .../impl-fn-parsing-ambiguities.stderr | 6 +- .../issues/issue-54895.edition2015.stderr | 6 +- .../issues/issue-54895.edition2024.stderr | 18 ++--- tests/ui/impl-trait/issues/issue-54895.rs | 1 - tests/ui/impl-trait/issues/issue-67830.stderr | 6 +- .../ui/impl-trait/issues/issue-88236-2.stderr | 18 +++-- tests/ui/impl-trait/issues/issue-88236.stderr | 6 +- tests/ui/impl-trait/nested-rpit-hrtb.stderr | 20 +++--- .../bound-lifetime-through-dyn-trait.stderr | 4 +- .../escaping-bound-var.rs | 1 - .../escaping-bound-var.stderr | 16 +---- 18 files changed, 185 insertions(+), 76 deletions(-) create mode 100644 tests/ui/impl-trait/higher-ranked-lifetime-capture-deduplication.edition2015.stderr create mode 100644 tests/ui/impl-trait/higher-ranked-lifetime-capture-deduplication.edition2024.stderr create mode 100644 tests/ui/impl-trait/higher-ranked-lifetime-capture-deduplication.rs diff --git a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs index 8133f9f68234b..6f7ce916c7ac7 100644 --- a/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs +++ b/compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs @@ -66,6 +66,13 @@ struct BoundVarContext<'a, 'tcx> { rbv: &'a mut ResolveBoundVars, disambiguator: &'a mut DisambiguatorState, scope: ScopeRef<'a>, + opaque_capture_errors: RefCell>, +} + +struct OpaqueHigherRankedLifetimeCaptureErrors { + bad_place: &'static str, + capture_spans: Vec, + decl_spans: Vec, } #[derive(Debug)] @@ -253,6 +260,7 @@ fn resolve_bound_vars(tcx: TyCtxt<'_>, local_def_id: hir::OwnerId) -> ResolveBou rbv: &mut rbv, scope: &Scope::Root { opt_parent_item: None }, disambiguator: &mut DisambiguatorState::new(), + opaque_capture_errors: RefCell::new(None), }; match tcx.hir_owner_node(local_def_id) { hir::OwnerNode::Item(item) => visitor.visit_item(item), @@ -597,6 +605,8 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> { }) }); + self.emit_opaque_capture_errors(); + let captures = captures.into_inner().into_iter().collect(); debug!(?captures); self.rbv.opaque_captured_lifetimes.insert(opaque.def_id, captures); @@ -1089,12 +1099,20 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { F: for<'b> FnOnce(&mut BoundVarContext<'b, 'tcx>), { let BoundVarContext { tcx, rbv, disambiguator, .. } = self; - let mut this = BoundVarContext { tcx: *tcx, rbv, disambiguator, scope: &wrap_scope }; + let nested_errors = RefCell::new(self.opaque_capture_errors.borrow_mut().take()); + let mut this = BoundVarContext { + tcx: *tcx, + rbv, + disambiguator, + scope: &wrap_scope, + opaque_capture_errors: nested_errors, + }; let span = debug_span!("scope", scope = ?this.scope.debug_truncated()); { let _enter = span.enter(); f(&mut this); } + *self.opaque_capture_errors.borrow_mut() = this.opaque_capture_errors.into_inner(); } fn record_late_bound_vars(&mut self, hir_id: HirId, binder: Vec) { @@ -1424,21 +1442,52 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> { }; let decl_span = self.tcx.def_span(lifetime_def_id); - let (span, label) = if capture_span != decl_span { - (capture_span, None) - } else { - let opaque_span = self.tcx.def_span(opaque_def_id); - (opaque_span, Some(opaque_span)) - }; + let opaque_span = self.tcx.def_span(opaque_def_id); + + let mut errors = self.opaque_capture_errors.borrow_mut(); + let error_info = errors.get_or_insert_with(|| OpaqueHigherRankedLifetimeCaptureErrors { + bad_place, + capture_spans: Vec::new(), + decl_spans: Vec::new(), + }); + + if error_info.capture_spans.is_empty() { + error_info.capture_spans.push(opaque_span); + } + + if capture_span != decl_span && capture_span != opaque_span { + error_info.capture_spans.push(capture_span); + } + + if !error_info.decl_spans.contains(&decl_span) { + error_info.decl_spans.push(decl_span); + } + + // Errors should be emitted by `emit_opaque_capture_errors`. + Err(self.tcx.dcx().span_delayed_bug(capture_span, "opaque capture error not emitted")) + } + + fn emit_opaque_capture_errors(&self) -> Option { + let errors = self.opaque_capture_errors.borrow_mut().take()?; + if errors.capture_spans.is_empty() { + return None; + } + + let mut span = rustc_errors::MultiSpan::from_span(errors.capture_spans[0]); + for &capture_span in &errors.capture_spans[1..] { + span.push_span_label(capture_span, ""); + } + let decl_span = rustc_errors::MultiSpan::from_spans(errors.decl_spans); // Ensure that the parent of the def is an item, not HRTB let guar = self.tcx.dcx().emit_err(errors::OpaqueCapturesHigherRankedLifetime { span, - label, + label: Some(errors.capture_spans[0]), decl_span, - bad_place, + bad_place: errors.bad_place, }); - Err(guar) + + Some(guar) } #[instrument(level = "trace", skip(self, opaque_capture_scopes), ret)] diff --git a/compiler/rustc_hir_analysis/src/errors.rs b/compiler/rustc_hir_analysis/src/errors.rs index 49c5106422881..c0cb6f7327993 100644 --- a/compiler/rustc_hir_analysis/src/errors.rs +++ b/compiler/rustc_hir_analysis/src/errors.rs @@ -1562,11 +1562,11 @@ pub(crate) struct UnconstrainedGenericParameter { #[diag(hir_analysis_opaque_captures_higher_ranked_lifetime, code = E0657)] pub(crate) struct OpaqueCapturesHigherRankedLifetime { #[primary_span] - pub span: Span, + pub span: MultiSpan, #[label] pub label: Option, #[note] - pub decl_span: Span, + pub decl_span: MultiSpan, pub bad_place: &'static str, } diff --git a/tests/ui/error-codes/E0657.stderr b/tests/ui/error-codes/E0657.stderr index c9dfc9eb9069d..1d69af5d9654a 100644 --- a/tests/ui/error-codes/E0657.stderr +++ b/tests/ui/error-codes/E0657.stderr @@ -1,8 +1,8 @@ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type - --> $DIR/E0657.rs:10:35 + --> $DIR/E0657.rs:10:27 | LL | -> Box Id>> - | ^^ + | ^^^^^^^^--^ `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/E0657.rs:10:20 @@ -11,10 +11,10 @@ LL | -> Box Id>> | ^^ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type - --> $DIR/E0657.rs:19:39 + --> $DIR/E0657.rs:19:31 | LL | -> Box Id>> - | ^^ + | ^^^^^^^^--^ `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/E0657.rs:19:24 diff --git a/tests/ui/impl-trait/higher-ranked-lifetime-capture-deduplication.edition2015.stderr b/tests/ui/impl-trait/higher-ranked-lifetime-capture-deduplication.edition2015.stderr new file mode 100644 index 0000000000000..8954a802ab952 --- /dev/null +++ b/tests/ui/impl-trait/higher-ranked-lifetime-capture-deduplication.edition2015.stderr @@ -0,0 +1,17 @@ +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` + --> $DIR/higher-ranked-lifetime-capture-deduplication.rs:19:44 + | +LL | fn f() -> impl for<'a, 'b> Trait<'a, Out = impl Sized + 'a + 'b> { + | ^^^^^^^^^^^^^--^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope + | +note: lifetime declared here + --> $DIR/higher-ranked-lifetime-capture-deduplication.rs:19:20 + | +LL | fn f() -> impl for<'a, 'b> Trait<'a, Out = impl Sized + 'a + 'b> { + | ^^ ^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/impl-trait/higher-ranked-lifetime-capture-deduplication.edition2024.stderr b/tests/ui/impl-trait/higher-ranked-lifetime-capture-deduplication.edition2024.stderr new file mode 100644 index 0000000000000..8954a802ab952 --- /dev/null +++ b/tests/ui/impl-trait/higher-ranked-lifetime-capture-deduplication.edition2024.stderr @@ -0,0 +1,17 @@ +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` + --> $DIR/higher-ranked-lifetime-capture-deduplication.rs:19:44 + | +LL | fn f() -> impl for<'a, 'b> Trait<'a, Out = impl Sized + 'a + 'b> { + | ^^^^^^^^^^^^^--^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope + | +note: lifetime declared here + --> $DIR/higher-ranked-lifetime-capture-deduplication.rs:19:20 + | +LL | fn f() -> impl for<'a, 'b> Trait<'a, Out = impl Sized + 'a + 'b> { + | ^^ ^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/impl-trait/higher-ranked-lifetime-capture-deduplication.rs b/tests/ui/impl-trait/higher-ranked-lifetime-capture-deduplication.rs new file mode 100644 index 0000000000000..d8da93e5560d7 --- /dev/null +++ b/tests/ui/impl-trait/higher-ranked-lifetime-capture-deduplication.rs @@ -0,0 +1,26 @@ +//@revisions: edition2015 edition2024 +//@[edition2015] edition:2015 +//@[edition2024] edition:2024 + +trait Trait<'a> { + type Out; + fn call(&'a self) -> Self::Out; +} + +struct X(()); + +impl<'a> Trait<'a> for X { + type Out = (); + fn call(&'a self) -> Self::Out { + () + } +} + +fn f() -> impl for<'a, 'b> Trait<'a, Out = impl Sized + 'a + 'b> { + //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` + X(()) +} + +fn main() { + let _ = f(); +} diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr index 40cb6b647d1e9..36f52e8103a33 100644 --- a/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds.stderr @@ -12,10 +12,12 @@ LL + fn d() -> impl Fn() -> (impl Debug + 'static) { | error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/impl-fn-hrtb-bounds.rs:4:41 + --> $DIR/impl-fn-hrtb-bounds.rs:4:28 | LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) { - | ^^ + | ^^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/impl-fn-hrtb-bounds.rs:4:19 @@ -24,10 +26,12 @@ LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) { | ^ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/impl-fn-hrtb-bounds.rs:9:52 + --> $DIR/impl-fn-hrtb-bounds.rs:9:39 | LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { - | ^^ + | ^^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/impl-fn-hrtb-bounds.rs:9:20 @@ -36,10 +40,12 @@ LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) { | ^^ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/impl-fn-hrtb-bounds.rs:14:52 + --> $DIR/impl-fn-hrtb-bounds.rs:14:39 | LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) { - | ^^ + | ^^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/impl-fn-hrtb-bounds.rs:14:20 diff --git a/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr b/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr index 94b6ffdd91230..5ba9567e14e37 100644 --- a/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr +++ b/tests/ui/impl-trait/impl-fn-parsing-ambiguities.stderr @@ -21,10 +21,12 @@ LL | fn b() -> impl Fn() -> (impl Debug + Send) { | + + error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/impl-fn-parsing-ambiguities.rs:4:40 + --> $DIR/impl-fn-parsing-ambiguities.rs:4:27 | LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ { - | ^^ + | ^^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/impl-fn-parsing-ambiguities.rs:4:19 diff --git a/tests/ui/impl-trait/issues/issue-54895.edition2015.stderr b/tests/ui/impl-trait/issues/issue-54895.edition2015.stderr index 27a3c6c8b7ce0..8348a1d5e87b1 100644 --- a/tests/ui/impl-trait/issues/issue-54895.edition2015.stderr +++ b/tests/ui/impl-trait/issues/issue-54895.edition2015.stderr @@ -1,8 +1,10 @@ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/issue-54895.rs:18:53 + --> $DIR/issue-54895.rs:18:40 | LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { - | ^^ + | ^^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/issue-54895.rs:18:20 diff --git a/tests/ui/impl-trait/issues/issue-54895.edition2024.stderr b/tests/ui/impl-trait/issues/issue-54895.edition2024.stderr index 54aa29e62d880..8348a1d5e87b1 100644 --- a/tests/ui/impl-trait/issues/issue-54895.edition2024.stderr +++ b/tests/ui/impl-trait/issues/issue-54895.edition2024.stderr @@ -2,7 +2,9 @@ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `imp --> $DIR/issue-54895.rs:18:40 | LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { - | ^^^^^^^^^^^^^^^ `impl Trait` implicitly captures all lifetimes in scope + | ^^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/issue-54895.rs:18:20 @@ -10,18 +12,6 @@ note: lifetime declared here LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { | ^^ -error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/issue-54895.rs:18:53 - | -LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { - | ^^ - | -note: lifetime declared here - --> $DIR/issue-54895.rs:18:20 - | -LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { - | ^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/impl-trait/issues/issue-54895.rs b/tests/ui/impl-trait/issues/issue-54895.rs index bc1841209e170..ccdb0ce20f9a0 100644 --- a/tests/ui/impl-trait/issues/issue-54895.rs +++ b/tests/ui/impl-trait/issues/issue-54895.rs @@ -17,7 +17,6 @@ impl<'a> Trait<'a> for X { fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - //[edition2024]~^^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` X(()) } diff --git a/tests/ui/impl-trait/issues/issue-67830.stderr b/tests/ui/impl-trait/issues/issue-67830.stderr index a7633c7f20b65..7254955ed0bde 100644 --- a/tests/ui/impl-trait/issues/issue-67830.stderr +++ b/tests/ui/impl-trait/issues/issue-67830.stderr @@ -1,8 +1,10 @@ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/issue-67830.rs:20:64 + --> $DIR/issue-67830.rs:20:48 | LL | fn test() -> impl for<'a> MyFn<&'a A, Output = impl Iterator + 'a> { - | ^^ + | ^^^^^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/issue-67830.rs:20:23 diff --git a/tests/ui/impl-trait/issues/issue-88236-2.stderr b/tests/ui/impl-trait/issues/issue-88236-2.stderr index 4ded9ed386fa6..3943c41218454 100644 --- a/tests/ui/impl-trait/issues/issue-88236-2.stderr +++ b/tests/ui/impl-trait/issues/issue-88236-2.stderr @@ -1,8 +1,10 @@ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/issue-88236-2.rs:15:61 + --> $DIR/issue-88236-2.rs:15:49 | LL | fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {} - | ^^ + | ^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/issue-88236-2.rs:15:28 @@ -11,10 +13,12 @@ LL | fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {} | ^^ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/issue-88236-2.rs:18:80 + --> $DIR/issue-88236-2.rs:18:68 | LL | fn make_weird_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> { - | ^^ + | ^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/issue-88236-2.rs:18:47 @@ -23,10 +27,12 @@ LL | fn make_weird_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Sen | ^^ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/issue-88236-2.rs:23:78 + --> $DIR/issue-88236-2.rs:23:66 | LL | fn make_bad_impl<'b>(x: &'b ()) -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> { - | ^^ + | ^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/issue-88236-2.rs:23:45 diff --git a/tests/ui/impl-trait/issues/issue-88236.stderr b/tests/ui/impl-trait/issues/issue-88236.stderr index 5dee5f88c89f2..6303379288b7f 100644 --- a/tests/ui/impl-trait/issues/issue-88236.stderr +++ b/tests/ui/impl-trait/issues/issue-88236.stderr @@ -1,8 +1,10 @@ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/issue-88236.rs:15:61 + --> $DIR/issue-88236.rs:15:49 | LL | fn make_impl() -> impl for<'a> Hrtb<'a, Assoc = impl Send + 'a> {} - | ^^ + | ^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/issue-88236.rs:15:28 diff --git a/tests/ui/impl-trait/nested-rpit-hrtb.stderr b/tests/ui/impl-trait/nested-rpit-hrtb.stderr index 93cd7bd788f45..130723035b1ac 100644 --- a/tests/ui/impl-trait/nested-rpit-hrtb.stderr +++ b/tests/ui/impl-trait/nested-rpit-hrtb.stderr @@ -30,10 +30,12 @@ LL | fn two_htrb_outlives_uses<'b>() -> impl for<'a> Bar<'a, Assoc = impl for<'b | ++++ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/nested-rpit-hrtb.rs:25:69 + --> $DIR/nested-rpit-hrtb.rs:25:56 | LL | fn one_hrtb_outlives() -> impl for<'a> Foo<'a, Assoc = impl Sized + 'a> {} - | ^^ + | ^^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/nested-rpit-hrtb.rs:25:36 @@ -42,10 +44,10 @@ LL | fn one_hrtb_outlives() -> impl for<'a> Foo<'a, Assoc = impl Sized + 'a> {} | ^^ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/nested-rpit-hrtb.rs:29:68 + --> $DIR/nested-rpit-hrtb.rs:29:59 | LL | fn one_hrtb_trait_param() -> impl for<'a> Foo<'a, Assoc = impl Qux<'a>> {} - | ^^ + | ^^^^^^^^^--^ `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/nested-rpit-hrtb.rs:29:39 @@ -54,10 +56,12 @@ LL | fn one_hrtb_trait_param() -> impl for<'a> Foo<'a, Assoc = impl Qux<'a>> {} | ^^ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/nested-rpit-hrtb.rs:32:74 + --> $DIR/nested-rpit-hrtb.rs:32:61 | LL | fn one_hrtb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'a> {} - | ^^ + | ^^^^^^^^^^^^^-- + | | + | `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/nested-rpit-hrtb.rs:32:41 @@ -66,10 +70,10 @@ LL | fn one_hrtb_outlives_uses() -> impl for<'a> Bar<'a, Assoc = impl Sized + 'a | ^^ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/nested-rpit-hrtb.rs:35:73 + --> $DIR/nested-rpit-hrtb.rs:35:64 | LL | fn one_hrtb_trait_param_uses() -> impl for<'a> Bar<'a, Assoc = impl Qux<'a>> {} - | ^^ + | ^^^^^^^^^--^ `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/nested-rpit-hrtb.rs:35:44 diff --git a/tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.stderr b/tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.stderr index 7219fda4772a2..6f0c6bb22060a 100644 --- a/tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.stderr +++ b/tests/ui/type-alias-impl-trait/bound-lifetime-through-dyn-trait.stderr @@ -1,8 +1,8 @@ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from `dyn` type - --> $DIR/bound-lifetime-through-dyn-trait.rs:6:71 + --> $DIR/bound-lifetime-through-dyn-trait.rs:6:57 | LL | fn dyn_hoops() -> dyn for<'a> Iterator> { - | ^^ + | ^^^^^^^^^^^^^^--^ `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/bound-lifetime-through-dyn-trait.rs:6:37 diff --git a/tests/ui/type-alias-impl-trait/escaping-bound-var.rs b/tests/ui/type-alias-impl-trait/escaping-bound-var.rs index 31bdd0815ec34..4b17448080ed7 100644 --- a/tests/ui/type-alias-impl-trait/escaping-bound-var.rs +++ b/tests/ui/type-alias-impl-trait/escaping-bound-var.rs @@ -8,7 +8,6 @@ trait Test<'a> {} pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>; //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` -//~| ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` impl Trait<'_> for () { type Assoc = (); diff --git a/tests/ui/type-alias-impl-trait/escaping-bound-var.stderr b/tests/ui/type-alias-impl-trait/escaping-bound-var.stderr index c9f0618639afb..cdbcfa6f3dc95 100644 --- a/tests/ui/type-alias-impl-trait/escaping-bound-var.stderr +++ b/tests/ui/type-alias-impl-trait/escaping-bound-var.stderr @@ -2,7 +2,7 @@ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `imp --> $DIR/escaping-bound-var.rs:9:47 | LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>; - | ^^^^^^^^^^^^^ `impl Trait` implicitly captures all lifetimes in scope + | ^^^^^^^^^^--^ `impl Trait` implicitly captures all lifetimes in scope | note: lifetime declared here --> $DIR/escaping-bound-var.rs:9:25 @@ -10,18 +10,6 @@ note: lifetime declared here LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>; | ^^ -error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/escaping-bound-var.rs:9:57 - | -LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>; - | ^^ - | -note: lifetime declared here - --> $DIR/escaping-bound-var.rs:9:25 - | -LL | pub type Foo = impl for<'a> Trait<'a, Assoc = impl Test<'a>>; - | ^^ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0657`. From d60e7cf94b514897c4185ebab08438af281a464b Mon Sep 17 00:00:00 2001 From: chenx97 Date: Thu, 30 Oct 2025 20:47:36 +0800 Subject: [PATCH 02/21] callconv: adapt mips padding logic to mips64 MIPS64 needs to put a padding argument before an aggregate argument when this argument is in an odd-number position, starting from 0, and has an alignment of 16 bytes or higher, e.g. `void foo(int a, max_align_t b);` is the same as `void foo(int a, long _padding, max_align_t b);` This fix uses an i32 padding, but it should work just fine because i32 is aligned like i64 for arguments. --- compiler/rustc_target/src/callconv/mips64.rs | 121 ++++++++++--------- 1 file changed, 65 insertions(+), 56 deletions(-) diff --git a/compiler/rustc_target/src/callconv/mips64.rs b/compiler/rustc_target/src/callconv/mips64.rs index a4e94ce816051..4fafa7b3a5e2c 100644 --- a/compiler/rustc_target/src/callconv/mips64.rs +++ b/compiler/rustc_target/src/callconv/mips64.rs @@ -34,7 +34,7 @@ where } } -fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>) +fn classify_ret<'a, Ty, C>(cx: &C, ret: &mut ArgAbi<'a, Ty>, offset: &mut Size) where Ty: TyAbiInterface<'a, C> + Copy, C: HasDataLayout, @@ -70,77 +70,82 @@ where ret.cast_to(Uniform::new(Reg::i64(), size)); } else { ret.make_indirect(); + *offset += cx.data_layout().pointer_size(); } } -fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>) +fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>, offset: &mut Size) where Ty: TyAbiInterface<'a, C> + Copy, C: HasDataLayout, { - if !arg.layout.is_aggregate() { - extend_integer_width_mips(arg, 64); - return; - } - if arg.layout.pass_indirectly_in_non_rustic_abis(cx) { - arg.make_indirect(); - return; - } - let dl = cx.data_layout(); let size = arg.layout.size; let mut prefix = [None; 8]; let mut prefix_index = 0; - match arg.layout.fields { - FieldsShape::Primitive => unreachable!(), - FieldsShape::Array { .. } => { - // Arrays are passed indirectly - arg.make_indirect(); - return; - } - FieldsShape::Union(_) => { - // Unions and are always treated as a series of 64-bit integer chunks - } - FieldsShape::Arbitrary { .. } => { - // Structures are split up into a series of 64-bit integer chunks, but any aligned - // doubles not part of another aggregate are passed as floats. - let mut last_offset = Size::ZERO; - - for i in 0..arg.layout.fields.count() { - let field = arg.layout.field(cx, i); - let offset = arg.layout.fields.offset(i); - - // We only care about aligned doubles - if let BackendRepr::Scalar(scalar) = field.backend_repr { - if scalar.primitive() == Primitive::Float(Float::F64) { - if offset.is_aligned(dl.f64_align) { - // Insert enough integers to cover [last_offset, offset) - assert!(last_offset.is_aligned(dl.f64_align)); - for _ in 0..((offset - last_offset).bits() / 64) - .min((prefix.len() - prefix_index) as u64) - { - prefix[prefix_index] = Some(Reg::i64()); - prefix_index += 1; - } + // Detect need for padding + let align = Ord::clamp(arg.layout.align.abi, dl.i64_align, dl.i128_align); + let pad_i32 = !offset.is_aligned(align); - if prefix_index == prefix.len() { - break; + if !arg.layout.is_aggregate() { + extend_integer_width_mips(arg, 64); + } else if arg.layout.pass_indirectly_in_non_rustic_abis(cx) { + arg.make_indirect(); + } else { + match arg.layout.fields { + FieldsShape::Primitive => unreachable!(), + FieldsShape::Array { .. } => { + // Arrays are passed indirectly + arg.make_indirect(); + } + FieldsShape::Union(_) => { + // Unions and are always treated as a series of 64-bit integer chunks + } + FieldsShape::Arbitrary { .. } => { + // Structures are split up into a series of 64-bit integer chunks, but any aligned + // doubles not part of another aggregate are passed as floats. + let mut last_offset = Size::ZERO; + + for i in 0..arg.layout.fields.count() { + let field = arg.layout.field(cx, i); + let offset = arg.layout.fields.offset(i); + + // We only care about aligned doubles + if let BackendRepr::Scalar(scalar) = field.backend_repr { + if scalar.primitive() == Primitive::Float(Float::F64) { + if offset.is_aligned(dl.f64_align) { + // Insert enough integers to cover [last_offset, offset) + assert!(last_offset.is_aligned(dl.f64_align)); + for _ in 0..((offset - last_offset).bits() / 64) + .min((prefix.len() - prefix_index) as u64) + { + prefix[prefix_index] = Some(Reg::i64()); + prefix_index += 1; + } + + if prefix_index == prefix.len() { + break; + } + + prefix[prefix_index] = Some(Reg::f64()); + prefix_index += 1; + last_offset = offset + Reg::f64().size; } - - prefix[prefix_index] = Some(Reg::f64()); - prefix_index += 1; - last_offset = offset + Reg::f64().size; } } } } - } - }; - - // Extract first 8 chunks as the prefix - let rest_size = size - Size::from_bytes(8) * prefix_index as u64; - arg.cast_to(CastTarget::prefixed(prefix, Uniform::new(Reg::i64(), rest_size))); + }; + + // Extract first 8 chunks as the prefix + let rest_size = size - Size::from_bytes(8) * prefix_index as u64; + arg.cast_to_and_pad_i32( + CastTarget::prefixed(prefix, Uniform::new(Reg::i64(), rest_size)), + pad_i32, + ); + } + *offset = offset.align_to(align) + size.align_to(align); } pub(crate) fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>) @@ -148,14 +153,18 @@ where Ty: TyAbiInterface<'a, C> + Copy, C: HasDataLayout, { + // mips64 argument passing is also affected by the alignment of aggregates. + // see mips.rs for how the offset is used + let mut offset = Size::ZERO; + if !fn_abi.ret.is_ignore() && fn_abi.ret.layout.is_sized() { - classify_ret(cx, &mut fn_abi.ret); + classify_ret(cx, &mut fn_abi.ret, &mut offset); } for arg in fn_abi.args.iter_mut() { if arg.is_ignore() || !arg.layout.is_sized() { continue; } - classify_arg(cx, arg); + classify_arg(cx, arg, &mut offset); } } From c906b2a1d67a204259acc76801ebdf7c50b298d2 Mon Sep 17 00:00:00 2001 From: Jamie Hill-Daniel Date: Fri, 28 Nov 2025 11:47:27 +0000 Subject: [PATCH 03/21] tidy: Detect outdated workspaces in workspace list --- src/tools/tidy/src/deps.rs | 42 ++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 5b34f393316f7..716068bef32f3 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -1,6 +1,7 @@ //! Checks the licenses of third-party dependencies. use std::collections::{HashMap, HashSet}; +use std::fmt::{Display, Formatter}; use std::fs::{File, read_dir}; use std::io::Write; use std::path::Path; @@ -14,6 +15,25 @@ use crate::diagnostics::{RunningCheck, TidyCtx}; #[path = "../../../bootstrap/src/utils/proc_macro_deps.rs"] mod proc_macro_deps; +#[derive(Clone, Copy)] +struct ListLocation { + path: &'static str, + line: u32, +} + +impl Display for ListLocation { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{}:{}", self.path, self.line) + } +} + +/// Creates a [`ListLocation`] for the current location (with an additional offset to the actual list start); +macro_rules! location { + (+ $offset:literal) => { + ListLocation { path: file!(), line: line!() + $offset } + }; +} + /// These are licenses that are allowed for all crates, including the runtime, /// rustc, tools, etc. #[rustfmt::skip] @@ -87,6 +107,8 @@ pub(crate) struct WorkspaceInfo<'a> { pub(crate) submodules: &'a [&'a str], } +const WORKSPACE_LOCATION: ListLocation = location!(+4); + /// The workspaces to check for licensing and optionally permitted dependencies. // FIXME auto detect all cargo workspaces pub(crate) const WORKSPACES: &[WorkspaceInfo<'static>] = &[ @@ -248,19 +270,6 @@ const EXCEPTIONS_BOOTSTRAP: ExceptionList = &[]; const EXCEPTIONS_UEFI_QEMU_TEST: ExceptionList = &[]; -#[derive(Clone, Copy)] -struct ListLocation { - path: &'static str, - line: u32, -} - -/// Creates a [`ListLocation`] for the current location (with an additional offset to the actual list start); -macro_rules! location { - (+ $offset:literal) => { - ListLocation { path: file!(), line: line!() + $offset } - }; -} - const PERMITTED_RUSTC_DEPS_LOCATION: ListLocation = location!(+6); /// Crates rustc is allowed to depend on. Avoid adding to the list if possible. @@ -646,6 +655,13 @@ pub fn check(root: &Path, cargo: &Path, tidy_ctx: TidyCtx) { .other_options(vec!["--locked".to_owned()]); let metadata = t!(cmd.exec()); + // Check for packages which have been moved into a different workspace and not updated + let canonicalized_root = + if path == "." { root.to_path_buf() } else { t!(root.join(path).canonicalize()) }; + let canonicalized_root_real = t!(metadata.workspace_root.canonicalize()); + if canonicalized_root_real != canonicalized_root { + check.error(format!("{path} is part of another workspace, remove from `WORKSPACES` ({WORKSPACE_LOCATION})")); + } check_license_exceptions(&metadata, path, exceptions, &mut check); if let Some((crates, permitted_deps, location)) = crates_and_deps { let descr = crates.get(0).unwrap_or(&path); From 8f55c15bfe539a012f111bd00687241ad5a4a947 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 15 Oct 2025 09:55:38 +0000 Subject: [PATCH 04/21] Remove -Zoom=panic There are major questions remaining about the reentrancy that this allows. It doesn't have any users on github outside of a single project that uses it in a panic=abort project to show backtraces. It can still be emulated through #[alloc_error_handler] or set_alloc_error_hook depending on if you use the standard library or not. And finally it makes it harder to do various improvements to the allocator shim. --- .../rustc_codegen_cranelift/src/allocator.rs | 39 +--------------- compiler/rustc_codegen_gcc/src/allocator.rs | 39 +--------------- compiler/rustc_codegen_llvm/src/allocator.rs | 44 +------------------ .../src/back/symbol_export.rs | 3 +- compiler/rustc_interface/src/tests.rs | 9 ++-- compiler/rustc_session/src/config.rs | 26 +---------- compiler/rustc_session/src/options.rs | 12 ----- library/alloc/src/alloc.rs | 19 ++------ library/std/src/alloc.rs | 11 ----- src/tools/miri/src/shims/foreign_items.rs | 9 +--- .../tests/panic/alloc_error_handler_panic.rs | 18 -------- .../panic/alloc_error_handler_panic.stderr | 6 --- ...c-unwind.rs => alloc_error_hook-unwind.rs} | 8 ++-- 13 files changed, 22 insertions(+), 221 deletions(-) delete mode 100644 src/tools/miri/tests/panic/alloc_error_handler_panic.rs delete mode 100644 src/tools/miri/tests/panic/alloc_error_handler_panic.stderr rename tests/ui/panics/{oom-panic-unwind.rs => alloc_error_hook-unwind.rs} (84%) diff --git a/compiler/rustc_codegen_cranelift/src/allocator.rs b/compiler/rustc_codegen_cranelift/src/allocator.rs index 67b89114356b5..4a9b0c0952ff3 100644 --- a/compiler/rustc_codegen_cranelift/src/allocator.rs +++ b/compiler/rustc_codegen_cranelift/src/allocator.rs @@ -6,7 +6,6 @@ use rustc_ast::expand::allocator::{ AllocatorMethod, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, default_fn_name, global_fn_name, }; use rustc_codegen_ssa::base::{allocator_kind_for_codegen, allocator_shim_contents}; -use rustc_session::config::OomStrategy; use rustc_symbol_mangling::mangle_internal_symbol; use crate::prelude::*; @@ -15,16 +14,11 @@ use crate::prelude::*; pub(crate) fn codegen(tcx: TyCtxt<'_>, module: &mut dyn Module) -> bool { let Some(kind) = allocator_kind_for_codegen(tcx) else { return false }; let methods = allocator_shim_contents(tcx, kind); - codegen_inner(tcx, module, &methods, tcx.sess.opts.unstable_opts.oom); + codegen_inner(tcx, module, &methods); true } -fn codegen_inner( - tcx: TyCtxt<'_>, - module: &mut dyn Module, - methods: &[AllocatorMethod], - oom_strategy: OomStrategy, -) { +fn codegen_inner(tcx: TyCtxt<'_>, module: &mut dyn Module, methods: &[AllocatorMethod]) { let usize_ty = module.target_config().pointer_type(); for method in methods { @@ -65,35 +59,6 @@ fn codegen_inner( ); } - { - let sig = Signature { - call_conv: module.target_config().default_call_conv, - params: vec![], - returns: vec![AbiParam::new(types::I8)], - }; - let func_id = module - .declare_function( - &mangle_internal_symbol(tcx, OomStrategy::SYMBOL), - Linkage::Export, - &sig, - ) - .unwrap(); - let mut ctx = Context::new(); - ctx.func.signature = sig; - { - let mut func_ctx = FunctionBuilderContext::new(); - let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx); - - let block = bcx.create_block(); - bcx.switch_to_block(block); - let value = bcx.ins().iconst(types::I8, oom_strategy.should_panic() as i64); - bcx.ins().return_(&[value]); - bcx.seal_all_blocks(); - bcx.finalize(); - } - module.define_function(func_id, &mut ctx).unwrap(); - } - { let sig = Signature { call_conv: module.target_config().default_call_conv, diff --git a/compiler/rustc_codegen_gcc/src/allocator.rs b/compiler/rustc_codegen_gcc/src/allocator.rs index 647569694b04d..1f464d7e1226f 100644 --- a/compiler/rustc_codegen_gcc/src/allocator.rs +++ b/compiler/rustc_codegen_gcc/src/allocator.rs @@ -1,12 +1,11 @@ #[cfg(feature = "master")] use gccjit::FnAttribute; -use gccjit::{Context, FunctionType, RValue, ToRValue, Type}; +use gccjit::{Context, FunctionType, ToRValue, Type}; use rustc_ast::expand::allocator::{ AllocatorMethod, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE, default_fn_name, global_fn_name, }; use rustc_middle::bug; use rustc_middle::ty::TyCtxt; -use rustc_session::config::OomStrategy; use rustc_symbol_mangling::mangle_internal_symbol; use crate::GccContext; @@ -59,14 +58,6 @@ pub(crate) unsafe fn codegen( create_wrapper_function(tcx, context, &from_name, Some(&to_name), &types, output); } - create_const_value_function( - tcx, - context, - &mangle_internal_symbol(tcx, OomStrategy::SYMBOL), - i8, - context.new_rvalue_from_int(i8, tcx.sess.opts.unstable_opts.oom.should_panic() as i32), - ); - create_wrapper_function( tcx, context, @@ -77,34 +68,6 @@ pub(crate) unsafe fn codegen( ); } -fn create_const_value_function( - tcx: TyCtxt<'_>, - context: &Context<'_>, - name: &str, - output: Type<'_>, - value: RValue<'_>, -) { - let func = context.new_function(None, FunctionType::Exported, output, &[], name, false); - - #[cfg(feature = "master")] - { - func.add_attribute(FnAttribute::Visibility(symbol_visibility_to_gcc( - tcx.sess.default_visibility(), - ))); - - // FIXME(antoyo): cg_llvm sets AlwaysInline, but AlwaysInline is different in GCC and using - // it here will causes linking errors when using LTO. - func.add_attribute(FnAttribute::Inline); - } - - if tcx.sess.must_emit_unwind_tables() { - // TODO(antoyo): emit unwind tables. - } - - let block = func.new_block("entry"); - block.end_with_return(None, value); -} - fn create_wrapper_function( tcx: TyCtxt<'_>, context: &Context<'_>, diff --git a/compiler/rustc_codegen_llvm/src/allocator.rs b/compiler/rustc_codegen_llvm/src/allocator.rs index de0b85ebb63b8..24b2bd37aa46c 100644 --- a/compiler/rustc_codegen_llvm/src/allocator.rs +++ b/compiler/rustc_codegen_llvm/src/allocator.rs @@ -7,13 +7,13 @@ use rustc_codegen_ssa::traits::BaseTypeCodegenMethods as _; use rustc_middle::bug; use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}; use rustc_middle::ty::TyCtxt; -use rustc_session::config::{DebugInfo, OomStrategy}; +use rustc_session::config::DebugInfo; use rustc_symbol_mangling::mangle_internal_symbol; use crate::attributes::llfn_attrs_from_instance; use crate::builder::SBuilder; use crate::declare::declare_simple_fn; -use crate::llvm::{self, FALSE, FromGeneric, TRUE, Type, Value}; +use crate::llvm::{self, FromGeneric, TRUE, Type}; use crate::{SimpleCx, attributes, debuginfo}; pub(crate) unsafe fn codegen( @@ -28,7 +28,6 @@ pub(crate) unsafe fn codegen( 64 => cx.type_i64(), tws => bug!("Unsupported target word size for int: {}", tws), }; - let i8 = cx.type_i8(); let i8p = cx.type_ptr(); for method in methods { @@ -87,17 +86,6 @@ pub(crate) unsafe fn codegen( ); } - // __rust_alloc_error_handler_should_panic_v2 - create_const_value_function( - tcx, - &cx, - &mangle_internal_symbol(tcx, OomStrategy::SYMBOL), - &i8, - unsafe { - llvm::LLVMConstInt(i8, tcx.sess.opts.unstable_opts.oom.should_panic() as u64, FALSE) - }, - ); - // __rust_no_alloc_shim_is_unstable_v2 create_wrapper_function( tcx, @@ -117,34 +105,6 @@ pub(crate) unsafe fn codegen( } } -fn create_const_value_function( - tcx: TyCtxt<'_>, - cx: &SimpleCx<'_>, - name: &str, - output: &Type, - value: &Value, -) { - let ty = cx.type_func(&[], output); - let llfn = declare_simple_fn( - &cx, - name, - llvm::CallConv::CCallConv, - llvm::UnnamedAddr::Global, - llvm::Visibility::from_generic(tcx.sess.default_visibility()), - ty, - ); - - attributes::apply_to_llfn( - llfn, - llvm::AttributePlace::Function, - &[llvm::AttributeKind::AlwaysInline.create_attr(cx.llcx)], - ); - - let llbb = unsafe { llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, c"entry".as_ptr()) }; - let mut bx = SBuilder::build(&cx, llbb); - bx.ret(value); -} - fn create_wrapper_function( tcx: TyCtxt<'_>, cx: &SimpleCx<'_>, diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index a80976fad02a4..9d06de2b35c23 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -15,7 +15,7 @@ use rustc_middle::middle::exported_symbols::{ use rustc_middle::query::LocalCrate; use rustc_middle::ty::{self, GenericArgKind, GenericArgsRef, Instance, SymbolName, Ty, TyCtxt}; use rustc_middle::util::Providers; -use rustc_session::config::{CrateType, OomStrategy}; +use rustc_session::config::CrateType; use rustc_symbol_mangling::mangle_internal_symbol; use rustc_target::spec::{Arch, Os, TlsModel}; use tracing::debug; @@ -493,7 +493,6 @@ pub(crate) fn allocator_shim_symbols( .map(move |method| mangle_internal_symbol(tcx, global_fn_name(method.name).as_str())) .chain([ mangle_internal_symbol(tcx, global_fn_name(ALLOC_ERROR_HANDLER).as_str()), - mangle_internal_symbol(tcx, OomStrategy::SYMBOL), mangle_internal_symbol(tcx, NO_ALLOC_SHIM_IS_UNSTABLE), ]) .map(move |symbol_name| { diff --git a/compiler/rustc_interface/src/tests.rs b/compiler/rustc_interface/src/tests.rs index 8bf9f8420c05e..24de3620ca3c2 100644 --- a/compiler/rustc_interface/src/tests.rs +++ b/compiler/rustc_interface/src/tests.rs @@ -14,10 +14,10 @@ use rustc_session::config::{ CoverageOptions, DebugInfo, DumpMonoStatsFormat, ErrorOutputType, ExternEntry, ExternLocation, Externs, FmtDebug, FunctionReturn, InliningThreshold, Input, InstrumentCoverage, InstrumentXRay, LinkSelfContained, LinkerPluginLto, LocationDetail, LtoCli, MirIncludeSpans, - NextSolverConfig, Offload, OomStrategy, Options, OutFileName, OutputType, OutputTypes, - PAuthKey, PacRet, Passes, PatchableFunctionEntry, Polonius, ProcMacroExecutionStrategy, Strip, - SwitchWithOptPath, SymbolManglingVersion, WasiExecModel, build_configuration, - build_session_options, rustc_optgroups, + NextSolverConfig, Offload, Options, OutFileName, OutputType, OutputTypes, PAuthKey, PacRet, + Passes, PatchableFunctionEntry, Polonius, ProcMacroExecutionStrategy, Strip, SwitchWithOptPath, + SymbolManglingVersion, WasiExecModel, build_configuration, build_session_options, + rustc_optgroups, }; use rustc_session::lint::Level; use rustc_session::search_paths::SearchPath; @@ -839,7 +839,6 @@ fn test_unstable_options_tracking_hash() { tracked!(no_unique_section_names, true); tracked!(offload, vec![Offload::Enable]); tracked!(on_broken_pipe, OnBrokenPipe::Kill); - tracked!(oom, OomStrategy::Panic); tracked!(osx_rpath_install_name, true); tracked!(packed_bundled_libs, true); tracked!(panic_abort_tests, true); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index f97a29e064b65..c5f253a00e32e 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -3127,8 +3127,8 @@ pub(crate) mod dep_tracking { AnnotateMoves, AutoDiff, BranchProtection, CFGuard, CFProtection, CollapseMacroDebuginfo, CoverageOptions, CrateType, DebugInfo, DebugInfoCompression, ErrorOutputType, FmtDebug, FunctionReturn, InliningThreshold, InstrumentCoverage, InstrumentXRay, LinkerPluginLto, - LocationDetail, LtoCli, MirStripDebugInfo, NextSolverConfig, Offload, OomStrategy, - OptLevel, OutFileName, OutputType, OutputTypes, PatchableFunctionEntry, Polonius, + LocationDetail, LtoCli, MirStripDebugInfo, NextSolverConfig, Offload, OptLevel, + OutFileName, OutputType, OutputTypes, PatchableFunctionEntry, Polonius, RemapPathScopeComponents, ResolveDocLinks, SourceFileHashAlgorithm, SplitDwarfKind, SwitchWithOptPath, SymbolManglingVersion, WasiExecModel, }; @@ -3227,7 +3227,6 @@ pub(crate) mod dep_tracking { LocationDetail, FmtDebug, BranchProtection, - OomStrategy, LanguageIdentifier, NextSolverConfig, PatchableFunctionEntry, @@ -3340,27 +3339,6 @@ pub(crate) mod dep_tracking { } } -/// Default behavior to use in out-of-memory situations. -#[derive(Clone, Copy, PartialEq, Hash, Debug, Encodable, Decodable, HashStable_Generic)] -pub enum OomStrategy { - /// Generate a panic that can be caught by `catch_unwind`. - Panic, - - /// Abort the process immediately. - Abort, -} - -impl OomStrategy { - pub const SYMBOL: &'static str = "__rust_alloc_error_handler_should_panic_v2"; - - pub fn should_panic(self) -> u8 { - match self { - OomStrategy::Panic => 1, - OomStrategy::Abort => 0, - } - } -} - /// How to run proc-macro code when building this crate #[derive(Clone, Copy, PartialEq, Hash, Debug)] pub enum ProcMacroExecutionStrategy { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 7c7e9118d590f..f30612fa77b59 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -806,7 +806,6 @@ mod desc { pub(crate) const parse_on_broken_pipe: &str = "either `kill`, `error`, or `inherit`"; pub(crate) const parse_patchable_function_entry: &str = "either two comma separated integers (total_nops,prefix_nops), with prefix_nops <= total_nops, or one integer (total_nops)"; pub(crate) const parse_opt_panic_strategy: &str = parse_panic_strategy; - pub(crate) const parse_oom_strategy: &str = "either `panic` or `abort`"; pub(crate) const parse_relro_level: &str = "one of: `full`, `partial`, or `off`"; pub(crate) const parse_sanitizers: &str = "comma separated list of sanitizers: `address`, `cfi`, `dataflow`, `hwaddress`, `kcfi`, `kernel-address`, `leak`, `memory`, `memtag`, `safestack`, `shadow-call-stack`, `thread`, or 'realtime'"; pub(crate) const parse_sanitizer_memory_track_origins: &str = "0, 1, or 2"; @@ -1242,15 +1241,6 @@ pub mod parse { false } - pub(crate) fn parse_oom_strategy(slot: &mut OomStrategy, v: Option<&str>) -> bool { - match v { - Some("panic") => *slot = OomStrategy::Panic, - Some("abort") => *slot = OomStrategy::Abort, - _ => return false, - } - true - } - pub(crate) fn parse_relro_level(slot: &mut Option, v: Option<&str>) -> bool { match v { Some(s) => match s.parse::() { @@ -2529,8 +2519,6 @@ options! { Currently the only option available"), on_broken_pipe: OnBrokenPipe = (OnBrokenPipe::Default, parse_on_broken_pipe, [TRACKED], "behavior of std::io::ErrorKind::BrokenPipe (SIGPIPE)"), - oom: OomStrategy = (OomStrategy::Abort, parse_oom_strategy, [TRACKED], - "panic strategy for out-of-memory handling"), osx_rpath_install_name: bool = (false, parse_bool, [TRACKED], "pass `-install_name @rpath/...` to the macOS linker (default: no)"), packed_bundled_libs: bool = (false, parse_bool, [TRACKED], diff --git a/library/alloc/src/alloc.rs b/library/alloc/src/alloc.rs index 39450f69ce30a..c5f16f3708d74 100644 --- a/library/alloc/src/alloc.rs +++ b/library/alloc/src/alloc.rs @@ -426,20 +426,9 @@ pub mod __alloc_error_handler { // `#[alloc_error_handler]`. #[rustc_std_internal_symbol] pub unsafe fn __rdl_alloc_error_handler(size: usize, _align: usize) -> ! { - unsafe extern "Rust" { - // This symbol is emitted by rustc next to __rust_alloc_error_handler. - // Its value depends on the -Zoom={panic,abort} compiler option. - #[rustc_std_internal_symbol] - fn __rust_alloc_error_handler_should_panic_v2() -> u8; - } - - if unsafe { __rust_alloc_error_handler_should_panic_v2() != 0 } { - panic!("memory allocation of {size} bytes failed") - } else { - core::panicking::panic_nounwind_fmt( - format_args!("memory allocation of {size} bytes failed"), - /* force_no_backtrace */ false, - ) - } + core::panicking::panic_nounwind_fmt( + format_args!("memory allocation of {size} bytes failed"), + /* force_no_backtrace */ false, + ) } } diff --git a/library/std/src/alloc.rs b/library/std/src/alloc.rs index 701b3be6894da..35eb77315a222 100644 --- a/library/std/src/alloc.rs +++ b/library/std/src/alloc.rs @@ -350,17 +350,6 @@ fn default_alloc_error_hook(layout: Layout) { return; } - unsafe extern "Rust" { - // This symbol is emitted by rustc next to __rust_alloc_error_handler. - // Its value depends on the -Zoom={panic,abort} compiler option. - #[rustc_std_internal_symbol] - fn __rust_alloc_error_handler_should_panic_v2() -> u8; - } - - if unsafe { __rust_alloc_error_handler_should_panic_v2() != 0 } { - panic!("memory allocation of {} bytes failed", layout.size()); - } - // This is the default path taken on OOM, and the only path taken on stable with std. // Crucially, it does *not* call any user-defined code, and therefore users do not have to // worry about allocation failure causing reentrancy issues. That makes it different from diff --git a/src/tools/miri/src/shims/foreign_items.rs b/src/tools/miri/src/shims/foreign_items.rs index 440388673e7d4..8a959d06bf9ca 100644 --- a/src/tools/miri/src/shims/foreign_items.rs +++ b/src/tools/miri/src/shims/foreign_items.rs @@ -12,7 +12,6 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::mir::interpret::AllocInit; use rustc_middle::ty::{Instance, Ty}; use rustc_middle::{mir, ty}; -use rustc_session::config::OomStrategy; use rustc_span::Symbol; use rustc_target::callconv::FnAbi; use rustc_target::spec::{Arch, Os}; @@ -305,18 +304,12 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> { // Here we dispatch all the shims for foreign functions. If you have a platform specific // shim, add it to the corresponding submodule. match link_name.as_str() { - // Magic functions Rust emits (and not as part of the allocator shim). + // Magic function Rust emits (and not as part of the allocator shim). name if name == this.mangle_internal_symbol(NO_ALLOC_SHIM_IS_UNSTABLE) => { // This is a no-op shim that only exists to prevent making the allocator shims // instantly stable. let [] = this.check_shim_sig_lenient(abi, CanonAbi::Rust, link_name, args)?; } - name if name == this.mangle_internal_symbol(OomStrategy::SYMBOL) => { - // Gets the value of the `oom` option. - let [] = this.check_shim_sig_lenient(abi, CanonAbi::Rust, link_name, args)?; - let val = this.tcx.sess.opts.unstable_opts.oom.should_panic(); - this.write_int(val, dest)?; - } // Miri-specific extern functions "miri_alloc" => { diff --git a/src/tools/miri/tests/panic/alloc_error_handler_panic.rs b/src/tools/miri/tests/panic/alloc_error_handler_panic.rs deleted file mode 100644 index c434e8d3227a2..0000000000000 --- a/src/tools/miri/tests/panic/alloc_error_handler_panic.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@compile-flags: -Zoom=panic -#![feature(allocator_api)] - -use std::alloc::*; - -struct Bomb; -impl Drop for Bomb { - fn drop(&mut self) { - eprintln!("yes we are unwinding!"); - } -} - -#[allow(unreachable_code, unused_variables)] -fn main() { - let bomb = Bomb; - handle_alloc_error(Layout::for_value(&0)); - std::mem::forget(bomb); // defuse unwinding bomb -} diff --git a/src/tools/miri/tests/panic/alloc_error_handler_panic.stderr b/src/tools/miri/tests/panic/alloc_error_handler_panic.stderr deleted file mode 100644 index 7c2d089f952ef..0000000000000 --- a/src/tools/miri/tests/panic/alloc_error_handler_panic.stderr +++ /dev/null @@ -1,6 +0,0 @@ - -thread 'main' ($TID) panicked at RUSTLIB/std/src/alloc.rs:LL:CC: -memory allocation of 4 bytes failed -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -note: in Miri, you may have to set `MIRIFLAGS=-Zmiri-env-forward=RUST_BACKTRACE` for the environment variable to have an effect -yes we are unwinding! diff --git a/tests/ui/panics/oom-panic-unwind.rs b/tests/ui/panics/alloc_error_hook-unwind.rs similarity index 84% rename from tests/ui/panics/oom-panic-unwind.rs rename to tests/ui/panics/alloc_error_hook-unwind.rs index 4f7939ce60b20..8a107bc390d4a 100644 --- a/tests/ui/panics/oom-panic-unwind.rs +++ b/tests/ui/panics/alloc_error_hook-unwind.rs @@ -1,17 +1,19 @@ -//! Test that out-of-memory conditions trigger catchable panics with `-Z oom=panic`. +//! Test that out-of-memory conditions trigger catchable panics with `set_alloc_error_hook`. -//@ compile-flags: -Z oom=panic //@ run-pass -//@ no-prefer-dynamic //@ needs-unwind //@ only-linux //@ ignore-backends: gcc +#![feature(alloc_error_hook)] + use std::hint::black_box; use std::mem::forget; use std::panic::catch_unwind; fn main() { + std::alloc::set_alloc_error_hook(|_| panic!()); + let panic = catch_unwind(|| { // This is guaranteed to exceed even the size of the address space for _ in 0..16 { From a1f4caf46751d3e166a35897fa064c394c3a16dd Mon Sep 17 00:00:00 2001 From: Paul Murphy Date: Thu, 4 Dec 2025 17:52:55 -0600 Subject: [PATCH 05/21] Restrict spe_acc to PowerPC SPE targets Update the tests, add powerpc-*-gnuspe testing, and create a distinct clobber_abi list for PowerPC SPE targets. Note, the SPE target does not have vector, vector-scalar, or floating-point specific registers. --- compiler/rustc_target/src/asm/mod.rs | 24 +- compiler/rustc_target/src/asm/powerpc.rs | 12 +- tests/codegen-llvm/asm/powerpc-clobbers.rs | 31 +- tests/ui/asm/powerpc/bad-reg.aix64.stderr | 238 ++--- tests/ui/asm/powerpc/bad-reg.powerpc.stderr | 268 ++--- tests/ui/asm/powerpc/bad-reg.powerpc64.stderr | 258 ++--- .../ui/asm/powerpc/bad-reg.powerpc64le.stderr | 238 ++--- .../ui/asm/powerpc/bad-reg.powerpcspe.stderr | 938 ++++++++++++++++++ tests/ui/asm/powerpc/bad-reg.rs | 52 +- 9 files changed, 1547 insertions(+), 512 deletions(-) create mode 100644 tests/ui/asm/powerpc/bad-reg.powerpcspe.stderr diff --git a/compiler/rustc_target/src/asm/mod.rs b/compiler/rustc_target/src/asm/mod.rs index c6d22a51774c6..05b24d7109481 100644 --- a/compiler/rustc_target/src/asm/mod.rs +++ b/compiler/rustc_target/src/asm/mod.rs @@ -5,7 +5,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexSet}; use rustc_macros::{Decodable, Encodable, HashStable_Generic}; use rustc_span::Symbol; -use crate::spec::{Arch, RelocModel, Target}; +use crate::spec::{Abi, Arch, RelocModel, Target}; pub struct ModifierInfo { pub modifier: char, @@ -936,6 +936,7 @@ pub enum InlineAsmClobberAbi { RiscVE, LoongArch, PowerPC, + PowerPCSPE, S390x, Bpf, Msp430, @@ -1000,7 +1001,11 @@ impl InlineAsmClobberAbi { _ => Err(&["C", "system"]), }, InlineAsmArch::PowerPC | InlineAsmArch::PowerPC64 => match name { - "C" | "system" => Ok(InlineAsmClobberAbi::PowerPC), + "C" | "system" => Ok(if target.abi == Abi::Spe { + InlineAsmClobberAbi::PowerPCSPE + } else { + InlineAsmClobberAbi::PowerPC + }), _ => Err(&["C", "system"]), }, InlineAsmArch::S390x => match name { @@ -1271,8 +1276,21 @@ impl InlineAsmClobberAbi { ctr, lr, xer, + } + }, + InlineAsmClobberAbi::PowerPCSPE => clobbered_regs! { + PowerPC PowerPCInlineAsmReg { + // r0, r3-r12 + r0, + r3, r4, r5, r6, r7, + r8, r9, r10, r11, r12, - // These are only supported on PowerPC SPE targets. + // cr0-cr1, cr5-cr7, ctr, lr, xer, spe_acc + cr0, cr1, + cr5, cr6, cr7, + ctr, + lr, + xer, spe_acc, } }, diff --git a/compiler/rustc_target/src/asm/powerpc.rs b/compiler/rustc_target/src/asm/powerpc.rs index 4fbe8adcbc614..fd0e118fcc87c 100644 --- a/compiler/rustc_target/src/asm/powerpc.rs +++ b/compiler/rustc_target/src/asm/powerpc.rs @@ -115,6 +115,16 @@ fn reserved_v20to31( } } +fn spe_acc_target_check( + _arch: InlineAsmArch, + _reloc_model: RelocModel, + _target_features: &FxIndexSet, + target: &Target, + _is_clobber: bool, +) -> Result<(), &'static str> { + if target.abi == Abi::Spe { Ok(()) } else { Err("spe_acc is only available on spe targets") } +} + def_regs! { PowerPC PowerPCInlineAsmReg PowerPCInlineAsmRegClass { r0: reg = ["r0", "0"], @@ -286,7 +296,7 @@ def_regs! { ctr: ctr = ["ctr"], lr: lr = ["lr"], xer: xer = ["xer"], - spe_acc: spe_acc = ["spe_acc"], + spe_acc: spe_acc = ["spe_acc"] % spe_acc_target_check, #error = ["r1", "1", "sp"] => "the stack pointer cannot be used as an operand for inline asm", #error = ["r2", "2"] => diff --git a/tests/codegen-llvm/asm/powerpc-clobbers.rs b/tests/codegen-llvm/asm/powerpc-clobbers.rs index 6abf82cb0f4bc..c146d58e4ab6e 100644 --- a/tests/codegen-llvm/asm/powerpc-clobbers.rs +++ b/tests/codegen-llvm/asm/powerpc-clobbers.rs @@ -1,11 +1,13 @@ //@ add-minicore -//@ revisions: powerpc powerpc64 powerpc64le aix64 +//@ revisions: powerpc powerpc64 powerpc64le aix64 powerpcspe //@[powerpc] compile-flags: --target powerpc-unknown-linux-gnu //@[powerpc] needs-llvm-components: powerpc //@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu //@[powerpc64] needs-llvm-components: powerpc //@[powerpc64le] compile-flags: --target powerpc64le-unknown-linux-gnu //@[powerpc64le] needs-llvm-components: powerpc +//@[powerpcspe] compile-flags: --target powerpc-unknown-linux-gnuspe +//@[powerpcspe] needs-llvm-components: powerpc //@[aix64] compile-flags: --target powerpc64-ibm-aix //@[aix64] needs-llvm-components: powerpc // ignore-tidy-linelength @@ -67,12 +69,22 @@ pub unsafe fn vs32_clobber() { asm!("", out("vs32") _, options(nostack, nomem, preserves_flags)); } +// This register is only available on SPE targets. +// CHECK-LABEL: @spe_acc_clobber +// powerpcspe: call void asm sideeffect "", "~{spe_acc}"() +#[no_mangle] +pub unsafe fn spe_acc_clobber() { + #[cfg(target_abi = "spe")] + asm!("", out("spe_acc") _, options(nostack, nomem, preserves_flags)); +} + // Output format depends on the availability of altivec and vsx // CHECK-LABEL: @clobber_abi -// powerpc: asm sideeffect "", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},~{vs0},~{vs1},~{vs2},~{vs3},~{vs4},~{vs5},~{vs6},~{vs7},~{vs8},~{vs9},~{vs10},~{vs11},~{vs12},~{vs13},~{vs14},~{vs15},~{vs16},~{vs17},~{vs18},~{vs19},~{vs20},~{vs21},~{vs22},~{vs23},~{vs24},~{vs25},~{vs26},~{vs27},~{vs28},~{vs29},~{vs30},~{vs31},~{v0},~{v1},~{v2},~{v3},~{v4},~{v5},~{v6},~{v7},~{v8},~{v9},~{v10},~{v11},~{v12},~{v13},~{v14},~{v15},~{v16},~{v17},~{v18},~{v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer},~{spe_acc}"() -// powerpc64: asm sideeffect "", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},={v0},={v1},={v2},={v3},={v4},={v5},={v6},={v7},={v8},={v9},={v10},={v11},={v12},={v13},={v14},={v15},={v16},={v17},={v18},={v19},~{vs0},~{vs1},~{vs2},~{vs3},~{vs4},~{vs5},~{vs6},~{vs7},~{vs8},~{vs9},~{vs10},~{vs11},~{vs12},~{vs13},~{vs14},~{vs15},~{vs16},~{vs17},~{vs18},~{vs19},~{vs20},~{vs21},~{vs22},~{vs23},~{vs24},~{vs25},~{vs26},~{vs27},~{vs28},~{vs29},~{vs30},~{vs31},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer},~{spe_acc}"() -// powerpc64le: asm sideeffect "", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},={vs0},={vs1},={vs2},={vs3},={vs4},={vs5},={vs6},={vs7},={vs8},={vs9},={vs10},={vs11},={vs12},={vs13},={vs14},={vs15},={vs16},={vs17},={vs18},={vs19},={vs20},={vs21},={vs22},={vs23},={vs24},={vs25},={vs26},={vs27},={vs28},={vs29},={vs30},={vs31},={v0},={v1},={v2},={v3},={v4},={v5},={v6},={v7},={v8},={v9},={v10},={v11},={v12},={v13},={v14},={v15},={v16},={v17},={v18},={v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer},~{spe_acc}"() -// aix64: asm sideeffect "", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},={vs0},={vs1},={vs2},={vs3},={vs4},={vs5},={vs6},={vs7},={vs8},={vs9},={vs10},={vs11},={vs12},={vs13},={vs14},={vs15},={vs16},={vs17},={vs18},={vs19},={vs20},={vs21},={vs22},={vs23},={vs24},={vs25},={vs26},={vs27},={vs28},={vs29},={vs30},={vs31},={v0},={v1},={v2},={v3},={v4},={v5},={v6},={v7},={v8},={v9},={v10},={v11},={v12},={v13},={v14},={v15},={v16},={v17},={v18},={v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer},~{spe_acc}"() +// powerpc: asm sideeffect "", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},~{vs0},~{vs1},~{vs2},~{vs3},~{vs4},~{vs5},~{vs6},~{vs7},~{vs8},~{vs9},~{vs10},~{vs11},~{vs12},~{vs13},~{vs14},~{vs15},~{vs16},~{vs17},~{vs18},~{vs19},~{vs20},~{vs21},~{vs22},~{vs23},~{vs24},~{vs25},~{vs26},~{vs27},~{vs28},~{vs29},~{vs30},~{vs31},~{v0},~{v1},~{v2},~{v3},~{v4},~{v5},~{v6},~{v7},~{v8},~{v9},~{v10},~{v11},~{v12},~{v13},~{v14},~{v15},~{v16},~{v17},~{v18},~{v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer}"() +// powerpc64: asm sideeffect "", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},={v0},={v1},={v2},={v3},={v4},={v5},={v6},={v7},={v8},={v9},={v10},={v11},={v12},={v13},={v14},={v15},={v16},={v17},={v18},={v19},~{vs0},~{vs1},~{vs2},~{vs3},~{vs4},~{vs5},~{vs6},~{vs7},~{vs8},~{vs9},~{vs10},~{vs11},~{vs12},~{vs13},~{vs14},~{vs15},~{vs16},~{vs17},~{vs18},~{vs19},~{vs20},~{vs21},~{vs22},~{vs23},~{vs24},~{vs25},~{vs26},~{vs27},~{vs28},~{vs29},~{vs30},~{vs31},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer}"() +// powerpc64le: asm sideeffect "", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},={vs0},={vs1},={vs2},={vs3},={vs4},={vs5},={vs6},={vs7},={vs8},={vs9},={vs10},={vs11},={vs12},={vs13},={vs14},={vs15},={vs16},={vs17},={vs18},={vs19},={vs20},={vs21},={vs22},={vs23},={vs24},={vs25},={vs26},={vs27},={vs28},={vs29},={vs30},={vs31},={v0},={v1},={v2},={v3},={v4},={v5},={v6},={v7},={v8},={v9},={v10},={v11},={v12},={v13},={v14},={v15},={v16},={v17},={v18},={v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer}"() +// aix64: asm sideeffect "", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},={vs0},={vs1},={vs2},={vs3},={vs4},={vs5},={vs6},={vs7},={vs8},={vs9},={vs10},={vs11},={vs12},={vs13},={vs14},={vs15},={vs16},={vs17},={vs18},={vs19},={vs20},={vs21},={vs22},={vs23},={vs24},={vs25},={vs26},={vs27},={vs28},={vs29},={vs30},={vs31},={v0},={v1},={v2},={v3},={v4},={v5},={v6},={v7},={v8},={v9},={v10},={v11},={v12},={v13},={v14},={v15},={v16},={v17},={v18},={v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer}"() +// powerpcspe: asm sideeffect "", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer},~{spe_acc}"() #[no_mangle] pub unsafe fn clobber_abi() { asm!("", clobber_abi("C"), options(nostack, nomem, preserves_flags)); @@ -104,10 +116,11 @@ pub unsafe fn clobber_preservesflags() { // Output format depends on the availability of altivec and vsx // CHECK-LABEL: @clobber_abi_no_preserves_flags #[no_mangle] -// powerpc: asm sideeffect "nop", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},~{vs0},~{vs1},~{vs2},~{vs3},~{vs4},~{vs5},~{vs6},~{vs7},~{vs8},~{vs9},~{vs10},~{vs11},~{vs12},~{vs13},~{vs14},~{vs15},~{vs16},~{vs17},~{vs18},~{vs19},~{vs20},~{vs21},~{vs22},~{vs23},~{vs24},~{vs25},~{vs26},~{vs27},~{vs28},~{vs29},~{vs30},~{vs31},~{v0},~{v1},~{v2},~{v3},~{v4},~{v5},~{v6},~{v7},~{v8},~{v9},~{v10},~{v11},~{v12},~{v13},~{v14},~{v15},~{v16},~{v17},~{v18},~{v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer},~{spe_acc}"() -// powerpc64: asm sideeffect "nop", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},={v0},={v1},={v2},={v3},={v4},={v5},={v6},={v7},={v8},={v9},={v10},={v11},={v12},={v13},={v14},={v15},={v16},={v17},={v18},={v19},~{vs0},~{vs1},~{vs2},~{vs3},~{vs4},~{vs5},~{vs6},~{vs7},~{vs8},~{vs9},~{vs10},~{vs11},~{vs12},~{vs13},~{vs14},~{vs15},~{vs16},~{vs17},~{vs18},~{vs19},~{vs20},~{vs21},~{vs22},~{vs23},~{vs24},~{vs25},~{vs26},~{vs27},~{vs28},~{vs29},~{vs30},~{vs31},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer},~{spe_acc}"() -// powerpc64le: asm sideeffect "nop", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},={vs0},={vs1},={vs2},={vs3},={vs4},={vs5},={vs6},={vs7},={vs8},={vs9},={vs10},={vs11},={vs12},={vs13},={vs14},={vs15},={vs16},={vs17},={vs18},={vs19},={vs20},={vs21},={vs22},={vs23},={vs24},={vs25},={vs26},={vs27},={vs28},={vs29},={vs30},={vs31},={v0},={v1},={v2},={v3},={v4},={v5},={v6},={v7},={v8},={v9},={v10},={v11},={v12},={v13},={v14},={v15},={v16},={v17},={v18},={v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer},~{spe_acc}"() -// aix64: asm sideeffect "nop", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},={vs0},={vs1},={vs2},={vs3},={vs4},={vs5},={vs6},={vs7},={vs8},={vs9},={vs10},={vs11},={vs12},={vs13},={vs14},={vs15},={vs16},={vs17},={vs18},={vs19},={vs20},={vs21},={vs22},={vs23},={vs24},={vs25},={vs26},={vs27},={vs28},={vs29},={vs30},={vs31},={v0},={v1},={v2},={v3},={v4},={v5},={v6},={v7},={v8},={v9},={v10},={v11},={v12},={v13},={v14},={v15},={v16},={v17},={v18},={v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer},~{spe_acc}"() +// powerpc: asm sideeffect "nop", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},~{vs0},~{vs1},~{vs2},~{vs3},~{vs4},~{vs5},~{vs6},~{vs7},~{vs8},~{vs9},~{vs10},~{vs11},~{vs12},~{vs13},~{vs14},~{vs15},~{vs16},~{vs17},~{vs18},~{vs19},~{vs20},~{vs21},~{vs22},~{vs23},~{vs24},~{vs25},~{vs26},~{vs27},~{vs28},~{vs29},~{vs30},~{vs31},~{v0},~{v1},~{v2},~{v3},~{v4},~{v5},~{v6},~{v7},~{v8},~{v9},~{v10},~{v11},~{v12},~{v13},~{v14},~{v15},~{v16},~{v17},~{v18},~{v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer}"() +// powerpc64: asm sideeffect "nop", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},={v0},={v1},={v2},={v3},={v4},={v5},={v6},={v7},={v8},={v9},={v10},={v11},={v12},={v13},={v14},={v15},={v16},={v17},={v18},={v19},~{vs0},~{vs1},~{vs2},~{vs3},~{vs4},~{vs5},~{vs6},~{vs7},~{vs8},~{vs9},~{vs10},~{vs11},~{vs12},~{vs13},~{vs14},~{vs15},~{vs16},~{vs17},~{vs18},~{vs19},~{vs20},~{vs21},~{vs22},~{vs23},~{vs24},~{vs25},~{vs26},~{vs27},~{vs28},~{vs29},~{vs30},~{vs31},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer}"() +// powerpc64le: asm sideeffect "nop", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},={vs0},={vs1},={vs2},={vs3},={vs4},={vs5},={vs6},={vs7},={vs8},={vs9},={vs10},={vs11},={vs12},={vs13},={vs14},={vs15},={vs16},={vs17},={vs18},={vs19},={vs20},={vs21},={vs22},={vs23},={vs24},={vs25},={vs26},={vs27},={vs28},={vs29},={vs30},={vs31},={v0},={v1},={v2},={v3},={v4},={v5},={v6},={v7},={v8},={v9},={v10},={v11},={v12},={v13},={v14},={v15},={v16},={v17},={v18},={v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer}"() +// aix64: asm sideeffect "nop", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},={f0},={f1},={f2},={f3},={f4},={f5},={f6},={f7},={f8},={f9},={f10},={f11},={f12},={f13},={vs0},={vs1},={vs2},={vs3},={vs4},={vs5},={vs6},={vs7},={vs8},={vs9},={vs10},={vs11},={vs12},={vs13},={vs14},={vs15},={vs16},={vs17},={vs18},={vs19},={vs20},={vs21},={vs22},={vs23},={vs24},={vs25},={vs26},={vs27},={vs28},={vs29},={vs30},={vs31},={v0},={v1},={v2},={v3},={v4},={v5},={v6},={v7},={v8},={v9},={v10},={v11},={v12},={v13},={v14},={v15},={v16},={v17},={v18},={v19},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer}"() +// powerpcspe: asm sideeffect "nop", "={r0},={r3},={r4},={r5},={r6},={r7},={r8},={r9},={r10},={r11},={r12},~{cr0},~{cr1},~{cr5},~{cr6},~{cr7},~{ctr},~{lr},~{xer},~{spe_acc}"() pub unsafe fn clobber_abi_no_preserves_flags() { // Use a nop to prevent aliasing of identical functions here. asm!("nop", clobber_abi("C"), options(nostack, nomem)); diff --git a/tests/ui/asm/powerpc/bad-reg.aix64.stderr b/tests/ui/asm/powerpc/bad-reg.aix64.stderr index 4490053215b5d..c7373780e382c 100644 --- a/tests/ui/asm/powerpc/bad-reg.aix64.stderr +++ b/tests/ui/asm/powerpc/bad-reg.aix64.stderr @@ -1,131 +1,131 @@ error: invalid register `sp`: the stack pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:36:18 + --> $DIR/bad-reg.rs:38:18 | LL | asm!("", out("sp") _); | ^^^^^^^^^^^ error: invalid register `r2`: r2 is a system reserved register and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:38:18 + --> $DIR/bad-reg.rs:40:18 | LL | asm!("", out("r2") _); | ^^^^^^^^^^^ error: invalid register `r30`: r30 is used internally by LLVM and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:44:18 + --> $DIR/bad-reg.rs:46:18 | LL | asm!("", out("r30") _); | ^^^^^^^^^^^^ error: invalid register `fp`: the frame pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:46:18 + --> $DIR/bad-reg.rs:48:18 | LL | asm!("", out("fp") _); | ^^^^^^^^^^^ error: invalid register `vrsave`: the vrsave register cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:48:18 + --> $DIR/bad-reg.rs:50:18 | LL | asm!("", out("vrsave") _); | ^^^^^^^^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:137:18 + --> $DIR/bad-reg.rs:139:18 | LL | asm!("", in("cr") x); | ^^^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:140:18 + --> $DIR/bad-reg.rs:142:18 | LL | asm!("", out("cr") x); | ^^^^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:143:26 + --> $DIR/bad-reg.rs:145:26 | LL | asm!("/* {} */", in(cr) x); | ^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:146:26 + --> $DIR/bad-reg.rs:148:26 | LL | asm!("/* {} */", out(cr) _); | ^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:150:18 + --> $DIR/bad-reg.rs:152:18 | LL | asm!("", in("ctr") x); | ^^^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:153:18 + --> $DIR/bad-reg.rs:155:18 | LL | asm!("", out("ctr") x); | ^^^^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:156:26 + --> $DIR/bad-reg.rs:158:26 | LL | asm!("/* {} */", in(ctr) x); | ^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:159:26 + --> $DIR/bad-reg.rs:161:26 | LL | asm!("/* {} */", out(ctr) _); | ^^^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:163:18 + --> $DIR/bad-reg.rs:165:18 | LL | asm!("", in("lr") x); | ^^^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:166:18 + --> $DIR/bad-reg.rs:168:18 | LL | asm!("", out("lr") x); | ^^^^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:169:26 + --> $DIR/bad-reg.rs:171:26 | LL | asm!("/* {} */", in(lr) x); | ^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:172:26 + --> $DIR/bad-reg.rs:174:26 | LL | asm!("/* {} */", out(lr) _); | ^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:176:18 + --> $DIR/bad-reg.rs:178:18 | LL | asm!("", in("xer") x); | ^^^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:179:18 + --> $DIR/bad-reg.rs:181:18 | LL | asm!("", out("xer") x); | ^^^^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:182:26 + --> $DIR/bad-reg.rs:184:26 | LL | asm!("/* {} */", in(xer) x); | ^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:185:26 + --> $DIR/bad-reg.rs:187:26 | LL | asm!("/* {} */", out(xer) _); | ^^^^^^^^^^ error: register `cr0` conflicts with register `cr` - --> $DIR/bad-reg.rs:189:31 + --> $DIR/bad-reg.rs:191:31 | LL | asm!("", out("cr") _, out("cr0") _); | ----------- ^^^^^^^^^^^^ register `cr0` @@ -133,7 +133,7 @@ LL | asm!("", out("cr") _, out("cr0") _); | register `cr` error: register `cr1` conflicts with register `cr` - --> $DIR/bad-reg.rs:191:31 + --> $DIR/bad-reg.rs:193:31 | LL | asm!("", out("cr") _, out("cr1") _); | ----------- ^^^^^^^^^^^^ register `cr1` @@ -141,7 +141,7 @@ LL | asm!("", out("cr") _, out("cr1") _); | register `cr` error: register `cr2` conflicts with register `cr` - --> $DIR/bad-reg.rs:193:31 + --> $DIR/bad-reg.rs:195:31 | LL | asm!("", out("cr") _, out("cr2") _); | ----------- ^^^^^^^^^^^^ register `cr2` @@ -149,7 +149,7 @@ LL | asm!("", out("cr") _, out("cr2") _); | register `cr` error: register `cr3` conflicts with register `cr` - --> $DIR/bad-reg.rs:195:31 + --> $DIR/bad-reg.rs:197:31 | LL | asm!("", out("cr") _, out("cr3") _); | ----------- ^^^^^^^^^^^^ register `cr3` @@ -157,7 +157,7 @@ LL | asm!("", out("cr") _, out("cr3") _); | register `cr` error: register `cr4` conflicts with register `cr` - --> $DIR/bad-reg.rs:197:31 + --> $DIR/bad-reg.rs:199:31 | LL | asm!("", out("cr") _, out("cr4") _); | ----------- ^^^^^^^^^^^^ register `cr4` @@ -165,7 +165,7 @@ LL | asm!("", out("cr") _, out("cr4") _); | register `cr` error: register `cr5` conflicts with register `cr` - --> $DIR/bad-reg.rs:199:31 + --> $DIR/bad-reg.rs:201:31 | LL | asm!("", out("cr") _, out("cr5") _); | ----------- ^^^^^^^^^^^^ register `cr5` @@ -173,7 +173,7 @@ LL | asm!("", out("cr") _, out("cr5") _); | register `cr` error: register `cr6` conflicts with register `cr` - --> $DIR/bad-reg.rs:201:31 + --> $DIR/bad-reg.rs:203:31 | LL | asm!("", out("cr") _, out("cr6") _); | ----------- ^^^^^^^^^^^^ register `cr6` @@ -181,7 +181,7 @@ LL | asm!("", out("cr") _, out("cr6") _); | register `cr` error: register `cr7` conflicts with register `cr` - --> $DIR/bad-reg.rs:203:31 + --> $DIR/bad-reg.rs:205:31 | LL | asm!("", out("cr") _, out("cr7") _); | ----------- ^^^^^^^^^^^^ register `cr7` @@ -189,7 +189,7 @@ LL | asm!("", out("cr") _, out("cr7") _); | register `cr` error: register `vs0` conflicts with register `f0` - --> $DIR/bad-reg.rs:206:31 + --> $DIR/bad-reg.rs:208:31 | LL | asm!("", out("f0") _, out("vs0") _); | ----------- ^^^^^^^^^^^^ register `vs0` @@ -197,7 +197,7 @@ LL | asm!("", out("f0") _, out("vs0") _); | register `f0` error: register `vs1` conflicts with register `f1` - --> $DIR/bad-reg.rs:208:31 + --> $DIR/bad-reg.rs:210:31 | LL | asm!("", out("f1") _, out("vs1") _); | ----------- ^^^^^^^^^^^^ register `vs1` @@ -205,7 +205,7 @@ LL | asm!("", out("f1") _, out("vs1") _); | register `f1` error: register `vs2` conflicts with register `f2` - --> $DIR/bad-reg.rs:210:31 + --> $DIR/bad-reg.rs:212:31 | LL | asm!("", out("f2") _, out("vs2") _); | ----------- ^^^^^^^^^^^^ register `vs2` @@ -213,7 +213,7 @@ LL | asm!("", out("f2") _, out("vs2") _); | register `f2` error: register `vs3` conflicts with register `f3` - --> $DIR/bad-reg.rs:212:31 + --> $DIR/bad-reg.rs:214:31 | LL | asm!("", out("f3") _, out("vs3") _); | ----------- ^^^^^^^^^^^^ register `vs3` @@ -221,7 +221,7 @@ LL | asm!("", out("f3") _, out("vs3") _); | register `f3` error: register `vs4` conflicts with register `f4` - --> $DIR/bad-reg.rs:214:31 + --> $DIR/bad-reg.rs:216:31 | LL | asm!("", out("f4") _, out("vs4") _); | ----------- ^^^^^^^^^^^^ register `vs4` @@ -229,7 +229,7 @@ LL | asm!("", out("f4") _, out("vs4") _); | register `f4` error: register `vs5` conflicts with register `f5` - --> $DIR/bad-reg.rs:216:31 + --> $DIR/bad-reg.rs:218:31 | LL | asm!("", out("f5") _, out("vs5") _); | ----------- ^^^^^^^^^^^^ register `vs5` @@ -237,7 +237,7 @@ LL | asm!("", out("f5") _, out("vs5") _); | register `f5` error: register `vs6` conflicts with register `f6` - --> $DIR/bad-reg.rs:218:31 + --> $DIR/bad-reg.rs:220:31 | LL | asm!("", out("f6") _, out("vs6") _); | ----------- ^^^^^^^^^^^^ register `vs6` @@ -245,7 +245,7 @@ LL | asm!("", out("f6") _, out("vs6") _); | register `f6` error: register `vs7` conflicts with register `f7` - --> $DIR/bad-reg.rs:220:31 + --> $DIR/bad-reg.rs:222:31 | LL | asm!("", out("f7") _, out("vs7") _); | ----------- ^^^^^^^^^^^^ register `vs7` @@ -253,7 +253,7 @@ LL | asm!("", out("f7") _, out("vs7") _); | register `f7` error: register `vs8` conflicts with register `f8` - --> $DIR/bad-reg.rs:222:31 + --> $DIR/bad-reg.rs:224:31 | LL | asm!("", out("f8") _, out("vs8") _); | ----------- ^^^^^^^^^^^^ register `vs8` @@ -261,7 +261,7 @@ LL | asm!("", out("f8") _, out("vs8") _); | register `f8` error: register `vs9` conflicts with register `f9` - --> $DIR/bad-reg.rs:224:31 + --> $DIR/bad-reg.rs:226:31 | LL | asm!("", out("f9") _, out("vs9") _); | ----------- ^^^^^^^^^^^^ register `vs9` @@ -269,7 +269,7 @@ LL | asm!("", out("f9") _, out("vs9") _); | register `f9` error: register `vs10` conflicts with register `f10` - --> $DIR/bad-reg.rs:226:32 + --> $DIR/bad-reg.rs:228:32 | LL | asm!("", out("f10") _, out("vs10") _); | ------------ ^^^^^^^^^^^^^ register `vs10` @@ -277,7 +277,7 @@ LL | asm!("", out("f10") _, out("vs10") _); | register `f10` error: register `vs11` conflicts with register `f11` - --> $DIR/bad-reg.rs:228:32 + --> $DIR/bad-reg.rs:230:32 | LL | asm!("", out("f11") _, out("vs11") _); | ------------ ^^^^^^^^^^^^^ register `vs11` @@ -285,7 +285,7 @@ LL | asm!("", out("f11") _, out("vs11") _); | register `f11` error: register `vs12` conflicts with register `f12` - --> $DIR/bad-reg.rs:230:32 + --> $DIR/bad-reg.rs:232:32 | LL | asm!("", out("f12") _, out("vs12") _); | ------------ ^^^^^^^^^^^^^ register `vs12` @@ -293,7 +293,7 @@ LL | asm!("", out("f12") _, out("vs12") _); | register `f12` error: register `vs13` conflicts with register `f13` - --> $DIR/bad-reg.rs:232:32 + --> $DIR/bad-reg.rs:234:32 | LL | asm!("", out("f13") _, out("vs13") _); | ------------ ^^^^^^^^^^^^^ register `vs13` @@ -301,7 +301,7 @@ LL | asm!("", out("f13") _, out("vs13") _); | register `f13` error: register `vs14` conflicts with register `f14` - --> $DIR/bad-reg.rs:234:32 + --> $DIR/bad-reg.rs:236:32 | LL | asm!("", out("f14") _, out("vs14") _); | ------------ ^^^^^^^^^^^^^ register `vs14` @@ -309,7 +309,7 @@ LL | asm!("", out("f14") _, out("vs14") _); | register `f14` error: register `vs15` conflicts with register `f15` - --> $DIR/bad-reg.rs:236:32 + --> $DIR/bad-reg.rs:238:32 | LL | asm!("", out("f15") _, out("vs15") _); | ------------ ^^^^^^^^^^^^^ register `vs15` @@ -317,7 +317,7 @@ LL | asm!("", out("f15") _, out("vs15") _); | register `f15` error: register `vs16` conflicts with register `f16` - --> $DIR/bad-reg.rs:238:32 + --> $DIR/bad-reg.rs:240:32 | LL | asm!("", out("f16") _, out("vs16") _); | ------------ ^^^^^^^^^^^^^ register `vs16` @@ -325,7 +325,7 @@ LL | asm!("", out("f16") _, out("vs16") _); | register `f16` error: register `vs17` conflicts with register `f17` - --> $DIR/bad-reg.rs:240:32 + --> $DIR/bad-reg.rs:242:32 | LL | asm!("", out("f17") _, out("vs17") _); | ------------ ^^^^^^^^^^^^^ register `vs17` @@ -333,7 +333,7 @@ LL | asm!("", out("f17") _, out("vs17") _); | register `f17` error: register `vs18` conflicts with register `f18` - --> $DIR/bad-reg.rs:242:32 + --> $DIR/bad-reg.rs:244:32 | LL | asm!("", out("f18") _, out("vs18") _); | ------------ ^^^^^^^^^^^^^ register `vs18` @@ -341,7 +341,7 @@ LL | asm!("", out("f18") _, out("vs18") _); | register `f18` error: register `vs19` conflicts with register `f19` - --> $DIR/bad-reg.rs:244:32 + --> $DIR/bad-reg.rs:246:32 | LL | asm!("", out("f19") _, out("vs19") _); | ------------ ^^^^^^^^^^^^^ register `vs19` @@ -349,7 +349,7 @@ LL | asm!("", out("f19") _, out("vs19") _); | register `f19` error: register `vs20` conflicts with register `f20` - --> $DIR/bad-reg.rs:246:32 + --> $DIR/bad-reg.rs:248:32 | LL | asm!("", out("f20") _, out("vs20") _); | ------------ ^^^^^^^^^^^^^ register `vs20` @@ -357,7 +357,7 @@ LL | asm!("", out("f20") _, out("vs20") _); | register `f20` error: register `vs21` conflicts with register `f21` - --> $DIR/bad-reg.rs:248:32 + --> $DIR/bad-reg.rs:250:32 | LL | asm!("", out("f21") _, out("vs21") _); | ------------ ^^^^^^^^^^^^^ register `vs21` @@ -365,7 +365,7 @@ LL | asm!("", out("f21") _, out("vs21") _); | register `f21` error: register `vs22` conflicts with register `f22` - --> $DIR/bad-reg.rs:250:32 + --> $DIR/bad-reg.rs:252:32 | LL | asm!("", out("f22") _, out("vs22") _); | ------------ ^^^^^^^^^^^^^ register `vs22` @@ -373,7 +373,7 @@ LL | asm!("", out("f22") _, out("vs22") _); | register `f22` error: register `vs23` conflicts with register `f23` - --> $DIR/bad-reg.rs:252:32 + --> $DIR/bad-reg.rs:254:32 | LL | asm!("", out("f23") _, out("vs23") _); | ------------ ^^^^^^^^^^^^^ register `vs23` @@ -381,7 +381,7 @@ LL | asm!("", out("f23") _, out("vs23") _); | register `f23` error: register `vs24` conflicts with register `f24` - --> $DIR/bad-reg.rs:254:32 + --> $DIR/bad-reg.rs:256:32 | LL | asm!("", out("f24") _, out("vs24") _); | ------------ ^^^^^^^^^^^^^ register `vs24` @@ -389,7 +389,7 @@ LL | asm!("", out("f24") _, out("vs24") _); | register `f24` error: register `vs25` conflicts with register `f25` - --> $DIR/bad-reg.rs:256:32 + --> $DIR/bad-reg.rs:258:32 | LL | asm!("", out("f25") _, out("vs25") _); | ------------ ^^^^^^^^^^^^^ register `vs25` @@ -397,7 +397,7 @@ LL | asm!("", out("f25") _, out("vs25") _); | register `f25` error: register `vs26` conflicts with register `f26` - --> $DIR/bad-reg.rs:258:32 + --> $DIR/bad-reg.rs:260:32 | LL | asm!("", out("f26") _, out("vs26") _); | ------------ ^^^^^^^^^^^^^ register `vs26` @@ -405,7 +405,7 @@ LL | asm!("", out("f26") _, out("vs26") _); | register `f26` error: register `vs27` conflicts with register `f27` - --> $DIR/bad-reg.rs:260:32 + --> $DIR/bad-reg.rs:262:32 | LL | asm!("", out("f27") _, out("vs27") _); | ------------ ^^^^^^^^^^^^^ register `vs27` @@ -413,7 +413,7 @@ LL | asm!("", out("f27") _, out("vs27") _); | register `f27` error: register `vs28` conflicts with register `f28` - --> $DIR/bad-reg.rs:262:32 + --> $DIR/bad-reg.rs:264:32 | LL | asm!("", out("f28") _, out("vs28") _); | ------------ ^^^^^^^^^^^^^ register `vs28` @@ -421,7 +421,7 @@ LL | asm!("", out("f28") _, out("vs28") _); | register `f28` error: register `vs29` conflicts with register `f29` - --> $DIR/bad-reg.rs:264:32 + --> $DIR/bad-reg.rs:266:32 | LL | asm!("", out("f29") _, out("vs29") _); | ------------ ^^^^^^^^^^^^^ register `vs29` @@ -429,7 +429,7 @@ LL | asm!("", out("f29") _, out("vs29") _); | register `f29` error: register `vs30` conflicts with register `f30` - --> $DIR/bad-reg.rs:266:32 + --> $DIR/bad-reg.rs:268:32 | LL | asm!("", out("f30") _, out("vs30") _); | ------------ ^^^^^^^^^^^^^ register `vs30` @@ -437,7 +437,7 @@ LL | asm!("", out("f30") _, out("vs30") _); | register `f30` error: register `vs31` conflicts with register `f31` - --> $DIR/bad-reg.rs:268:32 + --> $DIR/bad-reg.rs:270:32 | LL | asm!("", out("f31") _, out("vs31") _); | ------------ ^^^^^^^^^^^^^ register `vs31` @@ -445,7 +445,7 @@ LL | asm!("", out("f31") _, out("vs31") _); | register `f31` error: register `v0` conflicts with register `vs32` - --> $DIR/bad-reg.rs:270:33 + --> $DIR/bad-reg.rs:272:33 | LL | asm!("", out("vs32") _, out("v0") _); | ------------- ^^^^^^^^^^^ register `v0` @@ -453,7 +453,7 @@ LL | asm!("", out("vs32") _, out("v0") _); | register `vs32` error: register `v1` conflicts with register `vs33` - --> $DIR/bad-reg.rs:272:33 + --> $DIR/bad-reg.rs:274:33 | LL | asm!("", out("vs33") _, out("v1") _); | ------------- ^^^^^^^^^^^ register `v1` @@ -461,7 +461,7 @@ LL | asm!("", out("vs33") _, out("v1") _); | register `vs33` error: register `v2` conflicts with register `vs34` - --> $DIR/bad-reg.rs:274:33 + --> $DIR/bad-reg.rs:276:33 | LL | asm!("", out("vs34") _, out("v2") _); | ------------- ^^^^^^^^^^^ register `v2` @@ -469,7 +469,7 @@ LL | asm!("", out("vs34") _, out("v2") _); | register `vs34` error: register `v3` conflicts with register `vs35` - --> $DIR/bad-reg.rs:276:33 + --> $DIR/bad-reg.rs:278:33 | LL | asm!("", out("vs35") _, out("v3") _); | ------------- ^^^^^^^^^^^ register `v3` @@ -477,7 +477,7 @@ LL | asm!("", out("vs35") _, out("v3") _); | register `vs35` error: register `v4` conflicts with register `vs36` - --> $DIR/bad-reg.rs:278:33 + --> $DIR/bad-reg.rs:280:33 | LL | asm!("", out("vs36") _, out("v4") _); | ------------- ^^^^^^^^^^^ register `v4` @@ -485,7 +485,7 @@ LL | asm!("", out("vs36") _, out("v4") _); | register `vs36` error: register `v5` conflicts with register `vs37` - --> $DIR/bad-reg.rs:280:33 + --> $DIR/bad-reg.rs:282:33 | LL | asm!("", out("vs37") _, out("v5") _); | ------------- ^^^^^^^^^^^ register `v5` @@ -493,7 +493,7 @@ LL | asm!("", out("vs37") _, out("v5") _); | register `vs37` error: register `v6` conflicts with register `vs38` - --> $DIR/bad-reg.rs:282:33 + --> $DIR/bad-reg.rs:284:33 | LL | asm!("", out("vs38") _, out("v6") _); | ------------- ^^^^^^^^^^^ register `v6` @@ -501,7 +501,7 @@ LL | asm!("", out("vs38") _, out("v6") _); | register `vs38` error: register `v7` conflicts with register `vs39` - --> $DIR/bad-reg.rs:284:33 + --> $DIR/bad-reg.rs:286:33 | LL | asm!("", out("vs39") _, out("v7") _); | ------------- ^^^^^^^^^^^ register `v7` @@ -509,7 +509,7 @@ LL | asm!("", out("vs39") _, out("v7") _); | register `vs39` error: register `v8` conflicts with register `vs40` - --> $DIR/bad-reg.rs:286:33 + --> $DIR/bad-reg.rs:288:33 | LL | asm!("", out("vs40") _, out("v8") _); | ------------- ^^^^^^^^^^^ register `v8` @@ -517,7 +517,7 @@ LL | asm!("", out("vs40") _, out("v8") _); | register `vs40` error: register `v9` conflicts with register `vs41` - --> $DIR/bad-reg.rs:288:33 + --> $DIR/bad-reg.rs:290:33 | LL | asm!("", out("vs41") _, out("v9") _); | ------------- ^^^^^^^^^^^ register `v9` @@ -525,7 +525,7 @@ LL | asm!("", out("vs41") _, out("v9") _); | register `vs41` error: register `v10` conflicts with register `vs42` - --> $DIR/bad-reg.rs:290:33 + --> $DIR/bad-reg.rs:292:33 | LL | asm!("", out("vs42") _, out("v10") _); | ------------- ^^^^^^^^^^^^ register `v10` @@ -533,7 +533,7 @@ LL | asm!("", out("vs42") _, out("v10") _); | register `vs42` error: register `v11` conflicts with register `vs43` - --> $DIR/bad-reg.rs:292:33 + --> $DIR/bad-reg.rs:294:33 | LL | asm!("", out("vs43") _, out("v11") _); | ------------- ^^^^^^^^^^^^ register `v11` @@ -541,7 +541,7 @@ LL | asm!("", out("vs43") _, out("v11") _); | register `vs43` error: register `v12` conflicts with register `vs44` - --> $DIR/bad-reg.rs:294:33 + --> $DIR/bad-reg.rs:296:33 | LL | asm!("", out("vs44") _, out("v12") _); | ------------- ^^^^^^^^^^^^ register `v12` @@ -549,7 +549,7 @@ LL | asm!("", out("vs44") _, out("v12") _); | register `vs44` error: register `v13` conflicts with register `vs45` - --> $DIR/bad-reg.rs:296:33 + --> $DIR/bad-reg.rs:298:33 | LL | asm!("", out("vs45") _, out("v13") _); | ------------- ^^^^^^^^^^^^ register `v13` @@ -557,7 +557,7 @@ LL | asm!("", out("vs45") _, out("v13") _); | register `vs45` error: register `v14` conflicts with register `vs46` - --> $DIR/bad-reg.rs:298:33 + --> $DIR/bad-reg.rs:300:33 | LL | asm!("", out("vs46") _, out("v14") _); | ------------- ^^^^^^^^^^^^ register `v14` @@ -565,7 +565,7 @@ LL | asm!("", out("vs46") _, out("v14") _); | register `vs46` error: register `v15` conflicts with register `vs47` - --> $DIR/bad-reg.rs:300:33 + --> $DIR/bad-reg.rs:302:33 | LL | asm!("", out("vs47") _, out("v15") _); | ------------- ^^^^^^^^^^^^ register `v15` @@ -573,7 +573,7 @@ LL | asm!("", out("vs47") _, out("v15") _); | register `vs47` error: register `v16` conflicts with register `vs48` - --> $DIR/bad-reg.rs:302:33 + --> $DIR/bad-reg.rs:304:33 | LL | asm!("", out("vs48") _, out("v16") _); | ------------- ^^^^^^^^^^^^ register `v16` @@ -581,7 +581,7 @@ LL | asm!("", out("vs48") _, out("v16") _); | register `vs48` error: register `v17` conflicts with register `vs49` - --> $DIR/bad-reg.rs:304:33 + --> $DIR/bad-reg.rs:306:33 | LL | asm!("", out("vs49") _, out("v17") _); | ------------- ^^^^^^^^^^^^ register `v17` @@ -589,7 +589,7 @@ LL | asm!("", out("vs49") _, out("v17") _); | register `vs49` error: register `v18` conflicts with register `vs50` - --> $DIR/bad-reg.rs:306:33 + --> $DIR/bad-reg.rs:308:33 | LL | asm!("", out("vs50") _, out("v18") _); | ------------- ^^^^^^^^^^^^ register `v18` @@ -597,7 +597,7 @@ LL | asm!("", out("vs50") _, out("v18") _); | register `vs50` error: register `v19` conflicts with register `vs51` - --> $DIR/bad-reg.rs:308:33 + --> $DIR/bad-reg.rs:310:33 | LL | asm!("", out("vs51") _, out("v19") _); | ------------- ^^^^^^^^^^^^ register `v19` @@ -605,7 +605,7 @@ LL | asm!("", out("vs51") _, out("v19") _); | register `vs51` error: register `v20` conflicts with register `vs52` - --> $DIR/bad-reg.rs:310:33 + --> $DIR/bad-reg.rs:312:33 | LL | asm!("", out("vs52") _, out("v20") _); | ------------- ^^^^^^^^^^^^ register `v20` @@ -613,7 +613,7 @@ LL | asm!("", out("vs52") _, out("v20") _); | register `vs52` error: register `v21` conflicts with register `vs53` - --> $DIR/bad-reg.rs:312:33 + --> $DIR/bad-reg.rs:314:33 | LL | asm!("", out("vs53") _, out("v21") _); | ------------- ^^^^^^^^^^^^ register `v21` @@ -621,7 +621,7 @@ LL | asm!("", out("vs53") _, out("v21") _); | register `vs53` error: register `v22` conflicts with register `vs54` - --> $DIR/bad-reg.rs:314:33 + --> $DIR/bad-reg.rs:316:33 | LL | asm!("", out("vs54") _, out("v22") _); | ------------- ^^^^^^^^^^^^ register `v22` @@ -629,7 +629,7 @@ LL | asm!("", out("vs54") _, out("v22") _); | register `vs54` error: register `v23` conflicts with register `vs55` - --> $DIR/bad-reg.rs:316:33 + --> $DIR/bad-reg.rs:318:33 | LL | asm!("", out("vs55") _, out("v23") _); | ------------- ^^^^^^^^^^^^ register `v23` @@ -637,7 +637,7 @@ LL | asm!("", out("vs55") _, out("v23") _); | register `vs55` error: register `v24` conflicts with register `vs56` - --> $DIR/bad-reg.rs:318:33 + --> $DIR/bad-reg.rs:320:33 | LL | asm!("", out("vs56") _, out("v24") _); | ------------- ^^^^^^^^^^^^ register `v24` @@ -645,7 +645,7 @@ LL | asm!("", out("vs56") _, out("v24") _); | register `vs56` error: register `v25` conflicts with register `vs57` - --> $DIR/bad-reg.rs:320:33 + --> $DIR/bad-reg.rs:322:33 | LL | asm!("", out("vs57") _, out("v25") _); | ------------- ^^^^^^^^^^^^ register `v25` @@ -653,7 +653,7 @@ LL | asm!("", out("vs57") _, out("v25") _); | register `vs57` error: register `v26` conflicts with register `vs58` - --> $DIR/bad-reg.rs:322:33 + --> $DIR/bad-reg.rs:324:33 | LL | asm!("", out("vs58") _, out("v26") _); | ------------- ^^^^^^^^^^^^ register `v26` @@ -661,7 +661,7 @@ LL | asm!("", out("vs58") _, out("v26") _); | register `vs58` error: register `v27` conflicts with register `vs59` - --> $DIR/bad-reg.rs:324:33 + --> $DIR/bad-reg.rs:326:33 | LL | asm!("", out("vs59") _, out("v27") _); | ------------- ^^^^^^^^^^^^ register `v27` @@ -669,7 +669,7 @@ LL | asm!("", out("vs59") _, out("v27") _); | register `vs59` error: register `v28` conflicts with register `vs60` - --> $DIR/bad-reg.rs:326:33 + --> $DIR/bad-reg.rs:328:33 | LL | asm!("", out("vs60") _, out("v28") _); | ------------- ^^^^^^^^^^^^ register `v28` @@ -677,7 +677,7 @@ LL | asm!("", out("vs60") _, out("v28") _); | register `vs60` error: register `v29` conflicts with register `vs61` - --> $DIR/bad-reg.rs:328:33 + --> $DIR/bad-reg.rs:330:33 | LL | asm!("", out("vs61") _, out("v29") _); | ------------- ^^^^^^^^^^^^ register `v29` @@ -685,7 +685,7 @@ LL | asm!("", out("vs61") _, out("v29") _); | register `vs61` error: register `v30` conflicts with register `vs62` - --> $DIR/bad-reg.rs:330:33 + --> $DIR/bad-reg.rs:332:33 | LL | asm!("", out("vs62") _, out("v30") _); | ------------- ^^^^^^^^^^^^ register `v30` @@ -693,21 +693,27 @@ LL | asm!("", out("vs62") _, out("v30") _); | register `vs62` error: register `v31` conflicts with register `vs63` - --> $DIR/bad-reg.rs:332:33 + --> $DIR/bad-reg.rs:334:33 | LL | asm!("", out("vs63") _, out("v31") _); | ------------- ^^^^^^^^^^^^ register `v31` | | | register `vs63` +error: register class `spe_acc` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:340:26 + | +LL | asm!("/* {} */", out(spe_acc) _); + | ^^^^^^^^^^^^^^ + error: cannot use register `r13`: r13 is a reserved register on this target - --> $DIR/bad-reg.rs:40:18 + --> $DIR/bad-reg.rs:42:18 | LL | asm!("", out("r13") _); | ^^^^^^^^^^^^ error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:63:27 + --> $DIR/bad-reg.rs:65:27 | LL | asm!("", in("v0") x); // FIXME: should be ok if vsx is available | ^ @@ -715,7 +721,7 @@ LL | asm!("", in("v0") x); // FIXME: should be ok if vsx is available = note: register class `vreg` supports these types: i8x16, i16x8, i32x4, f32x4, f32, f64, i64x2, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:66:28 + --> $DIR/bad-reg.rs:68:28 | LL | asm!("", out("v0") x); // FIXME: should be ok if vsx is available | ^ @@ -723,7 +729,7 @@ LL | asm!("", out("v0") x); // FIXME: should be ok if vsx is available = note: register class `vreg` supports these types: i8x16, i16x8, i32x4, f32x4, f32, f64, i64x2, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:74:35 + --> $DIR/bad-reg.rs:76:35 | LL | asm!("/* {} */", in(vreg) x); // FIXME: should be ok if vsx is available | ^ @@ -731,7 +737,7 @@ LL | asm!("/* {} */", in(vreg) x); // FIXME: should be ok if vsx is avai = note: register class `vreg` supports these types: i8x16, i16x8, i32x4, f32x4, f32, f64, i64x2, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:104:28 + --> $DIR/bad-reg.rs:106:28 | LL | asm!("", in("vs0") x); // FIXME: should be ok if vsx is available | ^ @@ -739,7 +745,7 @@ LL | asm!("", in("vs0") x); // FIXME: should be ok if vsx is available = note: register class `vsreg` supports these types: f32, f64, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:107:29 + --> $DIR/bad-reg.rs:109:29 | LL | asm!("", out("vs0") x); // FIXME: should be ok if vsx is available | ^ @@ -747,7 +753,7 @@ LL | asm!("", out("vs0") x); // FIXME: should be ok if vsx is available = note: register class `vsreg` supports these types: f32, f64, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:114:36 + --> $DIR/bad-reg.rs:116:36 | LL | asm!("/* {} */", in(vsreg) x); // FIXME: should be ok if vsx is available | ^ @@ -755,7 +761,7 @@ LL | asm!("/* {} */", in(vsreg) x); // FIXME: should be ok if vsx is ava = note: register class `vsreg` supports these types: f32, f64, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:137:27 + --> $DIR/bad-reg.rs:139:27 | LL | asm!("", in("cr") x); | ^ @@ -763,7 +769,7 @@ LL | asm!("", in("cr") x); = note: register class `cr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:140:28 + --> $DIR/bad-reg.rs:142:28 | LL | asm!("", out("cr") x); | ^ @@ -771,7 +777,7 @@ LL | asm!("", out("cr") x); = note: register class `cr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:143:33 + --> $DIR/bad-reg.rs:145:33 | LL | asm!("/* {} */", in(cr) x); | ^ @@ -779,7 +785,7 @@ LL | asm!("/* {} */", in(cr) x); = note: register class `cr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:150:28 + --> $DIR/bad-reg.rs:152:28 | LL | asm!("", in("ctr") x); | ^ @@ -787,7 +793,7 @@ LL | asm!("", in("ctr") x); = note: register class `ctr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:153:29 + --> $DIR/bad-reg.rs:155:29 | LL | asm!("", out("ctr") x); | ^ @@ -795,7 +801,7 @@ LL | asm!("", out("ctr") x); = note: register class `ctr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:156:34 + --> $DIR/bad-reg.rs:158:34 | LL | asm!("/* {} */", in(ctr) x); | ^ @@ -803,7 +809,7 @@ LL | asm!("/* {} */", in(ctr) x); = note: register class `ctr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:163:27 + --> $DIR/bad-reg.rs:165:27 | LL | asm!("", in("lr") x); | ^ @@ -811,7 +817,7 @@ LL | asm!("", in("lr") x); = note: register class `lr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:166:28 + --> $DIR/bad-reg.rs:168:28 | LL | asm!("", out("lr") x); | ^ @@ -819,7 +825,7 @@ LL | asm!("", out("lr") x); = note: register class `lr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:169:33 + --> $DIR/bad-reg.rs:171:33 | LL | asm!("/* {} */", in(lr) x); | ^ @@ -827,7 +833,7 @@ LL | asm!("/* {} */", in(lr) x); = note: register class `lr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:176:28 + --> $DIR/bad-reg.rs:178:28 | LL | asm!("", in("xer") x); | ^ @@ -835,7 +841,7 @@ LL | asm!("", in("xer") x); = note: register class `xer` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:179:29 + --> $DIR/bad-reg.rs:181:29 | LL | asm!("", out("xer") x); | ^ @@ -843,12 +849,18 @@ LL | asm!("", out("xer") x); = note: register class `xer` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:182:34 + --> $DIR/bad-reg.rs:184:34 | LL | asm!("/* {} */", in(xer) x); | ^ | = note: register class `xer` supports these types: -error: aborting due to 112 previous errors +error: cannot use register `spe_acc`: spe_acc is only available on spe targets + --> $DIR/bad-reg.rs:338:18 + | +LL | asm!("", out("spe_acc") _); + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 114 previous errors diff --git a/tests/ui/asm/powerpc/bad-reg.powerpc.stderr b/tests/ui/asm/powerpc/bad-reg.powerpc.stderr index 651e8cdfd3d51..5c4cd71c2d1ad 100644 --- a/tests/ui/asm/powerpc/bad-reg.powerpc.stderr +++ b/tests/ui/asm/powerpc/bad-reg.powerpc.stderr @@ -1,131 +1,131 @@ error: invalid register `sp`: the stack pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:36:18 + --> $DIR/bad-reg.rs:38:18 | LL | asm!("", out("sp") _); | ^^^^^^^^^^^ error: invalid register `r2`: r2 is a system reserved register and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:38:18 + --> $DIR/bad-reg.rs:40:18 | LL | asm!("", out("r2") _); | ^^^^^^^^^^^ error: invalid register `r30`: r30 is used internally by LLVM and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:44:18 + --> $DIR/bad-reg.rs:46:18 | LL | asm!("", out("r30") _); | ^^^^^^^^^^^^ error: invalid register `fp`: the frame pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:46:18 + --> $DIR/bad-reg.rs:48:18 | LL | asm!("", out("fp") _); | ^^^^^^^^^^^ error: invalid register `vrsave`: the vrsave register cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:48:18 + --> $DIR/bad-reg.rs:50:18 | LL | asm!("", out("vrsave") _); | ^^^^^^^^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:137:18 + --> $DIR/bad-reg.rs:139:18 | LL | asm!("", in("cr") x); | ^^^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:140:18 + --> $DIR/bad-reg.rs:142:18 | LL | asm!("", out("cr") x); | ^^^^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:143:26 + --> $DIR/bad-reg.rs:145:26 | LL | asm!("/* {} */", in(cr) x); | ^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:146:26 + --> $DIR/bad-reg.rs:148:26 | LL | asm!("/* {} */", out(cr) _); | ^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:150:18 + --> $DIR/bad-reg.rs:152:18 | LL | asm!("", in("ctr") x); | ^^^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:153:18 + --> $DIR/bad-reg.rs:155:18 | LL | asm!("", out("ctr") x); | ^^^^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:156:26 + --> $DIR/bad-reg.rs:158:26 | LL | asm!("/* {} */", in(ctr) x); | ^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:159:26 + --> $DIR/bad-reg.rs:161:26 | LL | asm!("/* {} */", out(ctr) _); | ^^^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:163:18 + --> $DIR/bad-reg.rs:165:18 | LL | asm!("", in("lr") x); | ^^^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:166:18 + --> $DIR/bad-reg.rs:168:18 | LL | asm!("", out("lr") x); | ^^^^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:169:26 + --> $DIR/bad-reg.rs:171:26 | LL | asm!("/* {} */", in(lr) x); | ^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:172:26 + --> $DIR/bad-reg.rs:174:26 | LL | asm!("/* {} */", out(lr) _); | ^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:176:18 + --> $DIR/bad-reg.rs:178:18 | LL | asm!("", in("xer") x); | ^^^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:179:18 + --> $DIR/bad-reg.rs:181:18 | LL | asm!("", out("xer") x); | ^^^^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:182:26 + --> $DIR/bad-reg.rs:184:26 | LL | asm!("/* {} */", in(xer) x); | ^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:185:26 + --> $DIR/bad-reg.rs:187:26 | LL | asm!("/* {} */", out(xer) _); | ^^^^^^^^^^ error: register `cr0` conflicts with register `cr` - --> $DIR/bad-reg.rs:189:31 + --> $DIR/bad-reg.rs:191:31 | LL | asm!("", out("cr") _, out("cr0") _); | ----------- ^^^^^^^^^^^^ register `cr0` @@ -133,7 +133,7 @@ LL | asm!("", out("cr") _, out("cr0") _); | register `cr` error: register `cr1` conflicts with register `cr` - --> $DIR/bad-reg.rs:191:31 + --> $DIR/bad-reg.rs:193:31 | LL | asm!("", out("cr") _, out("cr1") _); | ----------- ^^^^^^^^^^^^ register `cr1` @@ -141,7 +141,7 @@ LL | asm!("", out("cr") _, out("cr1") _); | register `cr` error: register `cr2` conflicts with register `cr` - --> $DIR/bad-reg.rs:193:31 + --> $DIR/bad-reg.rs:195:31 | LL | asm!("", out("cr") _, out("cr2") _); | ----------- ^^^^^^^^^^^^ register `cr2` @@ -149,7 +149,7 @@ LL | asm!("", out("cr") _, out("cr2") _); | register `cr` error: register `cr3` conflicts with register `cr` - --> $DIR/bad-reg.rs:195:31 + --> $DIR/bad-reg.rs:197:31 | LL | asm!("", out("cr") _, out("cr3") _); | ----------- ^^^^^^^^^^^^ register `cr3` @@ -157,7 +157,7 @@ LL | asm!("", out("cr") _, out("cr3") _); | register `cr` error: register `cr4` conflicts with register `cr` - --> $DIR/bad-reg.rs:197:31 + --> $DIR/bad-reg.rs:199:31 | LL | asm!("", out("cr") _, out("cr4") _); | ----------- ^^^^^^^^^^^^ register `cr4` @@ -165,7 +165,7 @@ LL | asm!("", out("cr") _, out("cr4") _); | register `cr` error: register `cr5` conflicts with register `cr` - --> $DIR/bad-reg.rs:199:31 + --> $DIR/bad-reg.rs:201:31 | LL | asm!("", out("cr") _, out("cr5") _); | ----------- ^^^^^^^^^^^^ register `cr5` @@ -173,7 +173,7 @@ LL | asm!("", out("cr") _, out("cr5") _); | register `cr` error: register `cr6` conflicts with register `cr` - --> $DIR/bad-reg.rs:201:31 + --> $DIR/bad-reg.rs:203:31 | LL | asm!("", out("cr") _, out("cr6") _); | ----------- ^^^^^^^^^^^^ register `cr6` @@ -181,7 +181,7 @@ LL | asm!("", out("cr") _, out("cr6") _); | register `cr` error: register `cr7` conflicts with register `cr` - --> $DIR/bad-reg.rs:203:31 + --> $DIR/bad-reg.rs:205:31 | LL | asm!("", out("cr") _, out("cr7") _); | ----------- ^^^^^^^^^^^^ register `cr7` @@ -189,7 +189,7 @@ LL | asm!("", out("cr") _, out("cr7") _); | register `cr` error: register `vs0` conflicts with register `f0` - --> $DIR/bad-reg.rs:206:31 + --> $DIR/bad-reg.rs:208:31 | LL | asm!("", out("f0") _, out("vs0") _); | ----------- ^^^^^^^^^^^^ register `vs0` @@ -197,7 +197,7 @@ LL | asm!("", out("f0") _, out("vs0") _); | register `f0` error: register `vs1` conflicts with register `f1` - --> $DIR/bad-reg.rs:208:31 + --> $DIR/bad-reg.rs:210:31 | LL | asm!("", out("f1") _, out("vs1") _); | ----------- ^^^^^^^^^^^^ register `vs1` @@ -205,7 +205,7 @@ LL | asm!("", out("f1") _, out("vs1") _); | register `f1` error: register `vs2` conflicts with register `f2` - --> $DIR/bad-reg.rs:210:31 + --> $DIR/bad-reg.rs:212:31 | LL | asm!("", out("f2") _, out("vs2") _); | ----------- ^^^^^^^^^^^^ register `vs2` @@ -213,7 +213,7 @@ LL | asm!("", out("f2") _, out("vs2") _); | register `f2` error: register `vs3` conflicts with register `f3` - --> $DIR/bad-reg.rs:212:31 + --> $DIR/bad-reg.rs:214:31 | LL | asm!("", out("f3") _, out("vs3") _); | ----------- ^^^^^^^^^^^^ register `vs3` @@ -221,7 +221,7 @@ LL | asm!("", out("f3") _, out("vs3") _); | register `f3` error: register `vs4` conflicts with register `f4` - --> $DIR/bad-reg.rs:214:31 + --> $DIR/bad-reg.rs:216:31 | LL | asm!("", out("f4") _, out("vs4") _); | ----------- ^^^^^^^^^^^^ register `vs4` @@ -229,7 +229,7 @@ LL | asm!("", out("f4") _, out("vs4") _); | register `f4` error: register `vs5` conflicts with register `f5` - --> $DIR/bad-reg.rs:216:31 + --> $DIR/bad-reg.rs:218:31 | LL | asm!("", out("f5") _, out("vs5") _); | ----------- ^^^^^^^^^^^^ register `vs5` @@ -237,7 +237,7 @@ LL | asm!("", out("f5") _, out("vs5") _); | register `f5` error: register `vs6` conflicts with register `f6` - --> $DIR/bad-reg.rs:218:31 + --> $DIR/bad-reg.rs:220:31 | LL | asm!("", out("f6") _, out("vs6") _); | ----------- ^^^^^^^^^^^^ register `vs6` @@ -245,7 +245,7 @@ LL | asm!("", out("f6") _, out("vs6") _); | register `f6` error: register `vs7` conflicts with register `f7` - --> $DIR/bad-reg.rs:220:31 + --> $DIR/bad-reg.rs:222:31 | LL | asm!("", out("f7") _, out("vs7") _); | ----------- ^^^^^^^^^^^^ register `vs7` @@ -253,7 +253,7 @@ LL | asm!("", out("f7") _, out("vs7") _); | register `f7` error: register `vs8` conflicts with register `f8` - --> $DIR/bad-reg.rs:222:31 + --> $DIR/bad-reg.rs:224:31 | LL | asm!("", out("f8") _, out("vs8") _); | ----------- ^^^^^^^^^^^^ register `vs8` @@ -261,7 +261,7 @@ LL | asm!("", out("f8") _, out("vs8") _); | register `f8` error: register `vs9` conflicts with register `f9` - --> $DIR/bad-reg.rs:224:31 + --> $DIR/bad-reg.rs:226:31 | LL | asm!("", out("f9") _, out("vs9") _); | ----------- ^^^^^^^^^^^^ register `vs9` @@ -269,7 +269,7 @@ LL | asm!("", out("f9") _, out("vs9") _); | register `f9` error: register `vs10` conflicts with register `f10` - --> $DIR/bad-reg.rs:226:32 + --> $DIR/bad-reg.rs:228:32 | LL | asm!("", out("f10") _, out("vs10") _); | ------------ ^^^^^^^^^^^^^ register `vs10` @@ -277,7 +277,7 @@ LL | asm!("", out("f10") _, out("vs10") _); | register `f10` error: register `vs11` conflicts with register `f11` - --> $DIR/bad-reg.rs:228:32 + --> $DIR/bad-reg.rs:230:32 | LL | asm!("", out("f11") _, out("vs11") _); | ------------ ^^^^^^^^^^^^^ register `vs11` @@ -285,7 +285,7 @@ LL | asm!("", out("f11") _, out("vs11") _); | register `f11` error: register `vs12` conflicts with register `f12` - --> $DIR/bad-reg.rs:230:32 + --> $DIR/bad-reg.rs:232:32 | LL | asm!("", out("f12") _, out("vs12") _); | ------------ ^^^^^^^^^^^^^ register `vs12` @@ -293,7 +293,7 @@ LL | asm!("", out("f12") _, out("vs12") _); | register `f12` error: register `vs13` conflicts with register `f13` - --> $DIR/bad-reg.rs:232:32 + --> $DIR/bad-reg.rs:234:32 | LL | asm!("", out("f13") _, out("vs13") _); | ------------ ^^^^^^^^^^^^^ register `vs13` @@ -301,7 +301,7 @@ LL | asm!("", out("f13") _, out("vs13") _); | register `f13` error: register `vs14` conflicts with register `f14` - --> $DIR/bad-reg.rs:234:32 + --> $DIR/bad-reg.rs:236:32 | LL | asm!("", out("f14") _, out("vs14") _); | ------------ ^^^^^^^^^^^^^ register `vs14` @@ -309,7 +309,7 @@ LL | asm!("", out("f14") _, out("vs14") _); | register `f14` error: register `vs15` conflicts with register `f15` - --> $DIR/bad-reg.rs:236:32 + --> $DIR/bad-reg.rs:238:32 | LL | asm!("", out("f15") _, out("vs15") _); | ------------ ^^^^^^^^^^^^^ register `vs15` @@ -317,7 +317,7 @@ LL | asm!("", out("f15") _, out("vs15") _); | register `f15` error: register `vs16` conflicts with register `f16` - --> $DIR/bad-reg.rs:238:32 + --> $DIR/bad-reg.rs:240:32 | LL | asm!("", out("f16") _, out("vs16") _); | ------------ ^^^^^^^^^^^^^ register `vs16` @@ -325,7 +325,7 @@ LL | asm!("", out("f16") _, out("vs16") _); | register `f16` error: register `vs17` conflicts with register `f17` - --> $DIR/bad-reg.rs:240:32 + --> $DIR/bad-reg.rs:242:32 | LL | asm!("", out("f17") _, out("vs17") _); | ------------ ^^^^^^^^^^^^^ register `vs17` @@ -333,7 +333,7 @@ LL | asm!("", out("f17") _, out("vs17") _); | register `f17` error: register `vs18` conflicts with register `f18` - --> $DIR/bad-reg.rs:242:32 + --> $DIR/bad-reg.rs:244:32 | LL | asm!("", out("f18") _, out("vs18") _); | ------------ ^^^^^^^^^^^^^ register `vs18` @@ -341,7 +341,7 @@ LL | asm!("", out("f18") _, out("vs18") _); | register `f18` error: register `vs19` conflicts with register `f19` - --> $DIR/bad-reg.rs:244:32 + --> $DIR/bad-reg.rs:246:32 | LL | asm!("", out("f19") _, out("vs19") _); | ------------ ^^^^^^^^^^^^^ register `vs19` @@ -349,7 +349,7 @@ LL | asm!("", out("f19") _, out("vs19") _); | register `f19` error: register `vs20` conflicts with register `f20` - --> $DIR/bad-reg.rs:246:32 + --> $DIR/bad-reg.rs:248:32 | LL | asm!("", out("f20") _, out("vs20") _); | ------------ ^^^^^^^^^^^^^ register `vs20` @@ -357,7 +357,7 @@ LL | asm!("", out("f20") _, out("vs20") _); | register `f20` error: register `vs21` conflicts with register `f21` - --> $DIR/bad-reg.rs:248:32 + --> $DIR/bad-reg.rs:250:32 | LL | asm!("", out("f21") _, out("vs21") _); | ------------ ^^^^^^^^^^^^^ register `vs21` @@ -365,7 +365,7 @@ LL | asm!("", out("f21") _, out("vs21") _); | register `f21` error: register `vs22` conflicts with register `f22` - --> $DIR/bad-reg.rs:250:32 + --> $DIR/bad-reg.rs:252:32 | LL | asm!("", out("f22") _, out("vs22") _); | ------------ ^^^^^^^^^^^^^ register `vs22` @@ -373,7 +373,7 @@ LL | asm!("", out("f22") _, out("vs22") _); | register `f22` error: register `vs23` conflicts with register `f23` - --> $DIR/bad-reg.rs:252:32 + --> $DIR/bad-reg.rs:254:32 | LL | asm!("", out("f23") _, out("vs23") _); | ------------ ^^^^^^^^^^^^^ register `vs23` @@ -381,7 +381,7 @@ LL | asm!("", out("f23") _, out("vs23") _); | register `f23` error: register `vs24` conflicts with register `f24` - --> $DIR/bad-reg.rs:254:32 + --> $DIR/bad-reg.rs:256:32 | LL | asm!("", out("f24") _, out("vs24") _); | ------------ ^^^^^^^^^^^^^ register `vs24` @@ -389,7 +389,7 @@ LL | asm!("", out("f24") _, out("vs24") _); | register `f24` error: register `vs25` conflicts with register `f25` - --> $DIR/bad-reg.rs:256:32 + --> $DIR/bad-reg.rs:258:32 | LL | asm!("", out("f25") _, out("vs25") _); | ------------ ^^^^^^^^^^^^^ register `vs25` @@ -397,7 +397,7 @@ LL | asm!("", out("f25") _, out("vs25") _); | register `f25` error: register `vs26` conflicts with register `f26` - --> $DIR/bad-reg.rs:258:32 + --> $DIR/bad-reg.rs:260:32 | LL | asm!("", out("f26") _, out("vs26") _); | ------------ ^^^^^^^^^^^^^ register `vs26` @@ -405,7 +405,7 @@ LL | asm!("", out("f26") _, out("vs26") _); | register `f26` error: register `vs27` conflicts with register `f27` - --> $DIR/bad-reg.rs:260:32 + --> $DIR/bad-reg.rs:262:32 | LL | asm!("", out("f27") _, out("vs27") _); | ------------ ^^^^^^^^^^^^^ register `vs27` @@ -413,7 +413,7 @@ LL | asm!("", out("f27") _, out("vs27") _); | register `f27` error: register `vs28` conflicts with register `f28` - --> $DIR/bad-reg.rs:262:32 + --> $DIR/bad-reg.rs:264:32 | LL | asm!("", out("f28") _, out("vs28") _); | ------------ ^^^^^^^^^^^^^ register `vs28` @@ -421,7 +421,7 @@ LL | asm!("", out("f28") _, out("vs28") _); | register `f28` error: register `vs29` conflicts with register `f29` - --> $DIR/bad-reg.rs:264:32 + --> $DIR/bad-reg.rs:266:32 | LL | asm!("", out("f29") _, out("vs29") _); | ------------ ^^^^^^^^^^^^^ register `vs29` @@ -429,7 +429,7 @@ LL | asm!("", out("f29") _, out("vs29") _); | register `f29` error: register `vs30` conflicts with register `f30` - --> $DIR/bad-reg.rs:266:32 + --> $DIR/bad-reg.rs:268:32 | LL | asm!("", out("f30") _, out("vs30") _); | ------------ ^^^^^^^^^^^^^ register `vs30` @@ -437,7 +437,7 @@ LL | asm!("", out("f30") _, out("vs30") _); | register `f30` error: register `vs31` conflicts with register `f31` - --> $DIR/bad-reg.rs:268:32 + --> $DIR/bad-reg.rs:270:32 | LL | asm!("", out("f31") _, out("vs31") _); | ------------ ^^^^^^^^^^^^^ register `vs31` @@ -445,7 +445,7 @@ LL | asm!("", out("f31") _, out("vs31") _); | register `f31` error: register `v0` conflicts with register `vs32` - --> $DIR/bad-reg.rs:270:33 + --> $DIR/bad-reg.rs:272:33 | LL | asm!("", out("vs32") _, out("v0") _); | ------------- ^^^^^^^^^^^ register `v0` @@ -453,7 +453,7 @@ LL | asm!("", out("vs32") _, out("v0") _); | register `vs32` error: register `v1` conflicts with register `vs33` - --> $DIR/bad-reg.rs:272:33 + --> $DIR/bad-reg.rs:274:33 | LL | asm!("", out("vs33") _, out("v1") _); | ------------- ^^^^^^^^^^^ register `v1` @@ -461,7 +461,7 @@ LL | asm!("", out("vs33") _, out("v1") _); | register `vs33` error: register `v2` conflicts with register `vs34` - --> $DIR/bad-reg.rs:274:33 + --> $DIR/bad-reg.rs:276:33 | LL | asm!("", out("vs34") _, out("v2") _); | ------------- ^^^^^^^^^^^ register `v2` @@ -469,7 +469,7 @@ LL | asm!("", out("vs34") _, out("v2") _); | register `vs34` error: register `v3` conflicts with register `vs35` - --> $DIR/bad-reg.rs:276:33 + --> $DIR/bad-reg.rs:278:33 | LL | asm!("", out("vs35") _, out("v3") _); | ------------- ^^^^^^^^^^^ register `v3` @@ -477,7 +477,7 @@ LL | asm!("", out("vs35") _, out("v3") _); | register `vs35` error: register `v4` conflicts with register `vs36` - --> $DIR/bad-reg.rs:278:33 + --> $DIR/bad-reg.rs:280:33 | LL | asm!("", out("vs36") _, out("v4") _); | ------------- ^^^^^^^^^^^ register `v4` @@ -485,7 +485,7 @@ LL | asm!("", out("vs36") _, out("v4") _); | register `vs36` error: register `v5` conflicts with register `vs37` - --> $DIR/bad-reg.rs:280:33 + --> $DIR/bad-reg.rs:282:33 | LL | asm!("", out("vs37") _, out("v5") _); | ------------- ^^^^^^^^^^^ register `v5` @@ -493,7 +493,7 @@ LL | asm!("", out("vs37") _, out("v5") _); | register `vs37` error: register `v6` conflicts with register `vs38` - --> $DIR/bad-reg.rs:282:33 + --> $DIR/bad-reg.rs:284:33 | LL | asm!("", out("vs38") _, out("v6") _); | ------------- ^^^^^^^^^^^ register `v6` @@ -501,7 +501,7 @@ LL | asm!("", out("vs38") _, out("v6") _); | register `vs38` error: register `v7` conflicts with register `vs39` - --> $DIR/bad-reg.rs:284:33 + --> $DIR/bad-reg.rs:286:33 | LL | asm!("", out("vs39") _, out("v7") _); | ------------- ^^^^^^^^^^^ register `v7` @@ -509,7 +509,7 @@ LL | asm!("", out("vs39") _, out("v7") _); | register `vs39` error: register `v8` conflicts with register `vs40` - --> $DIR/bad-reg.rs:286:33 + --> $DIR/bad-reg.rs:288:33 | LL | asm!("", out("vs40") _, out("v8") _); | ------------- ^^^^^^^^^^^ register `v8` @@ -517,7 +517,7 @@ LL | asm!("", out("vs40") _, out("v8") _); | register `vs40` error: register `v9` conflicts with register `vs41` - --> $DIR/bad-reg.rs:288:33 + --> $DIR/bad-reg.rs:290:33 | LL | asm!("", out("vs41") _, out("v9") _); | ------------- ^^^^^^^^^^^ register `v9` @@ -525,7 +525,7 @@ LL | asm!("", out("vs41") _, out("v9") _); | register `vs41` error: register `v10` conflicts with register `vs42` - --> $DIR/bad-reg.rs:290:33 + --> $DIR/bad-reg.rs:292:33 | LL | asm!("", out("vs42") _, out("v10") _); | ------------- ^^^^^^^^^^^^ register `v10` @@ -533,7 +533,7 @@ LL | asm!("", out("vs42") _, out("v10") _); | register `vs42` error: register `v11` conflicts with register `vs43` - --> $DIR/bad-reg.rs:292:33 + --> $DIR/bad-reg.rs:294:33 | LL | asm!("", out("vs43") _, out("v11") _); | ------------- ^^^^^^^^^^^^ register `v11` @@ -541,7 +541,7 @@ LL | asm!("", out("vs43") _, out("v11") _); | register `vs43` error: register `v12` conflicts with register `vs44` - --> $DIR/bad-reg.rs:294:33 + --> $DIR/bad-reg.rs:296:33 | LL | asm!("", out("vs44") _, out("v12") _); | ------------- ^^^^^^^^^^^^ register `v12` @@ -549,7 +549,7 @@ LL | asm!("", out("vs44") _, out("v12") _); | register `vs44` error: register `v13` conflicts with register `vs45` - --> $DIR/bad-reg.rs:296:33 + --> $DIR/bad-reg.rs:298:33 | LL | asm!("", out("vs45") _, out("v13") _); | ------------- ^^^^^^^^^^^^ register `v13` @@ -557,7 +557,7 @@ LL | asm!("", out("vs45") _, out("v13") _); | register `vs45` error: register `v14` conflicts with register `vs46` - --> $DIR/bad-reg.rs:298:33 + --> $DIR/bad-reg.rs:300:33 | LL | asm!("", out("vs46") _, out("v14") _); | ------------- ^^^^^^^^^^^^ register `v14` @@ -565,7 +565,7 @@ LL | asm!("", out("vs46") _, out("v14") _); | register `vs46` error: register `v15` conflicts with register `vs47` - --> $DIR/bad-reg.rs:300:33 + --> $DIR/bad-reg.rs:302:33 | LL | asm!("", out("vs47") _, out("v15") _); | ------------- ^^^^^^^^^^^^ register `v15` @@ -573,7 +573,7 @@ LL | asm!("", out("vs47") _, out("v15") _); | register `vs47` error: register `v16` conflicts with register `vs48` - --> $DIR/bad-reg.rs:302:33 + --> $DIR/bad-reg.rs:304:33 | LL | asm!("", out("vs48") _, out("v16") _); | ------------- ^^^^^^^^^^^^ register `v16` @@ -581,7 +581,7 @@ LL | asm!("", out("vs48") _, out("v16") _); | register `vs48` error: register `v17` conflicts with register `vs49` - --> $DIR/bad-reg.rs:304:33 + --> $DIR/bad-reg.rs:306:33 | LL | asm!("", out("vs49") _, out("v17") _); | ------------- ^^^^^^^^^^^^ register `v17` @@ -589,7 +589,7 @@ LL | asm!("", out("vs49") _, out("v17") _); | register `vs49` error: register `v18` conflicts with register `vs50` - --> $DIR/bad-reg.rs:306:33 + --> $DIR/bad-reg.rs:308:33 | LL | asm!("", out("vs50") _, out("v18") _); | ------------- ^^^^^^^^^^^^ register `v18` @@ -597,7 +597,7 @@ LL | asm!("", out("vs50") _, out("v18") _); | register `vs50` error: register `v19` conflicts with register `vs51` - --> $DIR/bad-reg.rs:308:33 + --> $DIR/bad-reg.rs:310:33 | LL | asm!("", out("vs51") _, out("v19") _); | ------------- ^^^^^^^^^^^^ register `v19` @@ -605,7 +605,7 @@ LL | asm!("", out("vs51") _, out("v19") _); | register `vs51` error: register `v20` conflicts with register `vs52` - --> $DIR/bad-reg.rs:310:33 + --> $DIR/bad-reg.rs:312:33 | LL | asm!("", out("vs52") _, out("v20") _); | ------------- ^^^^^^^^^^^^ register `v20` @@ -613,7 +613,7 @@ LL | asm!("", out("vs52") _, out("v20") _); | register `vs52` error: register `v21` conflicts with register `vs53` - --> $DIR/bad-reg.rs:312:33 + --> $DIR/bad-reg.rs:314:33 | LL | asm!("", out("vs53") _, out("v21") _); | ------------- ^^^^^^^^^^^^ register `v21` @@ -621,7 +621,7 @@ LL | asm!("", out("vs53") _, out("v21") _); | register `vs53` error: register `v22` conflicts with register `vs54` - --> $DIR/bad-reg.rs:314:33 + --> $DIR/bad-reg.rs:316:33 | LL | asm!("", out("vs54") _, out("v22") _); | ------------- ^^^^^^^^^^^^ register `v22` @@ -629,7 +629,7 @@ LL | asm!("", out("vs54") _, out("v22") _); | register `vs54` error: register `v23` conflicts with register `vs55` - --> $DIR/bad-reg.rs:316:33 + --> $DIR/bad-reg.rs:318:33 | LL | asm!("", out("vs55") _, out("v23") _); | ------------- ^^^^^^^^^^^^ register `v23` @@ -637,7 +637,7 @@ LL | asm!("", out("vs55") _, out("v23") _); | register `vs55` error: register `v24` conflicts with register `vs56` - --> $DIR/bad-reg.rs:318:33 + --> $DIR/bad-reg.rs:320:33 | LL | asm!("", out("vs56") _, out("v24") _); | ------------- ^^^^^^^^^^^^ register `v24` @@ -645,7 +645,7 @@ LL | asm!("", out("vs56") _, out("v24") _); | register `vs56` error: register `v25` conflicts with register `vs57` - --> $DIR/bad-reg.rs:320:33 + --> $DIR/bad-reg.rs:322:33 | LL | asm!("", out("vs57") _, out("v25") _); | ------------- ^^^^^^^^^^^^ register `v25` @@ -653,7 +653,7 @@ LL | asm!("", out("vs57") _, out("v25") _); | register `vs57` error: register `v26` conflicts with register `vs58` - --> $DIR/bad-reg.rs:322:33 + --> $DIR/bad-reg.rs:324:33 | LL | asm!("", out("vs58") _, out("v26") _); | ------------- ^^^^^^^^^^^^ register `v26` @@ -661,7 +661,7 @@ LL | asm!("", out("vs58") _, out("v26") _); | register `vs58` error: register `v27` conflicts with register `vs59` - --> $DIR/bad-reg.rs:324:33 + --> $DIR/bad-reg.rs:326:33 | LL | asm!("", out("vs59") _, out("v27") _); | ------------- ^^^^^^^^^^^^ register `v27` @@ -669,7 +669,7 @@ LL | asm!("", out("vs59") _, out("v27") _); | register `vs59` error: register `v28` conflicts with register `vs60` - --> $DIR/bad-reg.rs:326:33 + --> $DIR/bad-reg.rs:328:33 | LL | asm!("", out("vs60") _, out("v28") _); | ------------- ^^^^^^^^^^^^ register `v28` @@ -677,7 +677,7 @@ LL | asm!("", out("vs60") _, out("v28") _); | register `vs60` error: register `v29` conflicts with register `vs61` - --> $DIR/bad-reg.rs:328:33 + --> $DIR/bad-reg.rs:330:33 | LL | asm!("", out("vs61") _, out("v29") _); | ------------- ^^^^^^^^^^^^ register `v29` @@ -685,7 +685,7 @@ LL | asm!("", out("vs61") _, out("v29") _); | register `vs61` error: register `v30` conflicts with register `vs62` - --> $DIR/bad-reg.rs:330:33 + --> $DIR/bad-reg.rs:332:33 | LL | asm!("", out("vs62") _, out("v30") _); | ------------- ^^^^^^^^^^^^ register `v30` @@ -693,147 +693,153 @@ LL | asm!("", out("vs62") _, out("v30") _); | register `vs62` error: register `v31` conflicts with register `vs63` - --> $DIR/bad-reg.rs:332:33 + --> $DIR/bad-reg.rs:334:33 | LL | asm!("", out("vs63") _, out("v31") _); | ------------- ^^^^^^^^^^^^ register `v31` | | | register `vs63` +error: register class `spe_acc` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:340:26 + | +LL | asm!("/* {} */", out(spe_acc) _); + | ^^^^^^^^^^^^^^ + error: cannot use register `r13`: r13 is a reserved register on this target - --> $DIR/bad-reg.rs:40:18 + --> $DIR/bad-reg.rs:42:18 | LL | asm!("", out("r13") _); | ^^^^^^^^^^^^ error: cannot use register `r29`: r29 is used internally by LLVM and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:42:18 + --> $DIR/bad-reg.rs:44:18 | LL | asm!("", out("r29") _); | ^^^^^^^^^^^^ error: register class `vreg` requires at least one of the following target features: altivec, vsx - --> $DIR/bad-reg.rs:53:18 + --> $DIR/bad-reg.rs:55:18 | LL | asm!("", in("v0") v32x4); // requires altivec | ^^^^^^^^^^^^^^ error: register class `vreg` requires at least one of the following target features: altivec, vsx - --> $DIR/bad-reg.rs:55:18 + --> $DIR/bad-reg.rs:57:18 | LL | asm!("", out("v0") v32x4); // requires altivec | ^^^^^^^^^^^^^^^ error: register class `vreg` requires at least one of the following target features: altivec, vsx - --> $DIR/bad-reg.rs:57:18 + --> $DIR/bad-reg.rs:59:18 | LL | asm!("", in("v0") v64x2); // requires vsx | ^^^^^^^^^^^^^^ error: register class `vreg` requires at least one of the following target features: altivec, vsx - --> $DIR/bad-reg.rs:60:18 + --> $DIR/bad-reg.rs:62:18 | LL | asm!("", out("v0") v64x2); // requires vsx | ^^^^^^^^^^^^^^^ error: register class `vreg` requires at least one of the following target features: altivec, vsx - --> $DIR/bad-reg.rs:63:18 + --> $DIR/bad-reg.rs:65:18 | LL | asm!("", in("v0") x); // FIXME: should be ok if vsx is available | ^^^^^^^^^^ error: register class `vreg` requires at least one of the following target features: altivec, vsx - --> $DIR/bad-reg.rs:66:18 + --> $DIR/bad-reg.rs:68:18 | LL | asm!("", out("v0") x); // FIXME: should be ok if vsx is available | ^^^^^^^^^^^ error: register class `vreg` requires at least one of the following target features: altivec, vsx - --> $DIR/bad-reg.rs:69:26 + --> $DIR/bad-reg.rs:71:26 | LL | asm!("/* {} */", in(vreg) v32x4); // requires altivec | ^^^^^^^^^^^^^^ error: register class `vreg` requires at least one of the following target features: altivec, vsx - --> $DIR/bad-reg.rs:71:26 + --> $DIR/bad-reg.rs:73:26 | LL | asm!("/* {} */", in(vreg) v64x2); // requires vsx | ^^^^^^^^^^^^^^ error: register class `vreg` requires at least one of the following target features: altivec, vsx - --> $DIR/bad-reg.rs:74:26 + --> $DIR/bad-reg.rs:76:26 | LL | asm!("/* {} */", in(vreg) x); // FIXME: should be ok if vsx is available | ^^^^^^^^^^ error: register class `vreg` requires at least one of the following target features: altivec, vsx - --> $DIR/bad-reg.rs:77:26 + --> $DIR/bad-reg.rs:79:26 | LL | asm!("/* {} */", out(vreg) _); // requires altivec | ^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:96:18 + --> $DIR/bad-reg.rs:98:18 | LL | asm!("", in("vs0") v32x4); // requires vsx | ^^^^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:98:18 + --> $DIR/bad-reg.rs:100:18 | LL | asm!("", out("vs0") v32x4); // requires vsx | ^^^^^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:100:18 + --> $DIR/bad-reg.rs:102:18 | LL | asm!("", in("vs0") v64x2); // requires vsx | ^^^^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:102:18 + --> $DIR/bad-reg.rs:104:18 | LL | asm!("", out("vs0") v64x2); // requires vsx | ^^^^^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:104:18 + --> $DIR/bad-reg.rs:106:18 | LL | asm!("", in("vs0") x); // FIXME: should be ok if vsx is available | ^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:107:18 + --> $DIR/bad-reg.rs:109:18 | LL | asm!("", out("vs0") x); // FIXME: should be ok if vsx is available | ^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:110:26 + --> $DIR/bad-reg.rs:112:26 | LL | asm!("/* {} */", in(vsreg) v32x4); // requires vsx | ^^^^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:112:26 + --> $DIR/bad-reg.rs:114:26 | LL | asm!("/* {} */", in(vsreg) v64x2); // requires vsx | ^^^^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:114:26 + --> $DIR/bad-reg.rs:116:26 | LL | asm!("/* {} */", in(vsreg) x); // FIXME: should be ok if vsx is available | ^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:117:26 + --> $DIR/bad-reg.rs:119:26 | LL | asm!("/* {} */", out(vsreg) _); // requires vsx | ^^^^^^^^^^^^ error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:137:27 + --> $DIR/bad-reg.rs:139:27 | LL | asm!("", in("cr") x); | ^ @@ -841,7 +847,7 @@ LL | asm!("", in("cr") x); = note: register class `cr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:140:28 + --> $DIR/bad-reg.rs:142:28 | LL | asm!("", out("cr") x); | ^ @@ -849,7 +855,7 @@ LL | asm!("", out("cr") x); = note: register class `cr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:143:33 + --> $DIR/bad-reg.rs:145:33 | LL | asm!("/* {} */", in(cr) x); | ^ @@ -857,7 +863,7 @@ LL | asm!("/* {} */", in(cr) x); = note: register class `cr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:150:28 + --> $DIR/bad-reg.rs:152:28 | LL | asm!("", in("ctr") x); | ^ @@ -865,7 +871,7 @@ LL | asm!("", in("ctr") x); = note: register class `ctr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:153:29 + --> $DIR/bad-reg.rs:155:29 | LL | asm!("", out("ctr") x); | ^ @@ -873,7 +879,7 @@ LL | asm!("", out("ctr") x); = note: register class `ctr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:156:34 + --> $DIR/bad-reg.rs:158:34 | LL | asm!("/* {} */", in(ctr) x); | ^ @@ -881,7 +887,7 @@ LL | asm!("/* {} */", in(ctr) x); = note: register class `ctr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:163:27 + --> $DIR/bad-reg.rs:165:27 | LL | asm!("", in("lr") x); | ^ @@ -889,7 +895,7 @@ LL | asm!("", in("lr") x); = note: register class `lr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:166:28 + --> $DIR/bad-reg.rs:168:28 | LL | asm!("", out("lr") x); | ^ @@ -897,7 +903,7 @@ LL | asm!("", out("lr") x); = note: register class `lr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:169:33 + --> $DIR/bad-reg.rs:171:33 | LL | asm!("/* {} */", in(lr) x); | ^ @@ -905,7 +911,7 @@ LL | asm!("/* {} */", in(lr) x); = note: register class `lr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:176:28 + --> $DIR/bad-reg.rs:178:28 | LL | asm!("", in("xer") x); | ^ @@ -913,7 +919,7 @@ LL | asm!("", in("xer") x); = note: register class `xer` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:179:29 + --> $DIR/bad-reg.rs:181:29 | LL | asm!("", out("xer") x); | ^ @@ -921,12 +927,18 @@ LL | asm!("", out("xer") x); = note: register class `xer` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:182:34 + --> $DIR/bad-reg.rs:184:34 | LL | asm!("/* {} */", in(xer) x); | ^ | = note: register class `xer` supports these types: -error: aborting due to 127 previous errors +error: cannot use register `spe_acc`: spe_acc is only available on spe targets + --> $DIR/bad-reg.rs:338:18 + | +LL | asm!("", out("spe_acc") _); + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 129 previous errors diff --git a/tests/ui/asm/powerpc/bad-reg.powerpc64.stderr b/tests/ui/asm/powerpc/bad-reg.powerpc64.stderr index 552fb0504b8de..151bb5682e03b 100644 --- a/tests/ui/asm/powerpc/bad-reg.powerpc64.stderr +++ b/tests/ui/asm/powerpc/bad-reg.powerpc64.stderr @@ -1,131 +1,131 @@ error: invalid register `sp`: the stack pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:36:18 + --> $DIR/bad-reg.rs:38:18 | LL | asm!("", out("sp") _); | ^^^^^^^^^^^ error: invalid register `r2`: r2 is a system reserved register and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:38:18 + --> $DIR/bad-reg.rs:40:18 | LL | asm!("", out("r2") _); | ^^^^^^^^^^^ error: invalid register `r30`: r30 is used internally by LLVM and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:44:18 + --> $DIR/bad-reg.rs:46:18 | LL | asm!("", out("r30") _); | ^^^^^^^^^^^^ error: invalid register `fp`: the frame pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:46:18 + --> $DIR/bad-reg.rs:48:18 | LL | asm!("", out("fp") _); | ^^^^^^^^^^^ error: invalid register `vrsave`: the vrsave register cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:48:18 + --> $DIR/bad-reg.rs:50:18 | LL | asm!("", out("vrsave") _); | ^^^^^^^^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:137:18 + --> $DIR/bad-reg.rs:139:18 | LL | asm!("", in("cr") x); | ^^^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:140:18 + --> $DIR/bad-reg.rs:142:18 | LL | asm!("", out("cr") x); | ^^^^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:143:26 + --> $DIR/bad-reg.rs:145:26 | LL | asm!("/* {} */", in(cr) x); | ^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:146:26 + --> $DIR/bad-reg.rs:148:26 | LL | asm!("/* {} */", out(cr) _); | ^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:150:18 + --> $DIR/bad-reg.rs:152:18 | LL | asm!("", in("ctr") x); | ^^^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:153:18 + --> $DIR/bad-reg.rs:155:18 | LL | asm!("", out("ctr") x); | ^^^^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:156:26 + --> $DIR/bad-reg.rs:158:26 | LL | asm!("/* {} */", in(ctr) x); | ^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:159:26 + --> $DIR/bad-reg.rs:161:26 | LL | asm!("/* {} */", out(ctr) _); | ^^^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:163:18 + --> $DIR/bad-reg.rs:165:18 | LL | asm!("", in("lr") x); | ^^^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:166:18 + --> $DIR/bad-reg.rs:168:18 | LL | asm!("", out("lr") x); | ^^^^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:169:26 + --> $DIR/bad-reg.rs:171:26 | LL | asm!("/* {} */", in(lr) x); | ^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:172:26 + --> $DIR/bad-reg.rs:174:26 | LL | asm!("/* {} */", out(lr) _); | ^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:176:18 + --> $DIR/bad-reg.rs:178:18 | LL | asm!("", in("xer") x); | ^^^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:179:18 + --> $DIR/bad-reg.rs:181:18 | LL | asm!("", out("xer") x); | ^^^^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:182:26 + --> $DIR/bad-reg.rs:184:26 | LL | asm!("/* {} */", in(xer) x); | ^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:185:26 + --> $DIR/bad-reg.rs:187:26 | LL | asm!("/* {} */", out(xer) _); | ^^^^^^^^^^ error: register `cr0` conflicts with register `cr` - --> $DIR/bad-reg.rs:189:31 + --> $DIR/bad-reg.rs:191:31 | LL | asm!("", out("cr") _, out("cr0") _); | ----------- ^^^^^^^^^^^^ register `cr0` @@ -133,7 +133,7 @@ LL | asm!("", out("cr") _, out("cr0") _); | register `cr` error: register `cr1` conflicts with register `cr` - --> $DIR/bad-reg.rs:191:31 + --> $DIR/bad-reg.rs:193:31 | LL | asm!("", out("cr") _, out("cr1") _); | ----------- ^^^^^^^^^^^^ register `cr1` @@ -141,7 +141,7 @@ LL | asm!("", out("cr") _, out("cr1") _); | register `cr` error: register `cr2` conflicts with register `cr` - --> $DIR/bad-reg.rs:193:31 + --> $DIR/bad-reg.rs:195:31 | LL | asm!("", out("cr") _, out("cr2") _); | ----------- ^^^^^^^^^^^^ register `cr2` @@ -149,7 +149,7 @@ LL | asm!("", out("cr") _, out("cr2") _); | register `cr` error: register `cr3` conflicts with register `cr` - --> $DIR/bad-reg.rs:195:31 + --> $DIR/bad-reg.rs:197:31 | LL | asm!("", out("cr") _, out("cr3") _); | ----------- ^^^^^^^^^^^^ register `cr3` @@ -157,7 +157,7 @@ LL | asm!("", out("cr") _, out("cr3") _); | register `cr` error: register `cr4` conflicts with register `cr` - --> $DIR/bad-reg.rs:197:31 + --> $DIR/bad-reg.rs:199:31 | LL | asm!("", out("cr") _, out("cr4") _); | ----------- ^^^^^^^^^^^^ register `cr4` @@ -165,7 +165,7 @@ LL | asm!("", out("cr") _, out("cr4") _); | register `cr` error: register `cr5` conflicts with register `cr` - --> $DIR/bad-reg.rs:199:31 + --> $DIR/bad-reg.rs:201:31 | LL | asm!("", out("cr") _, out("cr5") _); | ----------- ^^^^^^^^^^^^ register `cr5` @@ -173,7 +173,7 @@ LL | asm!("", out("cr") _, out("cr5") _); | register `cr` error: register `cr6` conflicts with register `cr` - --> $DIR/bad-reg.rs:201:31 + --> $DIR/bad-reg.rs:203:31 | LL | asm!("", out("cr") _, out("cr6") _); | ----------- ^^^^^^^^^^^^ register `cr6` @@ -181,7 +181,7 @@ LL | asm!("", out("cr") _, out("cr6") _); | register `cr` error: register `cr7` conflicts with register `cr` - --> $DIR/bad-reg.rs:203:31 + --> $DIR/bad-reg.rs:205:31 | LL | asm!("", out("cr") _, out("cr7") _); | ----------- ^^^^^^^^^^^^ register `cr7` @@ -189,7 +189,7 @@ LL | asm!("", out("cr") _, out("cr7") _); | register `cr` error: register `vs0` conflicts with register `f0` - --> $DIR/bad-reg.rs:206:31 + --> $DIR/bad-reg.rs:208:31 | LL | asm!("", out("f0") _, out("vs0") _); | ----------- ^^^^^^^^^^^^ register `vs0` @@ -197,7 +197,7 @@ LL | asm!("", out("f0") _, out("vs0") _); | register `f0` error: register `vs1` conflicts with register `f1` - --> $DIR/bad-reg.rs:208:31 + --> $DIR/bad-reg.rs:210:31 | LL | asm!("", out("f1") _, out("vs1") _); | ----------- ^^^^^^^^^^^^ register `vs1` @@ -205,7 +205,7 @@ LL | asm!("", out("f1") _, out("vs1") _); | register `f1` error: register `vs2` conflicts with register `f2` - --> $DIR/bad-reg.rs:210:31 + --> $DIR/bad-reg.rs:212:31 | LL | asm!("", out("f2") _, out("vs2") _); | ----------- ^^^^^^^^^^^^ register `vs2` @@ -213,7 +213,7 @@ LL | asm!("", out("f2") _, out("vs2") _); | register `f2` error: register `vs3` conflicts with register `f3` - --> $DIR/bad-reg.rs:212:31 + --> $DIR/bad-reg.rs:214:31 | LL | asm!("", out("f3") _, out("vs3") _); | ----------- ^^^^^^^^^^^^ register `vs3` @@ -221,7 +221,7 @@ LL | asm!("", out("f3") _, out("vs3") _); | register `f3` error: register `vs4` conflicts with register `f4` - --> $DIR/bad-reg.rs:214:31 + --> $DIR/bad-reg.rs:216:31 | LL | asm!("", out("f4") _, out("vs4") _); | ----------- ^^^^^^^^^^^^ register `vs4` @@ -229,7 +229,7 @@ LL | asm!("", out("f4") _, out("vs4") _); | register `f4` error: register `vs5` conflicts with register `f5` - --> $DIR/bad-reg.rs:216:31 + --> $DIR/bad-reg.rs:218:31 | LL | asm!("", out("f5") _, out("vs5") _); | ----------- ^^^^^^^^^^^^ register `vs5` @@ -237,7 +237,7 @@ LL | asm!("", out("f5") _, out("vs5") _); | register `f5` error: register `vs6` conflicts with register `f6` - --> $DIR/bad-reg.rs:218:31 + --> $DIR/bad-reg.rs:220:31 | LL | asm!("", out("f6") _, out("vs6") _); | ----------- ^^^^^^^^^^^^ register `vs6` @@ -245,7 +245,7 @@ LL | asm!("", out("f6") _, out("vs6") _); | register `f6` error: register `vs7` conflicts with register `f7` - --> $DIR/bad-reg.rs:220:31 + --> $DIR/bad-reg.rs:222:31 | LL | asm!("", out("f7") _, out("vs7") _); | ----------- ^^^^^^^^^^^^ register `vs7` @@ -253,7 +253,7 @@ LL | asm!("", out("f7") _, out("vs7") _); | register `f7` error: register `vs8` conflicts with register `f8` - --> $DIR/bad-reg.rs:222:31 + --> $DIR/bad-reg.rs:224:31 | LL | asm!("", out("f8") _, out("vs8") _); | ----------- ^^^^^^^^^^^^ register `vs8` @@ -261,7 +261,7 @@ LL | asm!("", out("f8") _, out("vs8") _); | register `f8` error: register `vs9` conflicts with register `f9` - --> $DIR/bad-reg.rs:224:31 + --> $DIR/bad-reg.rs:226:31 | LL | asm!("", out("f9") _, out("vs9") _); | ----------- ^^^^^^^^^^^^ register `vs9` @@ -269,7 +269,7 @@ LL | asm!("", out("f9") _, out("vs9") _); | register `f9` error: register `vs10` conflicts with register `f10` - --> $DIR/bad-reg.rs:226:32 + --> $DIR/bad-reg.rs:228:32 | LL | asm!("", out("f10") _, out("vs10") _); | ------------ ^^^^^^^^^^^^^ register `vs10` @@ -277,7 +277,7 @@ LL | asm!("", out("f10") _, out("vs10") _); | register `f10` error: register `vs11` conflicts with register `f11` - --> $DIR/bad-reg.rs:228:32 + --> $DIR/bad-reg.rs:230:32 | LL | asm!("", out("f11") _, out("vs11") _); | ------------ ^^^^^^^^^^^^^ register `vs11` @@ -285,7 +285,7 @@ LL | asm!("", out("f11") _, out("vs11") _); | register `f11` error: register `vs12` conflicts with register `f12` - --> $DIR/bad-reg.rs:230:32 + --> $DIR/bad-reg.rs:232:32 | LL | asm!("", out("f12") _, out("vs12") _); | ------------ ^^^^^^^^^^^^^ register `vs12` @@ -293,7 +293,7 @@ LL | asm!("", out("f12") _, out("vs12") _); | register `f12` error: register `vs13` conflicts with register `f13` - --> $DIR/bad-reg.rs:232:32 + --> $DIR/bad-reg.rs:234:32 | LL | asm!("", out("f13") _, out("vs13") _); | ------------ ^^^^^^^^^^^^^ register `vs13` @@ -301,7 +301,7 @@ LL | asm!("", out("f13") _, out("vs13") _); | register `f13` error: register `vs14` conflicts with register `f14` - --> $DIR/bad-reg.rs:234:32 + --> $DIR/bad-reg.rs:236:32 | LL | asm!("", out("f14") _, out("vs14") _); | ------------ ^^^^^^^^^^^^^ register `vs14` @@ -309,7 +309,7 @@ LL | asm!("", out("f14") _, out("vs14") _); | register `f14` error: register `vs15` conflicts with register `f15` - --> $DIR/bad-reg.rs:236:32 + --> $DIR/bad-reg.rs:238:32 | LL | asm!("", out("f15") _, out("vs15") _); | ------------ ^^^^^^^^^^^^^ register `vs15` @@ -317,7 +317,7 @@ LL | asm!("", out("f15") _, out("vs15") _); | register `f15` error: register `vs16` conflicts with register `f16` - --> $DIR/bad-reg.rs:238:32 + --> $DIR/bad-reg.rs:240:32 | LL | asm!("", out("f16") _, out("vs16") _); | ------------ ^^^^^^^^^^^^^ register `vs16` @@ -325,7 +325,7 @@ LL | asm!("", out("f16") _, out("vs16") _); | register `f16` error: register `vs17` conflicts with register `f17` - --> $DIR/bad-reg.rs:240:32 + --> $DIR/bad-reg.rs:242:32 | LL | asm!("", out("f17") _, out("vs17") _); | ------------ ^^^^^^^^^^^^^ register `vs17` @@ -333,7 +333,7 @@ LL | asm!("", out("f17") _, out("vs17") _); | register `f17` error: register `vs18` conflicts with register `f18` - --> $DIR/bad-reg.rs:242:32 + --> $DIR/bad-reg.rs:244:32 | LL | asm!("", out("f18") _, out("vs18") _); | ------------ ^^^^^^^^^^^^^ register `vs18` @@ -341,7 +341,7 @@ LL | asm!("", out("f18") _, out("vs18") _); | register `f18` error: register `vs19` conflicts with register `f19` - --> $DIR/bad-reg.rs:244:32 + --> $DIR/bad-reg.rs:246:32 | LL | asm!("", out("f19") _, out("vs19") _); | ------------ ^^^^^^^^^^^^^ register `vs19` @@ -349,7 +349,7 @@ LL | asm!("", out("f19") _, out("vs19") _); | register `f19` error: register `vs20` conflicts with register `f20` - --> $DIR/bad-reg.rs:246:32 + --> $DIR/bad-reg.rs:248:32 | LL | asm!("", out("f20") _, out("vs20") _); | ------------ ^^^^^^^^^^^^^ register `vs20` @@ -357,7 +357,7 @@ LL | asm!("", out("f20") _, out("vs20") _); | register `f20` error: register `vs21` conflicts with register `f21` - --> $DIR/bad-reg.rs:248:32 + --> $DIR/bad-reg.rs:250:32 | LL | asm!("", out("f21") _, out("vs21") _); | ------------ ^^^^^^^^^^^^^ register `vs21` @@ -365,7 +365,7 @@ LL | asm!("", out("f21") _, out("vs21") _); | register `f21` error: register `vs22` conflicts with register `f22` - --> $DIR/bad-reg.rs:250:32 + --> $DIR/bad-reg.rs:252:32 | LL | asm!("", out("f22") _, out("vs22") _); | ------------ ^^^^^^^^^^^^^ register `vs22` @@ -373,7 +373,7 @@ LL | asm!("", out("f22") _, out("vs22") _); | register `f22` error: register `vs23` conflicts with register `f23` - --> $DIR/bad-reg.rs:252:32 + --> $DIR/bad-reg.rs:254:32 | LL | asm!("", out("f23") _, out("vs23") _); | ------------ ^^^^^^^^^^^^^ register `vs23` @@ -381,7 +381,7 @@ LL | asm!("", out("f23") _, out("vs23") _); | register `f23` error: register `vs24` conflicts with register `f24` - --> $DIR/bad-reg.rs:254:32 + --> $DIR/bad-reg.rs:256:32 | LL | asm!("", out("f24") _, out("vs24") _); | ------------ ^^^^^^^^^^^^^ register `vs24` @@ -389,7 +389,7 @@ LL | asm!("", out("f24") _, out("vs24") _); | register `f24` error: register `vs25` conflicts with register `f25` - --> $DIR/bad-reg.rs:256:32 + --> $DIR/bad-reg.rs:258:32 | LL | asm!("", out("f25") _, out("vs25") _); | ------------ ^^^^^^^^^^^^^ register `vs25` @@ -397,7 +397,7 @@ LL | asm!("", out("f25") _, out("vs25") _); | register `f25` error: register `vs26` conflicts with register `f26` - --> $DIR/bad-reg.rs:258:32 + --> $DIR/bad-reg.rs:260:32 | LL | asm!("", out("f26") _, out("vs26") _); | ------------ ^^^^^^^^^^^^^ register `vs26` @@ -405,7 +405,7 @@ LL | asm!("", out("f26") _, out("vs26") _); | register `f26` error: register `vs27` conflicts with register `f27` - --> $DIR/bad-reg.rs:260:32 + --> $DIR/bad-reg.rs:262:32 | LL | asm!("", out("f27") _, out("vs27") _); | ------------ ^^^^^^^^^^^^^ register `vs27` @@ -413,7 +413,7 @@ LL | asm!("", out("f27") _, out("vs27") _); | register `f27` error: register `vs28` conflicts with register `f28` - --> $DIR/bad-reg.rs:262:32 + --> $DIR/bad-reg.rs:264:32 | LL | asm!("", out("f28") _, out("vs28") _); | ------------ ^^^^^^^^^^^^^ register `vs28` @@ -421,7 +421,7 @@ LL | asm!("", out("f28") _, out("vs28") _); | register `f28` error: register `vs29` conflicts with register `f29` - --> $DIR/bad-reg.rs:264:32 + --> $DIR/bad-reg.rs:266:32 | LL | asm!("", out("f29") _, out("vs29") _); | ------------ ^^^^^^^^^^^^^ register `vs29` @@ -429,7 +429,7 @@ LL | asm!("", out("f29") _, out("vs29") _); | register `f29` error: register `vs30` conflicts with register `f30` - --> $DIR/bad-reg.rs:266:32 + --> $DIR/bad-reg.rs:268:32 | LL | asm!("", out("f30") _, out("vs30") _); | ------------ ^^^^^^^^^^^^^ register `vs30` @@ -437,7 +437,7 @@ LL | asm!("", out("f30") _, out("vs30") _); | register `f30` error: register `vs31` conflicts with register `f31` - --> $DIR/bad-reg.rs:268:32 + --> $DIR/bad-reg.rs:270:32 | LL | asm!("", out("f31") _, out("vs31") _); | ------------ ^^^^^^^^^^^^^ register `vs31` @@ -445,7 +445,7 @@ LL | asm!("", out("f31") _, out("vs31") _); | register `f31` error: register `v0` conflicts with register `vs32` - --> $DIR/bad-reg.rs:270:33 + --> $DIR/bad-reg.rs:272:33 | LL | asm!("", out("vs32") _, out("v0") _); | ------------- ^^^^^^^^^^^ register `v0` @@ -453,7 +453,7 @@ LL | asm!("", out("vs32") _, out("v0") _); | register `vs32` error: register `v1` conflicts with register `vs33` - --> $DIR/bad-reg.rs:272:33 + --> $DIR/bad-reg.rs:274:33 | LL | asm!("", out("vs33") _, out("v1") _); | ------------- ^^^^^^^^^^^ register `v1` @@ -461,7 +461,7 @@ LL | asm!("", out("vs33") _, out("v1") _); | register `vs33` error: register `v2` conflicts with register `vs34` - --> $DIR/bad-reg.rs:274:33 + --> $DIR/bad-reg.rs:276:33 | LL | asm!("", out("vs34") _, out("v2") _); | ------------- ^^^^^^^^^^^ register `v2` @@ -469,7 +469,7 @@ LL | asm!("", out("vs34") _, out("v2") _); | register `vs34` error: register `v3` conflicts with register `vs35` - --> $DIR/bad-reg.rs:276:33 + --> $DIR/bad-reg.rs:278:33 | LL | asm!("", out("vs35") _, out("v3") _); | ------------- ^^^^^^^^^^^ register `v3` @@ -477,7 +477,7 @@ LL | asm!("", out("vs35") _, out("v3") _); | register `vs35` error: register `v4` conflicts with register `vs36` - --> $DIR/bad-reg.rs:278:33 + --> $DIR/bad-reg.rs:280:33 | LL | asm!("", out("vs36") _, out("v4") _); | ------------- ^^^^^^^^^^^ register `v4` @@ -485,7 +485,7 @@ LL | asm!("", out("vs36") _, out("v4") _); | register `vs36` error: register `v5` conflicts with register `vs37` - --> $DIR/bad-reg.rs:280:33 + --> $DIR/bad-reg.rs:282:33 | LL | asm!("", out("vs37") _, out("v5") _); | ------------- ^^^^^^^^^^^ register `v5` @@ -493,7 +493,7 @@ LL | asm!("", out("vs37") _, out("v5") _); | register `vs37` error: register `v6` conflicts with register `vs38` - --> $DIR/bad-reg.rs:282:33 + --> $DIR/bad-reg.rs:284:33 | LL | asm!("", out("vs38") _, out("v6") _); | ------------- ^^^^^^^^^^^ register `v6` @@ -501,7 +501,7 @@ LL | asm!("", out("vs38") _, out("v6") _); | register `vs38` error: register `v7` conflicts with register `vs39` - --> $DIR/bad-reg.rs:284:33 + --> $DIR/bad-reg.rs:286:33 | LL | asm!("", out("vs39") _, out("v7") _); | ------------- ^^^^^^^^^^^ register `v7` @@ -509,7 +509,7 @@ LL | asm!("", out("vs39") _, out("v7") _); | register `vs39` error: register `v8` conflicts with register `vs40` - --> $DIR/bad-reg.rs:286:33 + --> $DIR/bad-reg.rs:288:33 | LL | asm!("", out("vs40") _, out("v8") _); | ------------- ^^^^^^^^^^^ register `v8` @@ -517,7 +517,7 @@ LL | asm!("", out("vs40") _, out("v8") _); | register `vs40` error: register `v9` conflicts with register `vs41` - --> $DIR/bad-reg.rs:288:33 + --> $DIR/bad-reg.rs:290:33 | LL | asm!("", out("vs41") _, out("v9") _); | ------------- ^^^^^^^^^^^ register `v9` @@ -525,7 +525,7 @@ LL | asm!("", out("vs41") _, out("v9") _); | register `vs41` error: register `v10` conflicts with register `vs42` - --> $DIR/bad-reg.rs:290:33 + --> $DIR/bad-reg.rs:292:33 | LL | asm!("", out("vs42") _, out("v10") _); | ------------- ^^^^^^^^^^^^ register `v10` @@ -533,7 +533,7 @@ LL | asm!("", out("vs42") _, out("v10") _); | register `vs42` error: register `v11` conflicts with register `vs43` - --> $DIR/bad-reg.rs:292:33 + --> $DIR/bad-reg.rs:294:33 | LL | asm!("", out("vs43") _, out("v11") _); | ------------- ^^^^^^^^^^^^ register `v11` @@ -541,7 +541,7 @@ LL | asm!("", out("vs43") _, out("v11") _); | register `vs43` error: register `v12` conflicts with register `vs44` - --> $DIR/bad-reg.rs:294:33 + --> $DIR/bad-reg.rs:296:33 | LL | asm!("", out("vs44") _, out("v12") _); | ------------- ^^^^^^^^^^^^ register `v12` @@ -549,7 +549,7 @@ LL | asm!("", out("vs44") _, out("v12") _); | register `vs44` error: register `v13` conflicts with register `vs45` - --> $DIR/bad-reg.rs:296:33 + --> $DIR/bad-reg.rs:298:33 | LL | asm!("", out("vs45") _, out("v13") _); | ------------- ^^^^^^^^^^^^ register `v13` @@ -557,7 +557,7 @@ LL | asm!("", out("vs45") _, out("v13") _); | register `vs45` error: register `v14` conflicts with register `vs46` - --> $DIR/bad-reg.rs:298:33 + --> $DIR/bad-reg.rs:300:33 | LL | asm!("", out("vs46") _, out("v14") _); | ------------- ^^^^^^^^^^^^ register `v14` @@ -565,7 +565,7 @@ LL | asm!("", out("vs46") _, out("v14") _); | register `vs46` error: register `v15` conflicts with register `vs47` - --> $DIR/bad-reg.rs:300:33 + --> $DIR/bad-reg.rs:302:33 | LL | asm!("", out("vs47") _, out("v15") _); | ------------- ^^^^^^^^^^^^ register `v15` @@ -573,7 +573,7 @@ LL | asm!("", out("vs47") _, out("v15") _); | register `vs47` error: register `v16` conflicts with register `vs48` - --> $DIR/bad-reg.rs:302:33 + --> $DIR/bad-reg.rs:304:33 | LL | asm!("", out("vs48") _, out("v16") _); | ------------- ^^^^^^^^^^^^ register `v16` @@ -581,7 +581,7 @@ LL | asm!("", out("vs48") _, out("v16") _); | register `vs48` error: register `v17` conflicts with register `vs49` - --> $DIR/bad-reg.rs:304:33 + --> $DIR/bad-reg.rs:306:33 | LL | asm!("", out("vs49") _, out("v17") _); | ------------- ^^^^^^^^^^^^ register `v17` @@ -589,7 +589,7 @@ LL | asm!("", out("vs49") _, out("v17") _); | register `vs49` error: register `v18` conflicts with register `vs50` - --> $DIR/bad-reg.rs:306:33 + --> $DIR/bad-reg.rs:308:33 | LL | asm!("", out("vs50") _, out("v18") _); | ------------- ^^^^^^^^^^^^ register `v18` @@ -597,7 +597,7 @@ LL | asm!("", out("vs50") _, out("v18") _); | register `vs50` error: register `v19` conflicts with register `vs51` - --> $DIR/bad-reg.rs:308:33 + --> $DIR/bad-reg.rs:310:33 | LL | asm!("", out("vs51") _, out("v19") _); | ------------- ^^^^^^^^^^^^ register `v19` @@ -605,7 +605,7 @@ LL | asm!("", out("vs51") _, out("v19") _); | register `vs51` error: register `v20` conflicts with register `vs52` - --> $DIR/bad-reg.rs:310:33 + --> $DIR/bad-reg.rs:312:33 | LL | asm!("", out("vs52") _, out("v20") _); | ------------- ^^^^^^^^^^^^ register `v20` @@ -613,7 +613,7 @@ LL | asm!("", out("vs52") _, out("v20") _); | register `vs52` error: register `v21` conflicts with register `vs53` - --> $DIR/bad-reg.rs:312:33 + --> $DIR/bad-reg.rs:314:33 | LL | asm!("", out("vs53") _, out("v21") _); | ------------- ^^^^^^^^^^^^ register `v21` @@ -621,7 +621,7 @@ LL | asm!("", out("vs53") _, out("v21") _); | register `vs53` error: register `v22` conflicts with register `vs54` - --> $DIR/bad-reg.rs:314:33 + --> $DIR/bad-reg.rs:316:33 | LL | asm!("", out("vs54") _, out("v22") _); | ------------- ^^^^^^^^^^^^ register `v22` @@ -629,7 +629,7 @@ LL | asm!("", out("vs54") _, out("v22") _); | register `vs54` error: register `v23` conflicts with register `vs55` - --> $DIR/bad-reg.rs:316:33 + --> $DIR/bad-reg.rs:318:33 | LL | asm!("", out("vs55") _, out("v23") _); | ------------- ^^^^^^^^^^^^ register `v23` @@ -637,7 +637,7 @@ LL | asm!("", out("vs55") _, out("v23") _); | register `vs55` error: register `v24` conflicts with register `vs56` - --> $DIR/bad-reg.rs:318:33 + --> $DIR/bad-reg.rs:320:33 | LL | asm!("", out("vs56") _, out("v24") _); | ------------- ^^^^^^^^^^^^ register `v24` @@ -645,7 +645,7 @@ LL | asm!("", out("vs56") _, out("v24") _); | register `vs56` error: register `v25` conflicts with register `vs57` - --> $DIR/bad-reg.rs:320:33 + --> $DIR/bad-reg.rs:322:33 | LL | asm!("", out("vs57") _, out("v25") _); | ------------- ^^^^^^^^^^^^ register `v25` @@ -653,7 +653,7 @@ LL | asm!("", out("vs57") _, out("v25") _); | register `vs57` error: register `v26` conflicts with register `vs58` - --> $DIR/bad-reg.rs:322:33 + --> $DIR/bad-reg.rs:324:33 | LL | asm!("", out("vs58") _, out("v26") _); | ------------- ^^^^^^^^^^^^ register `v26` @@ -661,7 +661,7 @@ LL | asm!("", out("vs58") _, out("v26") _); | register `vs58` error: register `v27` conflicts with register `vs59` - --> $DIR/bad-reg.rs:324:33 + --> $DIR/bad-reg.rs:326:33 | LL | asm!("", out("vs59") _, out("v27") _); | ------------- ^^^^^^^^^^^^ register `v27` @@ -669,7 +669,7 @@ LL | asm!("", out("vs59") _, out("v27") _); | register `vs59` error: register `v28` conflicts with register `vs60` - --> $DIR/bad-reg.rs:326:33 + --> $DIR/bad-reg.rs:328:33 | LL | asm!("", out("vs60") _, out("v28") _); | ------------- ^^^^^^^^^^^^ register `v28` @@ -677,7 +677,7 @@ LL | asm!("", out("vs60") _, out("v28") _); | register `vs60` error: register `v29` conflicts with register `vs61` - --> $DIR/bad-reg.rs:328:33 + --> $DIR/bad-reg.rs:330:33 | LL | asm!("", out("vs61") _, out("v29") _); | ------------- ^^^^^^^^^^^^ register `v29` @@ -685,7 +685,7 @@ LL | asm!("", out("vs61") _, out("v29") _); | register `vs61` error: register `v30` conflicts with register `vs62` - --> $DIR/bad-reg.rs:330:33 + --> $DIR/bad-reg.rs:332:33 | LL | asm!("", out("vs62") _, out("v30") _); | ------------- ^^^^^^^^^^^^ register `v30` @@ -693,21 +693,27 @@ LL | asm!("", out("vs62") _, out("v30") _); | register `vs62` error: register `v31` conflicts with register `vs63` - --> $DIR/bad-reg.rs:332:33 + --> $DIR/bad-reg.rs:334:33 | LL | asm!("", out("vs63") _, out("v31") _); | ------------- ^^^^^^^^^^^^ register `v31` | | | register `vs63` +error: register class `spe_acc` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:340:26 + | +LL | asm!("/* {} */", out(spe_acc) _); + | ^^^^^^^^^^^^^^ + error: cannot use register `r13`: r13 is a reserved register on this target - --> $DIR/bad-reg.rs:40:18 + --> $DIR/bad-reg.rs:42:18 | LL | asm!("", out("r13") _); | ^^^^^^^^^^^^ error: `vsx` target feature is not enabled - --> $DIR/bad-reg.rs:57:27 + --> $DIR/bad-reg.rs:59:27 | LL | asm!("", in("v0") v64x2); // requires vsx | ^^^^^ @@ -715,7 +721,7 @@ LL | asm!("", in("v0") v64x2); // requires vsx = note: this is required to use type `i64x2` with register class `vreg` error: `vsx` target feature is not enabled - --> $DIR/bad-reg.rs:60:28 + --> $DIR/bad-reg.rs:62:28 | LL | asm!("", out("v0") v64x2); // requires vsx | ^^^^^ @@ -723,7 +729,7 @@ LL | asm!("", out("v0") v64x2); // requires vsx = note: this is required to use type `i64x2` with register class `vreg` error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:63:27 + --> $DIR/bad-reg.rs:65:27 | LL | asm!("", in("v0") x); // FIXME: should be ok if vsx is available | ^ @@ -731,7 +737,7 @@ LL | asm!("", in("v0") x); // FIXME: should be ok if vsx is available = note: register class `vreg` supports these types: i8x16, i16x8, i32x4, f32x4, f32, f64, i64x2, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:66:28 + --> $DIR/bad-reg.rs:68:28 | LL | asm!("", out("v0") x); // FIXME: should be ok if vsx is available | ^ @@ -739,7 +745,7 @@ LL | asm!("", out("v0") x); // FIXME: should be ok if vsx is available = note: register class `vreg` supports these types: i8x16, i16x8, i32x4, f32x4, f32, f64, i64x2, f64x2 error: `vsx` target feature is not enabled - --> $DIR/bad-reg.rs:71:35 + --> $DIR/bad-reg.rs:73:35 | LL | asm!("/* {} */", in(vreg) v64x2); // requires vsx | ^^^^^ @@ -747,7 +753,7 @@ LL | asm!("/* {} */", in(vreg) v64x2); // requires vsx = note: this is required to use type `i64x2` with register class `vreg` error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:74:35 + --> $DIR/bad-reg.rs:76:35 | LL | asm!("/* {} */", in(vreg) x); // FIXME: should be ok if vsx is available | ^ @@ -755,67 +761,67 @@ LL | asm!("/* {} */", in(vreg) x); // FIXME: should be ok if vsx is avai = note: register class `vreg` supports these types: i8x16, i16x8, i32x4, f32x4, f32, f64, i64x2, f64x2 error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:96:18 + --> $DIR/bad-reg.rs:98:18 | LL | asm!("", in("vs0") v32x4); // requires vsx | ^^^^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:98:18 + --> $DIR/bad-reg.rs:100:18 | LL | asm!("", out("vs0") v32x4); // requires vsx | ^^^^^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:100:18 + --> $DIR/bad-reg.rs:102:18 | LL | asm!("", in("vs0") v64x2); // requires vsx | ^^^^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:102:18 + --> $DIR/bad-reg.rs:104:18 | LL | asm!("", out("vs0") v64x2); // requires vsx | ^^^^^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:104:18 + --> $DIR/bad-reg.rs:106:18 | LL | asm!("", in("vs0") x); // FIXME: should be ok if vsx is available | ^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:107:18 + --> $DIR/bad-reg.rs:109:18 | LL | asm!("", out("vs0") x); // FIXME: should be ok if vsx is available | ^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:110:26 + --> $DIR/bad-reg.rs:112:26 | LL | asm!("/* {} */", in(vsreg) v32x4); // requires vsx | ^^^^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:112:26 + --> $DIR/bad-reg.rs:114:26 | LL | asm!("/* {} */", in(vsreg) v64x2); // requires vsx | ^^^^^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:114:26 + --> $DIR/bad-reg.rs:116:26 | LL | asm!("/* {} */", in(vsreg) x); // FIXME: should be ok if vsx is available | ^^^^^^^^^^^ error: register class `vsreg` requires the `vsx` target feature - --> $DIR/bad-reg.rs:117:26 + --> $DIR/bad-reg.rs:119:26 | LL | asm!("/* {} */", out(vsreg) _); // requires vsx | ^^^^^^^^^^^^ error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:137:27 + --> $DIR/bad-reg.rs:139:27 | LL | asm!("", in("cr") x); | ^ @@ -823,7 +829,7 @@ LL | asm!("", in("cr") x); = note: register class `cr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:140:28 + --> $DIR/bad-reg.rs:142:28 | LL | asm!("", out("cr") x); | ^ @@ -831,7 +837,7 @@ LL | asm!("", out("cr") x); = note: register class `cr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:143:33 + --> $DIR/bad-reg.rs:145:33 | LL | asm!("/* {} */", in(cr) x); | ^ @@ -839,7 +845,7 @@ LL | asm!("/* {} */", in(cr) x); = note: register class `cr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:150:28 + --> $DIR/bad-reg.rs:152:28 | LL | asm!("", in("ctr") x); | ^ @@ -847,7 +853,7 @@ LL | asm!("", in("ctr") x); = note: register class `ctr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:153:29 + --> $DIR/bad-reg.rs:155:29 | LL | asm!("", out("ctr") x); | ^ @@ -855,7 +861,7 @@ LL | asm!("", out("ctr") x); = note: register class `ctr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:156:34 + --> $DIR/bad-reg.rs:158:34 | LL | asm!("/* {} */", in(ctr) x); | ^ @@ -863,7 +869,7 @@ LL | asm!("/* {} */", in(ctr) x); = note: register class `ctr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:163:27 + --> $DIR/bad-reg.rs:165:27 | LL | asm!("", in("lr") x); | ^ @@ -871,7 +877,7 @@ LL | asm!("", in("lr") x); = note: register class `lr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:166:28 + --> $DIR/bad-reg.rs:168:28 | LL | asm!("", out("lr") x); | ^ @@ -879,7 +885,7 @@ LL | asm!("", out("lr") x); = note: register class `lr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:169:33 + --> $DIR/bad-reg.rs:171:33 | LL | asm!("/* {} */", in(lr) x); | ^ @@ -887,7 +893,7 @@ LL | asm!("/* {} */", in(lr) x); = note: register class `lr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:176:28 + --> $DIR/bad-reg.rs:178:28 | LL | asm!("", in("xer") x); | ^ @@ -895,7 +901,7 @@ LL | asm!("", in("xer") x); = note: register class `xer` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:179:29 + --> $DIR/bad-reg.rs:181:29 | LL | asm!("", out("xer") x); | ^ @@ -903,12 +909,18 @@ LL | asm!("", out("xer") x); = note: register class `xer` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:182:34 + --> $DIR/bad-reg.rs:184:34 | LL | asm!("/* {} */", in(xer) x); | ^ | = note: register class `xer` supports these types: -error: aborting due to 122 previous errors +error: cannot use register `spe_acc`: spe_acc is only available on spe targets + --> $DIR/bad-reg.rs:338:18 + | +LL | asm!("", out("spe_acc") _); + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 124 previous errors diff --git a/tests/ui/asm/powerpc/bad-reg.powerpc64le.stderr b/tests/ui/asm/powerpc/bad-reg.powerpc64le.stderr index 4490053215b5d..c7373780e382c 100644 --- a/tests/ui/asm/powerpc/bad-reg.powerpc64le.stderr +++ b/tests/ui/asm/powerpc/bad-reg.powerpc64le.stderr @@ -1,131 +1,131 @@ error: invalid register `sp`: the stack pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:36:18 + --> $DIR/bad-reg.rs:38:18 | LL | asm!("", out("sp") _); | ^^^^^^^^^^^ error: invalid register `r2`: r2 is a system reserved register and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:38:18 + --> $DIR/bad-reg.rs:40:18 | LL | asm!("", out("r2") _); | ^^^^^^^^^^^ error: invalid register `r30`: r30 is used internally by LLVM and cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:44:18 + --> $DIR/bad-reg.rs:46:18 | LL | asm!("", out("r30") _); | ^^^^^^^^^^^^ error: invalid register `fp`: the frame pointer cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:46:18 + --> $DIR/bad-reg.rs:48:18 | LL | asm!("", out("fp") _); | ^^^^^^^^^^^ error: invalid register `vrsave`: the vrsave register cannot be used as an operand for inline asm - --> $DIR/bad-reg.rs:48:18 + --> $DIR/bad-reg.rs:50:18 | LL | asm!("", out("vrsave") _); | ^^^^^^^^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:137:18 + --> $DIR/bad-reg.rs:139:18 | LL | asm!("", in("cr") x); | ^^^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:140:18 + --> $DIR/bad-reg.rs:142:18 | LL | asm!("", out("cr") x); | ^^^^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:143:26 + --> $DIR/bad-reg.rs:145:26 | LL | asm!("/* {} */", in(cr) x); | ^^^^^^^^ error: register class `cr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:146:26 + --> $DIR/bad-reg.rs:148:26 | LL | asm!("/* {} */", out(cr) _); | ^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:150:18 + --> $DIR/bad-reg.rs:152:18 | LL | asm!("", in("ctr") x); | ^^^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:153:18 + --> $DIR/bad-reg.rs:155:18 | LL | asm!("", out("ctr") x); | ^^^^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:156:26 + --> $DIR/bad-reg.rs:158:26 | LL | asm!("/* {} */", in(ctr) x); | ^^^^^^^^^ error: register class `ctr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:159:26 + --> $DIR/bad-reg.rs:161:26 | LL | asm!("/* {} */", out(ctr) _); | ^^^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:163:18 + --> $DIR/bad-reg.rs:165:18 | LL | asm!("", in("lr") x); | ^^^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:166:18 + --> $DIR/bad-reg.rs:168:18 | LL | asm!("", out("lr") x); | ^^^^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:169:26 + --> $DIR/bad-reg.rs:171:26 | LL | asm!("/* {} */", in(lr) x); | ^^^^^^^^ error: register class `lr` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:172:26 + --> $DIR/bad-reg.rs:174:26 | LL | asm!("/* {} */", out(lr) _); | ^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:176:18 + --> $DIR/bad-reg.rs:178:18 | LL | asm!("", in("xer") x); | ^^^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:179:18 + --> $DIR/bad-reg.rs:181:18 | LL | asm!("", out("xer") x); | ^^^^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:182:26 + --> $DIR/bad-reg.rs:184:26 | LL | asm!("/* {} */", in(xer) x); | ^^^^^^^^^ error: register class `xer` can only be used as a clobber, not as an input or output - --> $DIR/bad-reg.rs:185:26 + --> $DIR/bad-reg.rs:187:26 | LL | asm!("/* {} */", out(xer) _); | ^^^^^^^^^^ error: register `cr0` conflicts with register `cr` - --> $DIR/bad-reg.rs:189:31 + --> $DIR/bad-reg.rs:191:31 | LL | asm!("", out("cr") _, out("cr0") _); | ----------- ^^^^^^^^^^^^ register `cr0` @@ -133,7 +133,7 @@ LL | asm!("", out("cr") _, out("cr0") _); | register `cr` error: register `cr1` conflicts with register `cr` - --> $DIR/bad-reg.rs:191:31 + --> $DIR/bad-reg.rs:193:31 | LL | asm!("", out("cr") _, out("cr1") _); | ----------- ^^^^^^^^^^^^ register `cr1` @@ -141,7 +141,7 @@ LL | asm!("", out("cr") _, out("cr1") _); | register `cr` error: register `cr2` conflicts with register `cr` - --> $DIR/bad-reg.rs:193:31 + --> $DIR/bad-reg.rs:195:31 | LL | asm!("", out("cr") _, out("cr2") _); | ----------- ^^^^^^^^^^^^ register `cr2` @@ -149,7 +149,7 @@ LL | asm!("", out("cr") _, out("cr2") _); | register `cr` error: register `cr3` conflicts with register `cr` - --> $DIR/bad-reg.rs:195:31 + --> $DIR/bad-reg.rs:197:31 | LL | asm!("", out("cr") _, out("cr3") _); | ----------- ^^^^^^^^^^^^ register `cr3` @@ -157,7 +157,7 @@ LL | asm!("", out("cr") _, out("cr3") _); | register `cr` error: register `cr4` conflicts with register `cr` - --> $DIR/bad-reg.rs:197:31 + --> $DIR/bad-reg.rs:199:31 | LL | asm!("", out("cr") _, out("cr4") _); | ----------- ^^^^^^^^^^^^ register `cr4` @@ -165,7 +165,7 @@ LL | asm!("", out("cr") _, out("cr4") _); | register `cr` error: register `cr5` conflicts with register `cr` - --> $DIR/bad-reg.rs:199:31 + --> $DIR/bad-reg.rs:201:31 | LL | asm!("", out("cr") _, out("cr5") _); | ----------- ^^^^^^^^^^^^ register `cr5` @@ -173,7 +173,7 @@ LL | asm!("", out("cr") _, out("cr5") _); | register `cr` error: register `cr6` conflicts with register `cr` - --> $DIR/bad-reg.rs:201:31 + --> $DIR/bad-reg.rs:203:31 | LL | asm!("", out("cr") _, out("cr6") _); | ----------- ^^^^^^^^^^^^ register `cr6` @@ -181,7 +181,7 @@ LL | asm!("", out("cr") _, out("cr6") _); | register `cr` error: register `cr7` conflicts with register `cr` - --> $DIR/bad-reg.rs:203:31 + --> $DIR/bad-reg.rs:205:31 | LL | asm!("", out("cr") _, out("cr7") _); | ----------- ^^^^^^^^^^^^ register `cr7` @@ -189,7 +189,7 @@ LL | asm!("", out("cr") _, out("cr7") _); | register `cr` error: register `vs0` conflicts with register `f0` - --> $DIR/bad-reg.rs:206:31 + --> $DIR/bad-reg.rs:208:31 | LL | asm!("", out("f0") _, out("vs0") _); | ----------- ^^^^^^^^^^^^ register `vs0` @@ -197,7 +197,7 @@ LL | asm!("", out("f0") _, out("vs0") _); | register `f0` error: register `vs1` conflicts with register `f1` - --> $DIR/bad-reg.rs:208:31 + --> $DIR/bad-reg.rs:210:31 | LL | asm!("", out("f1") _, out("vs1") _); | ----------- ^^^^^^^^^^^^ register `vs1` @@ -205,7 +205,7 @@ LL | asm!("", out("f1") _, out("vs1") _); | register `f1` error: register `vs2` conflicts with register `f2` - --> $DIR/bad-reg.rs:210:31 + --> $DIR/bad-reg.rs:212:31 | LL | asm!("", out("f2") _, out("vs2") _); | ----------- ^^^^^^^^^^^^ register `vs2` @@ -213,7 +213,7 @@ LL | asm!("", out("f2") _, out("vs2") _); | register `f2` error: register `vs3` conflicts with register `f3` - --> $DIR/bad-reg.rs:212:31 + --> $DIR/bad-reg.rs:214:31 | LL | asm!("", out("f3") _, out("vs3") _); | ----------- ^^^^^^^^^^^^ register `vs3` @@ -221,7 +221,7 @@ LL | asm!("", out("f3") _, out("vs3") _); | register `f3` error: register `vs4` conflicts with register `f4` - --> $DIR/bad-reg.rs:214:31 + --> $DIR/bad-reg.rs:216:31 | LL | asm!("", out("f4") _, out("vs4") _); | ----------- ^^^^^^^^^^^^ register `vs4` @@ -229,7 +229,7 @@ LL | asm!("", out("f4") _, out("vs4") _); | register `f4` error: register `vs5` conflicts with register `f5` - --> $DIR/bad-reg.rs:216:31 + --> $DIR/bad-reg.rs:218:31 | LL | asm!("", out("f5") _, out("vs5") _); | ----------- ^^^^^^^^^^^^ register `vs5` @@ -237,7 +237,7 @@ LL | asm!("", out("f5") _, out("vs5") _); | register `f5` error: register `vs6` conflicts with register `f6` - --> $DIR/bad-reg.rs:218:31 + --> $DIR/bad-reg.rs:220:31 | LL | asm!("", out("f6") _, out("vs6") _); | ----------- ^^^^^^^^^^^^ register `vs6` @@ -245,7 +245,7 @@ LL | asm!("", out("f6") _, out("vs6") _); | register `f6` error: register `vs7` conflicts with register `f7` - --> $DIR/bad-reg.rs:220:31 + --> $DIR/bad-reg.rs:222:31 | LL | asm!("", out("f7") _, out("vs7") _); | ----------- ^^^^^^^^^^^^ register `vs7` @@ -253,7 +253,7 @@ LL | asm!("", out("f7") _, out("vs7") _); | register `f7` error: register `vs8` conflicts with register `f8` - --> $DIR/bad-reg.rs:222:31 + --> $DIR/bad-reg.rs:224:31 | LL | asm!("", out("f8") _, out("vs8") _); | ----------- ^^^^^^^^^^^^ register `vs8` @@ -261,7 +261,7 @@ LL | asm!("", out("f8") _, out("vs8") _); | register `f8` error: register `vs9` conflicts with register `f9` - --> $DIR/bad-reg.rs:224:31 + --> $DIR/bad-reg.rs:226:31 | LL | asm!("", out("f9") _, out("vs9") _); | ----------- ^^^^^^^^^^^^ register `vs9` @@ -269,7 +269,7 @@ LL | asm!("", out("f9") _, out("vs9") _); | register `f9` error: register `vs10` conflicts with register `f10` - --> $DIR/bad-reg.rs:226:32 + --> $DIR/bad-reg.rs:228:32 | LL | asm!("", out("f10") _, out("vs10") _); | ------------ ^^^^^^^^^^^^^ register `vs10` @@ -277,7 +277,7 @@ LL | asm!("", out("f10") _, out("vs10") _); | register `f10` error: register `vs11` conflicts with register `f11` - --> $DIR/bad-reg.rs:228:32 + --> $DIR/bad-reg.rs:230:32 | LL | asm!("", out("f11") _, out("vs11") _); | ------------ ^^^^^^^^^^^^^ register `vs11` @@ -285,7 +285,7 @@ LL | asm!("", out("f11") _, out("vs11") _); | register `f11` error: register `vs12` conflicts with register `f12` - --> $DIR/bad-reg.rs:230:32 + --> $DIR/bad-reg.rs:232:32 | LL | asm!("", out("f12") _, out("vs12") _); | ------------ ^^^^^^^^^^^^^ register `vs12` @@ -293,7 +293,7 @@ LL | asm!("", out("f12") _, out("vs12") _); | register `f12` error: register `vs13` conflicts with register `f13` - --> $DIR/bad-reg.rs:232:32 + --> $DIR/bad-reg.rs:234:32 | LL | asm!("", out("f13") _, out("vs13") _); | ------------ ^^^^^^^^^^^^^ register `vs13` @@ -301,7 +301,7 @@ LL | asm!("", out("f13") _, out("vs13") _); | register `f13` error: register `vs14` conflicts with register `f14` - --> $DIR/bad-reg.rs:234:32 + --> $DIR/bad-reg.rs:236:32 | LL | asm!("", out("f14") _, out("vs14") _); | ------------ ^^^^^^^^^^^^^ register `vs14` @@ -309,7 +309,7 @@ LL | asm!("", out("f14") _, out("vs14") _); | register `f14` error: register `vs15` conflicts with register `f15` - --> $DIR/bad-reg.rs:236:32 + --> $DIR/bad-reg.rs:238:32 | LL | asm!("", out("f15") _, out("vs15") _); | ------------ ^^^^^^^^^^^^^ register `vs15` @@ -317,7 +317,7 @@ LL | asm!("", out("f15") _, out("vs15") _); | register `f15` error: register `vs16` conflicts with register `f16` - --> $DIR/bad-reg.rs:238:32 + --> $DIR/bad-reg.rs:240:32 | LL | asm!("", out("f16") _, out("vs16") _); | ------------ ^^^^^^^^^^^^^ register `vs16` @@ -325,7 +325,7 @@ LL | asm!("", out("f16") _, out("vs16") _); | register `f16` error: register `vs17` conflicts with register `f17` - --> $DIR/bad-reg.rs:240:32 + --> $DIR/bad-reg.rs:242:32 | LL | asm!("", out("f17") _, out("vs17") _); | ------------ ^^^^^^^^^^^^^ register `vs17` @@ -333,7 +333,7 @@ LL | asm!("", out("f17") _, out("vs17") _); | register `f17` error: register `vs18` conflicts with register `f18` - --> $DIR/bad-reg.rs:242:32 + --> $DIR/bad-reg.rs:244:32 | LL | asm!("", out("f18") _, out("vs18") _); | ------------ ^^^^^^^^^^^^^ register `vs18` @@ -341,7 +341,7 @@ LL | asm!("", out("f18") _, out("vs18") _); | register `f18` error: register `vs19` conflicts with register `f19` - --> $DIR/bad-reg.rs:244:32 + --> $DIR/bad-reg.rs:246:32 | LL | asm!("", out("f19") _, out("vs19") _); | ------------ ^^^^^^^^^^^^^ register `vs19` @@ -349,7 +349,7 @@ LL | asm!("", out("f19") _, out("vs19") _); | register `f19` error: register `vs20` conflicts with register `f20` - --> $DIR/bad-reg.rs:246:32 + --> $DIR/bad-reg.rs:248:32 | LL | asm!("", out("f20") _, out("vs20") _); | ------------ ^^^^^^^^^^^^^ register `vs20` @@ -357,7 +357,7 @@ LL | asm!("", out("f20") _, out("vs20") _); | register `f20` error: register `vs21` conflicts with register `f21` - --> $DIR/bad-reg.rs:248:32 + --> $DIR/bad-reg.rs:250:32 | LL | asm!("", out("f21") _, out("vs21") _); | ------------ ^^^^^^^^^^^^^ register `vs21` @@ -365,7 +365,7 @@ LL | asm!("", out("f21") _, out("vs21") _); | register `f21` error: register `vs22` conflicts with register `f22` - --> $DIR/bad-reg.rs:250:32 + --> $DIR/bad-reg.rs:252:32 | LL | asm!("", out("f22") _, out("vs22") _); | ------------ ^^^^^^^^^^^^^ register `vs22` @@ -373,7 +373,7 @@ LL | asm!("", out("f22") _, out("vs22") _); | register `f22` error: register `vs23` conflicts with register `f23` - --> $DIR/bad-reg.rs:252:32 + --> $DIR/bad-reg.rs:254:32 | LL | asm!("", out("f23") _, out("vs23") _); | ------------ ^^^^^^^^^^^^^ register `vs23` @@ -381,7 +381,7 @@ LL | asm!("", out("f23") _, out("vs23") _); | register `f23` error: register `vs24` conflicts with register `f24` - --> $DIR/bad-reg.rs:254:32 + --> $DIR/bad-reg.rs:256:32 | LL | asm!("", out("f24") _, out("vs24") _); | ------------ ^^^^^^^^^^^^^ register `vs24` @@ -389,7 +389,7 @@ LL | asm!("", out("f24") _, out("vs24") _); | register `f24` error: register `vs25` conflicts with register `f25` - --> $DIR/bad-reg.rs:256:32 + --> $DIR/bad-reg.rs:258:32 | LL | asm!("", out("f25") _, out("vs25") _); | ------------ ^^^^^^^^^^^^^ register `vs25` @@ -397,7 +397,7 @@ LL | asm!("", out("f25") _, out("vs25") _); | register `f25` error: register `vs26` conflicts with register `f26` - --> $DIR/bad-reg.rs:258:32 + --> $DIR/bad-reg.rs:260:32 | LL | asm!("", out("f26") _, out("vs26") _); | ------------ ^^^^^^^^^^^^^ register `vs26` @@ -405,7 +405,7 @@ LL | asm!("", out("f26") _, out("vs26") _); | register `f26` error: register `vs27` conflicts with register `f27` - --> $DIR/bad-reg.rs:260:32 + --> $DIR/bad-reg.rs:262:32 | LL | asm!("", out("f27") _, out("vs27") _); | ------------ ^^^^^^^^^^^^^ register `vs27` @@ -413,7 +413,7 @@ LL | asm!("", out("f27") _, out("vs27") _); | register `f27` error: register `vs28` conflicts with register `f28` - --> $DIR/bad-reg.rs:262:32 + --> $DIR/bad-reg.rs:264:32 | LL | asm!("", out("f28") _, out("vs28") _); | ------------ ^^^^^^^^^^^^^ register `vs28` @@ -421,7 +421,7 @@ LL | asm!("", out("f28") _, out("vs28") _); | register `f28` error: register `vs29` conflicts with register `f29` - --> $DIR/bad-reg.rs:264:32 + --> $DIR/bad-reg.rs:266:32 | LL | asm!("", out("f29") _, out("vs29") _); | ------------ ^^^^^^^^^^^^^ register `vs29` @@ -429,7 +429,7 @@ LL | asm!("", out("f29") _, out("vs29") _); | register `f29` error: register `vs30` conflicts with register `f30` - --> $DIR/bad-reg.rs:266:32 + --> $DIR/bad-reg.rs:268:32 | LL | asm!("", out("f30") _, out("vs30") _); | ------------ ^^^^^^^^^^^^^ register `vs30` @@ -437,7 +437,7 @@ LL | asm!("", out("f30") _, out("vs30") _); | register `f30` error: register `vs31` conflicts with register `f31` - --> $DIR/bad-reg.rs:268:32 + --> $DIR/bad-reg.rs:270:32 | LL | asm!("", out("f31") _, out("vs31") _); | ------------ ^^^^^^^^^^^^^ register `vs31` @@ -445,7 +445,7 @@ LL | asm!("", out("f31") _, out("vs31") _); | register `f31` error: register `v0` conflicts with register `vs32` - --> $DIR/bad-reg.rs:270:33 + --> $DIR/bad-reg.rs:272:33 | LL | asm!("", out("vs32") _, out("v0") _); | ------------- ^^^^^^^^^^^ register `v0` @@ -453,7 +453,7 @@ LL | asm!("", out("vs32") _, out("v0") _); | register `vs32` error: register `v1` conflicts with register `vs33` - --> $DIR/bad-reg.rs:272:33 + --> $DIR/bad-reg.rs:274:33 | LL | asm!("", out("vs33") _, out("v1") _); | ------------- ^^^^^^^^^^^ register `v1` @@ -461,7 +461,7 @@ LL | asm!("", out("vs33") _, out("v1") _); | register `vs33` error: register `v2` conflicts with register `vs34` - --> $DIR/bad-reg.rs:274:33 + --> $DIR/bad-reg.rs:276:33 | LL | asm!("", out("vs34") _, out("v2") _); | ------------- ^^^^^^^^^^^ register `v2` @@ -469,7 +469,7 @@ LL | asm!("", out("vs34") _, out("v2") _); | register `vs34` error: register `v3` conflicts with register `vs35` - --> $DIR/bad-reg.rs:276:33 + --> $DIR/bad-reg.rs:278:33 | LL | asm!("", out("vs35") _, out("v3") _); | ------------- ^^^^^^^^^^^ register `v3` @@ -477,7 +477,7 @@ LL | asm!("", out("vs35") _, out("v3") _); | register `vs35` error: register `v4` conflicts with register `vs36` - --> $DIR/bad-reg.rs:278:33 + --> $DIR/bad-reg.rs:280:33 | LL | asm!("", out("vs36") _, out("v4") _); | ------------- ^^^^^^^^^^^ register `v4` @@ -485,7 +485,7 @@ LL | asm!("", out("vs36") _, out("v4") _); | register `vs36` error: register `v5` conflicts with register `vs37` - --> $DIR/bad-reg.rs:280:33 + --> $DIR/bad-reg.rs:282:33 | LL | asm!("", out("vs37") _, out("v5") _); | ------------- ^^^^^^^^^^^ register `v5` @@ -493,7 +493,7 @@ LL | asm!("", out("vs37") _, out("v5") _); | register `vs37` error: register `v6` conflicts with register `vs38` - --> $DIR/bad-reg.rs:282:33 + --> $DIR/bad-reg.rs:284:33 | LL | asm!("", out("vs38") _, out("v6") _); | ------------- ^^^^^^^^^^^ register `v6` @@ -501,7 +501,7 @@ LL | asm!("", out("vs38") _, out("v6") _); | register `vs38` error: register `v7` conflicts with register `vs39` - --> $DIR/bad-reg.rs:284:33 + --> $DIR/bad-reg.rs:286:33 | LL | asm!("", out("vs39") _, out("v7") _); | ------------- ^^^^^^^^^^^ register `v7` @@ -509,7 +509,7 @@ LL | asm!("", out("vs39") _, out("v7") _); | register `vs39` error: register `v8` conflicts with register `vs40` - --> $DIR/bad-reg.rs:286:33 + --> $DIR/bad-reg.rs:288:33 | LL | asm!("", out("vs40") _, out("v8") _); | ------------- ^^^^^^^^^^^ register `v8` @@ -517,7 +517,7 @@ LL | asm!("", out("vs40") _, out("v8") _); | register `vs40` error: register `v9` conflicts with register `vs41` - --> $DIR/bad-reg.rs:288:33 + --> $DIR/bad-reg.rs:290:33 | LL | asm!("", out("vs41") _, out("v9") _); | ------------- ^^^^^^^^^^^ register `v9` @@ -525,7 +525,7 @@ LL | asm!("", out("vs41") _, out("v9") _); | register `vs41` error: register `v10` conflicts with register `vs42` - --> $DIR/bad-reg.rs:290:33 + --> $DIR/bad-reg.rs:292:33 | LL | asm!("", out("vs42") _, out("v10") _); | ------------- ^^^^^^^^^^^^ register `v10` @@ -533,7 +533,7 @@ LL | asm!("", out("vs42") _, out("v10") _); | register `vs42` error: register `v11` conflicts with register `vs43` - --> $DIR/bad-reg.rs:292:33 + --> $DIR/bad-reg.rs:294:33 | LL | asm!("", out("vs43") _, out("v11") _); | ------------- ^^^^^^^^^^^^ register `v11` @@ -541,7 +541,7 @@ LL | asm!("", out("vs43") _, out("v11") _); | register `vs43` error: register `v12` conflicts with register `vs44` - --> $DIR/bad-reg.rs:294:33 + --> $DIR/bad-reg.rs:296:33 | LL | asm!("", out("vs44") _, out("v12") _); | ------------- ^^^^^^^^^^^^ register `v12` @@ -549,7 +549,7 @@ LL | asm!("", out("vs44") _, out("v12") _); | register `vs44` error: register `v13` conflicts with register `vs45` - --> $DIR/bad-reg.rs:296:33 + --> $DIR/bad-reg.rs:298:33 | LL | asm!("", out("vs45") _, out("v13") _); | ------------- ^^^^^^^^^^^^ register `v13` @@ -557,7 +557,7 @@ LL | asm!("", out("vs45") _, out("v13") _); | register `vs45` error: register `v14` conflicts with register `vs46` - --> $DIR/bad-reg.rs:298:33 + --> $DIR/bad-reg.rs:300:33 | LL | asm!("", out("vs46") _, out("v14") _); | ------------- ^^^^^^^^^^^^ register `v14` @@ -565,7 +565,7 @@ LL | asm!("", out("vs46") _, out("v14") _); | register `vs46` error: register `v15` conflicts with register `vs47` - --> $DIR/bad-reg.rs:300:33 + --> $DIR/bad-reg.rs:302:33 | LL | asm!("", out("vs47") _, out("v15") _); | ------------- ^^^^^^^^^^^^ register `v15` @@ -573,7 +573,7 @@ LL | asm!("", out("vs47") _, out("v15") _); | register `vs47` error: register `v16` conflicts with register `vs48` - --> $DIR/bad-reg.rs:302:33 + --> $DIR/bad-reg.rs:304:33 | LL | asm!("", out("vs48") _, out("v16") _); | ------------- ^^^^^^^^^^^^ register `v16` @@ -581,7 +581,7 @@ LL | asm!("", out("vs48") _, out("v16") _); | register `vs48` error: register `v17` conflicts with register `vs49` - --> $DIR/bad-reg.rs:304:33 + --> $DIR/bad-reg.rs:306:33 | LL | asm!("", out("vs49") _, out("v17") _); | ------------- ^^^^^^^^^^^^ register `v17` @@ -589,7 +589,7 @@ LL | asm!("", out("vs49") _, out("v17") _); | register `vs49` error: register `v18` conflicts with register `vs50` - --> $DIR/bad-reg.rs:306:33 + --> $DIR/bad-reg.rs:308:33 | LL | asm!("", out("vs50") _, out("v18") _); | ------------- ^^^^^^^^^^^^ register `v18` @@ -597,7 +597,7 @@ LL | asm!("", out("vs50") _, out("v18") _); | register `vs50` error: register `v19` conflicts with register `vs51` - --> $DIR/bad-reg.rs:308:33 + --> $DIR/bad-reg.rs:310:33 | LL | asm!("", out("vs51") _, out("v19") _); | ------------- ^^^^^^^^^^^^ register `v19` @@ -605,7 +605,7 @@ LL | asm!("", out("vs51") _, out("v19") _); | register `vs51` error: register `v20` conflicts with register `vs52` - --> $DIR/bad-reg.rs:310:33 + --> $DIR/bad-reg.rs:312:33 | LL | asm!("", out("vs52") _, out("v20") _); | ------------- ^^^^^^^^^^^^ register `v20` @@ -613,7 +613,7 @@ LL | asm!("", out("vs52") _, out("v20") _); | register `vs52` error: register `v21` conflicts with register `vs53` - --> $DIR/bad-reg.rs:312:33 + --> $DIR/bad-reg.rs:314:33 | LL | asm!("", out("vs53") _, out("v21") _); | ------------- ^^^^^^^^^^^^ register `v21` @@ -621,7 +621,7 @@ LL | asm!("", out("vs53") _, out("v21") _); | register `vs53` error: register `v22` conflicts with register `vs54` - --> $DIR/bad-reg.rs:314:33 + --> $DIR/bad-reg.rs:316:33 | LL | asm!("", out("vs54") _, out("v22") _); | ------------- ^^^^^^^^^^^^ register `v22` @@ -629,7 +629,7 @@ LL | asm!("", out("vs54") _, out("v22") _); | register `vs54` error: register `v23` conflicts with register `vs55` - --> $DIR/bad-reg.rs:316:33 + --> $DIR/bad-reg.rs:318:33 | LL | asm!("", out("vs55") _, out("v23") _); | ------------- ^^^^^^^^^^^^ register `v23` @@ -637,7 +637,7 @@ LL | asm!("", out("vs55") _, out("v23") _); | register `vs55` error: register `v24` conflicts with register `vs56` - --> $DIR/bad-reg.rs:318:33 + --> $DIR/bad-reg.rs:320:33 | LL | asm!("", out("vs56") _, out("v24") _); | ------------- ^^^^^^^^^^^^ register `v24` @@ -645,7 +645,7 @@ LL | asm!("", out("vs56") _, out("v24") _); | register `vs56` error: register `v25` conflicts with register `vs57` - --> $DIR/bad-reg.rs:320:33 + --> $DIR/bad-reg.rs:322:33 | LL | asm!("", out("vs57") _, out("v25") _); | ------------- ^^^^^^^^^^^^ register `v25` @@ -653,7 +653,7 @@ LL | asm!("", out("vs57") _, out("v25") _); | register `vs57` error: register `v26` conflicts with register `vs58` - --> $DIR/bad-reg.rs:322:33 + --> $DIR/bad-reg.rs:324:33 | LL | asm!("", out("vs58") _, out("v26") _); | ------------- ^^^^^^^^^^^^ register `v26` @@ -661,7 +661,7 @@ LL | asm!("", out("vs58") _, out("v26") _); | register `vs58` error: register `v27` conflicts with register `vs59` - --> $DIR/bad-reg.rs:324:33 + --> $DIR/bad-reg.rs:326:33 | LL | asm!("", out("vs59") _, out("v27") _); | ------------- ^^^^^^^^^^^^ register `v27` @@ -669,7 +669,7 @@ LL | asm!("", out("vs59") _, out("v27") _); | register `vs59` error: register `v28` conflicts with register `vs60` - --> $DIR/bad-reg.rs:326:33 + --> $DIR/bad-reg.rs:328:33 | LL | asm!("", out("vs60") _, out("v28") _); | ------------- ^^^^^^^^^^^^ register `v28` @@ -677,7 +677,7 @@ LL | asm!("", out("vs60") _, out("v28") _); | register `vs60` error: register `v29` conflicts with register `vs61` - --> $DIR/bad-reg.rs:328:33 + --> $DIR/bad-reg.rs:330:33 | LL | asm!("", out("vs61") _, out("v29") _); | ------------- ^^^^^^^^^^^^ register `v29` @@ -685,7 +685,7 @@ LL | asm!("", out("vs61") _, out("v29") _); | register `vs61` error: register `v30` conflicts with register `vs62` - --> $DIR/bad-reg.rs:330:33 + --> $DIR/bad-reg.rs:332:33 | LL | asm!("", out("vs62") _, out("v30") _); | ------------- ^^^^^^^^^^^^ register `v30` @@ -693,21 +693,27 @@ LL | asm!("", out("vs62") _, out("v30") _); | register `vs62` error: register `v31` conflicts with register `vs63` - --> $DIR/bad-reg.rs:332:33 + --> $DIR/bad-reg.rs:334:33 | LL | asm!("", out("vs63") _, out("v31") _); | ------------- ^^^^^^^^^^^^ register `v31` | | | register `vs63` +error: register class `spe_acc` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:340:26 + | +LL | asm!("/* {} */", out(spe_acc) _); + | ^^^^^^^^^^^^^^ + error: cannot use register `r13`: r13 is a reserved register on this target - --> $DIR/bad-reg.rs:40:18 + --> $DIR/bad-reg.rs:42:18 | LL | asm!("", out("r13") _); | ^^^^^^^^^^^^ error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:63:27 + --> $DIR/bad-reg.rs:65:27 | LL | asm!("", in("v0") x); // FIXME: should be ok if vsx is available | ^ @@ -715,7 +721,7 @@ LL | asm!("", in("v0") x); // FIXME: should be ok if vsx is available = note: register class `vreg` supports these types: i8x16, i16x8, i32x4, f32x4, f32, f64, i64x2, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:66:28 + --> $DIR/bad-reg.rs:68:28 | LL | asm!("", out("v0") x); // FIXME: should be ok if vsx is available | ^ @@ -723,7 +729,7 @@ LL | asm!("", out("v0") x); // FIXME: should be ok if vsx is available = note: register class `vreg` supports these types: i8x16, i16x8, i32x4, f32x4, f32, f64, i64x2, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:74:35 + --> $DIR/bad-reg.rs:76:35 | LL | asm!("/* {} */", in(vreg) x); // FIXME: should be ok if vsx is available | ^ @@ -731,7 +737,7 @@ LL | asm!("/* {} */", in(vreg) x); // FIXME: should be ok if vsx is avai = note: register class `vreg` supports these types: i8x16, i16x8, i32x4, f32x4, f32, f64, i64x2, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:104:28 + --> $DIR/bad-reg.rs:106:28 | LL | asm!("", in("vs0") x); // FIXME: should be ok if vsx is available | ^ @@ -739,7 +745,7 @@ LL | asm!("", in("vs0") x); // FIXME: should be ok if vsx is available = note: register class `vsreg` supports these types: f32, f64, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:107:29 + --> $DIR/bad-reg.rs:109:29 | LL | asm!("", out("vs0") x); // FIXME: should be ok if vsx is available | ^ @@ -747,7 +753,7 @@ LL | asm!("", out("vs0") x); // FIXME: should be ok if vsx is available = note: register class `vsreg` supports these types: f32, f64, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:114:36 + --> $DIR/bad-reg.rs:116:36 | LL | asm!("/* {} */", in(vsreg) x); // FIXME: should be ok if vsx is available | ^ @@ -755,7 +761,7 @@ LL | asm!("/* {} */", in(vsreg) x); // FIXME: should be ok if vsx is ava = note: register class `vsreg` supports these types: f32, f64, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2 error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:137:27 + --> $DIR/bad-reg.rs:139:27 | LL | asm!("", in("cr") x); | ^ @@ -763,7 +769,7 @@ LL | asm!("", in("cr") x); = note: register class `cr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:140:28 + --> $DIR/bad-reg.rs:142:28 | LL | asm!("", out("cr") x); | ^ @@ -771,7 +777,7 @@ LL | asm!("", out("cr") x); = note: register class `cr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:143:33 + --> $DIR/bad-reg.rs:145:33 | LL | asm!("/* {} */", in(cr) x); | ^ @@ -779,7 +785,7 @@ LL | asm!("/* {} */", in(cr) x); = note: register class `cr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:150:28 + --> $DIR/bad-reg.rs:152:28 | LL | asm!("", in("ctr") x); | ^ @@ -787,7 +793,7 @@ LL | asm!("", in("ctr") x); = note: register class `ctr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:153:29 + --> $DIR/bad-reg.rs:155:29 | LL | asm!("", out("ctr") x); | ^ @@ -795,7 +801,7 @@ LL | asm!("", out("ctr") x); = note: register class `ctr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:156:34 + --> $DIR/bad-reg.rs:158:34 | LL | asm!("/* {} */", in(ctr) x); | ^ @@ -803,7 +809,7 @@ LL | asm!("/* {} */", in(ctr) x); = note: register class `ctr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:163:27 + --> $DIR/bad-reg.rs:165:27 | LL | asm!("", in("lr") x); | ^ @@ -811,7 +817,7 @@ LL | asm!("", in("lr") x); = note: register class `lr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:166:28 + --> $DIR/bad-reg.rs:168:28 | LL | asm!("", out("lr") x); | ^ @@ -819,7 +825,7 @@ LL | asm!("", out("lr") x); = note: register class `lr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:169:33 + --> $DIR/bad-reg.rs:171:33 | LL | asm!("/* {} */", in(lr) x); | ^ @@ -827,7 +833,7 @@ LL | asm!("/* {} */", in(lr) x); = note: register class `lr` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:176:28 + --> $DIR/bad-reg.rs:178:28 | LL | asm!("", in("xer") x); | ^ @@ -835,7 +841,7 @@ LL | asm!("", in("xer") x); = note: register class `xer` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:179:29 + --> $DIR/bad-reg.rs:181:29 | LL | asm!("", out("xer") x); | ^ @@ -843,12 +849,18 @@ LL | asm!("", out("xer") x); = note: register class `xer` supports these types: error: type `i32` cannot be used with this register class - --> $DIR/bad-reg.rs:182:34 + --> $DIR/bad-reg.rs:184:34 | LL | asm!("/* {} */", in(xer) x); | ^ | = note: register class `xer` supports these types: -error: aborting due to 112 previous errors +error: cannot use register `spe_acc`: spe_acc is only available on spe targets + --> $DIR/bad-reg.rs:338:18 + | +LL | asm!("", out("spe_acc") _); + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 114 previous errors diff --git a/tests/ui/asm/powerpc/bad-reg.powerpcspe.stderr b/tests/ui/asm/powerpc/bad-reg.powerpcspe.stderr new file mode 100644 index 0000000000000..2b4657bf358e5 --- /dev/null +++ b/tests/ui/asm/powerpc/bad-reg.powerpcspe.stderr @@ -0,0 +1,938 @@ +error: invalid register `sp`: the stack pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:38:18 + | +LL | asm!("", out("sp") _); + | ^^^^^^^^^^^ + +error: invalid register `r2`: r2 is a system reserved register and cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:40:18 + | +LL | asm!("", out("r2") _); + | ^^^^^^^^^^^ + +error: invalid register `r30`: r30 is used internally by LLVM and cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:46:18 + | +LL | asm!("", out("r30") _); + | ^^^^^^^^^^^^ + +error: invalid register `fp`: the frame pointer cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:48:18 + | +LL | asm!("", out("fp") _); + | ^^^^^^^^^^^ + +error: invalid register `vrsave`: the vrsave register cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:50:18 + | +LL | asm!("", out("vrsave") _); + | ^^^^^^^^^^^^^^^ + +error: register class `cr` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:139:18 + | +LL | asm!("", in("cr") x); + | ^^^^^^^^^^ + +error: register class `cr` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:142:18 + | +LL | asm!("", out("cr") x); + | ^^^^^^^^^^^ + +error: register class `cr` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:145:26 + | +LL | asm!("/* {} */", in(cr) x); + | ^^^^^^^^ + +error: register class `cr` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:148:26 + | +LL | asm!("/* {} */", out(cr) _); + | ^^^^^^^^^ + +error: register class `ctr` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:152:18 + | +LL | asm!("", in("ctr") x); + | ^^^^^^^^^^^ + +error: register class `ctr` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:155:18 + | +LL | asm!("", out("ctr") x); + | ^^^^^^^^^^^^ + +error: register class `ctr` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:158:26 + | +LL | asm!("/* {} */", in(ctr) x); + | ^^^^^^^^^ + +error: register class `ctr` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:161:26 + | +LL | asm!("/* {} */", out(ctr) _); + | ^^^^^^^^^^ + +error: register class `lr` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:165:18 + | +LL | asm!("", in("lr") x); + | ^^^^^^^^^^ + +error: register class `lr` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:168:18 + | +LL | asm!("", out("lr") x); + | ^^^^^^^^^^^ + +error: register class `lr` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:171:26 + | +LL | asm!("/* {} */", in(lr) x); + | ^^^^^^^^ + +error: register class `lr` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:174:26 + | +LL | asm!("/* {} */", out(lr) _); + | ^^^^^^^^^ + +error: register class `xer` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:178:18 + | +LL | asm!("", in("xer") x); + | ^^^^^^^^^^^ + +error: register class `xer` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:181:18 + | +LL | asm!("", out("xer") x); + | ^^^^^^^^^^^^ + +error: register class `xer` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:184:26 + | +LL | asm!("/* {} */", in(xer) x); + | ^^^^^^^^^ + +error: register class `xer` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:187:26 + | +LL | asm!("/* {} */", out(xer) _); + | ^^^^^^^^^^ + +error: register `cr0` conflicts with register `cr` + --> $DIR/bad-reg.rs:191:31 + | +LL | asm!("", out("cr") _, out("cr0") _); + | ----------- ^^^^^^^^^^^^ register `cr0` + | | + | register `cr` + +error: register `cr1` conflicts with register `cr` + --> $DIR/bad-reg.rs:193:31 + | +LL | asm!("", out("cr") _, out("cr1") _); + | ----------- ^^^^^^^^^^^^ register `cr1` + | | + | register `cr` + +error: register `cr2` conflicts with register `cr` + --> $DIR/bad-reg.rs:195:31 + | +LL | asm!("", out("cr") _, out("cr2") _); + | ----------- ^^^^^^^^^^^^ register `cr2` + | | + | register `cr` + +error: register `cr3` conflicts with register `cr` + --> $DIR/bad-reg.rs:197:31 + | +LL | asm!("", out("cr") _, out("cr3") _); + | ----------- ^^^^^^^^^^^^ register `cr3` + | | + | register `cr` + +error: register `cr4` conflicts with register `cr` + --> $DIR/bad-reg.rs:199:31 + | +LL | asm!("", out("cr") _, out("cr4") _); + | ----------- ^^^^^^^^^^^^ register `cr4` + | | + | register `cr` + +error: register `cr5` conflicts with register `cr` + --> $DIR/bad-reg.rs:201:31 + | +LL | asm!("", out("cr") _, out("cr5") _); + | ----------- ^^^^^^^^^^^^ register `cr5` + | | + | register `cr` + +error: register `cr6` conflicts with register `cr` + --> $DIR/bad-reg.rs:203:31 + | +LL | asm!("", out("cr") _, out("cr6") _); + | ----------- ^^^^^^^^^^^^ register `cr6` + | | + | register `cr` + +error: register `cr7` conflicts with register `cr` + --> $DIR/bad-reg.rs:205:31 + | +LL | asm!("", out("cr") _, out("cr7") _); + | ----------- ^^^^^^^^^^^^ register `cr7` + | | + | register `cr` + +error: register `vs0` conflicts with register `f0` + --> $DIR/bad-reg.rs:208:31 + | +LL | asm!("", out("f0") _, out("vs0") _); + | ----------- ^^^^^^^^^^^^ register `vs0` + | | + | register `f0` + +error: register `vs1` conflicts with register `f1` + --> $DIR/bad-reg.rs:210:31 + | +LL | asm!("", out("f1") _, out("vs1") _); + | ----------- ^^^^^^^^^^^^ register `vs1` + | | + | register `f1` + +error: register `vs2` conflicts with register `f2` + --> $DIR/bad-reg.rs:212:31 + | +LL | asm!("", out("f2") _, out("vs2") _); + | ----------- ^^^^^^^^^^^^ register `vs2` + | | + | register `f2` + +error: register `vs3` conflicts with register `f3` + --> $DIR/bad-reg.rs:214:31 + | +LL | asm!("", out("f3") _, out("vs3") _); + | ----------- ^^^^^^^^^^^^ register `vs3` + | | + | register `f3` + +error: register `vs4` conflicts with register `f4` + --> $DIR/bad-reg.rs:216:31 + | +LL | asm!("", out("f4") _, out("vs4") _); + | ----------- ^^^^^^^^^^^^ register `vs4` + | | + | register `f4` + +error: register `vs5` conflicts with register `f5` + --> $DIR/bad-reg.rs:218:31 + | +LL | asm!("", out("f5") _, out("vs5") _); + | ----------- ^^^^^^^^^^^^ register `vs5` + | | + | register `f5` + +error: register `vs6` conflicts with register `f6` + --> $DIR/bad-reg.rs:220:31 + | +LL | asm!("", out("f6") _, out("vs6") _); + | ----------- ^^^^^^^^^^^^ register `vs6` + | | + | register `f6` + +error: register `vs7` conflicts with register `f7` + --> $DIR/bad-reg.rs:222:31 + | +LL | asm!("", out("f7") _, out("vs7") _); + | ----------- ^^^^^^^^^^^^ register `vs7` + | | + | register `f7` + +error: register `vs8` conflicts with register `f8` + --> $DIR/bad-reg.rs:224:31 + | +LL | asm!("", out("f8") _, out("vs8") _); + | ----------- ^^^^^^^^^^^^ register `vs8` + | | + | register `f8` + +error: register `vs9` conflicts with register `f9` + --> $DIR/bad-reg.rs:226:31 + | +LL | asm!("", out("f9") _, out("vs9") _); + | ----------- ^^^^^^^^^^^^ register `vs9` + | | + | register `f9` + +error: register `vs10` conflicts with register `f10` + --> $DIR/bad-reg.rs:228:32 + | +LL | asm!("", out("f10") _, out("vs10") _); + | ------------ ^^^^^^^^^^^^^ register `vs10` + | | + | register `f10` + +error: register `vs11` conflicts with register `f11` + --> $DIR/bad-reg.rs:230:32 + | +LL | asm!("", out("f11") _, out("vs11") _); + | ------------ ^^^^^^^^^^^^^ register `vs11` + | | + | register `f11` + +error: register `vs12` conflicts with register `f12` + --> $DIR/bad-reg.rs:232:32 + | +LL | asm!("", out("f12") _, out("vs12") _); + | ------------ ^^^^^^^^^^^^^ register `vs12` + | | + | register `f12` + +error: register `vs13` conflicts with register `f13` + --> $DIR/bad-reg.rs:234:32 + | +LL | asm!("", out("f13") _, out("vs13") _); + | ------------ ^^^^^^^^^^^^^ register `vs13` + | | + | register `f13` + +error: register `vs14` conflicts with register `f14` + --> $DIR/bad-reg.rs:236:32 + | +LL | asm!("", out("f14") _, out("vs14") _); + | ------------ ^^^^^^^^^^^^^ register `vs14` + | | + | register `f14` + +error: register `vs15` conflicts with register `f15` + --> $DIR/bad-reg.rs:238:32 + | +LL | asm!("", out("f15") _, out("vs15") _); + | ------------ ^^^^^^^^^^^^^ register `vs15` + | | + | register `f15` + +error: register `vs16` conflicts with register `f16` + --> $DIR/bad-reg.rs:240:32 + | +LL | asm!("", out("f16") _, out("vs16") _); + | ------------ ^^^^^^^^^^^^^ register `vs16` + | | + | register `f16` + +error: register `vs17` conflicts with register `f17` + --> $DIR/bad-reg.rs:242:32 + | +LL | asm!("", out("f17") _, out("vs17") _); + | ------------ ^^^^^^^^^^^^^ register `vs17` + | | + | register `f17` + +error: register `vs18` conflicts with register `f18` + --> $DIR/bad-reg.rs:244:32 + | +LL | asm!("", out("f18") _, out("vs18") _); + | ------------ ^^^^^^^^^^^^^ register `vs18` + | | + | register `f18` + +error: register `vs19` conflicts with register `f19` + --> $DIR/bad-reg.rs:246:32 + | +LL | asm!("", out("f19") _, out("vs19") _); + | ------------ ^^^^^^^^^^^^^ register `vs19` + | | + | register `f19` + +error: register `vs20` conflicts with register `f20` + --> $DIR/bad-reg.rs:248:32 + | +LL | asm!("", out("f20") _, out("vs20") _); + | ------------ ^^^^^^^^^^^^^ register `vs20` + | | + | register `f20` + +error: register `vs21` conflicts with register `f21` + --> $DIR/bad-reg.rs:250:32 + | +LL | asm!("", out("f21") _, out("vs21") _); + | ------------ ^^^^^^^^^^^^^ register `vs21` + | | + | register `f21` + +error: register `vs22` conflicts with register `f22` + --> $DIR/bad-reg.rs:252:32 + | +LL | asm!("", out("f22") _, out("vs22") _); + | ------------ ^^^^^^^^^^^^^ register `vs22` + | | + | register `f22` + +error: register `vs23` conflicts with register `f23` + --> $DIR/bad-reg.rs:254:32 + | +LL | asm!("", out("f23") _, out("vs23") _); + | ------------ ^^^^^^^^^^^^^ register `vs23` + | | + | register `f23` + +error: register `vs24` conflicts with register `f24` + --> $DIR/bad-reg.rs:256:32 + | +LL | asm!("", out("f24") _, out("vs24") _); + | ------------ ^^^^^^^^^^^^^ register `vs24` + | | + | register `f24` + +error: register `vs25` conflicts with register `f25` + --> $DIR/bad-reg.rs:258:32 + | +LL | asm!("", out("f25") _, out("vs25") _); + | ------------ ^^^^^^^^^^^^^ register `vs25` + | | + | register `f25` + +error: register `vs26` conflicts with register `f26` + --> $DIR/bad-reg.rs:260:32 + | +LL | asm!("", out("f26") _, out("vs26") _); + | ------------ ^^^^^^^^^^^^^ register `vs26` + | | + | register `f26` + +error: register `vs27` conflicts with register `f27` + --> $DIR/bad-reg.rs:262:32 + | +LL | asm!("", out("f27") _, out("vs27") _); + | ------------ ^^^^^^^^^^^^^ register `vs27` + | | + | register `f27` + +error: register `vs28` conflicts with register `f28` + --> $DIR/bad-reg.rs:264:32 + | +LL | asm!("", out("f28") _, out("vs28") _); + | ------------ ^^^^^^^^^^^^^ register `vs28` + | | + | register `f28` + +error: register `vs29` conflicts with register `f29` + --> $DIR/bad-reg.rs:266:32 + | +LL | asm!("", out("f29") _, out("vs29") _); + | ------------ ^^^^^^^^^^^^^ register `vs29` + | | + | register `f29` + +error: register `vs30` conflicts with register `f30` + --> $DIR/bad-reg.rs:268:32 + | +LL | asm!("", out("f30") _, out("vs30") _); + | ------------ ^^^^^^^^^^^^^ register `vs30` + | | + | register `f30` + +error: register `vs31` conflicts with register `f31` + --> $DIR/bad-reg.rs:270:32 + | +LL | asm!("", out("f31") _, out("vs31") _); + | ------------ ^^^^^^^^^^^^^ register `vs31` + | | + | register `f31` + +error: register `v0` conflicts with register `vs32` + --> $DIR/bad-reg.rs:272:33 + | +LL | asm!("", out("vs32") _, out("v0") _); + | ------------- ^^^^^^^^^^^ register `v0` + | | + | register `vs32` + +error: register `v1` conflicts with register `vs33` + --> $DIR/bad-reg.rs:274:33 + | +LL | asm!("", out("vs33") _, out("v1") _); + | ------------- ^^^^^^^^^^^ register `v1` + | | + | register `vs33` + +error: register `v2` conflicts with register `vs34` + --> $DIR/bad-reg.rs:276:33 + | +LL | asm!("", out("vs34") _, out("v2") _); + | ------------- ^^^^^^^^^^^ register `v2` + | | + | register `vs34` + +error: register `v3` conflicts with register `vs35` + --> $DIR/bad-reg.rs:278:33 + | +LL | asm!("", out("vs35") _, out("v3") _); + | ------------- ^^^^^^^^^^^ register `v3` + | | + | register `vs35` + +error: register `v4` conflicts with register `vs36` + --> $DIR/bad-reg.rs:280:33 + | +LL | asm!("", out("vs36") _, out("v4") _); + | ------------- ^^^^^^^^^^^ register `v4` + | | + | register `vs36` + +error: register `v5` conflicts with register `vs37` + --> $DIR/bad-reg.rs:282:33 + | +LL | asm!("", out("vs37") _, out("v5") _); + | ------------- ^^^^^^^^^^^ register `v5` + | | + | register `vs37` + +error: register `v6` conflicts with register `vs38` + --> $DIR/bad-reg.rs:284:33 + | +LL | asm!("", out("vs38") _, out("v6") _); + | ------------- ^^^^^^^^^^^ register `v6` + | | + | register `vs38` + +error: register `v7` conflicts with register `vs39` + --> $DIR/bad-reg.rs:286:33 + | +LL | asm!("", out("vs39") _, out("v7") _); + | ------------- ^^^^^^^^^^^ register `v7` + | | + | register `vs39` + +error: register `v8` conflicts with register `vs40` + --> $DIR/bad-reg.rs:288:33 + | +LL | asm!("", out("vs40") _, out("v8") _); + | ------------- ^^^^^^^^^^^ register `v8` + | | + | register `vs40` + +error: register `v9` conflicts with register `vs41` + --> $DIR/bad-reg.rs:290:33 + | +LL | asm!("", out("vs41") _, out("v9") _); + | ------------- ^^^^^^^^^^^ register `v9` + | | + | register `vs41` + +error: register `v10` conflicts with register `vs42` + --> $DIR/bad-reg.rs:292:33 + | +LL | asm!("", out("vs42") _, out("v10") _); + | ------------- ^^^^^^^^^^^^ register `v10` + | | + | register `vs42` + +error: register `v11` conflicts with register `vs43` + --> $DIR/bad-reg.rs:294:33 + | +LL | asm!("", out("vs43") _, out("v11") _); + | ------------- ^^^^^^^^^^^^ register `v11` + | | + | register `vs43` + +error: register `v12` conflicts with register `vs44` + --> $DIR/bad-reg.rs:296:33 + | +LL | asm!("", out("vs44") _, out("v12") _); + | ------------- ^^^^^^^^^^^^ register `v12` + | | + | register `vs44` + +error: register `v13` conflicts with register `vs45` + --> $DIR/bad-reg.rs:298:33 + | +LL | asm!("", out("vs45") _, out("v13") _); + | ------------- ^^^^^^^^^^^^ register `v13` + | | + | register `vs45` + +error: register `v14` conflicts with register `vs46` + --> $DIR/bad-reg.rs:300:33 + | +LL | asm!("", out("vs46") _, out("v14") _); + | ------------- ^^^^^^^^^^^^ register `v14` + | | + | register `vs46` + +error: register `v15` conflicts with register `vs47` + --> $DIR/bad-reg.rs:302:33 + | +LL | asm!("", out("vs47") _, out("v15") _); + | ------------- ^^^^^^^^^^^^ register `v15` + | | + | register `vs47` + +error: register `v16` conflicts with register `vs48` + --> $DIR/bad-reg.rs:304:33 + | +LL | asm!("", out("vs48") _, out("v16") _); + | ------------- ^^^^^^^^^^^^ register `v16` + | | + | register `vs48` + +error: register `v17` conflicts with register `vs49` + --> $DIR/bad-reg.rs:306:33 + | +LL | asm!("", out("vs49") _, out("v17") _); + | ------------- ^^^^^^^^^^^^ register `v17` + | | + | register `vs49` + +error: register `v18` conflicts with register `vs50` + --> $DIR/bad-reg.rs:308:33 + | +LL | asm!("", out("vs50") _, out("v18") _); + | ------------- ^^^^^^^^^^^^ register `v18` + | | + | register `vs50` + +error: register `v19` conflicts with register `vs51` + --> $DIR/bad-reg.rs:310:33 + | +LL | asm!("", out("vs51") _, out("v19") _); + | ------------- ^^^^^^^^^^^^ register `v19` + | | + | register `vs51` + +error: register `v20` conflicts with register `vs52` + --> $DIR/bad-reg.rs:312:33 + | +LL | asm!("", out("vs52") _, out("v20") _); + | ------------- ^^^^^^^^^^^^ register `v20` + | | + | register `vs52` + +error: register `v21` conflicts with register `vs53` + --> $DIR/bad-reg.rs:314:33 + | +LL | asm!("", out("vs53") _, out("v21") _); + | ------------- ^^^^^^^^^^^^ register `v21` + | | + | register `vs53` + +error: register `v22` conflicts with register `vs54` + --> $DIR/bad-reg.rs:316:33 + | +LL | asm!("", out("vs54") _, out("v22") _); + | ------------- ^^^^^^^^^^^^ register `v22` + | | + | register `vs54` + +error: register `v23` conflicts with register `vs55` + --> $DIR/bad-reg.rs:318:33 + | +LL | asm!("", out("vs55") _, out("v23") _); + | ------------- ^^^^^^^^^^^^ register `v23` + | | + | register `vs55` + +error: register `v24` conflicts with register `vs56` + --> $DIR/bad-reg.rs:320:33 + | +LL | asm!("", out("vs56") _, out("v24") _); + | ------------- ^^^^^^^^^^^^ register `v24` + | | + | register `vs56` + +error: register `v25` conflicts with register `vs57` + --> $DIR/bad-reg.rs:322:33 + | +LL | asm!("", out("vs57") _, out("v25") _); + | ------------- ^^^^^^^^^^^^ register `v25` + | | + | register `vs57` + +error: register `v26` conflicts with register `vs58` + --> $DIR/bad-reg.rs:324:33 + | +LL | asm!("", out("vs58") _, out("v26") _); + | ------------- ^^^^^^^^^^^^ register `v26` + | | + | register `vs58` + +error: register `v27` conflicts with register `vs59` + --> $DIR/bad-reg.rs:326:33 + | +LL | asm!("", out("vs59") _, out("v27") _); + | ------------- ^^^^^^^^^^^^ register `v27` + | | + | register `vs59` + +error: register `v28` conflicts with register `vs60` + --> $DIR/bad-reg.rs:328:33 + | +LL | asm!("", out("vs60") _, out("v28") _); + | ------------- ^^^^^^^^^^^^ register `v28` + | | + | register `vs60` + +error: register `v29` conflicts with register `vs61` + --> $DIR/bad-reg.rs:330:33 + | +LL | asm!("", out("vs61") _, out("v29") _); + | ------------- ^^^^^^^^^^^^ register `v29` + | | + | register `vs61` + +error: register `v30` conflicts with register `vs62` + --> $DIR/bad-reg.rs:332:33 + | +LL | asm!("", out("vs62") _, out("v30") _); + | ------------- ^^^^^^^^^^^^ register `v30` + | | + | register `vs62` + +error: register `v31` conflicts with register `vs63` + --> $DIR/bad-reg.rs:334:33 + | +LL | asm!("", out("vs63") _, out("v31") _); + | ------------- ^^^^^^^^^^^^ register `v31` + | | + | register `vs63` + +error: register class `spe_acc` can only be used as a clobber, not as an input or output + --> $DIR/bad-reg.rs:340:26 + | +LL | asm!("/* {} */", out(spe_acc) _); + | ^^^^^^^^^^^^^^ + +error: cannot use register `r13`: r13 is a reserved register on this target + --> $DIR/bad-reg.rs:42:18 + | +LL | asm!("", out("r13") _); + | ^^^^^^^^^^^^ + +error: cannot use register `r29`: r29 is used internally by LLVM and cannot be used as an operand for inline asm + --> $DIR/bad-reg.rs:44:18 + | +LL | asm!("", out("r29") _); + | ^^^^^^^^^^^^ + +error: register class `vreg` requires at least one of the following target features: altivec, vsx + --> $DIR/bad-reg.rs:55:18 + | +LL | asm!("", in("v0") v32x4); // requires altivec + | ^^^^^^^^^^^^^^ + +error: register class `vreg` requires at least one of the following target features: altivec, vsx + --> $DIR/bad-reg.rs:57:18 + | +LL | asm!("", out("v0") v32x4); // requires altivec + | ^^^^^^^^^^^^^^^ + +error: register class `vreg` requires at least one of the following target features: altivec, vsx + --> $DIR/bad-reg.rs:59:18 + | +LL | asm!("", in("v0") v64x2); // requires vsx + | ^^^^^^^^^^^^^^ + +error: register class `vreg` requires at least one of the following target features: altivec, vsx + --> $DIR/bad-reg.rs:62:18 + | +LL | asm!("", out("v0") v64x2); // requires vsx + | ^^^^^^^^^^^^^^^ + +error: register class `vreg` requires at least one of the following target features: altivec, vsx + --> $DIR/bad-reg.rs:65:18 + | +LL | asm!("", in("v0") x); // FIXME: should be ok if vsx is available + | ^^^^^^^^^^ + +error: register class `vreg` requires at least one of the following target features: altivec, vsx + --> $DIR/bad-reg.rs:68:18 + | +LL | asm!("", out("v0") x); // FIXME: should be ok if vsx is available + | ^^^^^^^^^^^ + +error: register class `vreg` requires at least one of the following target features: altivec, vsx + --> $DIR/bad-reg.rs:71:26 + | +LL | asm!("/* {} */", in(vreg) v32x4); // requires altivec + | ^^^^^^^^^^^^^^ + +error: register class `vreg` requires at least one of the following target features: altivec, vsx + --> $DIR/bad-reg.rs:73:26 + | +LL | asm!("/* {} */", in(vreg) v64x2); // requires vsx + | ^^^^^^^^^^^^^^ + +error: register class `vreg` requires at least one of the following target features: altivec, vsx + --> $DIR/bad-reg.rs:76:26 + | +LL | asm!("/* {} */", in(vreg) x); // FIXME: should be ok if vsx is available + | ^^^^^^^^^^ + +error: register class `vreg` requires at least one of the following target features: altivec, vsx + --> $DIR/bad-reg.rs:79:26 + | +LL | asm!("/* {} */", out(vreg) _); // requires altivec + | ^^^^^^^^^^^ + +error: register class `vsreg` requires the `vsx` target feature + --> $DIR/bad-reg.rs:98:18 + | +LL | asm!("", in("vs0") v32x4); // requires vsx + | ^^^^^^^^^^^^^^^ + +error: register class `vsreg` requires the `vsx` target feature + --> $DIR/bad-reg.rs:100:18 + | +LL | asm!("", out("vs0") v32x4); // requires vsx + | ^^^^^^^^^^^^^^^^ + +error: register class `vsreg` requires the `vsx` target feature + --> $DIR/bad-reg.rs:102:18 + | +LL | asm!("", in("vs0") v64x2); // requires vsx + | ^^^^^^^^^^^^^^^ + +error: register class `vsreg` requires the `vsx` target feature + --> $DIR/bad-reg.rs:104:18 + | +LL | asm!("", out("vs0") v64x2); // requires vsx + | ^^^^^^^^^^^^^^^^ + +error: register class `vsreg` requires the `vsx` target feature + --> $DIR/bad-reg.rs:106:18 + | +LL | asm!("", in("vs0") x); // FIXME: should be ok if vsx is available + | ^^^^^^^^^^^ + +error: register class `vsreg` requires the `vsx` target feature + --> $DIR/bad-reg.rs:109:18 + | +LL | asm!("", out("vs0") x); // FIXME: should be ok if vsx is available + | ^^^^^^^^^^^^ + +error: register class `vsreg` requires the `vsx` target feature + --> $DIR/bad-reg.rs:112:26 + | +LL | asm!("/* {} */", in(vsreg) v32x4); // requires vsx + | ^^^^^^^^^^^^^^^ + +error: register class `vsreg` requires the `vsx` target feature + --> $DIR/bad-reg.rs:114:26 + | +LL | asm!("/* {} */", in(vsreg) v64x2); // requires vsx + | ^^^^^^^^^^^^^^^ + +error: register class `vsreg` requires the `vsx` target feature + --> $DIR/bad-reg.rs:116:26 + | +LL | asm!("/* {} */", in(vsreg) x); // FIXME: should be ok if vsx is available + | ^^^^^^^^^^^ + +error: register class `vsreg` requires the `vsx` target feature + --> $DIR/bad-reg.rs:119:26 + | +LL | asm!("/* {} */", out(vsreg) _); // requires vsx + | ^^^^^^^^^^^^ + +error: type `i32` cannot be used with this register class + --> $DIR/bad-reg.rs:139:27 + | +LL | asm!("", in("cr") x); + | ^ + | + = note: register class `cr` supports these types: + +error: type `i32` cannot be used with this register class + --> $DIR/bad-reg.rs:142:28 + | +LL | asm!("", out("cr") x); + | ^ + | + = note: register class `cr` supports these types: + +error: type `i32` cannot be used with this register class + --> $DIR/bad-reg.rs:145:33 + | +LL | asm!("/* {} */", in(cr) x); + | ^ + | + = note: register class `cr` supports these types: + +error: type `i32` cannot be used with this register class + --> $DIR/bad-reg.rs:152:28 + | +LL | asm!("", in("ctr") x); + | ^ + | + = note: register class `ctr` supports these types: + +error: type `i32` cannot be used with this register class + --> $DIR/bad-reg.rs:155:29 + | +LL | asm!("", out("ctr") x); + | ^ + | + = note: register class `ctr` supports these types: + +error: type `i32` cannot be used with this register class + --> $DIR/bad-reg.rs:158:34 + | +LL | asm!("/* {} */", in(ctr) x); + | ^ + | + = note: register class `ctr` supports these types: + +error: type `i32` cannot be used with this register class + --> $DIR/bad-reg.rs:165:27 + | +LL | asm!("", in("lr") x); + | ^ + | + = note: register class `lr` supports these types: + +error: type `i32` cannot be used with this register class + --> $DIR/bad-reg.rs:168:28 + | +LL | asm!("", out("lr") x); + | ^ + | + = note: register class `lr` supports these types: + +error: type `i32` cannot be used with this register class + --> $DIR/bad-reg.rs:171:33 + | +LL | asm!("/* {} */", in(lr) x); + | ^ + | + = note: register class `lr` supports these types: + +error: type `i32` cannot be used with this register class + --> $DIR/bad-reg.rs:178:28 + | +LL | asm!("", in("xer") x); + | ^ + | + = note: register class `xer` supports these types: + +error: type `i32` cannot be used with this register class + --> $DIR/bad-reg.rs:181:29 + | +LL | asm!("", out("xer") x); + | ^ + | + = note: register class `xer` supports these types: + +error: type `i32` cannot be used with this register class + --> $DIR/bad-reg.rs:184:34 + | +LL | asm!("/* {} */", in(xer) x); + | ^ + | + = note: register class `xer` supports these types: + +error: aborting due to 128 previous errors + diff --git a/tests/ui/asm/powerpc/bad-reg.rs b/tests/ui/asm/powerpc/bad-reg.rs index 7ceae5c6d8d36..c06dcf668d1b6 100644 --- a/tests/ui/asm/powerpc/bad-reg.rs +++ b/tests/ui/asm/powerpc/bad-reg.rs @@ -1,5 +1,5 @@ //@ add-minicore -//@ revisions: powerpc powerpc64 powerpc64le aix64 +//@ revisions: powerpc powerpc64 powerpc64le aix64 powerpcspe //@[powerpc] compile-flags: --target powerpc-unknown-linux-gnu //@[powerpc] needs-llvm-components: powerpc //@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu @@ -8,6 +8,8 @@ //@[powerpc64le] needs-llvm-components: powerpc //@[aix64] compile-flags: --target powerpc64-ibm-aix //@[aix64] needs-llvm-components: powerpc +//@[powerpcspe] compile-flags: --target powerpc-unknown-linux-gnuspe +//@[powerpcspe] needs-llvm-components: powerpc //@ ignore-backends: gcc // ignore-tidy-linelength @@ -40,7 +42,7 @@ fn f() { asm!("", out("r13") _); //~^ ERROR cannot use register `r13`: r13 is a reserved register on this target asm!("", out("r29") _); - //[powerpc]~^ ERROR cannot use register `r29`: r29 is used internally by LLVM and cannot be used as an operand for inline asm + //[powerpc,powerpcspe]~^ ERROR cannot use register `r29`: r29 is used internally by LLVM and cannot be used as an operand for inline asm asm!("", out("r30") _); //~^ ERROR invalid register `r30`: r30 is used internally by LLVM and cannot be used as an operand for inline asm asm!("", out("fp") _); @@ -51,31 +53,31 @@ fn f() { // vreg asm!("", out("v0") _); // always ok asm!("", in("v0") v32x4); // requires altivec - //[powerpc]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx + //[powerpc,powerpcspe]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx asm!("", out("v0") v32x4); // requires altivec - //[powerpc]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx + //[powerpc,powerpcspe]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx asm!("", in("v0") v64x2); // requires vsx - //[powerpc]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx + //[powerpc,powerpcspe]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx //[powerpc64]~^^ ERROR `vsx` target feature is not enabled asm!("", out("v0") v64x2); // requires vsx - //[powerpc]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx + //[powerpc,powerpcspe]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx //[powerpc64]~^^ ERROR `vsx` target feature is not enabled asm!("", in("v0") x); // FIXME: should be ok if vsx is available - //[powerpc]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx + //[powerpc,powerpcspe]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx //[powerpc64,powerpc64le,aix64]~^^ ERROR type `i32` cannot be used with this register class asm!("", out("v0") x); // FIXME: should be ok if vsx is available - //[powerpc]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx + //[powerpc,powerpcspe]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx //[powerpc64,powerpc64le,aix64]~^^ ERROR type `i32` cannot be used with this register class asm!("/* {} */", in(vreg) v32x4); // requires altivec - //[powerpc]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx + //[powerpc,powerpcspe]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx asm!("/* {} */", in(vreg) v64x2); // requires vsx - //[powerpc]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx + //[powerpc,powerpcspe]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx //[powerpc64]~^^ ERROR `vsx` target feature is not enabled asm!("/* {} */", in(vreg) x); // FIXME: should be ok if vsx is available - //[powerpc]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx + //[powerpc,powerpcspe]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx //[powerpc64,powerpc64le,aix64]~^^ ERROR type `i32` cannot be used with this register class asm!("/* {} */", out(vreg) _); // requires altivec - //[powerpc]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx + //[powerpc,powerpcspe]~^ ERROR register class `vreg` requires at least one of the following target features: altivec, vsx // v20-v31 (vs52-vs63) are reserved on AIX with vec-default ABI (this ABI is not currently used in Rust's builtin AIX targets). asm!("", out("v20") _); asm!("", out("v21") _); @@ -94,28 +96,28 @@ fn f() { // vsreg asm!("", out("vs0") _); // always ok asm!("", in("vs0") v32x4); // requires vsx - //[powerpc,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature + //[powerpc,powerpcspe,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature asm!("", out("vs0") v32x4); // requires vsx - //[powerpc,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature + //[powerpc,powerpcspe,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature asm!("", in("vs0") v64x2); // requires vsx - //[powerpc,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature + //[powerpc,powerpcspe,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature asm!("", out("vs0") v64x2); // requires vsx - //[powerpc,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature + //[powerpc,powerpcspe,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature asm!("", in("vs0") x); // FIXME: should be ok if vsx is available - //[powerpc,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature + //[powerpc,powerpcspe,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature //[powerpc64le,aix64]~^^ ERROR type `i32` cannot be used with this register class asm!("", out("vs0") x); // FIXME: should be ok if vsx is available - //[powerpc,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature + //[powerpc,powerpcspe,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature //[powerpc64le,aix64]~^^ ERROR type `i32` cannot be used with this register class asm!("/* {} */", in(vsreg) v32x4); // requires vsx - //[powerpc,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature + //[powerpc,powerpcspe,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature asm!("/* {} */", in(vsreg) v64x2); // requires vsx - //[powerpc,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature + //[powerpc,powerpcspe,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature asm!("/* {} */", in(vsreg) x); // FIXME: should be ok if vsx is available - //[powerpc,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature + //[powerpc,powerpcspe,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature //[powerpc64le,aix64]~^^ ERROR type `i32` cannot be used with this register class asm!("/* {} */", out(vsreg) _); // requires vsx - //[powerpc,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature + //[powerpc,powerpcspe,powerpc64]~^ ERROR register class `vsreg` requires the `vsx` target feature // v20-v31 (vs52-vs63) are reserved on AIX with vec-default ABI (this ABI is not currently used in Rust's builtin AIX targets). asm!("", out("vs52") _); @@ -331,5 +333,11 @@ fn f() { //~^ ERROR register `v30` conflicts with register `vs62` asm!("", out("vs63") _, out("v31") _); //~^ ERROR register `v31` conflicts with register `vs63` + + // powerpc-*spe target specific tests + asm!("", out("spe_acc") _); + //[aix64,powerpc,powerpc64,powerpc64le]~^ ERROR cannot use register `spe_acc`: spe_acc is only available on spe targets + asm!("/* {} */", out(spe_acc) _); + //~^ ERROR can only be used as a clobber } } From 4c6544b06ef037f8d0e29f1c010486609442a891 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 9 Dec 2025 12:14:28 +0100 Subject: [PATCH 06/21] Run clippy both with and without default features on the GCC backend --- src/bootstrap/src/core/build_steps/clippy.rs | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs index d8b74b43cfab8..f80cf58fbb2a5 100644 --- a/src/bootstrap/src/core/build_steps/clippy.rs +++ b/src/bootstrap/src/core/build_steps/clippy.rs @@ -379,15 +379,23 @@ impl Step for CodegenGcc { let stamp = BuildStamp::new(&builder.cargo_out(build_compiler, Mode::Codegen, target)) .with_prefix("rustc_codegen_gcc-check"); - run_cargo( + let args = lint_args(builder, &self.config, &[]); + run_cargo(builder, cargo, args.clone(), &stamp, vec![], true, false); + + // Same but we disable the features enabled by default. + let mut cargo = prepare_tool_cargo( builder, - cargo, - lint_args(builder, &self.config, &[]), - &stamp, - vec![], - true, - false, + build_compiler, + Mode::Codegen, + target, + Kind::Clippy, + "compiler/rustc_codegen_gcc", + SourceType::InTree, + &[], ); + self.build_compiler.configure_cargo(&mut cargo); + cargo.arg("--no-default-features"); + run_cargo(builder, cargo, args, &stamp, vec![], true, false); } fn metadata(&self) -> Option { From 50e9839d4849d932810ebba52a664d39baed5253 Mon Sep 17 00:00:00 2001 From: mu001999 Date: Tue, 9 Dec 2025 00:31:56 +0800 Subject: [PATCH 07/21] Don't suggest wrapping attr in unsafe if it may come from proc macro --- compiler/rustc_attr_parsing/src/safety.rs | 19 ++++++++-- .../src/session_diagnostics.rs | 2 +- compiler/rustc_lint/src/early/diagnostics.rs | 14 +++---- compiler/rustc_lint/src/lints.rs | 2 +- compiler/rustc_lint_defs/src/lib.rs | 2 +- .../auxiliary/unsafe-attributes-pm-in-2024.rs | 29 +++++++++++++++ .../unsafe-attributes-from-pm-in-2024.rs | 18 +++++++++ .../unsafe-attributes-from-pm-in-2024.stderr | 37 +++++++++++++++++++ 8 files changed, 110 insertions(+), 13 deletions(-) create mode 100644 tests/ui/rust-2024/unsafe-attributes/auxiliary/unsafe-attributes-pm-in-2024.rs create mode 100644 tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-from-pm-in-2024.rs create mode 100644 tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-from-pm-in-2024.stderr diff --git a/compiler/rustc_attr_parsing/src/safety.rs b/compiler/rustc_attr_parsing/src/safety.rs index 52baf2136173d..817785108a1ed 100644 --- a/compiler/rustc_attr_parsing/src/safety.rs +++ b/compiler/rustc_attr_parsing/src/safety.rs @@ -62,16 +62,28 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> { Some(unsafe_since) => path_span.edition() >= unsafe_since, }; + let mut not_from_proc_macro = true; + if diag_span.from_expansion() + && let Ok(mut snippet) = self.sess.source_map().span_to_snippet(diag_span) + { + snippet.retain(|c| !c.is_whitespace()); + if snippet.contains("!(") || snippet.starts_with("#[") && snippet.ends_with("]") + { + not_from_proc_macro = false; + } + } + if emit_error { self.stage.emit_err( self.sess, crate::session_diagnostics::UnsafeAttrOutsideUnsafe { span: path_span, - suggestion: + suggestion: not_from_proc_macro.then(|| { crate::session_diagnostics::UnsafeAttrOutsideUnsafeSuggestion { left: diag_span.shrink_to_lo(), right: diag_span.shrink_to_hi(), - }, + } + }), }, ); } else { @@ -81,7 +93,8 @@ impl<'sess, S: Stage> AttributeParser<'sess, S> { span: path_span, kind: AttributeLintKind::UnsafeAttrOutsideUnsafe { attribute_name_span: path_span, - sugg_spans: (diag_span.shrink_to_lo(), diag_span.shrink_to_hi()), + sugg_spans: not_from_proc_macro + .then(|| (diag_span.shrink_to_lo(), diag_span.shrink_to_hi())), }, }) } diff --git a/compiler/rustc_attr_parsing/src/session_diagnostics.rs b/compiler/rustc_attr_parsing/src/session_diagnostics.rs index c4f6f9c6a38cb..cf3f3760d9629 100644 --- a/compiler/rustc_attr_parsing/src/session_diagnostics.rs +++ b/compiler/rustc_attr_parsing/src/session_diagnostics.rs @@ -758,7 +758,7 @@ pub(crate) struct UnsafeAttrOutsideUnsafe { #[label] pub span: Span, #[subdiagnostic] - pub suggestion: UnsafeAttrOutsideUnsafeSuggestion, + pub suggestion: Option, } #[derive(Subdiagnostic)] diff --git a/compiler/rustc_lint/src/early/diagnostics.rs b/compiler/rustc_lint/src/early/diagnostics.rs index 589594a3ec5e6..c44e0ba67daac 100644 --- a/compiler/rustc_lint/src/early/diagnostics.rs +++ b/compiler/rustc_lint/src/early/diagnostics.rs @@ -353,14 +353,14 @@ pub fn decorate_attribute_lint( } .decorate_lint(diag) } - &AttributeLintKind::UnsafeAttrOutsideUnsafe { - attribute_name_span, - sugg_spans: (left, right), - } => lints::UnsafeAttrOutsideUnsafeLint { - span: attribute_name_span, - suggestion: lints::UnsafeAttrOutsideUnsafeSuggestion { left, right }, + &AttributeLintKind::UnsafeAttrOutsideUnsafe { attribute_name_span, sugg_spans } => { + lints::UnsafeAttrOutsideUnsafeLint { + span: attribute_name_span, + suggestion: sugg_spans + .map(|(left, right)| lints::UnsafeAttrOutsideUnsafeSuggestion { left, right }), + } + .decorate_lint(diag) } - .decorate_lint(diag), &AttributeLintKind::UnexpectedCfgName(name, value) => { check_cfg::unexpected_cfg_name(sess, tcx, name, value).decorate_lint(diag) } diff --git a/compiler/rustc_lint/src/lints.rs b/compiler/rustc_lint/src/lints.rs index 1bec316ce45a7..20262c9c6bcf6 100644 --- a/compiler/rustc_lint/src/lints.rs +++ b/compiler/rustc_lint/src/lints.rs @@ -3177,7 +3177,7 @@ pub(crate) struct UnsafeAttrOutsideUnsafeLint { #[label] pub span: Span, #[subdiagnostic] - pub suggestion: UnsafeAttrOutsideUnsafeSuggestion, + pub suggestion: Option, } #[derive(Subdiagnostic)] diff --git a/compiler/rustc_lint_defs/src/lib.rs b/compiler/rustc_lint_defs/src/lib.rs index 376310838cc74..bb153afecc4c6 100644 --- a/compiler/rustc_lint_defs/src/lib.rs +++ b/compiler/rustc_lint_defs/src/lib.rs @@ -729,7 +729,7 @@ pub enum AttributeLintKind { }, UnsafeAttrOutsideUnsafe { attribute_name_span: Span, - sugg_spans: (Span, Span), + sugg_spans: Option<(Span, Span)>, }, UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>), UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>), diff --git a/tests/ui/rust-2024/unsafe-attributes/auxiliary/unsafe-attributes-pm-in-2024.rs b/tests/ui/rust-2024/unsafe-attributes/auxiliary/unsafe-attributes-pm-in-2024.rs new file mode 100644 index 0000000000000..5f44223df90cf --- /dev/null +++ b/tests/ui/rust-2024/unsafe-attributes/auxiliary/unsafe-attributes-pm-in-2024.rs @@ -0,0 +1,29 @@ +//@ edition: 2024 + +extern crate proc_macro; + +use proc_macro::TokenStream; + +#[proc_macro] +pub fn missing_unsafe(_input: TokenStream) -> TokenStream { + "#[no_mangle] pub fn abc() {}".parse().unwrap() +} + +#[proc_macro_attribute] +pub fn attr_missing_unsafe(_attr: TokenStream, _input: TokenStream) -> TokenStream { + "#[no_mangle] pub fn bar() {}".parse().unwrap() +} + +#[proc_macro_derive(AttrMissingUnsafe)] +pub fn derive_attr_missing_unsafe(_input: TokenStream) -> TokenStream { + "#[no_mangle] pub fn baz() {}".parse().unwrap() +} + +#[proc_macro] +pub fn macro_rules_missing_unsafe(_input: TokenStream) -> TokenStream { + "macro_rules! make_fn { + () => { #[no_mangle] pub fn foo() { } }; + }" + .parse() + .unwrap() +} diff --git a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-from-pm-in-2024.rs b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-from-pm-in-2024.rs new file mode 100644 index 0000000000000..dca05cc27f6e1 --- /dev/null +++ b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-from-pm-in-2024.rs @@ -0,0 +1,18 @@ +// Test for unsafe attributes generated by a proc-macro. + +//@ proc-macro: unsafe-attributes-pm-in-2024.rs +//@ ignore-backends: gcc + +unsafe_attributes_pm_in_2024::missing_unsafe!(); //~ ERROR unsafe attribute used without unsafe + +#[unsafe_attributes_pm_in_2024::attr_missing_unsafe] //~ ERROR unsafe attribute used without unsafe +pub fn bar() {} + +#[derive(unsafe_attributes_pm_in_2024::AttrMissingUnsafe)] //~ ERROR unsafe attribute used without unsafe +struct Baz; + +unsafe_attributes_pm_in_2024::macro_rules_missing_unsafe!(); //~ ERROR unsafe attribute used without unsafe + +make_fn!(); + +fn main() {} diff --git a/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-from-pm-in-2024.stderr b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-from-pm-in-2024.stderr new file mode 100644 index 0000000000000..fa36b148bf3de --- /dev/null +++ b/tests/ui/rust-2024/unsafe-attributes/unsafe-attributes-from-pm-in-2024.stderr @@ -0,0 +1,37 @@ +error: unsafe attribute used without unsafe + --> $DIR/unsafe-attributes-from-pm-in-2024.rs:6:1 + | +LL | unsafe_attributes_pm_in_2024::missing_unsafe!(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ usage of unsafe attribute + | + = note: this error originates in the macro `unsafe_attributes_pm_in_2024::missing_unsafe` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: unsafe attribute used without unsafe + --> $DIR/unsafe-attributes-from-pm-in-2024.rs:8:1 + | +LL | #[unsafe_attributes_pm_in_2024::attr_missing_unsafe] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ usage of unsafe attribute + | + = note: this error originates in the attribute macro `unsafe_attributes_pm_in_2024::attr_missing_unsafe` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: unsafe attribute used without unsafe + --> $DIR/unsafe-attributes-from-pm-in-2024.rs:11:10 + | +LL | #[derive(unsafe_attributes_pm_in_2024::AttrMissingUnsafe)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ usage of unsafe attribute + | + = note: this error originates in the derive macro `unsafe_attributes_pm_in_2024::AttrMissingUnsafe` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: unsafe attribute used without unsafe + --> $DIR/unsafe-attributes-from-pm-in-2024.rs:14:1 + | +LL | unsafe_attributes_pm_in_2024::macro_rules_missing_unsafe!(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ usage of unsafe attribute +LL | +LL | make_fn!(); + | ---------- in this macro invocation + | + = note: this error originates in the macro `make_fn` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 4 previous errors + From 4501327be4fb0aa85a6e2d8bb29c43da658e09bf Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 9 Dec 2025 15:42:22 +0100 Subject: [PATCH 08/21] Fix clippy lint in `cg_gcc` --- compiler/rustc_codegen_gcc/src/builder.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_codegen_gcc/src/builder.rs b/compiler/rustc_codegen_gcc/src/builder.rs index 1787415b72e6d..df1e64c75b963 100644 --- a/compiler/rustc_codegen_gcc/src/builder.rs +++ b/compiler/rustc_codegen_gcc/src/builder.rs @@ -500,11 +500,11 @@ impl<'gcc, 'tcx> BackendTypes for Builder<'_, 'gcc, 'tcx> { } fn set_rvalue_location<'a, 'gcc, 'tcx>( - bx: &mut Builder<'a, 'gcc, 'tcx>, + _bx: &mut Builder<'a, 'gcc, 'tcx>, rvalue: RValue<'gcc>, ) -> RValue<'gcc> { - if let Some(location) = bx.location { - #[cfg(feature = "master")] + #[cfg(feature = "master")] + if let Some(location) = _bx.location { rvalue.set_location(location); } rvalue From 20fabb48b90b00c59c79354dc819fb5148fa1c83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 4 Nov 2025 18:00:38 +0000 Subject: [PATCH 09/21] Use return type `Span` on async fns instead of whole fn def `Span` --- compiler/rustc_ast_lowering/src/lib.rs | 5 ++--- .../ui/async-await/async-await-let-else.stderr | 2 +- .../async-fn/recurse-ice-129215.stderr | 4 ++-- ...ync-example-desugared-boxed-in-trait.stderr | 4 ++-- .../async-example-desugared-boxed.stderr | 2 +- .../async-example-desugared-manual.stderr | 2 +- .../in-trait/async-generics-and-bounds.stderr | 18 ++++++++---------- .../async-await/in-trait/async-generics.stderr | 18 ++++++++---------- ...-project-to-specializable-projection.stderr | 8 ++++---- .../inference_var_self_argument.stderr | 4 ++-- .../ui/async-await/issue-64130-3-other.stderr | 2 +- tests/ui/async-await/issues/issue-67893.stderr | 4 ++-- .../partial-drop-partial-reinit.stderr | 2 +- tests/ui/c-variadic/not-async.stderr | 12 ++++++------ .../cmse-nonsecure-entry/c-variadic.stderr | 4 ++-- .../in-trait/async-and-ret-ref.stderr | 10 +++++----- .../note-and-explain-ReVar-124973.stderr | 6 +++--- .../lifetimes/issue-76168-hr-outlives-3.stderr | 18 ++++++------------ .../type-match-with-late-bound.stderr | 15 ++++++--------- .../hkl_forbidden4.stderr | 4 ++-- 20 files changed, 65 insertions(+), 79 deletions(-) diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index dff46ece65430..19e826cf18f31 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -1670,7 +1670,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { let output = match coro { Some(coro) => { let fn_def_id = self.local_def_id(fn_node_id); - self.lower_coroutine_fn_ret_ty(&decl.output, fn_def_id, coro, kind, fn_span) + self.lower_coroutine_fn_ret_ty(&decl.output, fn_def_id, coro, kind) } None => match &decl.output { FnRetTy::Ty(ty) => { @@ -1755,9 +1755,8 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { fn_def_id: LocalDefId, coro: CoroutineKind, fn_kind: FnDeclKind, - fn_span: Span, ) -> hir::FnRetTy<'hir> { - let span = self.lower_span(fn_span); + let span = self.lower_span(output.span()); let (opaque_ty_node_id, allowed_features) = match coro { CoroutineKind::Async { return_impl_trait_id, .. } => (return_impl_trait_id, None), diff --git a/tests/ui/async-await/async-await-let-else.stderr b/tests/ui/async-await/async-await-let-else.stderr index 5883f34f87de6..b5b56d3242f4d 100644 --- a/tests/ui/async-await/async-await-let-else.stderr +++ b/tests/ui/async-await/async-await-let-else.stderr @@ -22,7 +22,7 @@ error[E0277]: `Rc<()>` cannot be sent between threads safely --> $DIR/async-await-let-else.rs:47:13 | LL | async fn foo2(x: Option) { - | ------------------------------ within this `impl Future` + | - within this `impl Future` ... LL | is_send(foo2(Some(true))); | ------- ^^^^^^^^^^^^^^^^ `Rc<()>` cannot be sent between threads safely diff --git a/tests/ui/async-await/async-fn/recurse-ice-129215.stderr b/tests/ui/async-await/async-fn/recurse-ice-129215.stderr index 98c7be2a5a3f2..232246590cf10 100644 --- a/tests/ui/async-await/async-fn/recurse-ice-129215.stderr +++ b/tests/ui/async-await/async-fn/recurse-ice-129215.stderr @@ -7,10 +7,10 @@ LL | a() = help: the trait `Future` is not implemented for `()` error[E0277]: `()` is not a future - --> $DIR/recurse-ice-129215.rs:3:1 + --> $DIR/recurse-ice-129215.rs:3:13 | LL | async fn a() { - | ^^^^^^^^^^^^ `()` is not a future + | ^ `()` is not a future | = help: the trait `Future` is not implemented for `()` diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr index 54df0edf5a8e4..c98df134072eb 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr @@ -1,8 +1,8 @@ error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:11:5 + --> $DIR/async-example-desugared-boxed-in-trait.rs:11:28 | LL | async fn foo(&self) -> i32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Pin>>`, found future + | ^^^ expected `Pin>>`, found future | note: type in trait --> $DIR/async-example-desugared-boxed-in-trait.rs:7:22 diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr index b7f2879727f24..d3765a7e6e6fd 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr @@ -2,7 +2,7 @@ warning: impl trait in impl method signature does not match trait method signatu --> $DIR/async-example-desugared-boxed.rs:14:22 | LL | async fn foo(&self) -> i32; - | --------------------------- return type from trait method defined here + | --- return type from trait method defined here ... LL | fn foo(&self) -> Pin + '_>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr b/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr index 86546df88c175..3328dea37fe4d 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr @@ -2,7 +2,7 @@ warning: impl trait in impl method signature does not match trait method signatu --> $DIR/async-example-desugared-manual.rs:22:22 | LL | async fn foo(&self) -> i32; - | --------------------------- return type from trait method defined here + | --- return type from trait method defined here ... LL | fn foo(&self) -> MyFuture { | ^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr index 183b0fa152aa3..52fd887b296f4 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr @@ -1,11 +1,10 @@ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics-and-bounds.rs:8:5 + --> $DIR/async-generics-and-bounds.rs:8:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | the parameter type `T` must be valid for the anonymous lifetime as defined here... - | ...so that the reference type `&(T, U)` does not outlive the data it points at + | - ^^^^^^^ ...so that the reference type `&(T, U)` does not outlive the data it points at + | | + | the parameter type `T` must be valid for the anonymous lifetime as defined here... | help: consider adding an explicit lifetime bound | @@ -13,13 +12,12 @@ LL | async fn foo<'a>(&'a self) -> &'a (T, U) where T: Debug + Sized, U: Has | ++++ ++ ++ +++++++ error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics-and-bounds.rs:8:5 + --> $DIR/async-generics-and-bounds.rs:8:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; - | ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | | - | | the parameter type `U` must be valid for the anonymous lifetime as defined here... - | ...so that the reference type `&(T, U)` does not outlive the data it points at + | - ^^^^^^^ ...so that the reference type `&(T, U)` does not outlive the data it points at + | | + | the parameter type `U` must be valid for the anonymous lifetime as defined here... | help: consider adding an explicit lifetime bound | diff --git a/tests/ui/async-await/in-trait/async-generics.stderr b/tests/ui/async-await/in-trait/async-generics.stderr index 8916ef5ab6830..3f44e4cdb6778 100644 --- a/tests/ui/async-await/in-trait/async-generics.stderr +++ b/tests/ui/async-await/in-trait/async-generics.stderr @@ -1,11 +1,10 @@ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics.rs:5:5 + --> $DIR/async-generics.rs:5:28 | LL | async fn foo(&self) -> &(T, U); - | ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^ - | | | - | | the parameter type `T` must be valid for the anonymous lifetime as defined here... - | ...so that the reference type `&(T, U)` does not outlive the data it points at + | - ^^^^^^^ ...so that the reference type `&(T, U)` does not outlive the data it points at + | | + | the parameter type `T` must be valid for the anonymous lifetime as defined here... | help: consider adding an explicit lifetime bound | @@ -13,13 +12,12 @@ LL | async fn foo<'a>(&'a self) -> &'a (T, U) where T: 'a; | ++++ ++ ++ +++++++++++ error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics.rs:5:5 + --> $DIR/async-generics.rs:5:28 | LL | async fn foo(&self) -> &(T, U); - | ^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^ - | | | - | | the parameter type `U` must be valid for the anonymous lifetime as defined here... - | ...so that the reference type `&(T, U)` does not outlive the data it points at + | - ^^^^^^^ ...so that the reference type `&(T, U)` does not outlive the data it points at + | | + | the parameter type `U` must be valid for the anonymous lifetime as defined here... | help: consider adding an explicit lifetime bound | diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr index 823d8d5b92fce..d0c11565f4e90 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr @@ -1,14 +1,14 @@ error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/dont-project-to-specializable-projection.rs:14:5 + --> $DIR/dont-project-to-specializable-projection.rs:14:35 | LL | default async fn foo(_: T) -> &'static str { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected associated type, found future + | ^^^^^^^^^^^^ expected associated type, found future | note: type in trait - --> $DIR/dont-project-to-specializable-projection.rs:10:5 + --> $DIR/dont-project-to-specializable-projection.rs:10:27 | LL | async fn foo(_: T) -> &'static str; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ = note: expected signature `fn(_) -> impl Future` found signature `fn(_) -> impl Future` diff --git a/tests/ui/async-await/inference_var_self_argument.stderr b/tests/ui/async-await/inference_var_self_argument.stderr index 1fccc32470ff6..c4240a095e685 100644 --- a/tests/ui/async-await/inference_var_self_argument.stderr +++ b/tests/ui/async-await/inference_var_self_argument.stderr @@ -8,10 +8,10 @@ LL | async fn foo(self: &dyn Foo) { = help: consider changing to `self`, `&self`, `&mut self`, `self: Box`, `self: Rc`, `self: Arc`, or `self: Pin

` (where P is one of the previous types except `Self`) error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/inference_var_self_argument.rs:5:5 + --> $DIR/inference_var_self_argument.rs:5:33 | LL | async fn foo(self: &dyn Foo) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Foo` is not dyn compatible + | ^ `Foo` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit diff --git a/tests/ui/async-await/issue-64130-3-other.stderr b/tests/ui/async-await/issue-64130-3-other.stderr index d683366ed4737..531a7028f7e0e 100644 --- a/tests/ui/async-await/issue-64130-3-other.stderr +++ b/tests/ui/async-await/issue-64130-3-other.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Foo: Qux` is not satisfied in `impl Future $DIR/issue-64130-3-other.rs:25:12 | LL | async fn bar() { - | -------------- within this `impl Future` + | - within this `impl Future` ... LL | is_qux(bar()); | ^^^^^ unsatisfied trait bound diff --git a/tests/ui/async-await/issues/issue-67893.stderr b/tests/ui/async-await/issues/issue-67893.stderr index 34f28dd53c7b9..610ed60bc8fda 100644 --- a/tests/ui/async-await/issues/issue-67893.stderr +++ b/tests/ui/async-await/issues/issue-67893.stderr @@ -6,10 +6,10 @@ LL | g(issue_67893::run()) | | | required by a bound introduced by this call | - ::: $DIR/auxiliary/issue_67893.rs:9:1 + ::: $DIR/auxiliary/issue_67893.rs:9:19 | LL | pub async fn run() { - | ------------------ within this `impl Future` + | - within this `impl Future` | = help: within `impl Future`, the trait `Send` is not implemented for `std::sync::MutexGuard<'_, ()>` note: required because it's used within this `async` fn body diff --git a/tests/ui/async-await/partial-drop-partial-reinit.stderr b/tests/ui/async-await/partial-drop-partial-reinit.stderr index cef835f7aed8b..cf4b408ad12b8 100644 --- a/tests/ui/async-await/partial-drop-partial-reinit.stderr +++ b/tests/ui/async-await/partial-drop-partial-reinit.stderr @@ -7,7 +7,7 @@ LL | gimme_send(foo()); | required by a bound introduced by this call ... LL | async fn foo() { - | -------------- within this `impl Future` + | - within this `impl Future` | help: within `impl Future`, the trait `Send` is not implemented for `NotSend` --> $DIR/partial-drop-partial-reinit.rs:19:1 diff --git a/tests/ui/c-variadic/not-async.stderr b/tests/ui/c-variadic/not-async.stderr index fc5eb10bec4f7..bb8cc64e15fa4 100644 --- a/tests/ui/c-variadic/not-async.stderr +++ b/tests/ui/c-variadic/not-async.stderr @@ -14,9 +14,9 @@ error[E0700]: hidden type for `impl Future` captures lifetime that --> $DIR/not-async.rs:5:65 | LL | async unsafe extern "C" fn fn_cannot_be_async(x: isize, _: ...) {} - | --------------------------------------------------------------- ^^ - | | - | opaque type defined here + | -^^ + | | + | opaque type defined here | = note: hidden type `{async fn body of fn_cannot_be_async()}` captures lifetime `'_` @@ -24,9 +24,9 @@ error[E0700]: hidden type for `impl Future` captures lifetime that --> $DIR/not-async.rs:12:73 | LL | async unsafe extern "C" fn method_cannot_be_async(x: isize, _: ...) {} - | ------------------------------------------------------------------- ^^ - | | - | opaque type defined here + | -^^ + | | + | opaque type defined here | = note: hidden type `{async fn body of S::method_cannot_be_async()}` captures lifetime `'_` diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.stderr index c8f4ef98c124e..2a2d769c7cf89 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.stderr @@ -25,10 +25,10 @@ LL | async unsafe extern "cmse-nonsecure-entry" fn async_and_c_variadic(_: ...) = help: only `extern "C"` and `extern "C-unwind"` functions may have a C variable argument list error[E0798]: `impl Trait` is not allowed in `extern "cmse-nonsecure-entry"` signatures - --> $DIR/c-variadic.rs:26:1 + --> $DIR/c-variadic.rs:26:69 | LL | async unsafe extern "cmse-nonsecure-entry" fn async_is_not_allowed() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ error: aborting due to 4 previous errors diff --git a/tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr b/tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr index 19ffff9d3f2bd..75d7224020969 100644 --- a/tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr +++ b/tests/ui/impl-trait/in-trait/async-and-ret-ref.stderr @@ -1,11 +1,11 @@ error[E0310]: the associated type `impl T` may not live long enough - --> $DIR/async-and-ret-ref.rs:7:5 + --> $DIR/async-and-ret-ref.rs:7:23 | LL | async fn foo() -> &'static impl T; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | the associated type `impl T` must be valid for the static lifetime... - | ...so that the reference type `&'static impl T` does not outlive the data it points at + | ^^^^^^^^^^^^^^^ + | | + | the associated type `impl T` must be valid for the static lifetime... + | ...so that the reference type `&'static impl T` does not outlive the data it points at error: aborting due to 1 previous error diff --git a/tests/ui/inference/note-and-explain-ReVar-124973.stderr b/tests/ui/inference/note-and-explain-ReVar-124973.stderr index bb37e6231a323..2b5e79e9a1c64 100644 --- a/tests/ui/inference/note-and-explain-ReVar-124973.stderr +++ b/tests/ui/inference/note-and-explain-ReVar-124973.stderr @@ -8,9 +8,9 @@ error[E0700]: hidden type for `impl Future` captures lifetime that --> $DIR/note-and-explain-ReVar-124973.rs:5:76 | LL | async unsafe extern "C" fn multiple_named_lifetimes<'a, 'b>(_: u8, _: ...) {} - | -------------------------------------------------------------------------- ^^ - | | - | opaque type defined here + | -^^ + | | + | opaque type defined here | = note: hidden type `{async fn body of multiple_named_lifetimes<'a, 'b>()}` captures lifetime `'_` diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr index 945d38d17f63d..bb8e847242571 100644 --- a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr +++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr @@ -34,24 +34,18 @@ LL | for<'a> >::Output: Future + 'a, = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32` - --> $DIR/issue-76168-hr-outlives-3.rs:6:1 + --> $DIR/issue-76168-hr-outlives-3.rs:6:26 | -LL | / async fn wrapper(f: F) -... | -LL | | F:, -LL | | for<'a> >::Output: Future + 'a, - | |__________________________________________________________________________^ expected an `FnOnce(&'a mut i32)` closure, found `i32` +LL | async fn wrapper(f: F) + | ^ expected an `FnOnce(&'a mut i32)` closure, found `i32` | = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32` - --> $DIR/issue-76168-hr-outlives-3.rs:6:1 + --> $DIR/issue-76168-hr-outlives-3.rs:6:26 | -LL | / async fn wrapper(f: F) -... | -LL | | F:, -LL | | for<'a> >::Output: Future + 'a, - | |__________________________________________________________________________^ expected an `FnOnce(&'a mut i32)` closure, found `i32` +LL | async fn wrapper(f: F) + | ^ expected an `FnOnce(&'a mut i32)` closure, found `i32` | = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr index 15902bf16de5c..c325718b3033e 100644 --- a/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr +++ b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr @@ -8,15 +8,12 @@ LL | #![feature(non_lifetime_binders)] = note: `#[warn(incomplete_features)]` on by default error[E0309]: the placeholder type `F` may not live long enough - --> $DIR/type-match-with-late-bound.rs:8:1 - | -LL | async fn walk2<'a, T: 'a>(_: T) - | ^ -- the placeholder type `F` must be valid for the lifetime `'a` as defined here... - | _| - | | -LL | | where -LL | | for F: 'a, - | |_________________^ ...so that the type `F` will meet its required lifetime bounds... + --> $DIR/type-match-with-late-bound.rs:8:32 + | +LL | async fn walk2<'a, T: 'a>(_: T) + | -- ^ ...so that the type `F` will meet its required lifetime bounds... + | | + | the placeholder type `F` must be valid for the lifetime `'a` as defined here... | note: ...that is required by this bound --> $DIR/type-match-with-late-bound.rs:10:15 diff --git a/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr b/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr index 2aacf9698379b..87313e3495249 100644 --- a/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr +++ b/tests/ui/type-alias-impl-trait/hkl_forbidden4.stderr @@ -18,10 +18,10 @@ LL | call(operation).await | ^^^^^^^^^^^^^^^ expected `{async fn body of operation()}`, got `FutNothing<'_>` | note: previous use here - --> $DIR/hkl_forbidden4.rs:12:1 + --> $DIR/hkl_forbidden4.rs:12:35 | LL | async fn operation(_: &mut ()) -> () { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^ error: aborting due to 2 previous errors From 76f02cf142b24ce73794c72d196094192144d47c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 4 Nov 2025 18:08:36 +0000 Subject: [PATCH 10/21] Add test for `dyn Trait` in `async fn` return type --- .../async-fn/dyn-in-return-type.rs | 10 ++++++++ .../async-fn/dyn-in-return-type.stderr | 25 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/ui/async-await/async-fn/dyn-in-return-type.rs create mode 100644 tests/ui/async-await/async-fn/dyn-in-return-type.stderr diff --git a/tests/ui/async-await/async-fn/dyn-in-return-type.rs b/tests/ui/async-await/async-fn/dyn-in-return-type.rs new file mode 100644 index 0000000000000..ec793bf80f287 --- /dev/null +++ b/tests/ui/async-await/async-fn/dyn-in-return-type.rs @@ -0,0 +1,10 @@ +//@ edition:2024 + +async fn f() -> dyn core::fmt::Debug { +//~^ ERROR return type cannot be a trait object without pointer indirection +//~| HELP consider returning an `impl Trait` instead of a `dyn Trait` +//~| HELP alternatively, box the return type, and wrap all of the returned values in `Box::new` + loop {} +} + +fn main() {} diff --git a/tests/ui/async-await/async-fn/dyn-in-return-type.stderr b/tests/ui/async-await/async-fn/dyn-in-return-type.stderr new file mode 100644 index 0000000000000..6b1b092f5555c --- /dev/null +++ b/tests/ui/async-await/async-fn/dyn-in-return-type.stderr @@ -0,0 +1,25 @@ +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-in-return-type.rs:3:38 + | +LL | async fn f() -> dyn core::fmt::Debug { + | ______________________________________^ +... | +LL | | } + | |_^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL | async fn f() -> dyn core::fmt::Debug impl { + | ++++ +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ async fn f() -> dyn core::fmt::Debug Box + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0746`. From 7868d20bd585906c19557ae7221ae5cc74a8f5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 4 Nov 2025 18:11:51 +0000 Subject: [PATCH 11/21] Account for `async fn` with `dyn Trait` return type in `impl Trait` suggestion --- .../src/error_reporting/traits/suggestions.rs | 16 +++++++++++++++- .../async-fn/dyn-in-return-type.stderr | 13 +++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 1094f00e42f29..16bb4c186447f 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -1891,7 +1891,21 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { err.primary_message("return type cannot be a trait object without pointer indirection"); err.children.clear(); - let span = obligation.cause.span; + let mut span = obligation.cause.span; + if let DefKind::Closure = self.tcx.def_kind(obligation.cause.body_id) + && let parent = self.tcx.parent(obligation.cause.body_id.into()) + && let DefKind::Fn = self.tcx.def_kind(parent) + && self.tcx.asyncness(parent).is_async() + && let Some(parent) = parent.as_local() + && let Node::Item(hir::Item { kind: hir::ItemKind::Fn { sig: fn_sig, .. }, .. }) = + self.tcx.hir_node_by_def_id(parent) + { + // Do not suggest (#147894) + // async fn foo() -> dyn Display impl { .. } + // and + // async fn foo() -> dyn Display Box + span = fn_sig.decl.output.span(); + } let body = self.tcx.hir_body_owned_by(obligation.cause.body_id); let mut visitor = ReturnsVisitor::default(); diff --git a/tests/ui/async-await/async-fn/dyn-in-return-type.stderr b/tests/ui/async-await/async-fn/dyn-in-return-type.stderr index 6b1b092f5555c..bd2ee4c208cad 100644 --- a/tests/ui/async-await/async-fn/dyn-in-return-type.stderr +++ b/tests/ui/async-await/async-fn/dyn-in-return-type.stderr @@ -9,16 +9,13 @@ LL | | } | help: consider returning an `impl Trait` instead of a `dyn Trait` | -LL | async fn f() -> dyn core::fmt::Debug impl { - | ++++ -help: alternatively, box the return type, and wrap all of the returned values in `Box::new` +LL - async fn f() -> dyn core::fmt::Debug { +LL + async fn f() -> impl core::fmt::Debug { | -LL ~ async fn f() -> dyn core::fmt::Debug Box +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` | +LL | async fn f() -> Box { + | ++++ + error: aborting due to 1 previous error From fabf5746a20876e49a8ce9fce3e6c859ba49f39b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 4 Nov 2025 18:31:31 +0000 Subject: [PATCH 12/21] Add test for `type Alias = dyn Trait` in return type --- .../dyn-trait-type-alias-return-type.rs | 8 ++++++++ .../dyn-trait-type-alias-return-type.stderr | 18 ++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/ui/type-alias/dyn-trait-type-alias-return-type.rs create mode 100644 tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr diff --git a/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs b/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs new file mode 100644 index 0000000000000..f96cd989a4ce2 --- /dev/null +++ b/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs @@ -0,0 +1,8 @@ +type T = dyn core::fmt::Debug; + +fn f() -> T { loop {} } +//~^ ERROR return type cannot be a trait object without pointer indirection +//~| HELP +//~| HELP + +fn main() {} diff --git a/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr b/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr new file mode 100644 index 0000000000000..d67ba77595512 --- /dev/null +++ b/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr @@ -0,0 +1,18 @@ +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-type-alias-return-type.rs:3:11 + | +LL | fn f() -> T { loop {} } + | ^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL | fn f() -> impl T { loop {} } + | ++++ +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL | fn f() -> Box { Box::new(loop {}) } + | +++++++ + +++++++++ + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0746`. From 60b227acccf40cff72df2104fbdedc8185e8a57f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 4 Nov 2025 18:41:04 +0000 Subject: [PATCH 13/21] Recognize `type Alias = dyn Trait` in `fn` return types ``` error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time --> $DIR/dyn-trait-type-alias-return-type.rs:4:11 | LL | fn f() -> T { loop {} } | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Debug + 'static)` note: this type alias is unsized --> $DIR/dyn-trait-type-alias-return-type.rs:1:1 | LL | type T = dyn core::fmt::Debug; | ^^^^^^ = note: the return type of a function must have a statically known size ``` --- .../src/error_reporting/traits/suggestions.rs | 13 +++++++ .../clippy/tests/ui/future_not_send.stderr | 37 +++++++++---------- .../dyn-trait-type-alias-return-type.rs | 10 +++-- .../dyn-trait-type-alias-return-type.stderr | 19 +++++----- tests/ui/unsized/issue-91801.rs | 2 +- tests/ui/unsized/issue-91801.stderr | 17 ++++----- 6 files changed, 54 insertions(+), 44 deletions(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 16bb4c186447f..822025b986b83 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -1886,6 +1886,19 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let ty::Dynamic(_, _) = trait_pred.self_ty().skip_binder().kind() else { return false; }; + if let Node::Item(hir::Item { kind: hir::ItemKind::Fn { sig: fn_sig, .. }, .. }) = + self.tcx.hir_node_by_def_id(obligation.cause.body_id) + && let hir::FnRetTy::Return(ty) = fn_sig.decl.output + && let hir::TyKind::Path(qpath) = ty.kind + && let hir::QPath::Resolved(None, path) = qpath + && let Res::Def(DefKind::TyAlias, def_id) = path.res + { + // Do not suggest + // type T = dyn Trait; + // fn foo() -> impl T { .. } + err.span_note(self.tcx.def_span(def_id), "this type alias is unsized"); + return false; + } err.code(E0746); err.primary_message("return type cannot be a trait object without pointer indirection"); diff --git a/src/tools/clippy/tests/ui/future_not_send.stderr b/src/tools/clippy/tests/ui/future_not_send.stderr index e366dc2d21958..8b8af1ebaed39 100644 --- a/src/tools/clippy/tests/ui/future_not_send.stderr +++ b/src/tools/clippy/tests/ui/future_not_send.stderr @@ -1,8 +1,8 @@ error: future cannot be sent between threads safely - --> tests/ui/future_not_send.rs:8:1 + --> tests/ui/future_not_send.rs:8:62 | LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future` is not `Send` + | ^^^^ future returned by `private_future` is not `Send` | note: future is not `Send` as this value is used across an await --> tests/ui/future_not_send.rs:11:20 @@ -23,10 +23,10 @@ LL | async fn private_future(rc: Rc<[u8]>, cell: &Cell) -> bool { = help: to override `-D warnings` add `#[allow(clippy::future_not_send)]` error: future cannot be sent between threads safely - --> tests/ui/future_not_send.rs:14:1 + --> tests/ui/future_not_send.rs:14:41 | LL | pub async fn public_future(rc: Rc<[u8]>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future` is not `Send` + | ^ future returned by `public_future` is not `Send` | note: future is not `Send` as this value is used across an await --> tests/ui/future_not_send.rs:17:20 @@ -39,10 +39,10 @@ LL | async { true }.await; = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` error: future cannot be sent between threads safely - --> tests/ui/future_not_send.rs:24:1 + --> tests/ui/future_not_send.rs:24:63 | LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell) -> bool { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future2` is not `Send` + | ^^^^ future returned by `private_future2` is not `Send` | note: captured value is not `Send` --> tests/ui/future_not_send.rs:24:26 @@ -58,10 +58,10 @@ LL | async fn private_future2(rc: Rc<[u8]>, cell: &Cell) -> bool { = note: `std::cell::Cell` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> tests/ui/future_not_send.rs:30:1 + --> tests/ui/future_not_send.rs:30:42 | LL | pub async fn public_future2(rc: Rc<[u8]>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future2` is not `Send` + | ^ future returned by `public_future2` is not `Send` | note: captured value is not `Send` --> tests/ui/future_not_send.rs:30:29 @@ -71,10 +71,10 @@ LL | pub async fn public_future2(rc: Rc<[u8]>) {} = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Send` error: future cannot be sent between threads safely - --> tests/ui/future_not_send.rs:42:5 + --> tests/ui/future_not_send.rs:42:39 | LL | async fn private_future(&self) -> usize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `private_future` is not `Send` + | ^^^^^ future returned by `private_future` is not `Send` | note: future is not `Send` as this value is used across an await --> tests/ui/future_not_send.rs:45:24 @@ -87,10 +87,10 @@ LL | async { true }.await; = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> tests/ui/future_not_send.rs:49:5 + --> tests/ui/future_not_send.rs:49:38 | LL | pub async fn public_future(&self) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `public_future` is not `Send` + | ^ future returned by `public_future` is not `Send` | note: captured value is not `Send` because `&` references cannot be sent unless their referent is `Sync` --> tests/ui/future_not_send.rs:49:32 @@ -100,13 +100,10 @@ LL | pub async fn public_future(&self) { = note: `std::rc::Rc<[u8]>` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> tests/ui/future_not_send.rs:61:1 + --> tests/ui/future_not_send.rs:61:37 | -LL | / async fn generic_future(t: T) -> T -LL | | -LL | | where -LL | | T: Send, - | |____________^ future returned by `generic_future` is not `Send` +LL | async fn generic_future(t: T) -> T + | ^ future returned by `generic_future` is not `Send` | note: future is not `Send` as this value is used across an await --> tests/ui/future_not_send.rs:67:20 @@ -118,10 +115,10 @@ LL | async { true }.await; = note: `T` doesn't implement `std::marker::Sync` error: future cannot be sent between threads safely - --> tests/ui/future_not_send.rs:83:1 + --> tests/ui/future_not_send.rs:83:51 | LL | async fn generic_future_always_unsend(_: Rc) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ future returned by `generic_future_always_unsend` is not `Send` + | ^ future returned by `generic_future_always_unsend` is not `Send` | note: future is not `Send` as this value is used across an await --> tests/ui/future_not_send.rs:86:20 diff --git a/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs b/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs index f96cd989a4ce2..fe1322a48d65e 100644 --- a/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs +++ b/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs @@ -1,8 +1,10 @@ type T = dyn core::fmt::Debug; - +//~^ NOTE this type alias is unsized + fn f() -> T { loop {} } -//~^ ERROR return type cannot be a trait object without pointer indirection -//~| HELP -//~| HELP +//~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time +//~| HELP the trait `Sized` is not implemented for `(dyn Debug + 'static)` +//~| NOTE doesn't have a size known at compile-time +//~| NOTE the return type of a function must have a statically known size fn main() {} diff --git a/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr b/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr index d67ba77595512..fc7f9f49d1652 100644 --- a/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr +++ b/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr @@ -1,18 +1,17 @@ -error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-type-alias-return-type.rs:3:11 +error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-type-alias-return-type.rs:4:11 | LL | fn f() -> T { loop {} } | ^ doesn't have a size known at compile-time | -help: consider returning an `impl Trait` instead of a `dyn Trait` + = help: the trait `Sized` is not implemented for `(dyn Debug + 'static)` +note: this type alias is unsized + --> $DIR/dyn-trait-type-alias-return-type.rs:1:1 | -LL | fn f() -> impl T { loop {} } - | ++++ -help: alternatively, box the return type, and wrap all of the returned values in `Box::new` - | -LL | fn f() -> Box { Box::new(loop {}) } - | +++++++ + +++++++++ + +LL | type T = dyn core::fmt::Debug; + | ^^^^^^ + = note: the return type of a function must have a statically known size error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0746`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized/issue-91801.rs b/tests/ui/unsized/issue-91801.rs index d906a08a55a21..8b4a3d214d5e7 100644 --- a/tests/ui/unsized/issue-91801.rs +++ b/tests/ui/unsized/issue-91801.rs @@ -6,7 +6,7 @@ pub static ALL_VALIDATORS: &[(&'static str, &'static Validator)] = &[("validate that credits and debits balance", &validate_something)]; fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> Validator<'a> { - //~^ ERROR return type cannot be a trait object without pointer indirection + //~^ ERROR E0277 return Box::new(move |something: &'_ Something| -> Result<(), ()> { first(something).or_else(|_| second(something)) }); diff --git a/tests/ui/unsized/issue-91801.stderr b/tests/ui/unsized/issue-91801.stderr index 28e10f9caa41a..73f9de92458eb 100644 --- a/tests/ui/unsized/issue-91801.stderr +++ b/tests/ui/unsized/issue-91801.stderr @@ -1,18 +1,17 @@ -error[E0746]: return type cannot be a trait object without pointer indirection +error[E0277]: the size for values of type `(dyn Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a)` cannot be known at compilation time --> $DIR/issue-91801.rs:8:77 | LL | fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> Validator<'a> { | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | -help: consider returning an `impl Trait` instead of a `dyn Trait` + = help: the trait `Sized` is not implemented for `(dyn Fn(&'a Something) -> Result<(), ()> + Send + Sync + 'a)` +note: this type alias is unsized + --> $DIR/issue-91801.rs:3:1 | -LL | fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> impl Validator<'a> { - | ++++ -help: alternatively, box the return type, and wrap all of the returned values in `Box::new` - | -LL | fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> Box> { - | +++++++ + +LL | type Validator<'a> = dyn 'a + Send + Sync + Fn(&'a Something) -> Result<(), ()>; + | ^^^^^^^^^^^^^^^^^^ + = note: the return type of a function must have a statically known size error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0746`. +For more information about this error, try `rustc --explain E0277`. From e2168b1da1fbdeb9bfd5bee53cb358552fdbc3d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 5 Nov 2025 18:28:44 +0000 Subject: [PATCH 14/21] Point at async fn return type instead of body in E0746 --- .../src/error_reporting/traits/suggestions.rs | 1 + tests/ui/async-await/async-fn/dyn-in-return-type.stderr | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 822025b986b83..e7f588a77f770 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -1918,6 +1918,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // and // async fn foo() -> dyn Display Box span = fn_sig.decl.output.span(); + err.span(span); } let body = self.tcx.hir_body_owned_by(obligation.cause.body_id); diff --git a/tests/ui/async-await/async-fn/dyn-in-return-type.stderr b/tests/ui/async-await/async-fn/dyn-in-return-type.stderr index bd2ee4c208cad..341d9561fd7ae 100644 --- a/tests/ui/async-await/async-fn/dyn-in-return-type.stderr +++ b/tests/ui/async-await/async-fn/dyn-in-return-type.stderr @@ -1,11 +1,8 @@ error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-in-return-type.rs:3:38 + --> $DIR/dyn-in-return-type.rs:3:17 | -LL | async fn f() -> dyn core::fmt::Debug { - | ______________________________________^ -... | -LL | | } - | |_^ doesn't have a size known at compile-time +LL | async fn f() -> dyn core::fmt::Debug { + | ^^^^^^^^^^^^^^^^^^^^ | help: consider returning an `impl Trait` instead of a `dyn Trait` | From 8c63852f1916cad2a9e5b125e879c38ba401bb84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 5 Nov 2025 18:48:40 +0000 Subject: [PATCH 15/21] Provide boxing suggestion for `type Alias = dyn Trait` return type --- .../src/error_reporting/traits/suggestions.rs | 11 +++++++++++ .../dyn-trait-type-alias-return-type.fixed | 18 ++++++++++++++++++ .../dyn-trait-type-alias-return-type.rs | 10 +++++++++- .../dyn-trait-type-alias-return-type.stderr | 19 ++++++++++++++++--- tests/ui/unsized/issue-91801.stderr | 4 ++++ 5 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 tests/ui/type-alias/dyn-trait-type-alias-return-type.fixed diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index e7f588a77f770..5ef6d05c419c4 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -1897,6 +1897,17 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { // type T = dyn Trait; // fn foo() -> impl T { .. } err.span_note(self.tcx.def_span(def_id), "this type alias is unsized"); + err.multipart_suggestion( + format!( + "consider boxing the return type, and wrapping all of the returned values in \ + `Box::new`", + ), + vec![ + (ty.span.shrink_to_lo(), "Box<".to_string()), + (ty.span.shrink_to_hi(), ">".to_string()), + ], + Applicability::MaybeIncorrect, + ); return false; } diff --git a/tests/ui/type-alias/dyn-trait-type-alias-return-type.fixed b/tests/ui/type-alias/dyn-trait-type-alias-return-type.fixed new file mode 100644 index 0000000000000..93472f808a8a7 --- /dev/null +++ b/tests/ui/type-alias/dyn-trait-type-alias-return-type.fixed @@ -0,0 +1,18 @@ +//@ run-rustfix +type T = dyn core::fmt::Debug; +//~^ NOTE this type alias is unsized + +fn f() -> Box { loop {} } +//~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time +//~| HELP the trait `Sized` is not implemented for `(dyn Debug + 'static)` +//~| NOTE doesn't have a size known at compile-time +//~| NOTE the return type of a function must have a statically known size +//~| HELP consider boxing the return type + +fn main() { + f(); + //~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time + //~| HELP the trait `Sized` is not implemented for `(dyn Debug + 'static)` + //~| NOTE doesn't have a size known at compile-time + //~| NOTE the return type of a function must have a statically known size +} diff --git a/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs b/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs index fe1322a48d65e..da9f8d07f8e05 100644 --- a/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs +++ b/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs @@ -1,3 +1,4 @@ +//@ run-rustfix type T = dyn core::fmt::Debug; //~^ NOTE this type alias is unsized @@ -6,5 +7,12 @@ fn f() -> T { loop {} } //~| HELP the trait `Sized` is not implemented for `(dyn Debug + 'static)` //~| NOTE doesn't have a size known at compile-time //~| NOTE the return type of a function must have a statically known size +//~| HELP consider boxing the return type -fn main() {} +fn main() { + f(); + //~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time + //~| HELP the trait `Sized` is not implemented for `(dyn Debug + 'static)` + //~| NOTE doesn't have a size known at compile-time + //~| NOTE the return type of a function must have a statically known size +} diff --git a/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr b/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr index fc7f9f49d1652..658abbe8f780f 100644 --- a/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr +++ b/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr @@ -1,17 +1,30 @@ error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-type-alias-return-type.rs:4:11 + --> $DIR/dyn-trait-type-alias-return-type.rs:5:11 | LL | fn f() -> T { loop {} } | ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Debug + 'static)` note: this type alias is unsized - --> $DIR/dyn-trait-type-alias-return-type.rs:1:1 + --> $DIR/dyn-trait-type-alias-return-type.rs:2:1 | LL | type T = dyn core::fmt::Debug; | ^^^^^^ = note: the return type of a function must have a statically known size +help: consider boxing the return type, and wrapping all of the returned values in `Box::new` + | +LL | fn f() -> Box { loop {} } + | ++++ + + +error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-type-alias-return-type.rs:13:5 + | +LL | f(); + | ^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Debug + 'static)` + = note: the return type of a function must have a statically known size -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/unsized/issue-91801.stderr b/tests/ui/unsized/issue-91801.stderr index 73f9de92458eb..192cdc767dd90 100644 --- a/tests/ui/unsized/issue-91801.stderr +++ b/tests/ui/unsized/issue-91801.stderr @@ -11,6 +11,10 @@ note: this type alias is unsized LL | type Validator<'a> = dyn 'a + Send + Sync + Fn(&'a Something) -> Result<(), ()>; | ^^^^^^^^^^^^^^^^^^ = note: the return type of a function must have a statically known size +help: consider boxing the return type, and wrapping all of the returned values in `Box::new` + | +LL | fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> Box> { + | ++++ + error: aborting due to 1 previous error From f7eaaf79e0520547b128a3066b5a59980f3b5844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 5 Nov 2025 19:59:08 +0000 Subject: [PATCH 16/21] Account for async fn in traits and impls --- .../src/error_reporting/traits/suggestions.rs | 13 ++++-- .../async-fn/dyn-in-return-type.fixed | 30 +++++++++++++ .../async-fn/dyn-in-return-type.rs | 24 ++++++++++- .../async-fn/dyn-in-return-type.stderr | 36 +++++++++++++++- .../dyn-trait-type-alias-return-type.fixed | 21 ++++++++++ .../dyn-trait-type-alias-return-type.rs | 21 ++++++++++ .../dyn-trait-type-alias-return-type.stderr | 42 +++++++++++++++++-- 7 files changed, 176 insertions(+), 11 deletions(-) create mode 100644 tests/ui/async-await/async-fn/dyn-in-return-type.fixed diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs index 5ef6d05c419c4..fd845e31c9093 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs @@ -1886,7 +1886,9 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let ty::Dynamic(_, _) = trait_pred.self_ty().skip_binder().kind() else { return false; }; - if let Node::Item(hir::Item { kind: hir::ItemKind::Fn { sig: fn_sig, .. }, .. }) = + if let Node::Item(hir::Item { kind: hir::ItemKind::Fn { sig: fn_sig, .. }, .. }) + | Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(fn_sig, _), .. }) + | Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(fn_sig, _), .. }) = self.tcx.hir_node_by_def_id(obligation.cause.body_id) && let hir::FnRetTy::Return(ty) = fn_sig.decl.output && let hir::TyKind::Path(qpath) = ty.kind @@ -1918,11 +1920,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { let mut span = obligation.cause.span; if let DefKind::Closure = self.tcx.def_kind(obligation.cause.body_id) && let parent = self.tcx.parent(obligation.cause.body_id.into()) - && let DefKind::Fn = self.tcx.def_kind(parent) + && let DefKind::Fn | DefKind::AssocFn = self.tcx.def_kind(parent) && self.tcx.asyncness(parent).is_async() && let Some(parent) = parent.as_local() - && let Node::Item(hir::Item { kind: hir::ItemKind::Fn { sig: fn_sig, .. }, .. }) = - self.tcx.hir_node_by_def_id(parent) + && let Node::Item(hir::Item { kind: hir::ItemKind::Fn { sig: fn_sig, .. }, .. }) + | Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(fn_sig, _), .. }) + | Node::TraitItem(hir::TraitItem { + kind: hir::TraitItemKind::Fn(fn_sig, _), .. + }) = self.tcx.hir_node_by_def_id(parent) { // Do not suggest (#147894) // async fn foo() -> dyn Display impl { .. } diff --git a/tests/ui/async-await/async-fn/dyn-in-return-type.fixed b/tests/ui/async-await/async-fn/dyn-in-return-type.fixed new file mode 100644 index 0000000000000..6a717f628460e --- /dev/null +++ b/tests/ui/async-await/async-fn/dyn-in-return-type.fixed @@ -0,0 +1,30 @@ +//@ edition:2024 +//@ run-rustfix + +async fn f() -> Box { +//~^ ERROR return type cannot be a trait object without pointer indirection +//~| HELP consider returning an `impl Trait` instead of a `dyn Trait` +//~| HELP alternatively, box the return type, and wrap all of the returned values in `Box::new` + Box::new("") +} +trait T { + async fn f(&self) -> Box { + //~^ ERROR return type cannot be a trait object without pointer indirection + //~| HELP consider returning an `impl Trait` instead of a `dyn Trait` + //~| HELP alternatively, box the return type, and wrap all of the returned values in `Box::new` + Box::new("") + } +} +impl T for () { + async fn f(&self) -> Box { + //~^ ERROR return type cannot be a trait object without pointer indirection + //~| HELP consider returning an `impl Trait` instead of a `dyn Trait` + //~| HELP alternatively, box the return type, and wrap all of the returned values in `Box::new` + Box::new("") + } +} + +fn main() { + let _ = f(); + let _ = ().f(); +} diff --git a/tests/ui/async-await/async-fn/dyn-in-return-type.rs b/tests/ui/async-await/async-fn/dyn-in-return-type.rs index ec793bf80f287..47d5e371f55f6 100644 --- a/tests/ui/async-await/async-fn/dyn-in-return-type.rs +++ b/tests/ui/async-await/async-fn/dyn-in-return-type.rs @@ -1,10 +1,30 @@ //@ edition:2024 +//@ run-rustfix async fn f() -> dyn core::fmt::Debug { //~^ ERROR return type cannot be a trait object without pointer indirection //~| HELP consider returning an `impl Trait` instead of a `dyn Trait` //~| HELP alternatively, box the return type, and wrap all of the returned values in `Box::new` - loop {} + Box::new("") +} +trait T { + async fn f(&self) -> dyn core::fmt::Debug { + //~^ ERROR return type cannot be a trait object without pointer indirection + //~| HELP consider returning an `impl Trait` instead of a `dyn Trait` + //~| HELP alternatively, box the return type, and wrap all of the returned values in `Box::new` + Box::new("") + } +} +impl T for () { + async fn f(&self) -> dyn core::fmt::Debug { + //~^ ERROR return type cannot be a trait object without pointer indirection + //~| HELP consider returning an `impl Trait` instead of a `dyn Trait` + //~| HELP alternatively, box the return type, and wrap all of the returned values in `Box::new` + Box::new("") + } } -fn main() {} +fn main() { + let _ = f(); + let _ = ().f(); +} diff --git a/tests/ui/async-await/async-fn/dyn-in-return-type.stderr b/tests/ui/async-await/async-fn/dyn-in-return-type.stderr index 341d9561fd7ae..0d8a92d33cf9a 100644 --- a/tests/ui/async-await/async-fn/dyn-in-return-type.stderr +++ b/tests/ui/async-await/async-fn/dyn-in-return-type.stderr @@ -1,5 +1,5 @@ error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-in-return-type.rs:3:17 + --> $DIR/dyn-in-return-type.rs:4:17 | LL | async fn f() -> dyn core::fmt::Debug { | ^^^^^^^^^^^^^^^^^^^^ @@ -14,6 +14,38 @@ help: alternatively, box the return type, and wrap all of the returned values in LL | async fn f() -> Box { | ++++ + -error: aborting due to 1 previous error +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-in-return-type.rs:11:26 + | +LL | async fn f(&self) -> dyn core::fmt::Debug { + | ^^^^^^^^^^^^^^^^^^^^ + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - async fn f(&self) -> dyn core::fmt::Debug { +LL + async fn f(&self) -> impl core::fmt::Debug { + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL | async fn f(&self) -> Box { + | ++++ + + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-in-return-type.rs:19:26 + | +LL | async fn f(&self) -> dyn core::fmt::Debug { + | ^^^^^^^^^^^^^^^^^^^^ + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - async fn f(&self) -> dyn core::fmt::Debug { +LL + async fn f(&self) -> impl core::fmt::Debug { + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL | async fn f(&self) -> Box { + | ++++ + + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0746`. diff --git a/tests/ui/type-alias/dyn-trait-type-alias-return-type.fixed b/tests/ui/type-alias/dyn-trait-type-alias-return-type.fixed index 93472f808a8a7..ba94e1967df39 100644 --- a/tests/ui/type-alias/dyn-trait-type-alias-return-type.fixed +++ b/tests/ui/type-alias/dyn-trait-type-alias-return-type.fixed @@ -1,6 +1,8 @@ //@ run-rustfix type T = dyn core::fmt::Debug; //~^ NOTE this type alias is unsized +//~| NOTE this type alias is unsized +//~| NOTE this type alias is unsized fn f() -> Box { loop {} } //~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time @@ -9,10 +11,29 @@ fn f() -> Box { loop {} } //~| NOTE the return type of a function must have a statically known size //~| HELP consider boxing the return type +trait X { + fn f(&self) -> Box { loop {} } + //~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time + //~| HELP the trait `Sized` is not implemented for `(dyn Debug + 'static)` + //~| NOTE doesn't have a size known at compile-time + //~| NOTE the return type of a function must have a statically known size + //~| HELP consider boxing the return type +} + +impl X for () { + fn f(&self) -> Box { loop {} } + //~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time + //~| HELP the trait `Sized` is not implemented for `(dyn Debug + 'static)` + //~| NOTE doesn't have a size known at compile-time + //~| NOTE the return type of a function must have a statically known size + //~| HELP consider boxing the return type +} + fn main() { f(); //~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time //~| HELP the trait `Sized` is not implemented for `(dyn Debug + 'static)` //~| NOTE doesn't have a size known at compile-time //~| NOTE the return type of a function must have a statically known size + ().f(); } diff --git a/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs b/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs index da9f8d07f8e05..76f6e7c443424 100644 --- a/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs +++ b/tests/ui/type-alias/dyn-trait-type-alias-return-type.rs @@ -1,6 +1,8 @@ //@ run-rustfix type T = dyn core::fmt::Debug; //~^ NOTE this type alias is unsized +//~| NOTE this type alias is unsized +//~| NOTE this type alias is unsized fn f() -> T { loop {} } //~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time @@ -9,10 +11,29 @@ fn f() -> T { loop {} } //~| NOTE the return type of a function must have a statically known size //~| HELP consider boxing the return type +trait X { + fn f(&self) -> T { loop {} } + //~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time + //~| HELP the trait `Sized` is not implemented for `(dyn Debug + 'static)` + //~| NOTE doesn't have a size known at compile-time + //~| NOTE the return type of a function must have a statically known size + //~| HELP consider boxing the return type +} + +impl X for () { + fn f(&self) -> T { loop {} } + //~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time + //~| HELP the trait `Sized` is not implemented for `(dyn Debug + 'static)` + //~| NOTE doesn't have a size known at compile-time + //~| NOTE the return type of a function must have a statically known size + //~| HELP consider boxing the return type +} + fn main() { f(); //~^ ERROR the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time //~| HELP the trait `Sized` is not implemented for `(dyn Debug + 'static)` //~| NOTE doesn't have a size known at compile-time //~| NOTE the return type of a function must have a statically known size + ().f(); } diff --git a/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr b/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr index 658abbe8f780f..bb6951687048f 100644 --- a/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr +++ b/tests/ui/type-alias/dyn-trait-type-alias-return-type.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-type-alias-return-type.rs:5:11 + --> $DIR/dyn-trait-type-alias-return-type.rs:7:11 | LL | fn f() -> T { loop {} } | ^ doesn't have a size known at compile-time @@ -17,7 +17,43 @@ LL | fn f() -> Box { loop {} } | ++++ + error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-type-alias-return-type.rs:13:5 + --> $DIR/dyn-trait-type-alias-return-type.rs:24:20 + | +LL | fn f(&self) -> T { loop {} } + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Debug + 'static)` +note: this type alias is unsized + --> $DIR/dyn-trait-type-alias-return-type.rs:2:1 + | +LL | type T = dyn core::fmt::Debug; + | ^^^^^^ + = note: the return type of a function must have a statically known size +help: consider boxing the return type, and wrapping all of the returned values in `Box::new` + | +LL | fn f(&self) -> Box { loop {} } + | ++++ + + +error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-type-alias-return-type.rs:15:20 + | +LL | fn f(&self) -> T { loop {} } + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Debug + 'static)` +note: this type alias is unsized + --> $DIR/dyn-trait-type-alias-return-type.rs:2:1 + | +LL | type T = dyn core::fmt::Debug; + | ^^^^^^ + = note: the return type of a function must have a statically known size +help: consider boxing the return type, and wrapping all of the returned values in `Box::new` + | +LL | fn f(&self) -> Box { loop {} } + | ++++ + + +error[E0277]: the size for values of type `(dyn Debug + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-type-alias-return-type.rs:33:5 | LL | f(); | ^^^ doesn't have a size known at compile-time @@ -25,6 +61,6 @@ LL | f(); = help: the trait `Sized` is not implemented for `(dyn Debug + 'static)` = note: the return type of a function must have a statically known size -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. From 06500aa2ddba47bc3511236dcdca640c83ee5252 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 9 Dec 2025 17:59:24 +0100 Subject: [PATCH 17/21] Add message when running clippy with `--no-default-features` for cg_gcc --- src/bootstrap/src/core/build_steps/clippy.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs index f80cf58fbb2a5..085c2d952e304 100644 --- a/src/bootstrap/src/core/build_steps/clippy.rs +++ b/src/bootstrap/src/core/build_steps/clippy.rs @@ -394,6 +394,7 @@ impl Step for CodegenGcc { &[], ); self.build_compiler.configure_cargo(&mut cargo); + println!("Now running clippy on `rustc_codegen_gcc` with `--no-default-features`"); cargo.arg("--no-default-features"); run_cargo(builder, cargo, args, &stamp, vec![], true, false); } From 6cd44a472c7a9374c975921815cf8a88029108d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 9 Dec 2025 16:20:07 +0000 Subject: [PATCH 18/21] Make typo in field and name suggestions verbose --- compiler/rustc_hir_typeck/src/pat.rs | 2 +- compiler/rustc_resolve/src/diagnostics.rs | 2 +- .../diagnostic-derive.stderr | 24 +++- .../argument-suggestions/issue-109831.stderr | 8 +- tests/ui/associated-item/issue-87638.stderr | 22 +-- tests/ui/associated-types/issue-19883.stderr | 11 +- tests/ui/associated-types/issue-22037.stderr | 11 +- .../attributes/align-on-fields-143987.stderr | 8 +- ...ruct-pattern-box-pattern-ice-121463.stderr | 20 +-- tests/ui/closures/issue-90871.stderr | 6 +- .../ui-testing-optout.stderr | 16 ++- .../generic_const_exprs/error_in_ty.stderr | 8 +- .../unevaluated-const-ice-119731.stderr | 24 +++- ...arent_generics_of_nested_in_default.stderr | 8 +- .../ice-unhandled-type-122191.stderr | 8 +- .../const-pattern-rewrite-error-32086.stderr | 16 ++- tests/ui/delegation/bad-resolve.stderr | 16 ++- .../deriving-meta-unknown-trait.stderr | 14 +- tests/ui/did_you_mean/println-typo.stderr | 7 +- .../typo-suggestion-improvement-46332.stderr | 8 +- tests/ui/expr/if/bad-if-let-suggestion.stderr | 32 ++++- .../format-args-capture-issue-102057.stderr | 40 +++++- .../format-args-capture-issue-94010.stderr | 16 ++- .../equality-bound.stderr | 59 ++++++-- .../hygiene/rustc-macro-transparency.stderr | 11 +- tests/ui/imports/glob-resolve1.stderr | 21 ++- tests/ui/macros/macro-context.stderr | 6 +- tests/ui/macros/macro-name-typo.stderr | 7 +- .../macros/macro-path-prelude-fail-3.stderr | 7 +- tests/ui/macros/macro-reexport-removed.stderr | 8 +- tests/ui/macros/macro_undefined.stderr | 7 +- tests/ui/parser/emoji-identifiers.stderr | 8 +- tests/ui/parser/kw-in-trait-bounds.stderr | 32 ++++- .../ui/parser/recover/raw-no-const-mut.stderr | 8 +- ...h-enum-struct-variant-field-missing.stderr | 11 +- .../ui/pattern/pattern-error-continue.stderr | 11 +- .../name-resolution.stderr | 120 ++++++++++++++-- ...n-with-missing-fields-resolve-error.stderr | 8 +- .../proc-macro/gen-macro-rules-hygiene.stderr | 14 +- .../ui/proc-macro/lints_in_proc_macros.stderr | 7 +- tests/ui/proc-macro/mixed-site-span.stderr | 14 +- .../ui/proc-macro/parent-source-spans.stderr | 21 ++- tests/ui/proc-macro/resolve-error.stderr | 76 +++++++++-- tests/ui/regions/outlives-with-missing.stderr | 8 +- tests/ui/resolve/112590-2.stderr | 10 +- tests/ui/resolve/issue-10200.stderr | 7 +- tests/ui/resolve/issue-49074.stderr | 8 +- tests/ui/resolve/levenshtein.stderr | 53 +++++++- tests/ui/resolve/privacy-enum-ctor.stderr | 28 +++- tests/ui/resolve/privacy-struct-ctor.stderr | 11 +- ...uggest-path-instead-of-mod-dot-item.stderr | 30 ++-- tests/ui/resolve/tuple-struct-alias.stderr | 8 +- ...e-with-name-similar-to-struct-field.stderr | 23 +++- .../typo-suggestion-mistyped-in-path.stderr | 30 ++-- tests/ui/span/suggestion-raw-68962.stderr | 16 ++- tests/ui/span/typo-suggestion.stderr | 8 +- .../stability-attribute/issue-109177.stderr | 8 +- .../struct-fields-shorthand-unresolved.stderr | 8 +- tests/ui/suggestions/attribute-typos.stderr | 21 ++- .../case-difference-suggestions.stderr | 128 +++++++++++++++--- ...-to-add-suggestions-with-no-changes.stderr | 7 +- .../issue-66968-suggest-sorted-words.stderr | 8 +- .../assoc_type_bound_with_struct.stderr | 6 +- .../ice-120503-async-const-method.stderr | 8 +- .../mismatched_generic_args.stderr | 8 +- tests/ui/traits/impl-for-module.stderr | 8 +- .../type-error-drop-elaboration.stderr | 8 +- tests/ui/type/issue-7607-1.stderr | 7 +- ...114423-ice-regression-in-suggestion.stderr | 8 +- tests/ui/typeck/issue-120856.stderr | 19 +-- tests/ui/typeck/issue-83693.stderr | 6 +- tests/ui/typeck/issue-88844.stderr | 7 +- tests/ui/ufcs/ufcs-partially-resolved.stderr | 110 ++++++++++++--- ...mismatch-closure-from-another-scope.stderr | 8 +- 74 files changed, 1165 insertions(+), 241 deletions(-) diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs index 0e9ff962435fc..06fd89837d516 100644 --- a/compiler/rustc_hir_typeck/src/pat.rs +++ b/compiler/rustc_hir_typeck/src/pat.rs @@ -2296,7 +2296,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { let suggested_name = find_best_match_for_name(&[field.name], pat_field.ident.name, None); if let Some(suggested_name) = suggested_name { - err.span_suggestion( + err.span_suggestion_verbose( pat_field.ident.span, "a field with a similar name exists", suggested_name, diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs index 33c111708e366..44d71947db857 100644 --- a/compiler/rustc_resolve/src/diagnostics.rs +++ b/compiler/rustc_resolve/src/diagnostics.rs @@ -1963,7 +1963,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> { }; (span, msg, suggestion.candidate.to_ident_string()) }; - err.span_suggestion(span, msg, sugg, Applicability::MaybeIncorrect); + err.span_suggestion_verbose(span, msg, sugg, Applicability::MaybeIncorrect); true } diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 59b48e9f0ecc2..8a0e753a9c52a 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -570,19 +570,37 @@ error: cannot find attribute `warn_` in this scope --> $DIR/diagnostic-derive.rs:590:3 | LL | #[warn_(no_crate_example, code = E0123)] - | ^^^^^ help: a built-in attribute with a similar name exists: `warn` + | ^^^^^ + | +help: a built-in attribute with a similar name exists + | +LL - #[warn_(no_crate_example, code = E0123)] +LL + #[warn(no_crate_example, code = E0123)] + | error: cannot find attribute `lint` in this scope --> $DIR/diagnostic-derive.rs:597:3 | LL | #[lint(no_crate_example, code = E0123)] - | ^^^^ help: a built-in attribute with a similar name exists: `link` + | ^^^^ + | +help: a built-in attribute with a similar name exists + | +LL - #[lint(no_crate_example, code = E0123)] +LL + #[link(no_crate_example, code = E0123)] + | error: cannot find attribute `lint` in this scope --> $DIR/diagnostic-derive.rs:604:3 | LL | #[lint(no_crate_example, code = E0123)] - | ^^^^ help: a built-in attribute with a similar name exists: `link` + | ^^^^ + | +help: a built-in attribute with a similar name exists + | +LL - #[lint(no_crate_example, code = E0123)] +LL + #[link(no_crate_example, code = E0123)] + | error: cannot find attribute `multipart_suggestion` in this scope --> $DIR/diagnostic-derive.rs:644:3 diff --git a/tests/ui/argument-suggestions/issue-109831.stderr b/tests/ui/argument-suggestions/issue-109831.stderr index 6c25236ebb1b0..852016c983f72 100644 --- a/tests/ui/argument-suggestions/issue-109831.stderr +++ b/tests/ui/argument-suggestions/issue-109831.stderr @@ -24,7 +24,13 @@ LL | struct A; | --------- similarly named unit struct `A` defined here ... LL | f(A, A, B, C); - | ^ help: a unit struct with a similar name exists: `A` + | ^ + | +help: a unit struct with a similar name exists + | +LL - f(A, A, B, C); +LL + f(A, A, B, A); + | error[E0061]: this function takes 3 arguments but 4 arguments were supplied --> $DIR/issue-109831.rs:7:5 diff --git a/tests/ui/associated-item/issue-87638.stderr b/tests/ui/associated-item/issue-87638.stderr index cf6083444b0e6..cce20318a23ba 100644 --- a/tests/ui/associated-item/issue-87638.stderr +++ b/tests/ui/associated-item/issue-87638.stderr @@ -5,10 +5,13 @@ LL | type Target; | ------------ associated type `Target` defined here ... LL | let _: ::Output; - | ^^^^^^ - | | - | not found in `Trait` - | help: maybe you meant this associated type: `Target` + | ^^^^^^ not found in `Trait` + | +help: maybe you meant this associated type + | +LL - let _: ::Output; +LL + let _: ::Target; + | error[E0576]: cannot find method or associated constant `BAR` in trait `Trait` --> $DIR/issue-87638.rs:20:27 @@ -17,10 +20,13 @@ LL | const FOO: usize; | ----------------- associated constant `FOO` defined here ... LL | let _ = ::BAR; - | ^^^ - | | - | not found in `Trait` - | help: maybe you meant this associated constant: `FOO` + | ^^^ not found in `Trait` + | +help: maybe you meant this associated constant + | +LL - let _ = ::BAR; +LL + let _ = ::FOO; + | error: aborting due to 2 previous errors diff --git a/tests/ui/associated-types/issue-19883.stderr b/tests/ui/associated-types/issue-19883.stderr index 35184e852cfe1..435c2933e3616 100644 --- a/tests/ui/associated-types/issue-19883.stderr +++ b/tests/ui/associated-types/issue-19883.stderr @@ -5,10 +5,13 @@ LL | type Output; | ------------ associated type `Output` defined here ... LL | >::Dst - | ^^^ - | | - | not found in `From` - | help: maybe you meant this associated type: `Output` + | ^^^ not found in `From` + | +help: maybe you meant this associated type + | +LL - >::Dst +LL + >::Output + | error: aborting due to 1 previous error diff --git a/tests/ui/associated-types/issue-22037.stderr b/tests/ui/associated-types/issue-22037.stderr index b02dad97d354e..0b5f18f81c0bf 100644 --- a/tests/ui/associated-types/issue-22037.stderr +++ b/tests/ui/associated-types/issue-22037.stderr @@ -4,10 +4,13 @@ error[E0576]: cannot find associated type `X` in trait `A` LL | type Output; | ------------ associated type `Output` defined here LL | fn a(&self) -> ::X; - | ^ - | | - | not found in `A` - | help: maybe you meant this associated type: `Output` + | ^ not found in `A` + | +help: maybe you meant this associated type + | +LL - fn a(&self) -> ::X; +LL + fn a(&self) -> ::Output; + | error: aborting due to 1 previous error diff --git a/tests/ui/attributes/align-on-fields-143987.stderr b/tests/ui/attributes/align-on-fields-143987.stderr index c95543a74c1a1..1ffbf4a37cb93 100644 --- a/tests/ui/attributes/align-on-fields-143987.stderr +++ b/tests/ui/attributes/align-on-fields-143987.stderr @@ -2,7 +2,13 @@ error[E0425]: cannot find type `usize8` in this scope --> $DIR/align-on-fields-143987.rs:17:8 | LL | x: usize8, - | ^^^^^^ help: a builtin type with a similar name exists: `usize` + | ^^^^^^ + | +help: a builtin type with a similar name exists + | +LL - x: usize8, +LL + x: usize, + | error: `#[rustc_align]` attribute cannot be used on struct fields --> $DIR/align-on-fields-143987.rs:10:5 diff --git a/tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.stderr b/tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.stderr index 349546606a57e..ae5c67eae9a6c 100644 --- a/tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.stderr +++ b/tests/ui/borrowck/non-ADT-struct-pattern-box-pattern-ice-121463.stderr @@ -2,19 +2,23 @@ error[E0433]: failed to resolve: use of undeclared type `E` --> $DIR/non-ADT-struct-pattern-box-pattern-ice-121463.rs:6:17 | LL | let mut a = E::StructVar { boxed: Box::new(5_i32) }; - | ^ - | | - | use of undeclared type `E` - | help: a trait with a similar name exists: `Eq` + | ^ use of undeclared type `E` + | +help: a trait with a similar name exists + | +LL | let mut a = Eq::StructVar { boxed: Box::new(5_i32) }; + | + error[E0433]: failed to resolve: use of undeclared type `E` --> $DIR/non-ADT-struct-pattern-box-pattern-ice-121463.rs:9:9 | LL | E::StructVar { box boxed } => { } - | ^ - | | - | use of undeclared type `E` - | help: a trait with a similar name exists: `Eq` + | ^ use of undeclared type `E` + | +help: a trait with a similar name exists + | +LL | Eq::StructVar { box boxed } => { } + | + error: aborting due to 2 previous errors diff --git a/tests/ui/closures/issue-90871.stderr b/tests/ui/closures/issue-90871.stderr index 071694def4135..140f249821404 100644 --- a/tests/ui/closures/issue-90871.stderr +++ b/tests/ui/closures/issue-90871.stderr @@ -2,11 +2,15 @@ error[E0425]: cannot find type `n` in this scope --> $DIR/issue-90871.rs:4:22 | LL | type_ascribe!(2, n([u8; || 1])) - | ^ help: a trait with a similar name exists: `Fn` + | ^ | --> $SRC_DIR/core/src/ops/function.rs:LL:COL | = note: similarly named trait `Fn` defined here +help: a trait with a similar name exists + | +LL | type_ascribe!(2, Fn([u8; || 1])) + | + error[E0308]: mismatched types --> $DIR/issue-90871.rs:4:29 diff --git a/tests/ui/compiletest-self-test/ui-testing-optout.stderr b/tests/ui/compiletest-self-test/ui-testing-optout.stderr index b0d495edfb62a..6a4950c55afd8 100644 --- a/tests/ui/compiletest-self-test/ui-testing-optout.stderr +++ b/tests/ui/compiletest-self-test/ui-testing-optout.stderr @@ -11,7 +11,13 @@ error[E0425]: cannot find type `D` in this scope | ----------- similarly named type alias `A` defined here ... 7 | type C = D; - | ^ help: a type alias with a similar name exists: `A` + | ^ + | +help: a type alias with a similar name exists + | +7 - type C = D; +7 + type C = A; + | error[E0425]: cannot find type `F` in this scope --> $DIR/ui-testing-optout.rs:92:10 @@ -20,7 +26,13 @@ error[E0425]: cannot find type `F` in this scope | ----------- similarly named type alias `A` defined here ... 92 | type E = F; - | ^ help: a type alias with a similar name exists: `A` + | ^ + | +help: a type alias with a similar name exists + | +92 - type E = F; +92 + type E = A; + | error: aborting due to 3 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr b/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr index d822fa5894a5b..58f0d31b09601 100644 --- a/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr +++ b/tests/ui/const-generics/generic_const_exprs/error_in_ty.stderr @@ -2,9 +2,15 @@ error[E0425]: cannot find value `x` in this scope --> $DIR/error_in_ty.rs:6:31 | LL | pub struct A {} - | - ^ help: a const parameter with a similar name exists: `z` + | - ^ | | | similarly named const parameter `z` defined here + | +help: a const parameter with a similar name exists + | +LL - pub struct A {} +LL + pub struct A {} + | error: `[usize; x]` is forbidden as the type of a const generic parameter --> $DIR/error_in_ty.rs:6:23 diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr index d3a7e286fdd60..b547bdd7d07a4 100644 --- a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr @@ -20,7 +20,13 @@ LL | pub type v11 = [[usize; v4]; v4]; | --------------------------------- similarly named type alias `v11` defined here ... LL | pub const fn v21() -> v18 {} - | ^^^ help: a type alias with a similar name exists: `v11` + | ^^^ + | +help: a type alias with a similar name exists + | +LL - pub const fn v21() -> v18 {} +LL + pub const fn v21() -> v11 {} + | error[E0425]: cannot find type `v18` in this scope --> $DIR/unevaluated-const-ice-119731.rs:35:31 @@ -29,7 +35,13 @@ LL | pub type v11 = [[usize; v4]; v4]; | --------------------------------- similarly named type alias `v11` defined here ... LL | pub const fn v21() -> v18 { - | ^^^ help: a type alias with a similar name exists: `v11` + | ^^^ + | +help: a type alias with a similar name exists + | +LL - pub const fn v21() -> v18 { +LL + pub const fn v21() -> v11 { + | error[E0422]: cannot find struct, variant or union type `v18` in this scope --> $DIR/unevaluated-const-ice-119731.rs:37:13 @@ -38,7 +50,13 @@ LL | pub type v11 = [[usize; v4]; v4]; | --------------------------------- similarly named type alias `v11` defined here ... LL | v18 { _p: () } - | ^^^ help: a type alias with a similar name exists: `v11` + | ^^^ + | +help: a type alias with a similar name exists + | +LL - v18 { _p: () } +LL + v11 { _p: () } + | warning: type `v11` should have an upper camel case name --> $DIR/unevaluated-const-ice-119731.rs:9:14 diff --git a/tests/ui/const-generics/parent_generics_of_nested_in_default.stderr b/tests/ui/const-generics/parent_generics_of_nested_in_default.stderr index 00eeecb9595f3..9452e747a7553 100644 --- a/tests/ui/const-generics/parent_generics_of_nested_in_default.stderr +++ b/tests/ui/const-generics/parent_generics_of_nested_in_default.stderr @@ -8,9 +8,15 @@ error[E0425]: cannot find value `B` in this scope --> $DIR/parent_generics_of_nested_in_default.rs:1:30 | LL | impl Tr {} - | - ^ help: a const parameter with a similar name exists: `A` + | - ^ | | | similarly named const parameter `A` defined here + | +help: a const parameter with a similar name exists + | +LL - impl Tr {} +LL + impl Tr {} + | error: defaults for generic parameters are not allowed here --> $DIR/parent_generics_of_nested_in_default.rs:1:6 diff --git a/tests/ui/consts/const-eval/ice-unhandled-type-122191.stderr b/tests/ui/consts/const-eval/ice-unhandled-type-122191.stderr index bcb6a80a8f2b2..5e2e3524ae9ea 100644 --- a/tests/ui/consts/const-eval/ice-unhandled-type-122191.stderr +++ b/tests/ui/consts/const-eval/ice-unhandled-type-122191.stderr @@ -22,10 +22,16 @@ error[E0425]: cannot find function `value` in this scope --> $DIR/ice-unhandled-type-122191.rs:9:5 | LL | value() - | ^^^^^ help: a constant with a similar name exists: `VALUE` + | ^^^^^ ... LL | const VALUE: Foo = foo(); | ------------------------- similarly named constant `VALUE` defined here + | +help: a constant with a similar name exists + | +LL - value() +LL + VALUE() + | error[E0308]: mismatched types --> $DIR/ice-unhandled-type-122191.rs:17:9 diff --git a/tests/ui/consts/const-pattern-rewrite-error-32086.stderr b/tests/ui/consts/const-pattern-rewrite-error-32086.stderr index 47616b0663214..9c8ac70087098 100644 --- a/tests/ui/consts/const-pattern-rewrite-error-32086.stderr +++ b/tests/ui/consts/const-pattern-rewrite-error-32086.stderr @@ -5,7 +5,13 @@ LL | struct S(u8); | ------------- similarly named tuple struct `S` defined here ... LL | let C(a) = S(11); - | ^ help: a tuple struct with a similar name exists: `S` + | ^ + | +help: a tuple struct with a similar name exists + | +LL - let C(a) = S(11); +LL + let S(a) = S(11); + | error[E0532]: expected tuple struct or tuple variant, found constant `C` --> $DIR/const-pattern-rewrite-error-32086.rs:7:9 @@ -14,7 +20,13 @@ LL | struct S(u8); | ------------- similarly named tuple struct `S` defined here ... LL | let C(..) = S(11); - | ^ help: a tuple struct with a similar name exists: `S` + | ^ + | +help: a tuple struct with a similar name exists + | +LL - let C(..) = S(11); +LL + let S(..) = S(11); + | error: aborting due to 2 previous errors diff --git a/tests/ui/delegation/bad-resolve.stderr b/tests/ui/delegation/bad-resolve.stderr index fc6811292a6ff..4c015c226b18f 100644 --- a/tests/ui/delegation/bad-resolve.stderr +++ b/tests/ui/delegation/bad-resolve.stderr @@ -53,7 +53,13 @@ LL | fn bar() {} | -------- similarly named associated function `bar` defined here ... LL | reuse ::baz; - | ^^^ help: an associated function with a similar name exists: `bar` + | ^^^ + | +help: an associated function with a similar name exists + | +LL - reuse ::baz; +LL + reuse ::bar; + | error[E0425]: cannot find function `foo` in this scope --> $DIR/bad-resolve.rs:35:11 @@ -68,7 +74,13 @@ LL | fn foo(&self, x: i32) -> i32 { x } | ---------------------------- similarly named associated function `foo` defined here ... LL | reuse Trait::foo2 { self.0 } - | ^^^^ help: an associated function with a similar name exists: `foo` + | ^^^^ + | +help: an associated function with a similar name exists + | +LL - reuse Trait::foo2 { self.0 } +LL + reuse Trait::foo { self.0 } + | error[E0046]: not all trait items implemented, missing: `Type` --> $DIR/bad-resolve.rs:22:1 diff --git a/tests/ui/derives/deriving-meta-unknown-trait.stderr b/tests/ui/derives/deriving-meta-unknown-trait.stderr index 7ee90ae9eb0c3..1cf31502dfb8b 100644 --- a/tests/ui/derives/deriving-meta-unknown-trait.stderr +++ b/tests/ui/derives/deriving-meta-unknown-trait.stderr @@ -2,23 +2,33 @@ error: cannot find derive macro `Eqr` in this scope --> $DIR/deriving-meta-unknown-trait.rs:1:10 | LL | #[derive(Eqr)] - | ^^^ help: a derive macro with a similar name exists: `Eq` + | ^^^ | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named derive macro `Eq` defined here +help: a derive macro with a similar name exists + | +LL - #[derive(Eqr)] +LL + #[derive(Eq)] + | error: cannot find derive macro `Eqr` in this scope --> $DIR/deriving-meta-unknown-trait.rs:1:10 | LL | #[derive(Eqr)] - | ^^^ help: a derive macro with a similar name exists: `Eq` + | ^^^ | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named derive macro `Eq` defined here | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: a derive macro with a similar name exists + | +LL - #[derive(Eqr)] +LL + #[derive(Eq)] + | error: aborting due to 2 previous errors diff --git a/tests/ui/did_you_mean/println-typo.stderr b/tests/ui/did_you_mean/println-typo.stderr index 7dd6fbba620b0..471d49b6ee2e6 100644 --- a/tests/ui/did_you_mean/println-typo.stderr +++ b/tests/ui/did_you_mean/println-typo.stderr @@ -2,11 +2,16 @@ error: cannot find macro `prinltn` in this scope --> $DIR/println-typo.rs:4:5 | LL | prinltn!(); - | ^^^^^^^ help: a macro with a similar name exists: `println` + | ^^^^^^^ | --> $SRC_DIR/std/src/macros.rs:LL:COL | = note: similarly named macro `println` defined here +help: a macro with a similar name exists + | +LL - prinltn!(); +LL + println!(); + | error: aborting due to 1 previous error diff --git a/tests/ui/did_you_mean/typo-suggestion-improvement-46332.stderr b/tests/ui/did_you_mean/typo-suggestion-improvement-46332.stderr index 502f81518785c..d677152314dc6 100644 --- a/tests/ui/did_you_mean/typo-suggestion-improvement-46332.stderr +++ b/tests/ui/did_you_mean/typo-suggestion-improvement-46332.stderr @@ -5,7 +5,13 @@ LL | struct TyUint {} | ------------- similarly named struct `TyUint` defined here ... LL | TyUInt {}; - | ^^^^^^ help: a struct with a similar name exists (notice the capitalization): `TyUint` + | ^^^^^^ + | +help: a struct with a similar name exists (notice the capitalization) + | +LL - TyUInt {}; +LL + TyUint {}; + | error: aborting due to 1 previous error diff --git a/tests/ui/expr/if/bad-if-let-suggestion.stderr b/tests/ui/expr/if/bad-if-let-suggestion.stderr index 0d1f895bd82bf..4244a3bb06eea 100644 --- a/tests/ui/expr/if/bad-if-let-suggestion.stderr +++ b/tests/ui/expr/if/bad-if-let-suggestion.stderr @@ -27,7 +27,13 @@ LL | fn a() { | ------ similarly named function `a` defined here ... LL | if (i + j) = i {} - | ^ help: a function with a similar name exists: `a` + | ^ + | +help: a function with a similar name exists + | +LL - if (i + j) = i {} +LL + if (a + j) = i {} + | error[E0425]: cannot find value `j` in this scope --> $DIR/bad-if-let-suggestion.rs:9:13 @@ -36,7 +42,13 @@ LL | fn a() { | ------ similarly named function `a` defined here ... LL | if (i + j) = i {} - | ^ help: a function with a similar name exists: `a` + | ^ + | +help: a function with a similar name exists + | +LL - if (i + j) = i {} +LL + if (i + a) = i {} + | error[E0425]: cannot find value `i` in this scope --> $DIR/bad-if-let-suggestion.rs:9:18 @@ -45,7 +57,13 @@ LL | fn a() { | ------ similarly named function `a` defined here ... LL | if (i + j) = i {} - | ^ help: a function with a similar name exists: `a` + | ^ + | +help: a function with a similar name exists + | +LL - if (i + j) = i {} +LL + if (i + j) = a {} + | error[E0425]: cannot find value `x` in this scope --> $DIR/bad-if-let-suggestion.rs:16:8 @@ -54,7 +72,13 @@ LL | fn a() { | ------ similarly named function `a` defined here ... LL | if x[0] = 1 {} - | ^ help: a function with a similar name exists: `a` + | ^ + | +help: a function with a similar name exists + | +LL - if x[0] = 1 {} +LL + if a[0] = 1 {} + | error[E0308]: mismatched types --> $DIR/bad-if-let-suggestion.rs:2:8 diff --git a/tests/ui/fmt/format-args-capture-issue-102057.stderr b/tests/ui/fmt/format-args-capture-issue-102057.stderr index f2d625e7f8dc8..9a5bc5365df74 100644 --- a/tests/ui/fmt/format-args-capture-issue-102057.stderr +++ b/tests/ui/fmt/format-args-capture-issue-102057.stderr @@ -14,31 +14,61 @@ error[E0425]: cannot find value `b` in this scope --> $DIR/format-args-capture-issue-102057.rs:9:22 | LL | format!("\x7Ba} {b}"); - | ^ help: a local variable with a similar name exists: `a` + | ^ + | +help: a local variable with a similar name exists + | +LL - format!("\x7Ba} {b}"); +LL + format!("\x7Ba} {a}"); + | error[E0425]: cannot find value `b` in this scope --> $DIR/format-args-capture-issue-102057.rs:11:25 | LL | format!("\x7Ba\x7D {b}"); - | ^ help: a local variable with a similar name exists: `a` + | ^ + | +help: a local variable with a similar name exists + | +LL - format!("\x7Ba\x7D {b}"); +LL + format!("\x7Ba\x7D {a}"); + | error[E0425]: cannot find value `b` in this scope --> $DIR/format-args-capture-issue-102057.rs:13:25 | LL | format!("\x7Ba} \x7Bb}"); - | ^ help: a local variable with a similar name exists: `a` + | ^ + | +help: a local variable with a similar name exists + | +LL - format!("\x7Ba} \x7Bb}"); +LL + format!("\x7Ba} \x7Ba}"); + | error[E0425]: cannot find value `b` in this scope --> $DIR/format-args-capture-issue-102057.rs:15:28 | LL | format!("\x7Ba\x7D \x7Bb}"); - | ^ help: a local variable with a similar name exists: `a` + | ^ + | +help: a local variable with a similar name exists + | +LL - format!("\x7Ba\x7D \x7Bb}"); +LL + format!("\x7Ba\x7D \x7Ba}"); + | error[E0425]: cannot find value `b` in this scope --> $DIR/format-args-capture-issue-102057.rs:17:28 | LL | format!("\x7Ba\x7D \x7Bb\x7D"); - | ^ help: a local variable with a similar name exists: `a` + | ^ + | +help: a local variable with a similar name exists + | +LL - format!("\x7Ba\x7D \x7Bb\x7D"); +LL + format!("\x7Ba\x7D \x7Ba\x7D"); + | error: aborting due to 7 previous errors diff --git a/tests/ui/fmt/format-args-capture-issue-94010.stderr b/tests/ui/fmt/format-args-capture-issue-94010.stderr index ed90dc855360a..ccdaf0c67b2ba 100644 --- a/tests/ui/fmt/format-args-capture-issue-94010.stderr +++ b/tests/ui/fmt/format-args-capture-issue-94010.stderr @@ -4,7 +4,13 @@ error[E0425]: cannot find value `foo` in this scope LL | const FOO: i32 = 123; | --------------------- similarly named constant `FOO` defined here LL | println!("{foo:X}"); - | ^^^ help: a constant with a similar name exists (notice the capitalization): `FOO` + | ^^^ + | +help: a constant with a similar name exists (notice the capitalization) + | +LL - println!("{foo:X}"); +LL + println!("{FOO:X}"); + | error[E0425]: cannot find value `foo` in this scope --> $DIR/format-args-capture-issue-94010.rs:5:18 @@ -13,7 +19,13 @@ LL | const FOO: i32 = 123; | --------------------- similarly named constant `FOO` defined here ... LL | println!("{:.foo$}", 0); - | ^^^ help: a constant with a similar name exists (notice the capitalization): `FOO` + | ^^^ + | +help: a constant with a similar name exists (notice the capitalization) + | +LL - println!("{:.foo$}", 0); +LL + println!("{:.FOO$}", 0); + | error: aborting due to 2 previous errors diff --git a/tests/ui/generic-associated-types/equality-bound.stderr b/tests/ui/generic-associated-types/equality-bound.stderr index 03fafe3e21c1d..265c86ac5bb61 100644 --- a/tests/ui/generic-associated-types/equality-bound.stderr +++ b/tests/ui/generic-associated-types/equality-bound.stderr @@ -114,28 +114,46 @@ error[E0425]: cannot find type `A` in this scope --> $DIR/equality-bound.rs:20:79 | LL | fn from_iter(_: T) -> Self where T: IntoIterator, IntoIterator::Item = A, - | ^ help: a struct with a similar name exists: `K` + | ^ ... LL | struct K {} | -------- similarly named struct `K` defined here + | +help: a struct with a similar name exists + | +LL - fn from_iter(_: T) -> Self where T: IntoIterator, IntoIterator::Item = A, +LL + fn from_iter(_: T) -> Self where T: IntoIterator, IntoIterator::Item = K, + | error[E0425]: cannot find type `A` in this scope --> $DIR/equality-bound.rs:31:68 | LL | fn from_iter(_: T) -> Self where T: IntoIterator, T::Item = A, - | ^ help: a struct with a similar name exists: `K` + | ^ ... LL | struct K {} | -------- similarly named struct `K` defined here + | +help: a struct with a similar name exists + | +LL - fn from_iter(_: T) -> Self where T: IntoIterator, T::Item = A, +LL + fn from_iter(_: T) -> Self where T: IntoIterator, T::Item = K, + | error[E0425]: cannot find type `A` in this scope --> $DIR/equality-bound.rs:42:76 | LL | fn from_iter(_: T) -> Self where IntoIterator::Item = A, - | ^ help: a struct with a similar name exists: `K` + | ^ ... LL | struct K {} | -------- similarly named struct `K` defined here + | +help: a struct with a similar name exists + | +LL - fn from_iter(_: T) -> Self where IntoIterator::Item = A, +LL + fn from_iter(_: T) -> Self where IntoIterator::Item = K, + | error[E0425]: cannot find type `A` in this scope --> $DIR/equality-bound.rs:53:65 @@ -144,7 +162,13 @@ LL | struct K {} | -------- similarly named struct `K` defined here ... LL | fn from_iter(_: T) -> Self where T::Item = A, - | ^ help: a struct with a similar name exists: `K` + | ^ + | +help: a struct with a similar name exists + | +LL - fn from_iter(_: T) -> Self where T::Item = A, +LL + fn from_iter(_: T) -> Self where T::Item = K, + | error[E0425]: cannot find type `A` in this scope --> $DIR/equality-bound.rs:64:62 @@ -153,7 +177,13 @@ LL | struct K {} | -------- similarly named struct `K` defined here ... LL | fn from_iter(_: T) -> Self where IntoIterator::Item = A, T: IntoIterator, - | ^ help: a struct with a similar name exists: `K` + | ^ + | +help: a struct with a similar name exists + | +LL - fn from_iter(_: T) -> Self where IntoIterator::Item = A, T: IntoIterator, +LL + fn from_iter(_: T) -> Self where IntoIterator::Item = K, T: IntoIterator, + | error[E0425]: cannot find type `A` in this scope --> $DIR/equality-bound.rs:75:51 @@ -162,16 +192,25 @@ LL | struct K {} | -------- similarly named struct `K` defined here ... LL | fn from_iter(_: T) -> Self where T::Item = A, T: IntoIterator, - | ^ help: a struct with a similar name exists: `K` + | ^ + | +help: a struct with a similar name exists + | +LL - fn from_iter(_: T) -> Self where T::Item = A, T: IntoIterator, +LL + fn from_iter(_: T) -> Self where T::Item = K, T: IntoIterator, + | error[E0433]: failed to resolve: use of undeclared type `I` --> $DIR/equality-bound.rs:9:41 | LL | fn sum3(i: J) -> i32 where I::Item = i32 { - | ^ - | | - | use of undeclared type `I` - | help: a type parameter with a similar name exists: `J` + | ^ use of undeclared type `I` + | +help: a type parameter with a similar name exists + | +LL - fn sum3(i: J) -> i32 where I::Item = i32 { +LL + fn sum3(i: J) -> i32 where J::Item = i32 { + | error: aborting due to 16 previous errors diff --git a/tests/ui/hygiene/rustc-macro-transparency.stderr b/tests/ui/hygiene/rustc-macro-transparency.stderr index 1bea8a0ee4f31..af67bfe66cc84 100644 --- a/tests/ui/hygiene/rustc-macro-transparency.stderr +++ b/tests/ui/hygiene/rustc-macro-transparency.stderr @@ -11,10 +11,13 @@ LL | struct SemiOpaque; | ------------------ similarly named unit struct `SemiOpaque` defined here ... LL | semiopaque; - | ^^^^^^^^^^ - | | - | not a value - | help: a unit struct with a similar name exists (notice the capitalization): `SemiOpaque` + | ^^^^^^^^^^ not a value + | +help: a unit struct with a similar name exists (notice the capitalization) + | +LL - semiopaque; +LL + SemiOpaque; + | error[E0423]: expected value, found macro `opaque` --> $DIR/rustc-macro-transparency.rs:30:5 diff --git a/tests/ui/imports/glob-resolve1.stderr b/tests/ui/imports/glob-resolve1.stderr index 1356255a08501..5e02c933836d1 100644 --- a/tests/ui/imports/glob-resolve1.stderr +++ b/tests/ui/imports/glob-resolve1.stderr @@ -75,13 +75,18 @@ LL | pub enum B { | ---------- similarly named enum `B` defined here ... LL | foo::(); - | ^ help: an enum with a similar name exists: `B` + | ^ | note: enum `bar::A` exists but is inaccessible --> $DIR/glob-resolve1.rs:12:5 | LL | enum A { | ^^^^^^ not accessible +help: an enum with a similar name exists + | +LL - foo::(); +LL + foo::(); + | error[E0425]: cannot find type `C` in this scope --> $DIR/glob-resolve1.rs:34:11 @@ -90,13 +95,18 @@ LL | pub enum B { | ---------- similarly named enum `B` defined here ... LL | foo::(); - | ^ help: an enum with a similar name exists: `B` + | ^ | note: struct `bar::C` exists but is inaccessible --> $DIR/glob-resolve1.rs:19:5 | LL | struct C; | ^^^^^^^^^ not accessible +help: an enum with a similar name exists + | +LL - foo::(); +LL + foo::(); + | error[E0425]: cannot find type `D` in this scope --> $DIR/glob-resolve1.rs:35:11 @@ -105,13 +115,18 @@ LL | pub enum B { | ---------- similarly named enum `B` defined here ... LL | foo::(); - | ^ help: an enum with a similar name exists: `B` + | ^ | note: type alias `bar::D` exists but is inaccessible --> $DIR/glob-resolve1.rs:21:5 | LL | type D = isize; | ^^^^^^^^^^^^^^^ not accessible +help: an enum with a similar name exists + | +LL - foo::(); +LL + foo::(); + | error: aborting due to 8 previous errors diff --git a/tests/ui/macros/macro-context.stderr b/tests/ui/macros/macro-context.stderr index edddfef9de3b2..3ec1af3a82f82 100644 --- a/tests/ui/macros/macro-context.stderr +++ b/tests/ui/macros/macro-context.stderr @@ -46,12 +46,16 @@ error[E0425]: cannot find type `i` in this scope --> $DIR/macro-context.rs:3:13 | LL | () => ( i ; typeof ); - | ^ help: a builtin type with a similar name exists: `i8` + | ^ ... LL | let a: m!(); | ---- in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) +help: a builtin type with a similar name exists + | +LL | () => ( i8 ; typeof ); + | + error[E0425]: cannot find value `i` in this scope --> $DIR/macro-context.rs:3:13 diff --git a/tests/ui/macros/macro-name-typo.stderr b/tests/ui/macros/macro-name-typo.stderr index 1cc7ea6ec1b60..bca7dbe9369cb 100644 --- a/tests/ui/macros/macro-name-typo.stderr +++ b/tests/ui/macros/macro-name-typo.stderr @@ -2,11 +2,16 @@ error: cannot find macro `printlx` in this scope --> $DIR/macro-name-typo.rs:2:5 | LL | printlx!("oh noes!"); - | ^^^^^^^ help: a macro with a similar name exists: `println` + | ^^^^^^^ | --> $SRC_DIR/std/src/macros.rs:LL:COL | = note: similarly named macro `println` defined here +help: a macro with a similar name exists + | +LL - printlx!("oh noes!"); +LL + println!("oh noes!"); + | error: aborting due to 1 previous error diff --git a/tests/ui/macros/macro-path-prelude-fail-3.stderr b/tests/ui/macros/macro-path-prelude-fail-3.stderr index 3d0a074deeb05..7bf166d0e56f6 100644 --- a/tests/ui/macros/macro-path-prelude-fail-3.stderr +++ b/tests/ui/macros/macro-path-prelude-fail-3.stderr @@ -2,13 +2,18 @@ error: cannot find macro `inline` in this scope --> $DIR/macro-path-prelude-fail-3.rs:2:5 | LL | inline!(); - | ^^^^^^ help: a macro with a similar name exists: `line` + | ^^^^^^ | --> $SRC_DIR/core/src/macros/mod.rs:LL:COL | = note: similarly named macro `line` defined here | = note: `inline` is in scope, but it is an attribute: `#[inline]` +help: a macro with a similar name exists + | +LL - inline!(); +LL + line!(); + | error: aborting due to 1 previous error diff --git a/tests/ui/macros/macro-reexport-removed.stderr b/tests/ui/macros/macro-reexport-removed.stderr index 8130fe0c4bdaa..752133162214e 100644 --- a/tests/ui/macros/macro-reexport-removed.stderr +++ b/tests/ui/macros/macro-reexport-removed.stderr @@ -11,7 +11,13 @@ error: cannot find attribute `macro_reexport` in this scope --> $DIR/macro-reexport-removed.rs:5:3 | LL | #[macro_reexport(macro_one)] - | ^^^^^^^^^^^^^^ help: a built-in attribute with a similar name exists: `macro_export` + | ^^^^^^^^^^^^^^ + | +help: a built-in attribute with a similar name exists + | +LL - #[macro_reexport(macro_one)] +LL + #[macro_export(macro_one)] + | error: aborting due to 2 previous errors diff --git a/tests/ui/macros/macro_undefined.stderr b/tests/ui/macros/macro_undefined.stderr index cc3efacbc5415..ed58be8808b2f 100644 --- a/tests/ui/macros/macro_undefined.stderr +++ b/tests/ui/macros/macro_undefined.stderr @@ -5,7 +5,12 @@ LL | macro_rules! kl { | --------------- similarly named macro `kl` defined here ... LL | k!(); - | ^ help: a macro with a similar name exists: `kl` + | ^ + | +help: a macro with a similar name exists + | +LL | kl!(); + | + error: aborting due to 1 previous error diff --git a/tests/ui/parser/emoji-identifiers.stderr b/tests/ui/parser/emoji-identifiers.stderr index ef4e647b9f506..016ed0401caf8 100644 --- a/tests/ui/parser/emoji-identifiers.stderr +++ b/tests/ui/parser/emoji-identifiers.stderr @@ -91,7 +91,13 @@ LL | fn i_like_to_😅_a_lot() -> 👀 { | ----------------------------- similarly named function `i_like_to_😅_a_lot` defined here ... LL | let _ = i_like_to_😄_a_lot() ➖ 4; - | ^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `i_like_to_😅_a_lot` + | ^^^^^^^^^^^^^^^^^^ + | +help: a function with a similar name exists + | +LL - let _ = i_like_to_😄_a_lot() ➖ 4; +LL + let _ = i_like_to_😅_a_lot() ➖ 4; + | error: aborting due to 10 previous errors diff --git a/tests/ui/parser/kw-in-trait-bounds.stderr b/tests/ui/parser/kw-in-trait-bounds.stderr index 5a4adf3e37b4c..5f86b1430616b 100644 --- a/tests/ui/parser/kw-in-trait-bounds.stderr +++ b/tests/ui/parser/kw-in-trait-bounds.stderr @@ -94,37 +94,61 @@ error[E0405]: cannot find trait `r#struct` in this scope --> $DIR/kw-in-trait-bounds.rs:16:10 | LL | fn _g(_: impl struct, _: &dyn struct) - | ^^^^^^ help: a trait with a similar name exists (notice the capitalization): `Struct` + | ^^^^^^ ... LL | trait Struct {} | ------------ similarly named trait `Struct` defined here + | +help: a trait with a similar name exists (notice the capitalization) + | +LL - fn _g(_: impl struct, _: &dyn struct) +LL + fn _g(_: impl struct, _: &dyn struct) + | error[E0405]: cannot find trait `r#struct` in this scope --> $DIR/kw-in-trait-bounds.rs:30:8 | LL | B: struct, - | ^^^^^^ help: a trait with a similar name exists (notice the capitalization): `Struct` + | ^^^^^^ ... LL | trait Struct {} | ------------ similarly named trait `Struct` defined here + | +help: a trait with a similar name exists (notice the capitalization) + | +LL - B: struct, +LL + B: Struct, + | error[E0405]: cannot find trait `r#struct` in this scope --> $DIR/kw-in-trait-bounds.rs:16:29 | LL | fn _g(_: impl struct, _: &dyn struct) - | ^^^^^^ help: a trait with a similar name exists (notice the capitalization): `Struct` + | ^^^^^^ ... LL | trait Struct {} | ------------ similarly named trait `Struct` defined here + | +help: a trait with a similar name exists (notice the capitalization) + | +LL - fn _g(_: impl struct, _: &dyn struct) +LL + fn _g(_: impl Struct, _: &dyn struct) + | error[E0405]: cannot find trait `r#struct` in this scope --> $DIR/kw-in-trait-bounds.rs:16:45 | LL | fn _g(_: impl struct, _: &dyn struct) - | ^^^^^^ help: a trait with a similar name exists (notice the capitalization): `Struct` + | ^^^^^^ ... LL | trait Struct {} | ------------ similarly named trait `Struct` defined here + | +help: a trait with a similar name exists (notice the capitalization) + | +LL - fn _g(_: impl struct, _: &dyn struct) +LL + fn _g(_: impl struct, _: &dyn Struct) + | error: aborting due to 12 previous errors diff --git a/tests/ui/parser/recover/raw-no-const-mut.stderr b/tests/ui/parser/recover/raw-no-const-mut.stderr index 65032c807953d..3007134f7f5c0 100644 --- a/tests/ui/parser/recover/raw-no-const-mut.stderr +++ b/tests/ui/parser/recover/raw-no-const-mut.stderr @@ -101,7 +101,13 @@ LL | fn a() { | ------ similarly named function `a` defined here ... LL | f(&raw 2); - | ^ help: a function with a similar name exists: `a` + | ^ + | +help: a function with a similar name exists + | +LL - f(&raw 2); +LL + a(&raw 2); + | error: aborting due to 9 previous errors diff --git a/tests/ui/pattern/match-enum-struct-variant-field-missing.stderr b/tests/ui/pattern/match-enum-struct-variant-field-missing.stderr index 326595a7cb706..f449f00a6982d 100644 --- a/tests/ui/pattern/match-enum-struct-variant-field-missing.stderr +++ b/tests/ui/pattern/match-enum-struct-variant-field-missing.stderr @@ -2,10 +2,13 @@ error[E0026]: variant `A::A` does not have a field named `fob` --> $DIR/match-enum-struct-variant-field-missing.rs:12:16 | LL | A::A { fob } => { - | ^^^ - | | - | variant `A::A` does not have this field - | help: a field with a similar name exists: `foo` + | ^^^ variant `A::A` does not have this field + | +help: a field with a similar name exists + | +LL - A::A { fob } => { +LL + A::A { foo } => { + | error: aborting due to 1 previous error diff --git a/tests/ui/pattern/pattern-error-continue.stderr b/tests/ui/pattern/pattern-error-continue.stderr index a9ac96e3eaffb..de90d99a0ff1c 100644 --- a/tests/ui/pattern/pattern-error-continue.stderr +++ b/tests/ui/pattern/pattern-error-continue.stderr @@ -56,10 +56,13 @@ error[E0433]: failed to resolve: use of undeclared type `E` --> $DIR/pattern-error-continue.rs:35:9 | LL | E::V => {} - | ^ - | | - | use of undeclared type `E` - | help: an enum with a similar name exists: `A` + | ^ use of undeclared type `E` + | +help: an enum with a similar name exists + | +LL - E::V => {} +LL + A::V => {} + | error: aborting due to 5 previous errors diff --git a/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.stderr b/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.stderr index a5d9fd2b1a6ec..44e42f1427074 100644 --- a/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.stderr +++ b/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.stderr @@ -38,43 +38,85 @@ error[E0425]: cannot find value `x` in this scope --> $DIR/name-resolution.rs:10:34 | LL | fn bad_fn_item_1(x: bool, ((y if x) | y): bool) {} - | ^ help: a local variable with a similar name exists: `y` + | ^ + | +help: a local variable with a similar name exists + | +LL - fn bad_fn_item_1(x: bool, ((y if x) | y): bool) {} +LL + fn bad_fn_item_1(x: bool, ((y if y) | y): bool) {} + | error[E0425]: cannot find value `y` in this scope --> $DIR/name-resolution.rs:12:25 | LL | fn bad_fn_item_2(((x if y) | x): bool, y: bool) {} - | ^ help: a local variable with a similar name exists: `x` + | ^ + | +help: a local variable with a similar name exists + | +LL - fn bad_fn_item_2(((x if y) | x): bool, y: bool) {} +LL + fn bad_fn_item_2(((x if x) | x): bool, y: bool) {} + | error[E0425]: cannot find value `x` in this scope --> $DIR/name-resolution.rs:20:18 | LL | (x, y if x) => x && y, - | ^ help: a local variable with a similar name exists: `y` + | ^ + | +help: a local variable with a similar name exists + | +LL - (x, y if x) => x && y, +LL + (x, y if y) => x && y, + | error[E0425]: cannot find value `y` in this scope --> $DIR/name-resolution.rs:22:15 | LL | (x if y, y) => x && y, - | ^ help: a local variable with a similar name exists: `x` + | ^ + | +help: a local variable with a similar name exists + | +LL - (x if y, y) => x && y, +LL + (x if x, y) => x && y, + | error[E0425]: cannot find value `x` in this scope --> $DIR/name-resolution.rs:29:20 | LL | (x @ (y if x),) => x && y, - | ^ help: a local variable with a similar name exists: `y` + | ^ + | +help: a local variable with a similar name exists + | +LL - (x @ (y if x),) => x && y, +LL + (x @ (y if y),) => x && y, + | error[E0425]: cannot find value `y` in this scope --> $DIR/name-resolution.rs:37:20 | LL | ((Ok(x) if y) | (Err(y) if x),) => x && y, - | ^ help: a local variable with a similar name exists: `x` + | ^ + | +help: a local variable with a similar name exists + | +LL - ((Ok(x) if y) | (Err(y) if x),) => x && y, +LL + ((Ok(x) if x) | (Err(y) if x),) => x && y, + | error[E0425]: cannot find value `x` in this scope --> $DIR/name-resolution.rs:37:36 | LL | ((Ok(x) if y) | (Err(y) if x),) => x && y, - | ^ help: a local variable with a similar name exists: `y` + | ^ + | +help: a local variable with a similar name exists + | +LL - ((Ok(x) if y) | (Err(y) if x),) => x && y, +LL + ((Ok(x) if y) | (Err(y) if y),) => x && y, + | error[E0425]: cannot find value `nonexistent` in this scope --> $DIR/name-resolution.rs:44:15 @@ -86,49 +128,97 @@ error[E0425]: cannot find value `x` in this scope --> $DIR/name-resolution.rs:46:22 | LL | if let ((x, y if x) | (x if y, y)) = (true, true) { x && y; } - | ^ help: a local variable with a similar name exists: `y` + | ^ + | +help: a local variable with a similar name exists + | +LL - if let ((x, y if x) | (x if y, y)) = (true, true) { x && y; } +LL + if let ((x, y if y) | (x if y, y)) = (true, true) { x && y; } + | error[E0425]: cannot find value `y` in this scope --> $DIR/name-resolution.rs:46:33 | LL | if let ((x, y if x) | (x if y, y)) = (true, true) { x && y; } - | ^ help: a local variable with a similar name exists: `x` + | ^ + | +help: a local variable with a similar name exists + | +LL - if let ((x, y if x) | (x if y, y)) = (true, true) { x && y; } +LL + if let ((x, y if x) | (x if x, y)) = (true, true) { x && y; } + | error[E0425]: cannot find value `x` in this scope --> $DIR/name-resolution.rs:49:25 | LL | while let ((x, y if x) | (x if y, y)) = (true, true) { x && y; } - | ^ help: a local variable with a similar name exists: `y` + | ^ + | +help: a local variable with a similar name exists + | +LL - while let ((x, y if x) | (x if y, y)) = (true, true) { x && y; } +LL + while let ((x, y if y) | (x if y, y)) = (true, true) { x && y; } + | error[E0425]: cannot find value `y` in this scope --> $DIR/name-resolution.rs:49:36 | LL | while let ((x, y if x) | (x if y, y)) = (true, true) { x && y; } - | ^ help: a local variable with a similar name exists: `x` + | ^ + | +help: a local variable with a similar name exists + | +LL - while let ((x, y if x) | (x if y, y)) = (true, true) { x && y; } +LL + while let ((x, y if x) | (x if x, y)) = (true, true) { x && y; } + | error[E0425]: cannot find value `x` in this scope --> $DIR/name-resolution.rs:52:19 | LL | for ((x, y if x) | (x if y, y)) in [(true, true)] { x && y; } - | ^ help: a local variable with a similar name exists: `y` + | ^ + | +help: a local variable with a similar name exists + | +LL - for ((x, y if x) | (x if y, y)) in [(true, true)] { x && y; } +LL + for ((x, y if y) | (x if y, y)) in [(true, true)] { x && y; } + | error[E0425]: cannot find value `y` in this scope --> $DIR/name-resolution.rs:52:30 | LL | for ((x, y if x) | (x if y, y)) in [(true, true)] { x && y; } - | ^ help: a local variable with a similar name exists: `x` + | ^ + | +help: a local variable with a similar name exists + | +LL - for ((x, y if x) | (x if y, y)) in [(true, true)] { x && y; } +LL + for ((x, y if x) | (x if x, y)) in [(true, true)] { x && y; } + | error[E0425]: cannot find value `y` in this scope --> $DIR/name-resolution.rs:57:13 | LL | (|(x if y), (y if x)| x && y)(true, true); - | ^ help: a local variable with a similar name exists: `x` + | ^ + | +help: a local variable with a similar name exists + | +LL - (|(x if y), (y if x)| x && y)(true, true); +LL + (|(x if x), (y if x)| x && y)(true, true); + | error[E0425]: cannot find value `x` in this scope --> $DIR/name-resolution.rs:57:23 | LL | (|(x if y), (y if x)| x && y)(true, true); - | ^ help: a local variable with a similar name exists: `y` + | ^ + | +help: a local variable with a similar name exists + | +LL - (|(x if y), (y if x)| x && y)(true, true); +LL + (|(x if y), (y if y)| x && y)(true, true); + | error[E0308]: mismatched types --> $DIR/name-resolution.rs:75:18 diff --git a/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.stderr b/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.stderr index b985b771754ee..b8c6f1d867a19 100644 --- a/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.stderr +++ b/tests/ui/pattern/struct-pattern-with-missing-fields-resolve-error.stderr @@ -20,7 +20,13 @@ error[E0425]: cannot find value `a` in this scope LL | if let Foo::Bar { .. } = x { | --------------- this pattern doesn't include `a`, which is available in `Bar` LL | println!("{a}"); - | ^ help: a local variable with a similar name exists: `x` + | ^ + | +help: a local variable with a similar name exists + | +LL - println!("{a}"); +LL + println!("{x}"); + | error: aborting due to 3 previous errors diff --git a/tests/ui/proc-macro/gen-macro-rules-hygiene.stderr b/tests/ui/proc-macro/gen-macro-rules-hygiene.stderr index ed8ee4dc52cba..46cdbaccaeb6c 100644 --- a/tests/ui/proc-macro/gen-macro-rules-hygiene.stderr +++ b/tests/ui/proc-macro/gen-macro-rules-hygiene.stderr @@ -13,7 +13,7 @@ error[E0425]: cannot find value `local_use` in this scope --> $DIR/gen-macro-rules-hygiene.rs:13:1 | LL | gen_macro_rules!(); - | ^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `local_def` + | ^^^^^^^^^^^^^^^^^^ ... LL | generated!(); | ------------ in this macro invocation @@ -24,12 +24,17 @@ help: an identifier with the same name exists, but is not accessible due to macr LL | let local_use = 1; | ^^^^^^^^^ = note: this error originates in the macro `generated` (in Nightly builds, run with -Z macro-backtrace for more info) +help: a local variable with a similar name exists + | +LL - gen_macro_rules!(); +LL + local_def; + | error[E0425]: cannot find value `local_def` in this scope --> $DIR/gen-macro-rules-hygiene.rs:22:9 | LL | local_def; - | ^^^^^^^^^ help: a local variable with a similar name exists: `local_use` + | ^^^^^^^^^ | help: an identifier with the same name is defined here, but is not accessible due to macro hygiene --> $DIR/gen-macro-rules-hygiene.rs:13:1 @@ -40,6 +45,11 @@ LL | gen_macro_rules!(); LL | generated!(); | ------------ in this macro invocation = note: this error originates in the macro `generated` (in Nightly builds, run with -Z macro-backtrace for more info) +help: a local variable with a similar name exists + | +LL - local_def; +LL + local_use; + | error: aborting due to 3 previous errors diff --git a/tests/ui/proc-macro/lints_in_proc_macros.stderr b/tests/ui/proc-macro/lints_in_proc_macros.stderr index 016b236bda881..0b8df1b348d7e 100644 --- a/tests/ui/proc-macro/lints_in_proc_macros.stderr +++ b/tests/ui/proc-macro/lints_in_proc_macros.stderr @@ -2,9 +2,14 @@ error[E0425]: cannot find value `foobar2` in this scope --> $DIR/lints_in_proc_macros.rs:10:5 | LL | bang_proc_macro2!(); - | ^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `foobar` + | ^^^^^^^^^^^^^^^^^^^ | = note: this error originates in the macro `bang_proc_macro2` (in Nightly builds, run with -Z macro-backtrace for more info) +help: a local variable with a similar name exists + | +LL - bang_proc_macro2!(); +LL + foobar; + | error: aborting due to 1 previous error diff --git a/tests/ui/proc-macro/mixed-site-span.stderr b/tests/ui/proc-macro/mixed-site-span.stderr index 97e3f3e3dea8c..2cc7ff8a88679 100644 --- a/tests/ui/proc-macro/mixed-site-span.stderr +++ b/tests/ui/proc-macro/mixed-site-span.stderr @@ -592,7 +592,7 @@ error[E0425]: cannot find value `local_use` in this scope --> $DIR/mixed-site-span.rs:23:9 | LL | proc_macro_rules!(); - | ^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `local_def` + | ^^^^^^^^^^^^^^^^^^^ | help: an identifier with the same name exists, but is not accessible due to macro hygiene --> $DIR/mixed-site-span.rs:22:13 @@ -600,12 +600,17 @@ help: an identifier with the same name exists, but is not accessible due to macr LL | let local_use = 1; | ^^^^^^^^^ = note: this error originates in the macro `proc_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info) +help: a local variable with a similar name exists + | +LL - proc_macro_rules!(); +LL + local_def; + | error[E0425]: cannot find value `local_def` in this scope --> $DIR/mixed-site-span.rs:28:9 | LL | local_def; - | ^^^^^^^^^ help: a local variable with a similar name exists: `local_use` + | ^^^^^^^^^ | help: an identifier with the same name is defined here, but is not accessible due to macro hygiene --> $DIR/mixed-site-span.rs:23:9 @@ -613,6 +618,11 @@ help: an identifier with the same name is defined here, but is not accessible du LL | proc_macro_rules!(); | ^^^^^^^^^^^^^^^^^^^ = note: this error originates in the macro `proc_macro_rules` (in Nightly builds, run with -Z macro-backtrace for more info) +help: a local variable with a similar name exists + | +LL - local_def; +LL + local_use; + | error: aborting due to 52 previous errors diff --git a/tests/ui/proc-macro/parent-source-spans.stderr b/tests/ui/proc-macro/parent-source-spans.stderr index 28a70eea873d1..87b8dae74f489 100644 --- a/tests/ui/proc-macro/parent-source-spans.stderr +++ b/tests/ui/proc-macro/parent-source-spans.stderr @@ -140,7 +140,7 @@ error[E0425]: cannot find value `ok` in this scope --> $DIR/parent-source-spans.rs:30:5 | LL | parent_source_spans!($($tokens)*); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple variant with a similar name exists: `Ok` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... LL | one!("hello", "world"); | ---------------------- in this macro invocation @@ -150,12 +150,17 @@ LL | one!("hello", "world"); = note: similarly named tuple variant `Ok` defined here | = note: this error originates in the macro `parent_source_spans` which comes from the expansion of the macro `one` (in Nightly builds, run with -Z macro-backtrace for more info) +help: a tuple variant with a similar name exists + | +LL - parent_source_spans!($($tokens)*); +LL + Ok; + | error[E0425]: cannot find value `ok` in this scope --> $DIR/parent-source-spans.rs:30:5 | LL | parent_source_spans!($($tokens)*); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple variant with a similar name exists: `Ok` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... LL | two!("yay", "rust"); | ------------------- in this macro invocation @@ -165,12 +170,17 @@ LL | two!("yay", "rust"); = note: similarly named tuple variant `Ok` defined here | = note: this error originates in the macro `parent_source_spans` which comes from the expansion of the macro `two` (in Nightly builds, run with -Z macro-backtrace for more info) +help: a tuple variant with a similar name exists + | +LL - parent_source_spans!($($tokens)*); +LL + Ok; + | error[E0425]: cannot find value `ok` in this scope --> $DIR/parent-source-spans.rs:30:5 | LL | parent_source_spans!($($tokens)*); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: a tuple variant with a similar name exists: `Ok` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... LL | three!("hip", "hop"); | -------------------- in this macro invocation @@ -180,6 +190,11 @@ LL | three!("hip", "hop"); = note: similarly named tuple variant `Ok` defined here | = note: this error originates in the macro `parent_source_spans` which comes from the expansion of the macro `three` (in Nightly builds, run with -Z macro-backtrace for more info) +help: a tuple variant with a similar name exists + | +LL - parent_source_spans!($($tokens)*); +LL + Ok; + | error: aborting due to 21 previous errors diff --git a/tests/ui/proc-macro/resolve-error.stderr b/tests/ui/proc-macro/resolve-error.stderr index 45b71a3e7b3af..7efb751caaec3 100644 --- a/tests/ui/proc-macro/resolve-error.stderr +++ b/tests/ui/proc-macro/resolve-error.stderr @@ -2,12 +2,18 @@ error: cannot find macro `bang_proc_macrp` in this scope --> $DIR/resolve-error.rs:60:5 | LL | bang_proc_macrp!(); - | ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `bang_proc_macro` + | ^^^^^^^^^^^^^^^ | ::: $DIR/auxiliary/test-macros.rs:10:1 | LL | pub fn empty(_: TokenStream) -> TokenStream { | ------------------------------------------- similarly named macro `bang_proc_macro` defined here + | +help: a macro with a similar name exists + | +LL - bang_proc_macrp!(); +LL + bang_proc_macro!(); + | error: cannot find macro `Dlona` in this scope --> $DIR/resolve-error.rs:57:5 @@ -22,7 +28,13 @@ LL | macro_rules! attr_proc_mac { | -------------------------- similarly named macro `attr_proc_mac` defined here ... LL | attr_proc_macra!(); - | ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `attr_proc_mac` + | ^^^^^^^^^^^^^^^ + | +help: a macro with a similar name exists + | +LL - attr_proc_macra!(); +LL + attr_proc_mac!(); + | error: cannot find macro `FooWithLongNama` in this scope --> $DIR/resolve-error.rs:51:5 @@ -31,7 +43,13 @@ LL | macro_rules! FooWithLongNam { | --------------------------- similarly named macro `FooWithLongNam` defined here ... LL | FooWithLongNama!(); - | ^^^^^^^^^^^^^^^ help: a macro with a similar name exists: `FooWithLongNam` + | ^^^^^^^^^^^^^^^ + | +help: a macro with a similar name exists + | +LL - FooWithLongNama!(); +LL + FooWithLongNam!(); + | error: cannot find derive macro `attr_proc_macra` in this scope --> $DIR/resolve-error.rs:45:10 @@ -51,18 +69,24 @@ error: cannot find derive macro `Dlona` in this scope --> $DIR/resolve-error.rs:40:10 | LL | #[derive(Dlona)] - | ^^^^^ help: a derive macro with a similar name exists: `Clona` + | ^^^^^ | ::: $DIR/auxiliary/derive-clona.rs:6:1 | LL | pub fn derive_clonea(input: TokenStream) -> TokenStream { | ------------------------------------------------------- similarly named derive macro `Clona` defined here + | +help: a derive macro with a similar name exists + | +LL - #[derive(Dlona)] +LL + #[derive(Clona)] + | error: cannot find derive macro `Dlona` in this scope --> $DIR/resolve-error.rs:40:10 | LL | #[derive(Dlona)] - | ^^^^^ help: a derive macro with a similar name exists: `Clona` + | ^^^^^ | ::: $DIR/auxiliary/derive-clona.rs:6:1 | @@ -70,28 +94,43 @@ LL | pub fn derive_clonea(input: TokenStream) -> TokenStream { | ------------------------------------------------------- similarly named derive macro `Clona` defined here | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: a derive macro with a similar name exists + | +LL - #[derive(Dlona)] +LL + #[derive(Clona)] + | error: cannot find derive macro `Dlone` in this scope --> $DIR/resolve-error.rs:35:10 | LL | #[derive(Dlone)] - | ^^^^^ help: a derive macro with a similar name exists: `Clone` + | ^^^^^ | --> $SRC_DIR/core/src/clone.rs:LL:COL | = note: similarly named derive macro `Clone` defined here +help: a derive macro with a similar name exists + | +LL - #[derive(Dlone)] +LL + #[derive(Clone)] + | error: cannot find derive macro `Dlone` in this scope --> $DIR/resolve-error.rs:35:10 | LL | #[derive(Dlone)] - | ^^^^^ help: a derive macro with a similar name exists: `Clone` + | ^^^^^ | --> $SRC_DIR/core/src/clone.rs:LL:COL | = note: similarly named derive macro `Clone` defined here | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: a derive macro with a similar name exists + | +LL - #[derive(Dlone)] +LL + #[derive(Clone)] + | error: cannot find attribute `FooWithLongNan` in this scope --> $DIR/resolve-error.rs:32:3 @@ -103,29 +142,41 @@ error: cannot find attribute `attr_proc_macra` in this scope --> $DIR/resolve-error.rs:28:3 | LL | #[attr_proc_macra] - | ^^^^^^^^^^^^^^^ help: an attribute macro with a similar name exists: `attr_proc_macro` + | ^^^^^^^^^^^^^^^ | ::: $DIR/auxiliary/test-macros.rs:15:1 | LL | pub fn empty_attr(_: TokenStream, _: TokenStream) -> TokenStream { | ---------------------------------------------------------------- similarly named attribute macro `attr_proc_macro` defined here + | +help: an attribute macro with a similar name exists + | +LL - #[attr_proc_macra] +LL + #[attr_proc_macro] + | error: cannot find derive macro `FooWithLongNan` in this scope --> $DIR/resolve-error.rs:22:10 | LL | #[derive(FooWithLongNan)] - | ^^^^^^^^^^^^^^ help: a derive macro with a similar name exists: `FooWithLongName` + | ^^^^^^^^^^^^^^ | ::: $DIR/auxiliary/derive-foo.rs:6:1 | LL | pub fn derive_foo(input: TokenStream) -> TokenStream { | ---------------------------------------------------- similarly named derive macro `FooWithLongName` defined here + | +help: a derive macro with a similar name exists + | +LL - #[derive(FooWithLongNan)] +LL + #[derive(FooWithLongName)] + | error: cannot find derive macro `FooWithLongNan` in this scope --> $DIR/resolve-error.rs:22:10 | LL | #[derive(FooWithLongNan)] - | ^^^^^^^^^^^^^^ help: a derive macro with a similar name exists: `FooWithLongName` + | ^^^^^^^^^^^^^^ | ::: $DIR/auxiliary/derive-foo.rs:6:1 | @@ -133,6 +184,11 @@ LL | pub fn derive_foo(input: TokenStream) -> TokenStream { | ---------------------------------------------------- similarly named derive macro `FooWithLongName` defined here | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: a derive macro with a similar name exists + | +LL - #[derive(FooWithLongNan)] +LL + #[derive(FooWithLongName)] + | error: aborting due to 14 previous errors diff --git a/tests/ui/regions/outlives-with-missing.stderr b/tests/ui/regions/outlives-with-missing.stderr index b8762e9cb8f3e..25fac19706350 100644 --- a/tests/ui/regions/outlives-with-missing.stderr +++ b/tests/ui/regions/outlives-with-missing.stderr @@ -5,7 +5,13 @@ LL | impl HandlerWrapper { | - similarly named type parameter `H` defined here ... LL | T: Send + Sync + 'static, - | ^ help: a type parameter with a similar name exists: `H` + | ^ + | +help: a type parameter with a similar name exists + | +LL - T: Send + Sync + 'static, +LL + H: Send + Sync + 'static, + | error: aborting due to 1 previous error diff --git a/tests/ui/resolve/112590-2.stderr b/tests/ui/resolve/112590-2.stderr index 28d23ccf85375..d6f4a8f22a456 100644 --- a/tests/ui/resolve/112590-2.stderr +++ b/tests/ui/resolve/112590-2.stderr @@ -63,12 +63,14 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `vec --> $DIR/112590-2.rs:24:24 | LL | let _t: Vec = vec::new(); - | ^^^ - | | - | use of unresolved module or unlinked crate `vec` - | help: a struct with a similar name exists (notice the capitalization): `Vec` + | ^^^ use of unresolved module or unlinked crate `vec` | = help: you might be missing a crate named `vec` +help: a struct with a similar name exists (notice the capitalization) + | +LL - let _t: Vec = vec::new(); +LL + let _t: Vec = Vec::new(); + | error: aborting due to 5 previous errors diff --git a/tests/ui/resolve/issue-10200.stderr b/tests/ui/resolve/issue-10200.stderr index 4b6d9b6f1dfa6..62731960191ff 100644 --- a/tests/ui/resolve/issue-10200.stderr +++ b/tests/ui/resolve/issue-10200.stderr @@ -5,9 +5,14 @@ LL | struct Foo(bool); | ----------------- similarly named tuple struct `Foo` defined here ... LL | foo(x) - | ^^^ help: a tuple struct with a similar name exists (notice the capitalization): `Foo` + | ^^^ | = note: function calls are not allowed in patterns: +help: a tuple struct with a similar name exists (notice the capitalization) + | +LL - foo(x) +LL + Foo(x) + | error: aborting due to 1 previous error diff --git a/tests/ui/resolve/issue-49074.stderr b/tests/ui/resolve/issue-49074.stderr index bbfeb4ea9483a..16a4ede0c0b54 100644 --- a/tests/ui/resolve/issue-49074.stderr +++ b/tests/ui/resolve/issue-49074.stderr @@ -10,7 +10,13 @@ error: cannot find attribute `marco_use` in this scope --> $DIR/issue-49074.rs:3:3 | LL | #[marco_use] // typo - | ^^^^^^^^^ help: a built-in attribute with a similar name exists: `macro_use` + | ^^^^^^^^^ + | +help: a built-in attribute with a similar name exists + | +LL - #[marco_use] // typo +LL + #[macro_use] // typo + | error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/levenshtein.stderr b/tests/ui/resolve/levenshtein.stderr index 7a1abd1343303..48515b9e6bd51 100644 --- a/tests/ui/resolve/levenshtein.stderr +++ b/tests/ui/resolve/levenshtein.stderr @@ -2,7 +2,13 @@ error[E0425]: cannot find type `esize` in this scope --> $DIR/levenshtein.rs:5:11 | LL | fn foo(c: esize) {} // Misspelled primitive type name. - | ^^^^^ help: a builtin type with a similar name exists: `isize` + | ^^^^^ + | +help: a builtin type with a similar name exists + | +LL - fn foo(c: esize) {} // Misspelled primitive type name. +LL + fn foo(c: isize) {} // Misspelled primitive type name. + | error[E0425]: cannot find type `Baz` in this scope --> $DIR/levenshtein.rs:10:10 @@ -11,17 +17,28 @@ LL | enum Bar { } | -------- similarly named enum `Bar` defined here LL | LL | type A = Baz; // Misspelled type name. - | ^^^ help: an enum with a similar name exists: `Bar` + | ^^^ + | +help: an enum with a similar name exists + | +LL - type A = Baz; // Misspelled type name. +LL + type A = Bar; // Misspelled type name. + | error[E0425]: cannot find type `Opiton` in this scope --> $DIR/levenshtein.rs:12:10 | LL | type B = Opiton; // Misspelled type name from the prelude. - | ^^^^^^ help: an enum with a similar name exists: `Option` + | ^^^^^^ | --> $SRC_DIR/core/src/option.rs:LL:COL | = note: similarly named enum `Option` defined here +help: an enum with a similar name exists + | +LL - type B = Opiton; // Misspelled type name from the prelude. +LL + type B = Option; // Misspelled type name from the prelude. + | error[E0425]: cannot find type `Baz` in this scope --> $DIR/levenshtein.rs:16:14 @@ -36,7 +53,12 @@ LL | const MAX_ITEM: usize = 10; | --------------------------- similarly named constant `MAX_ITEM` defined here ... LL | let v = [0u32; MAXITEM]; // Misspelled constant name. - | ^^^^^^^ help: a constant with a similar name exists: `MAX_ITEM` + | ^^^^^^^ + | +help: a constant with a similar name exists + | +LL | let v = [0u32; MAX_ITEM]; // Misspelled constant name. + | + error[E0425]: cannot find type `first` in module `m` --> $DIR/levenshtein.rs:28:15 @@ -45,7 +67,13 @@ LL | pub struct First; | ----------------- similarly named struct `First` defined here ... LL | let b: m::first = m::second; // Misspelled item in module. - | ^^^^^ help: a struct with a similar name exists (notice the capitalization): `First` + | ^^^^^ + | +help: a struct with a similar name exists (notice the capitalization) + | +LL - let b: m::first = m::second; // Misspelled item in module. +LL + let b: m::First = m::second; // Misspelled item in module. + | error[E0425]: cannot find value `second` in module `m` --> $DIR/levenshtein.rs:28:26 @@ -54,7 +82,13 @@ LL | pub struct Second; | ------------------ similarly named unit struct `Second` defined here ... LL | let b: m::first = m::second; // Misspelled item in module. - | ^^^^^^ help: a unit struct with a similar name exists (notice the capitalization): `Second` + | ^^^^^^ + | +help: a unit struct with a similar name exists (notice the capitalization) + | +LL - let b: m::first = m::second; // Misspelled item in module. +LL + let b: m::first = m::Second; // Misspelled item in module. + | error[E0425]: cannot find function `foobar` in this scope --> $DIR/levenshtein.rs:26:5 @@ -63,7 +97,12 @@ LL | fn foo_bar() {} | ------------ similarly named function `foo_bar` defined here ... LL | foobar(); // Misspelled function name. - | ^^^^^^ help: a function with a similar name exists: `foo_bar` + | ^^^^^^ + | +help: a function with a similar name exists + | +LL | foo_bar(); // Misspelled function name. + | + error: aborting due to 8 previous errors diff --git a/tests/ui/resolve/privacy-enum-ctor.stderr b/tests/ui/resolve/privacy-enum-ctor.stderr index 81356c5040f8b..5349108065dc9 100644 --- a/tests/ui/resolve/privacy-enum-ctor.stderr +++ b/tests/ui/resolve/privacy-enum-ctor.stderr @@ -149,13 +149,18 @@ LL | pub enum E { | ---------- similarly named enum `E` defined here ... LL | let _: Z = m::n::Z; - | ^ help: an enum with a similar name exists: `E` + | ^ | note: enum `m::Z` exists but is inaccessible --> $DIR/privacy-enum-ctor.rs:12:9 | LL | pub(in crate::m) enum Z { | ^^^^^^^^^^^^^^^^^^^^^^^ not accessible +help: an enum with a similar name exists + | +LL - let _: Z = m::n::Z; +LL + let _: E = m::n::Z; + | error[E0423]: expected value, found enum `m::n::Z` --> $DIR/privacy-enum-ctor.rs:58:16 @@ -192,13 +197,18 @@ LL | pub enum E { | ---------- similarly named enum `E` defined here ... LL | let _: Z = m::n::Z::Fn; - | ^ help: an enum with a similar name exists: `E` + | ^ | note: enum `m::Z` exists but is inaccessible --> $DIR/privacy-enum-ctor.rs:12:9 | LL | pub(in crate::m) enum Z { | ^^^^^^^^^^^^^^^^^^^^^^^ not accessible +help: an enum with a similar name exists + | +LL - let _: Z = m::n::Z::Fn; +LL + let _: E = m::n::Z::Fn; + | error[E0425]: cannot find type `Z` in this scope --> $DIR/privacy-enum-ctor.rs:65:12 @@ -207,13 +217,18 @@ LL | pub enum E { | ---------- similarly named enum `E` defined here ... LL | let _: Z = m::n::Z::Struct; - | ^ help: an enum with a similar name exists: `E` + | ^ | note: enum `m::Z` exists but is inaccessible --> $DIR/privacy-enum-ctor.rs:12:9 | LL | pub(in crate::m) enum Z { | ^^^^^^^^^^^^^^^^^^^^^^^ not accessible +help: an enum with a similar name exists + | +LL - let _: Z = m::n::Z::Struct; +LL + let _: E = m::n::Z::Struct; + | error[E0425]: cannot find type `Z` in this scope --> $DIR/privacy-enum-ctor.rs:69:12 @@ -222,13 +237,18 @@ LL | pub enum E { | ---------- similarly named enum `E` defined here ... LL | let _: Z = m::n::Z::Unit {}; - | ^ help: an enum with a similar name exists: `E` + | ^ | note: enum `m::Z` exists but is inaccessible --> $DIR/privacy-enum-ctor.rs:12:9 | LL | pub(in crate::m) enum Z { | ^^^^^^^^^^^^^^^^^^^^^^^ not accessible +help: an enum with a similar name exists + | +LL - let _: Z = m::n::Z::Unit {}; +LL + let _: E = m::n::Z::Unit {}; + | error[E0603]: enum `Z` is private --> $DIR/privacy-enum-ctor.rs:58:22 diff --git a/tests/ui/resolve/privacy-struct-ctor.stderr b/tests/ui/resolve/privacy-struct-ctor.stderr index 96c3e6e5122df..5a01d51d24ffd 100644 --- a/tests/ui/resolve/privacy-struct-ctor.stderr +++ b/tests/ui/resolve/privacy-struct-ctor.stderr @@ -5,10 +5,13 @@ LL | pub struct S(u8); | ----------------- similarly named tuple struct `S` defined here ... LL | Z; - | ^ - | | - | constructor is not visible here due to private fields - | help: a tuple struct with a similar name exists: `S` + | ^ constructor is not visible here due to private fields + | +help: a tuple struct with a similar name exists + | +LL - Z; +LL + S; + | error[E0423]: expected value, found struct `S` --> $DIR/privacy-struct-ctor.rs:34:5 diff --git a/tests/ui/resolve/suggestions/suggest-path-instead-of-mod-dot-item.stderr b/tests/ui/resolve/suggestions/suggest-path-instead-of-mod-dot-item.stderr index 5db943cd10d0f..89c0cd54faeee 100644 --- a/tests/ui/resolve/suggestions/suggest-path-instead-of-mod-dot-item.stderr +++ b/tests/ui/resolve/suggestions/suggest-path-instead-of-mod-dot-item.stderr @@ -73,9 +73,13 @@ LL | pub const I: i32 = 1; | --------------------- similarly named constant `I` defined here ... LL | v.push(a::b); - | ^^^- - | | - | help: a constant with a similar name exists: `I` + | ^^^^ + | +help: a constant with a similar name exists + | +LL - v.push(a::b); +LL + v.push(a::I); + | error[E0423]: expected value, found module `a::b` --> $DIR/suggest-path-instead-of-mod-dot-item.rs:52:5 @@ -104,9 +108,13 @@ LL | pub const I: i32 = 1; | --------------------- similarly named constant `I` defined here ... LL | a::b - | ^^^- - | | - | help: a constant with a similar name exists: `I` + | ^^^^ + | +help: a constant with a similar name exists + | +LL - a::b +LL + a::I + | error[E0423]: expected function, found module `a::b` --> $DIR/suggest-path-instead-of-mod-dot-item.rs:65:5 @@ -115,9 +123,13 @@ LL | pub const I: i32 = 1; | --------------------- similarly named constant `I` defined here ... LL | a::b() - | ^^^- - | | - | help: a constant with a similar name exists: `I` + | ^^^^ + | +help: a constant with a similar name exists + | +LL - a::b() +LL + a::I() + | error[E0423]: expected value, found module `a` --> $DIR/suggest-path-instead-of-mod-dot-item.rs:72:9 diff --git a/tests/ui/resolve/tuple-struct-alias.stderr b/tests/ui/resolve/tuple-struct-alias.stderr index bf026a499b8c2..89b536708372b 100644 --- a/tests/ui/resolve/tuple-struct-alias.stderr +++ b/tests/ui/resolve/tuple-struct-alias.stderr @@ -5,7 +5,13 @@ LL | struct S(u8, u16); | ------------------ similarly named tuple struct `S` defined here ... LL | A(..) => {} - | ^ help: a tuple struct with a similar name exists: `S` + | ^ + | +help: a tuple struct with a similar name exists + | +LL - A(..) => {} +LL + S(..) => {} + | error[E0423]: expected function, tuple struct or tuple variant, found type alias `A` --> $DIR/tuple-struct-alias.rs:5:13 diff --git a/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr index 039410f8795f8..9c874d980cbe1 100644 --- a/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr +++ b/tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr @@ -5,7 +5,13 @@ LL | config: String, | ------ a field by that name exists in `Self` ... LL | Self { config } - | ^^^^^^ help: a local variable with a similar name exists: `cofig` + | ^^^^^^ + | +help: a local variable with a similar name exists + | +LL - Self { config } +LL + Self { cofig } + | error[E0425]: cannot find value `config` in this scope --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:11:20 @@ -14,15 +20,26 @@ LL | config: String, | ------ a field by that name exists in `Self` ... LL | println!("{config}"); - | ^^^^^^ help: a local variable with a similar name exists: `cofig` + | ^^^^^^ + | +help: a local variable with a similar name exists + | +LL - println!("{config}"); +LL + println!("{cofig}"); + | error[E0425]: cannot find value `config` in this scope --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:15:20 | LL | println!("{config}"); - | ^^^^^^ help: a local variable with a similar name exists: `cofig` + | ^^^^^^ | = help: you might have meant to use the available field in a format string: `"{}", self.config` +help: a local variable with a similar name exists + | +LL - println!("{config}"); +LL + println!("{cofig}"); + | error[E0425]: cannot find value `bah` in this scope --> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:33:9 diff --git a/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr b/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr index 2d0d0d0f38670..fef1f52b86b7e 100644 --- a/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr +++ b/tests/ui/resolve/typo-suggestion-mistyped-in-path.stderr @@ -2,10 +2,12 @@ error[E0433]: failed to resolve: could not find `Struc` in `module` --> $DIR/typo-suggestion-mistyped-in-path.rs:35:13 | LL | module::Struc::foo(); - | ^^^^^ - | | - | could not find `Struc` in `module` - | help: a struct with a similar name exists: `Struct` + | ^^^^^ could not find `Struc` in `module` + | +help: a struct with a similar name exists + | +LL | module::Struct::foo(); + | + error[E0599]: no function or associated item named `fob` found for struct `Struct` in the current scope --> $DIR/typo-suggestion-mistyped-in-path.rs:23:13 @@ -26,10 +28,12 @@ error[E0433]: failed to resolve: use of undeclared type `Struc` --> $DIR/typo-suggestion-mistyped-in-path.rs:27:5 | LL | Struc::foo(); - | ^^^^^ - | | - | use of undeclared type `Struc` - | help: a struct with a similar name exists: `Struct` + | ^^^^^ use of undeclared type `Struc` + | +help: a struct with a similar name exists + | +LL | Struct::foo(); + | + error[E0433]: failed to resolve: use of unresolved module or unlinked crate `modul` --> $DIR/typo-suggestion-mistyped-in-path.rs:31:5 @@ -46,10 +50,12 @@ error[E0433]: failed to resolve: use of undeclared type `Trai` --> $DIR/typo-suggestion-mistyped-in-path.rs:39:5 | LL | Trai::foo(); - | ^^^^ - | | - | use of undeclared type `Trai` - | help: a trait with a similar name exists: `Trait` + | ^^^^ use of undeclared type `Trai` + | +help: a trait with a similar name exists + | +LL | Trait::foo(); + | + error: aborting due to 5 previous errors diff --git a/tests/ui/span/suggestion-raw-68962.stderr b/tests/ui/span/suggestion-raw-68962.stderr index 2e25f5cbdf58d..2271acf15a802 100644 --- a/tests/ui/span/suggestion-raw-68962.stderr +++ b/tests/ui/span/suggestion-raw-68962.stderr @@ -2,7 +2,13 @@ error[E0425]: cannot find value `fina` in this scope --> $DIR/suggestion-raw-68962.rs:7:5 | LL | fina; - | ^^^^ help: a local variable with a similar name exists: `r#final` + | ^^^^ + | +help: a local variable with a similar name exists + | +LL - fina; +LL + r#final; + | error[E0425]: cannot find function `f` in this scope --> $DIR/suggestion-raw-68962.rs:10:5 @@ -11,7 +17,13 @@ LL | fn r#fn() {} | --------- similarly named function `r#fn` defined here ... LL | f(); - | ^ help: a function with a similar name exists: `r#fn` + | ^ + | +help: a function with a similar name exists + | +LL - f(); +LL + r#fn(); + | error: aborting due to 2 previous errors diff --git a/tests/ui/span/typo-suggestion.stderr b/tests/ui/span/typo-suggestion.stderr index 61d4e06119c4f..1f679221c0026 100644 --- a/tests/ui/span/typo-suggestion.stderr +++ b/tests/ui/span/typo-suggestion.stderr @@ -8,7 +8,13 @@ error[E0425]: cannot find value `fob` in this scope --> $DIR/typo-suggestion.rs:8:26 | LL | println!("Hello {}", fob); - | ^^^ help: a local variable with a similar name exists: `foo` + | ^^^ + | +help: a local variable with a similar name exists + | +LL - println!("Hello {}", fob); +LL + println!("Hello {}", foo); + | error: aborting due to 2 previous errors diff --git a/tests/ui/stability-attribute/issue-109177.stderr b/tests/ui/stability-attribute/issue-109177.stderr index 9c2ac591ace05..6f89bde7f8945 100644 --- a/tests/ui/stability-attribute/issue-109177.stderr +++ b/tests/ui/stability-attribute/issue-109177.stderr @@ -2,12 +2,18 @@ error[E0425]: cannot find function `foo1` in crate `similar_unstable_method` --> $DIR/issue-109177.rs:7:30 | LL | similar_unstable_method::foo1(); - | ^^^^ help: a function with a similar name exists: `foo` + | ^^^^ | ::: $DIR/auxiliary/similar-unstable-method.rs:5:1 | LL | pub fn foo() {} | ------------ similarly named function `foo` defined here + | +help: a function with a similar name exists + | +LL - similar_unstable_method::foo1(); +LL + similar_unstable_method::foo(); + | error[E0599]: no method named `foo1` found for struct `Foo` in the current scope --> $DIR/issue-109177.rs:11:9 diff --git a/tests/ui/structs/struct-fields-shorthand-unresolved.stderr b/tests/ui/structs/struct-fields-shorthand-unresolved.stderr index b485c17c1b270..5d8321130958a 100644 --- a/tests/ui/structs/struct-fields-shorthand-unresolved.stderr +++ b/tests/ui/structs/struct-fields-shorthand-unresolved.stderr @@ -2,7 +2,13 @@ error[E0425]: cannot find value `y` in this scope --> $DIR/struct-fields-shorthand-unresolved.rs:10:9 | LL | y - | ^ help: a local variable with a similar name exists: `x` + | ^ + | +help: a local variable with a similar name exists + | +LL - y +LL + x + | error: aborting due to 1 previous error diff --git a/tests/ui/suggestions/attribute-typos.stderr b/tests/ui/suggestions/attribute-typos.stderr index 1816a27dcdc8e..960e0b0f620ff 100644 --- a/tests/ui/suggestions/attribute-typos.stderr +++ b/tests/ui/suggestions/attribute-typos.stderr @@ -8,23 +8,38 @@ error: cannot find attribute `rustc_dumm` in this scope --> $DIR/attribute-typos.rs:7:3 | LL | #[rustc_dumm] - | ^^^^^^^^^^ help: a built-in attribute with a similar name exists: `rustc_dummy` + | ^^^^^^^^^^ + | +help: a built-in attribute with a similar name exists + | +LL | #[rustc_dummy] + | + error: cannot find attribute `tests` in this scope --> $DIR/attribute-typos.rs:4:3 | LL | #[tests] - | ^^^^^ help: an attribute macro with a similar name exists: `test` + | ^^^^^ | --> $SRC_DIR/core/src/macros/mod.rs:LL:COL | = note: similarly named attribute macro `test` defined here +help: an attribute macro with a similar name exists + | +LL - #[tests] +LL + #[test] + | error: cannot find attribute `deprcated` in this scope --> $DIR/attribute-typos.rs:1:3 | LL | #[deprcated] - | ^^^^^^^^^ help: a built-in attribute with a similar name exists: `deprecated` + | ^^^^^^^^^ + | +help: a built-in attribute with a similar name exists + | +LL | #[deprecated] + | + error: aborting due to 4 previous errors diff --git a/tests/ui/suggestions/case-difference-suggestions.stderr b/tests/ui/suggestions/case-difference-suggestions.stderr index c3d2410a6eb20..198c3c7a38c91 100644 --- a/tests/ui/suggestions/case-difference-suggestions.stderr +++ b/tests/ui/suggestions/case-difference-suggestions.stderr @@ -2,97 +2,193 @@ error[E0425]: cannot find value `Hello` in this scope --> $DIR/case-difference-suggestions.rs:5:20 | LL | println!("{}", Hello); - | ^^^^^ help: a local variable with a similar name exists: `hello` + | ^^^^^ + | +help: a local variable with a similar name exists + | +LL - println!("{}", Hello); +LL + println!("{}", hello); + | error[E0425]: cannot find value `myvariable` in this scope --> $DIR/case-difference-suggestions.rs:9:20 | LL | println!("{}", myvariable); - | ^^^^^^^^^^ help: a local variable with a similar name exists (notice the capitalization): `myVariable` + | ^^^^^^^^^^ + | +help: a local variable with a similar name exists (notice the capitalization) + | +LL - println!("{}", myvariable); +LL + println!("{}", myVariable); + | error[E0425]: cannot find value `User_Name` in this scope --> $DIR/case-difference-suggestions.rs:13:20 | LL | println!("{}", User_Name); - | ^^^^^^^^^ help: a local variable with a similar name exists: `user_name` + | ^^^^^^^^^ + | +help: a local variable with a similar name exists + | +LL - println!("{}", User_Name); +LL + println!("{}", user_name); + | error[E0425]: cannot find value `foo` in this scope --> $DIR/case-difference-suggestions.rs:17:20 | LL | println!("{}", foo); - | ^^^ help: a local variable with a similar name exists (notice the capitalization): `FOO` + | ^^^ + | +help: a local variable with a similar name exists (notice the capitalization) + | +LL - println!("{}", foo); +LL + println!("{}", FOO); + | error[E0425]: cannot find value `FFOO` in this scope --> $DIR/case-difference-suggestions.rs:22:20 | LL | println!("{}", FFOO); - | ^^^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `FFO0` + | ^^^^ + | +help: a local variable with a similar name exists (notice the digit/letter confusion) + | +LL - println!("{}", FFOO); +LL + println!("{}", FFO0); + | error[E0425]: cannot find value `list` in this scope --> $DIR/case-difference-suggestions.rs:25:20 | LL | println!("{}", list); - | ^^^^ help: a local variable with a similar name exists: `l1st` + | ^^^^ + | +help: a local variable with a similar name exists + | +LL - println!("{}", list); +LL + println!("{}", l1st); + | error[E0425]: cannot find value `SS` in this scope --> $DIR/case-difference-suggestions.rs:28:20 | LL | println!("{}", SS); - | ^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `S5` + | ^^ + | +help: a local variable with a similar name exists (notice the digit/letter confusion) + | +LL - println!("{}", SS); +LL + println!("{}", S5); + | error[E0425]: cannot find value `a55` in this scope --> $DIR/case-difference-suggestions.rs:31:20 | LL | println!("{}", a55); - | ^^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `aS5` + | ^^^ + | +help: a local variable with a similar name exists (notice the digit/letter confusion) + | +LL - println!("{}", a55); +LL + println!("{}", aS5); + | error[E0425]: cannot find value `BB` in this scope --> $DIR/case-difference-suggestions.rs:34:20 | LL | println!("{}", BB); - | ^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `B8` + | ^^ + | +help: a local variable with a similar name exists (notice the digit/letter confusion) + | +LL - println!("{}", BB); +LL + println!("{}", B8); + | error[E0425]: cannot find value `gg` in this scope --> $DIR/case-difference-suggestions.rs:37:20 | LL | println!("{}", gg); - | ^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `g9` + | ^^ + | +help: a local variable with a similar name exists (notice the digit/letter confusion) + | +LL - println!("{}", gg); +LL + println!("{}", g9); + | error[E0425]: cannot find value `old` in this scope --> $DIR/case-difference-suggestions.rs:40:20 | LL | println!("{}", old); - | ^^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `o1d` + | ^^^ + | +help: a local variable with a similar name exists (notice the digit/letter confusion) + | +LL - println!("{}", old); +LL + println!("{}", o1d); + | error[E0425]: cannot find value `newl` in this scope --> $DIR/case-difference-suggestions.rs:43:20 | LL | println!("{}", newl); - | ^^^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `new1` + | ^^^^ + | +help: a local variable with a similar name exists (notice the digit/letter confusion) + | +LL - println!("{}", newl); +LL + println!("{}", new1); + | error[E0425]: cannot find value `app1e` in this scope --> $DIR/case-difference-suggestions.rs:46:20 | LL | println!("{}", app1e); - | ^^^^^ help: a local variable with a similar name exists (notice the digit/letter confusion): `apple` + | ^^^^^ + | +help: a local variable with a similar name exists (notice the digit/letter confusion) + | +LL - println!("{}", app1e); +LL + println!("{}", apple); + | error[E0425]: cannot find value `A` in this scope --> $DIR/case-difference-suggestions.rs:49:20 | LL | println!("{}", A); - | ^ help: a local variable with a similar name exists: `a` + | ^ + | +help: a local variable with a similar name exists + | +LL - println!("{}", A); +LL + println!("{}", a); + | error[E0425]: cannot find value `world1U` in this scope --> $DIR/case-difference-suggestions.rs:52:20 | LL | println!("{}", world1U); - | ^^^^^^^ help: a local variable with a similar name exists (notice the capitalization and digit/letter confusion): `worldlu` + | ^^^^^^^ + | +help: a local variable with a similar name exists (notice the capitalization and digit/letter confusion) + | +LL - println!("{}", world1U); +LL + println!("{}", worldlu); + | error[E0425]: cannot find value `myv4r1able` in this scope --> $DIR/case-difference-suggestions.rs:55:20 | LL | println!("{}", myv4r1able); - | ^^^^^^^^^^ help: a local variable with a similar name exists (notice the capitalization and digit/letter confusion): `myV4rlable` + | ^^^^^^^^^^ + | +help: a local variable with a similar name exists (notice the capitalization and digit/letter confusion) + | +LL - println!("{}", myv4r1able); +LL + println!("{}", myV4rlable); + | error: aborting due to 16 previous errors diff --git a/tests/ui/suggestions/do-not-attempt-to-add-suggestions-with-no-changes.stderr b/tests/ui/suggestions/do-not-attempt-to-add-suggestions-with-no-changes.stderr index 112ed6fffd504..e54e5acffe8f8 100644 --- a/tests/ui/suggestions/do-not-attempt-to-add-suggestions-with-no-changes.stderr +++ b/tests/ui/suggestions/do-not-attempt-to-add-suggestions-with-no-changes.stderr @@ -2,11 +2,16 @@ error[E0573]: expected type, found module `result` --> $DIR/do-not-attempt-to-add-suggestions-with-no-changes.rs:3:6 | LL | impl result { - | ^^^^^^ help: an enum with a similar name exists: `Result` + | ^^^^^^ | --> $SRC_DIR/core/src/result.rs:LL:COL | = note: similarly named enum `Result` defined here +help: an enum with a similar name exists + | +LL - impl result { +LL + impl Result { + | error[E0573]: expected type, found variant `Err` --> $DIR/do-not-attempt-to-add-suggestions-with-no-changes.rs:4:25 diff --git a/tests/ui/suggestions/issue-66968-suggest-sorted-words.stderr b/tests/ui/suggestions/issue-66968-suggest-sorted-words.stderr index ce0087fbfcbab..b55353c9e6e47 100644 --- a/tests/ui/suggestions/issue-66968-suggest-sorted-words.stderr +++ b/tests/ui/suggestions/issue-66968-suggest-sorted-words.stderr @@ -2,7 +2,13 @@ error[E0425]: cannot find value `a_variable_longer_name` in this scope --> $DIR/issue-66968-suggest-sorted-words.rs:3:20 | LL | println!("{}", a_variable_longer_name); - | ^^^^^^^^^^^^^^^^^^^^^^ help: a local variable with a similar name exists: `a_longer_variable_name` + | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: a local variable with a similar name exists + | +LL - println!("{}", a_variable_longer_name); +LL + println!("{}", a_longer_variable_name); + | error: aborting due to 1 previous error diff --git a/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr b/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr index 40936ce1ec34d..660bbc120d0ed 100644 --- a/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr +++ b/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr @@ -84,11 +84,15 @@ error[E0404]: expected trait, found struct `String` --> $DIR/assoc_type_bound_with_struct.rs:19:51 | LL | fn issue_95327() where ::Assoc: String {} - | ^^^^^^ help: a trait with a similar name exists: `ToString` + | ^^^^^^ | --> $SRC_DIR/alloc/src/string.rs:LL:COL | = note: similarly named trait `ToString` defined here +help: a trait with a similar name exists + | +LL | fn issue_95327() where ::Assoc: ToString {} + | ++ error: aborting due to 6 previous errors diff --git a/tests/ui/traits/const-traits/ice-120503-async-const-method.stderr b/tests/ui/traits/const-traits/ice-120503-async-const-method.stderr index e499451d8971b..d2eea3a805d99 100644 --- a/tests/ui/traits/const-traits/ice-120503-async-const-method.stderr +++ b/tests/ui/traits/const-traits/ice-120503-async-const-method.stderr @@ -42,10 +42,16 @@ error[E0425]: cannot find function `main8` in this scope --> $DIR/ice-120503-async-const-method.rs:11:9 | LL | main8().await; - | ^^^^^ help: a function with a similar name exists: `main` + | ^^^^^ ... LL | fn main() {} | --------- similarly named function `main` defined here + | +help: a function with a similar name exists + | +LL - main8().await; +LL + main().await; + | error: aborting due to 5 previous errors diff --git a/tests/ui/traits/const-traits/mismatched_generic_args.stderr b/tests/ui/traits/const-traits/mismatched_generic_args.stderr index 8e12b40381fd2..e8103313dc4f6 100644 --- a/tests/ui/traits/const-traits/mismatched_generic_args.stderr +++ b/tests/ui/traits/const-traits/mismatched_generic_args.stderr @@ -5,7 +5,13 @@ LL | pub fn add(x: Quantity) -> Quantity { | - similarly named const parameter `U` defined here LL | LL | x + y - | ^ help: a const parameter with a similar name exists: `U` + | ^ + | +help: a const parameter with a similar name exists + | +LL - x + y +LL + x + U + | warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/mismatched_generic_args.rs:1:12 diff --git a/tests/ui/traits/impl-for-module.stderr b/tests/ui/traits/impl-for-module.stderr index b715c699e89f1..1011a913a4ab7 100644 --- a/tests/ui/traits/impl-for-module.stderr +++ b/tests/ui/traits/impl-for-module.stderr @@ -5,7 +5,13 @@ LL | trait A { | ------- similarly named trait `A` defined here ... LL | impl A for a { - | ^ help: a trait with a similar name exists: `A` + | ^ + | +help: a trait with a similar name exists + | +LL - impl A for a { +LL + impl A for A { + | error: aborting due to 1 previous error diff --git a/tests/ui/type-alias-impl-trait/type-error-drop-elaboration.stderr b/tests/ui/type-alias-impl-trait/type-error-drop-elaboration.stderr index 1cb33eabd902e..e5c35d58b72dc 100644 --- a/tests/ui/type-alias-impl-trait/type-error-drop-elaboration.stderr +++ b/tests/ui/type-alias-impl-trait/type-error-drop-elaboration.stderr @@ -2,10 +2,16 @@ error[E0425]: cannot find function `value` in this scope --> $DIR/type-error-drop-elaboration.rs:12:5 | LL | value() - | ^^^^^ help: a constant with a similar name exists: `VALUE` + | ^^^^^ ... LL | const VALUE: Foo = foo(); | ------------------------- similarly named constant `VALUE` defined here + | +help: a constant with a similar name exists + | +LL - value() +LL + VALUE() + | error: aborting due to 1 previous error diff --git a/tests/ui/type/issue-7607-1.stderr b/tests/ui/type/issue-7607-1.stderr index ac6034da75f1b..8edd0d31d7918 100644 --- a/tests/ui/type/issue-7607-1.stderr +++ b/tests/ui/type/issue-7607-1.stderr @@ -2,11 +2,16 @@ error[E0425]: cannot find type `Fo` in this scope --> $DIR/issue-7607-1.rs:5:6 | LL | impl Fo { - | ^^ help: a trait with a similar name exists: `Fn` + | ^^ | --> $SRC_DIR/core/src/ops/function.rs:LL:COL | = note: similarly named trait `Fn` defined here +help: a trait with a similar name exists + | +LL - impl Fo { +LL + impl Fn { + | error: aborting due to 1 previous error diff --git a/tests/ui/typeck/issue-114423-ice-regression-in-suggestion.stderr b/tests/ui/typeck/issue-114423-ice-regression-in-suggestion.stderr index 4ccfacfb00521..1d766e6e5cdb0 100644 --- a/tests/ui/typeck/issue-114423-ice-regression-in-suggestion.stderr +++ b/tests/ui/typeck/issue-114423-ice-regression-in-suggestion.stderr @@ -14,7 +14,13 @@ error[E0425]: cannot find value `g` in this scope --> $DIR/issue-114423-ice-regression-in-suggestion.rs:11:22 | LL | let _ = RGB { r, g, b }; - | ^ help: a local variable with a similar name exists: `b` + | ^ + | +help: a local variable with a similar name exists + | +LL - let _ = RGB { r, g, b }; +LL + let _ = RGB { r, b, b }; + | error[E0308]: mismatched types --> $DIR/issue-114423-ice-regression-in-suggestion.rs:7:50 diff --git a/tests/ui/typeck/issue-120856.stderr b/tests/ui/typeck/issue-120856.stderr index e366744409f4e..4ff9f345c48b0 100644 --- a/tests/ui/typeck/issue-120856.stderr +++ b/tests/ui/typeck/issue-120856.stderr @@ -2,23 +2,26 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `n` --> $DIR/issue-120856.rs:1:37 | LL | pub type Archived = ::Archived; - | ^ - | | - | use of unresolved module or unlinked crate `n` - | help: a trait with a similar name exists: `Fn` + | ^ use of unresolved module or unlinked crate `n` | = help: you might be missing a crate named `n` +help: a trait with a similar name exists + | +LL | pub type Archived = ::Archived; + | + error[E0433]: failed to resolve: use of unresolved module or unlinked crate `m` --> $DIR/issue-120856.rs:1:25 | LL | pub type Archived = ::Archived; - | ^ - | | - | use of unresolved module or unlinked crate `m` - | help: a type parameter with a similar name exists: `T` + | ^ use of unresolved module or unlinked crate `m` | = help: you might be missing a crate named `m` +help: a type parameter with a similar name exists + | +LL - pub type Archived = ::Archived; +LL + pub type Archived = ::Archived; + | error: aborting due to 2 previous errors diff --git a/tests/ui/typeck/issue-83693.stderr b/tests/ui/typeck/issue-83693.stderr index 521288c434022..2f83e5daff97e 100644 --- a/tests/ui/typeck/issue-83693.stderr +++ b/tests/ui/typeck/issue-83693.stderr @@ -2,11 +2,15 @@ error[E0425]: cannot find type `F` in this scope --> $DIR/issue-83693.rs:6:6 | LL | impl F { - | ^ help: a trait with a similar name exists: `Fn` + | ^ | --> $SRC_DIR/core/src/ops/function.rs:LL:COL | = note: similarly named trait `Fn` defined here +help: a trait with a similar name exists + | +LL | impl Fn { + | + error[E0425]: cannot find type `TestResult` in this scope --> $DIR/issue-83693.rs:9:22 diff --git a/tests/ui/typeck/issue-88844.stderr b/tests/ui/typeck/issue-88844.stderr index a5f4310c34dde..6d21317dfd7f5 100644 --- a/tests/ui/typeck/issue-88844.stderr +++ b/tests/ui/typeck/issue-88844.stderr @@ -5,7 +5,12 @@ LL | struct Struct { value: i32 } | ------------- similarly named struct `Struct` defined here ... LL | impl Stuct { - | ^^^^^ help: a struct with a similar name exists: `Struct` + | ^^^^^ + | +help: a struct with a similar name exists + | +LL | impl Struct { + | + error: aborting due to 1 previous error diff --git a/tests/ui/ufcs/ufcs-partially-resolved.stderr b/tests/ui/ufcs/ufcs-partially-resolved.stderr index a854ecb062224..e1df200feccff 100644 --- a/tests/ui/ufcs/ufcs-partially-resolved.stderr +++ b/tests/ui/ufcs/ufcs-partially-resolved.stderr @@ -5,17 +5,27 @@ LL | type Y = u16; | ------------- similarly named associated type `Y` defined here ... LL | let _: ::N; - | ^ help: an associated type with a similar name exists: `Y` + | ^ + | +help: an associated type with a similar name exists + | +LL - let _: ::N; +LL + let _: ::Y; + | error[E0404]: expected trait, found enum `E` --> $DIR/ufcs-partially-resolved.rs:20:19 | LL | let _: ::N; - | ^ help: a trait with a similar name exists: `Eq` + | ^ | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here +help: a trait with a similar name exists + | +LL | let _: ::N; + | + error[E0404]: expected trait, found type alias `A` --> $DIR/ufcs-partially-resolved.rs:21:19 @@ -36,17 +46,27 @@ LL | fn Y() {} | ------ similarly named associated function `Y` defined here ... LL | ::N; - | ^ help: an associated function with a similar name exists: `Y` + | ^ + | +help: an associated function with a similar name exists + | +LL - ::N; +LL + ::Y; + | error[E0404]: expected trait, found enum `E` --> $DIR/ufcs-partially-resolved.rs:23:12 | LL | ::N; - | ^ help: a trait with a similar name exists: `Eq` + | ^ | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here +help: a trait with a similar name exists + | +LL | ::N; + | + error[E0404]: expected trait, found type alias `A` --> $DIR/ufcs-partially-resolved.rs:24:12 @@ -64,21 +84,29 @@ error[E0404]: expected trait, found enum `E` --> $DIR/ufcs-partially-resolved.rs:26:19 | LL | let _: ::Y; - | ^ help: a trait with a similar name exists: `Eq` + | ^ | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here +help: a trait with a similar name exists + | +LL | let _: ::Y; + | + error[E0404]: expected trait, found enum `E` --> $DIR/ufcs-partially-resolved.rs:28:12 | LL | ::Y; - | ^ help: a trait with a similar name exists: `Eq` + | ^ | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here +help: a trait with a similar name exists + | +LL | ::Y; + | + error[E0576]: cannot find associated type `N` in trait `Tr` --> $DIR/ufcs-partially-resolved.rs:30:24 @@ -87,17 +115,27 @@ LL | type Y = u16; | ------------- similarly named associated type `Y` defined here ... LL | let _: ::N::NN; - | ^ help: an associated type with a similar name exists: `Y` + | ^ + | +help: an associated type with a similar name exists + | +LL - let _: ::N::NN; +LL + let _: ::Y::NN; + | error[E0404]: expected trait, found enum `E` --> $DIR/ufcs-partially-resolved.rs:31:19 | LL | let _: ::N::NN; - | ^ help: a trait with a similar name exists: `Eq` + | ^ | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here +help: a trait with a similar name exists + | +LL | let _: ::N::NN; + | + error[E0404]: expected trait, found type alias `A` --> $DIR/ufcs-partially-resolved.rs:32:19 @@ -118,17 +156,27 @@ LL | type Y = u16; | ------------- similarly named associated type `Y` defined here ... LL | ::N::NN; - | ^ help: an associated type with a similar name exists: `Y` + | ^ + | +help: an associated type with a similar name exists + | +LL - ::N::NN; +LL + ::Y::NN; + | error[E0404]: expected trait, found enum `E` --> $DIR/ufcs-partially-resolved.rs:34:12 | LL | ::N::NN; - | ^ help: a trait with a similar name exists: `Eq` + | ^ | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here +help: a trait with a similar name exists + | +LL | ::N::NN; + | + error[E0404]: expected trait, found type alias `A` --> $DIR/ufcs-partially-resolved.rs:35:12 @@ -146,21 +194,29 @@ error[E0404]: expected trait, found enum `E` --> $DIR/ufcs-partially-resolved.rs:37:19 | LL | let _: ::Y::NN; - | ^ help: a trait with a similar name exists: `Eq` + | ^ | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here +help: a trait with a similar name exists + | +LL | let _: ::Y::NN; + | + error[E0404]: expected trait, found enum `E` --> $DIR/ufcs-partially-resolved.rs:39:12 | LL | ::Y::NN; - | ^ help: a trait with a similar name exists: `Eq` + | ^ | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here +help: a trait with a similar name exists + | +LL | ::Y::NN; + | + error[E0405]: cannot find trait `N` in trait `Tr` --> $DIR/ufcs-partially-resolved.rs:41:23 @@ -229,9 +285,13 @@ LL | type X = u16; | ------------- similarly named associated type `X` defined here ... LL | let _: ::Z; - | ^^^^^^^^^^^^- - | | - | help: an associated type with a similar name exists: `X` + | ^^^^^^^^^^^^^ + | +help: an associated type with a similar name exists + | +LL - let _: ::Z; +LL + let _: ::X; + | error[E0575]: expected method or associated constant, found associated type `Dr::X` --> $DIR/ufcs-partially-resolved.rs:53:5 @@ -240,9 +300,13 @@ LL | fn Z() {} | ------ similarly named associated function `Z` defined here ... LL | ::X; - | ^^^^^^^^^^^^- - | | - | help: an associated function with a similar name exists: `Z` + | ^^^^^^^^^^^^^ + | +help: an associated function with a similar name exists + | +LL - ::X; +LL + ::Z; + | error[E0575]: expected associated type, found associated function `Dr::Z` --> $DIR/ufcs-partially-resolved.rs:54:12 @@ -251,9 +315,13 @@ LL | type X = u16; | ------------- similarly named associated type `X` defined here ... LL | let _: ::Z::N; - | ^^^^^^^^^^^^-^^^ - | | - | help: an associated type with a similar name exists: `X` + | ^^^^^^^^^^^^^^^^ + | +help: an associated type with a similar name exists + | +LL - let _: ::Z::N; +LL + let _: ::X::N; + | error[E0223]: ambiguous associated type --> $DIR/ufcs-partially-resolved.rs:36:12 diff --git a/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr b/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr index 5f22c781345ff..7e295c1d54f9a 100644 --- a/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr +++ b/tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr @@ -8,7 +8,13 @@ error[E0425]: cannot find value `y` in this scope --> $DIR/unboxed-closures-type-mismatch-closure-from-another-scope.rs:9:26 | LL | closure(&mut p, &y); - | ^ help: a local variable with a similar name exists: `p` + | ^ + | +help: a local variable with a similar name exists + | +LL - closure(&mut p, &y); +LL + closure(&mut p, &p); + | error[E0308]: mismatched types --> $DIR/unboxed-closures-type-mismatch-closure-from-another-scope.rs:9:17 From 0488690d3e248a72a98945fbd4ced83a5ba05d0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Tue, 9 Dec 2025 00:10:08 +0000 Subject: [PATCH 19/21] Use `let`...`else` instead of `match foo { ... _ => return };` and `if let ... else return` in std --- library/alloc/src/collections/linked_list.rs | 5 ++--- library/alloc/src/raw_vec/mod.rs | 4 +--- library/alloc/src/string.rs | 21 +++++++++----------- library/alloc/src/vec/splice.rs | 9 ++++----- library/core/src/num/dec2flt/mod.rs | 6 +----- library/core/src/time.rs | 7 +++---- library/std/src/sys/pal/windows/pipe.rs | 5 +---- 7 files changed, 21 insertions(+), 36 deletions(-) diff --git a/library/alloc/src/collections/linked_list.rs b/library/alloc/src/collections/linked_list.rs index 8bc0e08a4b26b..e738c29c237fa 100644 --- a/library/alloc/src/collections/linked_list.rs +++ b/library/alloc/src/collections/linked_list.rs @@ -1646,9 +1646,8 @@ impl<'a, T> CursorMut<'a, T> { #[unstable(feature = "linked_list_cursors", issue = "58533")] pub fn splice_after(&mut self, list: LinkedList) { unsafe { - let (splice_head, splice_tail, splice_len) = match list.detach_all_nodes() { - Some(parts) => parts, - _ => return, + let Some((splice_head, splice_tail, splice_len)) = list.detach_all_nodes() else { + return; }; let node_next = match self.current { None => self.list.head, diff --git a/library/alloc/src/raw_vec/mod.rs b/library/alloc/src/raw_vec/mod.rs index 236e33e2f450e..15b0823df9ec5 100644 --- a/library/alloc/src/raw_vec/mod.rs +++ b/library/alloc/src/raw_vec/mod.rs @@ -788,9 +788,7 @@ impl RawVecInner { elem_layout: Layout, ) -> Result<(), TryReserveError> { // SAFETY: Precondition passed to caller - let (ptr, layout) = if let Some(mem) = unsafe { self.current_memory(elem_layout) } { - mem - } else { + let Some((ptr, layout)) = (unsafe { self.current_memory(elem_layout) }) else { return Ok(()); }; diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index f5ba71c288334..64abdca32d211 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -619,16 +619,14 @@ impl String { pub fn from_utf8_lossy(v: &[u8]) -> Cow<'_, str> { let mut iter = v.utf8_chunks(); - let first_valid = if let Some(chunk) = iter.next() { - let valid = chunk.valid(); - if chunk.invalid().is_empty() { - debug_assert_eq!(valid.len(), v.len()); - return Cow::Borrowed(valid); - } - valid - } else { + let Some(chunk) = iter.next() else { return Cow::Borrowed(""); }; + let first_valid = chunk.valid(); + if chunk.invalid().is_empty() { + debug_assert_eq!(first_valid.len(), v.len()); + return Cow::Borrowed(first_valid); + } const REPLACEMENT: &str = "\u{FFFD}"; @@ -720,11 +718,10 @@ impl String { // FIXME: the function can be simplified again when #48994 is closed. let mut ret = String::with_capacity(v.len()); for c in char::decode_utf16(v.iter().cloned()) { - if let Ok(c) = c { - ret.push(c); - } else { + let Ok(c) = c else { return Err(FromUtf16Error(())); - } + }; + ret.push(c); } Ok(ret) } diff --git a/library/alloc/src/vec/splice.rs b/library/alloc/src/vec/splice.rs index d571e35828aeb..b08bb9cb6d191 100644 --- a/library/alloc/src/vec/splice.rs +++ b/library/alloc/src/vec/splice.rs @@ -112,12 +112,11 @@ impl Drain<'_, T, A> { }; for place in range_slice { - if let Some(new_item) = replace_with.next() { - unsafe { ptr::write(place, new_item) }; - vec.len += 1; - } else { + let Some(new_item) = replace_with.next() else { return false; - } + }; + unsafe { ptr::write(place, new_item) }; + vec.len += 1; } true } diff --git a/library/core/src/num/dec2flt/mod.rs b/library/core/src/num/dec2flt/mod.rs index dd4eccd24de03..eee8adf4f7554 100644 --- a/library/core/src/num/dec2flt/mod.rs +++ b/library/core/src/num/dec2flt/mod.rs @@ -255,11 +255,7 @@ fn biased_fp_to_float(x: BiasedFp) -> F { #[inline(always)] // Will be inlined into a function with `#[inline(never)]`, see above pub fn dec2flt(s: &str) -> Result { let mut s = s.as_bytes(); - let c = if let Some(&c) = s.first() { - c - } else { - return Err(pfe_empty()); - }; + let Some(&c) = s.first() else { return Err(pfe_empty()) }; let negative = c == b'-'; if c == b'-' || c == b'+' { s = &s[1..]; diff --git a/library/core/src/time.rs b/library/core/src/time.rs index 51a01545f5cf5..b85179e925d13 100644 --- a/library/core/src/time.rs +++ b/library/core/src/time.rs @@ -672,11 +672,10 @@ impl Duration { let mut nanos = self.nanos.as_inner() + rhs.nanos.as_inner(); if nanos >= NANOS_PER_SEC { nanos -= NANOS_PER_SEC; - if let Some(new_secs) = secs.checked_add(1) { - secs = new_secs; - } else { + let Some(new_secs) = secs.checked_add(1) else { return None; - } + }; + secs = new_secs; } debug_assert!(nanos < NANOS_PER_SEC); Some(Duration::new(secs, nanos)) diff --git a/library/std/src/sys/pal/windows/pipe.rs b/library/std/src/sys/pal/windows/pipe.rs index d8e306068d73c..32cf4695d4a15 100644 --- a/library/std/src/sys/pal/windows/pipe.rs +++ b/library/std/src/sys/pal/windows/pipe.rs @@ -530,10 +530,7 @@ impl<'a> AsyncPipe<'a> { impl<'a> Drop for AsyncPipe<'a> { fn drop(&mut self) { - match self.state { - State::Reading => {} - _ => return, - } + let State::Reading = self.state else { return }; // If we have a pending read operation, then we have to make sure that // it's *done* before we actually drop this type. The kernel requires From d440210f9a47572842ae6781303336ad4fe0f268 Mon Sep 17 00:00:00 2001 From: Shoyu Vanilla Date: Wed, 10 Dec 2025 08:58:34 +0900 Subject: [PATCH 20/21] Add a regression test for issue 145748 --- .../normalize/normalize-const-in-async-body.rs | 2 ++ .../non-defining-use-borrowck-issue-145748.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 tests/ui/traits/next-solver/opaques/non-defining-use-borrowck-issue-145748.rs diff --git a/tests/ui/traits/next-solver/normalize/normalize-const-in-async-body.rs b/tests/ui/traits/next-solver/normalize/normalize-const-in-async-body.rs index 2b9454db3fac7..4da078dbb4f49 100644 --- a/tests/ui/traits/next-solver/normalize/normalize-const-in-async-body.rs +++ b/tests/ui/traits/next-solver/normalize/normalize-const-in-async-body.rs @@ -2,6 +2,8 @@ //@ check-pass //@ edition:2021 +// Regression test for https://github.com/rust-lang/rust/issues/129865. + pub async fn cleanse_old_array_async(_: &[u8; BUCKET_LEN]) {} pub const BUCKET_LEN: usize = 0; diff --git a/tests/ui/traits/next-solver/opaques/non-defining-use-borrowck-issue-145748.rs b/tests/ui/traits/next-solver/opaques/non-defining-use-borrowck-issue-145748.rs new file mode 100644 index 0000000000000..ae70ffdfdaee1 --- /dev/null +++ b/tests/ui/traits/next-solver/opaques/non-defining-use-borrowck-issue-145748.rs @@ -0,0 +1,14 @@ +//@ ignore-compare-mode-next-solver +//@ compile-flags: -Znext-solver +//@ check-pass + +// Make sure that we support non-defining uses in borrowck. +// Regression test for https://github.com/rust-lang/rust/issues/145748. + +pub fn f(_: &()) -> impl Fn() + '_ { + || { + let _ = f(&()); + } +} + +fn main() {} From fc3d61ee7c221f38eec38166f9a9f5f0e0bd3a7e Mon Sep 17 00:00:00 2001 From: Jieyou Xu Date: Wed, 10 Dec 2025 09:35:24 +0800 Subject: [PATCH 21/21] compiletest: tidy up `adb_path`/`adb_test_dir` handling Be more faithful that they aren't always available. --- src/tools/compiletest/src/common.rs | 4 ++-- src/tools/compiletest/src/lib.rs | 8 +++----- src/tools/compiletest/src/runtest/debuginfo.rs | 12 ++++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 02b93593cbbd4..34153d93d463d 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -575,7 +575,7 @@ pub struct Config { /// /// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for /// `arm-linux-androideabi` target. - pub adb_path: Utf8PathBuf, + pub adb_path: Option, /// Extra parameter to run test suite on `arm-linux-androideabi`. /// @@ -584,7 +584,7 @@ pub struct Config { /// /// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for /// `arm-linux-androideabi` target. - pub adb_test_dir: Utf8PathBuf, + pub adb_test_dir: Option, /// Status whether android device available or not. When unavailable, this will cause tests to /// panic when the test binary is attempted to be run. diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index ff4cd81d33ff6..324ce2eaabeec 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -260,11 +260,9 @@ fn parse_config(args: Vec) -> Config { let android_cross_path = matches.opt_str("android-cross-path").map(Utf8PathBuf::from); - // FIXME: `adb_path` should be an `Option`... - let adb_path = matches.opt_str("adb-path").map(Utf8PathBuf::from).unwrap_or_default(); - // FIXME: `adb_test_dir` should be an `Option`... - let adb_test_dir = matches.opt_str("adb-test-dir").map(Utf8PathBuf::from).unwrap_or_default(); - let adb_device_status = target.contains("android") && !adb_test_dir.as_str().is_empty(); + let adb_path = matches.opt_str("adb-path").map(Utf8PathBuf::from); + let adb_test_dir = matches.opt_str("adb-test-dir").map(Utf8PathBuf::from); + let adb_device_status = target.contains("android") && adb_test_dir.is_some(); // FIXME: `cdb_version` is *derived* from cdb, but it's *not* technically a config! let cdb = debuggers::discover_cdb(matches.opt_str("cdb"), &target); diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index ac935910205b7..83b61b9be57d5 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -150,12 +150,16 @@ impl TestCx<'_> { debug!("script_str = {}", script_str); self.dump_output_file(&script_str, "debugger.script"); - let adb_path = &self.config.adb_path; + // Note: when `--android-cross-path` is specified, we expect both `adb_path` and + // `adb_test_dir` to be available. + let adb_path = self.config.adb_path.as_ref().expect("`adb_path` must be specified"); + let adb_test_dir = + self.config.adb_test_dir.as_ref().expect("`adb_test_dir` must be specified"); Command::new(adb_path) .arg("push") .arg(&exe_file) - .arg(&self.config.adb_test_dir) + .arg(adb_test_dir) .status() .unwrap_or_else(|e| panic!("failed to exec `{adb_path:?}`: {e:?}")); @@ -167,9 +171,9 @@ impl TestCx<'_> { let adb_arg = format!( "export LD_LIBRARY_PATH={}; \ gdbserver{} :5039 {}/{}", - self.config.adb_test_dir.clone(), + adb_test_dir, if self.config.target.contains("aarch64") { "64" } else { "" }, - self.config.adb_test_dir.clone(), + adb_test_dir, exe_file.file_name().unwrap() );