From e4d66c4d407eaf1b2f23e0c176adea57655be98d Mon Sep 17 00:00:00 2001 From: zannabianca1997 Date: Wed, 5 Aug 2026 19:12:20 +0200 Subject: [PATCH 1/3] Fix: removed Move from being printed at all it should give some info tho... --- compiler/rustc_middle/src/ty/context.rs | 6 +++++- compiler/rustc_middle/src/ty/print/pretty.rs | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_middle/src/ty/context.rs b/compiler/rustc_middle/src/ty/context.rs index 97eda369ff4c3..095b0e5f484e7 100644 --- a/compiler/rustc_middle/src/ty/context.rs +++ b/compiler/rustc_middle/src/ty/context.rs @@ -915,10 +915,14 @@ impl<'tcx> TyCtxt<'tcx> { pub fn is_implicit_trait(self, def_id: DefId, including_sized: bool) -> bool { self.is_default_trait(def_id) - || matches!(self.as_lang_item(def_id), Some(LangItem::Move)) + || self.is_move_trait(def_id) || (including_sized && self.is_sizedness_trait(def_id)) } + pub fn is_move_trait(self, def_id: DefId) -> bool { + matches!(self.as_lang_item(def_id), Some(LangItem::Move)) + } + pub fn is_sizedness_trait(self, def_id: DefId) -> bool { matches!(self.as_lang_item(def_id), Some(LangItem::Sized | LangItem::MetaSized)) } diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 3c7e3b63ee9b5..55bf3a0121470 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1470,7 +1470,9 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { // Builtin bounds. // FIXME(eddyb) avoid printing twice (needed to ensure // that the auto traits are sorted *and* printed via p). - let mut auto_traits: Vec<_> = predicates.auto_traits().collect(); + let mut auto_traits: Vec<_> = predicates.auto_traits() + .filter(|t| !self.tcx().is_move_trait(*t)) + .collect(); // The auto traits come ordered by `DefPathHash`. While // `DefPathHash` is *stable* in the sense that it depends on From 417e1f211978c921978bfd5704ee3595a0bb3665 Mon Sep 17 00:00:00 2001 From: zannabianca1997 Date: Wed, 5 Aug 2026 19:16:28 +0200 Subject: [PATCH 2/3] Chore: tidy --- compiler/rustc_middle/src/ty/print/pretty.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index 55bf3a0121470..b5c1fbbdbe7f4 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1470,9 +1470,8 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { // Builtin bounds. // FIXME(eddyb) avoid printing twice (needed to ensure // that the auto traits are sorted *and* printed via p). - let mut auto_traits: Vec<_> = predicates.auto_traits() - .filter(|t| !self.tcx().is_move_trait(*t)) - .collect(); + let mut auto_traits: Vec<_> = + predicates.auto_traits().filter(|t| !self.tcx().is_move_trait(*t)).collect(); // The auto traits come ordered by `DefPathHash`. While // `DefPathHash` is *stable* in the sense that it depends on From 89baaa458acec68bc55fa6015814abb945b970e8 Mon Sep 17 00:00:00 2001 From: zannabianca1997 Date: Wed, 5 Aug 2026 20:05:26 +0200 Subject: [PATCH 3/3] Feat: printing of `!Move` when type is indeed not moveable Do we need this? I feel like it's important to make notice that a dyn trait misses such an important thing still need to test it as the compiler ICE when creating an immoble type --- compiler/rustc_middle/src/ty/print/pretty.rs | 33 ++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_middle/src/ty/print/pretty.rs b/compiler/rustc_middle/src/ty/print/pretty.rs index b5c1fbbdbe7f4..849df87836668 100644 --- a/compiler/rustc_middle/src/ty/print/pretty.rs +++ b/compiler/rustc_middle/src/ty/print/pretty.rs @@ -1467,11 +1467,25 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { first = false; } + // Keep track if we need to add `!Move` at the end + // FIXME(zannabianca1997) I guess there will be a + // list of bounds like this in the future... + let mut ty_is_move = false; + // Builtin bounds. // FIXME(eddyb) avoid printing twice (needed to ensure // that the auto traits are sorted *and* printed via p). - let mut auto_traits: Vec<_> = - predicates.auto_traits().filter(|t| !self.tcx().is_move_trait(*t)).collect(); + let mut auto_traits: Vec<_> = predicates + .auto_traits() + .filter(|t| { + if self.tcx().is_move_trait(*t) { + ty_is_move = true; + false + } else { + true + } + }) + .collect(); // The auto traits come ordered by `DefPathHash`. While // `DefPathHash` is *stable* in the sense that it depends on @@ -1491,6 +1505,21 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write { self.print_def_path(def_id, &[])?; } + if !ty_is_move && let Some(move_trait) = self.tcx().lang_items().move_trait() { + if !first { + write!(self, " + ")?; + } + // FIXME(zannabianca1997) put this back when more is + // added after, commented out to avoid warning + // first = false; + + // maybe we should refer someway to the actual ast? + // we did not with the `+` so assuming no + write!(self, "!")?; + + self.print_def_path(move_trait, &[])?; + } + Ok(()) }