Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
32 changes: 31 additions & 1 deletion compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1467,10 +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().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
Expand All @@ -1490,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(())
}

Expand Down