-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the type_name
intrinsic deterministic
#60166
Conversation
This comment has been minimized.
This comment has been minimized.
I don't want to hold this back too much, but I'm not sure the printer as written is a good idea. Also, the implementation of the intrinsic should be in miri IMO (like all the other |
Can you elaborate on that? I was inferring how to use the
Yes definitely, I took care not to have any lifetime printing
That makes much more sense than what I'm doing right now. I'll do that |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
The test output changes seem reasonable, to me, but I don't think that I have enough expertise in this bit of the compiler to review. r? @eddyb |
This comment has been minimized.
This comment has been minimized.
// tuple | ||
std::intrinsics::type_name::<(i32, u32)>(), | ||
// impl trait | ||
type_name_of_val(foo()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impl trait prints the concrete type, so this will violate privacy
Addressed review comments |
| ty::Opaque(did, substs) | ||
=> self.print_value_path(did, substs), | ||
ty::Closure(did, substs) => self.print_value_path(did, substs.substs), | ||
ty::Generator(did, substs, _) => self.print_value_path(did, substs.substs), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit surprised all of these are using print_value_path
, I would've expected perhaps only FnDef
to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You said "everything with a DefId
" :D
Generators and Closures are now platform independent (they printed their file and line info before)
Adt, Foreign, FnDef and Opaque are probably fine via the pretty_print_type
path.
☔ The latest upstream changes (presumably #60815) made this pull request unmergeable. Please resolve the merge conflicts. |
☔ The latest upstream changes (presumably #61274) made this pull request unmergeable. Please resolve the merge conflicts. |
r=me after a rebase |
@bors r=eddyb |
📌 Commit 5b98489 has been approved by |
☀️ Test successful - checks-travis, status-appveyor |
@@ -14,6 +14,9 @@ use super::{ | |||
Machine, PlaceTy, OpTy, InterpretCx, | |||
}; | |||
|
|||
mod type_name; | |||
|
|||
pub use type_name::*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a bit funny to have that here when the intrinsic is not even available in CTFE?^^
let ty_name = LocalInternedString::intern(&tp_ty.to_string()); | ||
self.const_str_slice(ty_name) | ||
let ty_name = rustc_mir::interpret::type_name(self.tcx, tp_ty); | ||
OperandRef::from_const(self, ty_name).immediate_or_packed_pair(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oli-obk I assume Miri needs the same change then for its implementation of the intrinsic? Can you submit a PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I submitted a PR for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh, we can also just wait for #61399 to get merged, then miri will be able to just remove its implementation
cc @eddyb for the printing infrastructure
cc @Centril for the deterministic (coherent?) output
r? @sfackler