Skip to content
Closed
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
7 changes: 6 additions & 1 deletion compiler/rustc_const_eval/src/util/type_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
| ty::UnsafeBinder(_) => self.pretty_print_type(ty),

// Placeholders (all printed as `_` to uniformize them).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does sound like the _ was deliberate -- but I don't have a strong opinion either way.

ty::Param(_) | ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) | ty::Error(_) => {
ty::Bound(..) | ty::Placeholder(_) | ty::Infer(_) | ty::Error(_) => {
write!(self, "_")?;
Ok(())
}

ty::Param(param_ty) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment here? All the other sections in this match have a nice comment.

write!(self, "{}", param_ty.name)?;
Ok(())
}

// Types with identity (print the module path).
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did: def_id, .. }, _)), args)
| ty::FnDef(def_id, args)
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-61894.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ impl<M> Bar<M> {
}

fn main() {
assert_eq!(Bar(()).foo(), "issue_61894::Bar<_>::foo::f");
assert_eq!(Bar(()).foo(), "issue_61894::Bar<M>::foo::f");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is confusing about this is that there is no M in scope when printing the name. If M shadows the name of some other type, this could become misleading.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, iirc printing _ was on purpose, because it can't have been relevant for the type name if it's still an uninstantiated param. If there are two impl<M> Bar<M> (e.g. with different bounds, which is where such "dupliate impl blocks" are common), then the type names would still be the same, so adding the M does not really bring any benefit

}
Loading