Uh oh!
There was an error while loading. Please reload this page.
Move str to libcore. - #70911
Conversation
eddyb
commented
Apr 8, 2020
@bors try @rust-timer queue |
rust-timer
commented
Apr 8, 2020
Awaiting bors try build completion |
bors
commented
Apr 8, 2020
⌛ Trying commit 137c171 with merge f95a789e60e4d3fbb4e0c82de224af9d890e5b75... |
rust-highfive
commented
Apr 8, 2020
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 |
bors
commented
Apr 8, 2020
☀️ Try build successful - checks-azure |
rust-timer
commented
Apr 8, 2020
Queued f95a789e60e4d3fbb4e0c82de224af9d890e5b75 with parent 42abbd8, future comparison URL. |
SimonSapin
commented
Apr 8, 2020
Simplifying the language by pushing more of it into the standard library sounds nice from a theoretical point of view, but what is the practical benefit that we would gain by having someone spend the bandwidth to finish this? |
| ) -> InterpResult<'tcx> { | ||
| match op.layout.ty.kind { | ||
| ty::Str => { | ||
| // FIXME(eddyb) does this belong here? |
There was a problem hiding this comment.
Well you could remove that branch and then str would not be special any more in terms of validity. ;)
rust-timer
commented
Apr 8, 2020
Finished benchmarking try commit f95a789e60e4d3fbb4e0c82de224af9d890e5b75, comparison URL. |
eddyb
commented
Apr 8, 2020
Not sure there is much to finish, it's more about keeping this working and adjusting it due to review comments, throughout the approval process, whichever teams would decide on it. But also, wow, this is a slowdown. It really shouldn't, I think every single place in the compiler this PR makes slower also has been slowing down user-defined types w/o parameters this entire time, so it might be worth digging into some of these and trying to fix them. |
The previous attempt: #19612. I wanted to get this done in 2014 and I still want to get it done. |
oli-obk
commented
Apr 8, 2020
|
| Ok(Some(self.read_size_and_align_from_vtable(vtable)?)) | ||
| } | ||
| ty::Slice(_) | ty::Str => { |
There was a problem hiding this comment.
potential site for the perf regression, easy to test by doing the old logic if ty.is_str()
| pub fn read_str(&self, mplace: MPlaceTy<'tcx, M::PointerTag>) -> InterpResult<'tcx, &str> { | ||
| let len = mplace.len(self)?; | ||
| let bytes = self.memory.read_bytes(mplace.ptr, Size::from_bytes(len))?; | ||
| let bytes_mplace = self.mplace_field(mplace, 0)?; |
There was a problem hiding this comment.
potential site for the perf regression. We should probably check whether we can make mplace_field a no-op in case of repr(Rust) with one field or repr(transparent) types.
I think the main problem here is that we compute the field's layout even for cases like this one where we don't actually need the layout. We've seen major regressions in miri due to a single additional call to tcx.layout_of before.
petrochenkov
commented
Apr 8, 2020
Note: the diff is actually negative if you ignore the newly added tests. |
petrochenkov
commented
Apr 8, 2020
Reviewed. It feels like most of the special treatment in diagnostics can be removed if we officially recognize that The special case in mangling can be removed as well, except that it would needs a version bump. |
petrochenkov
commented
Apr 8, 2020
👍 |
eddyb
commented
Apr 8, 2020
I haven't done any testing on this but I wonder if:
We sort of had plans for that, along the lines of representing paths like However, I realize now that we could encode it as We shouldn't need a bump to make the |
eddyb
commented
Apr 8, 2020
To expand on this a bit: one of the unshadowed_prelude_items:FxHashMap<DefId,Symbol>,that we use in |
Yes,
It would, but that's not a big deal? EDIT: Unless you were talking about error messages here, |
eddyb
commented
Apr 9, 2020
Neat! Presumably scanning for locally defined items with the same names would be more effort, but maybe there's some map (oh, there's the
Sorry, yeah, my concerns are:
|
Thoughts from the language team meeting yesterday:
So in conclusion, I think we can green-light this from a lang team POV (regressions in perf etc. are for the compiler team to assess, and fix), but let's also be careful not to lock us into a world where this cannot be reverted. |
petrochenkov
commented
May 19, 2020
Closing due to inactivity. |
It's possible #73996 unblocked the "diagnostics should still say |
I was reminded we tried to do this before and didn't go through with it for some reason, after seeing rust-lang/unsafe-code-guidelines#78 (the impact on this PR on that question isn't significant, FWIW).
One thing I didn't do is change how
stris resolved: it's still a builtin type forrustc_resolve, which only after name resolution is turned into the right type, using the"str"lang item.(Presumably if
core::strhadcrate mod sealed { pub struct Str([u8]); }thencore::preludecould dopub use crate::str::sealed::Str as str;, but I haven't tried it - IMO a requirement is that users can't observecore::str::strorcore::str::Str. cc @petrochenkov)While this does seem to work with enough tweaks, I don't have the bandwidth to push this through.
So I suppose this could be considered insta-abandonware ♻️.
r? @ghost cc @rust-lang/libs @rust-lang/compiler