-
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
don't clone types that are copy, round two. #68459
Conversation
b1bfc3b
to
7841664
Compare
☔ The latest upstream changes (presumably #68474) made this pull request unmergeable. Please resolve the merge conflicts. |
7841664
to
28f1d62
Compare
Your PR failed (pretty log, raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem. 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 |
28f1d62
to
5627a3f
Compare
5627a3f
to
09f9701
Compare
@@ -1179,13 +1179,13 @@ impl EmitterWriter { | |||
let level_str = level.to_string(); | |||
// The failure note level itself does not provide any useful diagnostic information | |||
if *level != Level::FailureNote && !level_str.is_empty() { | |||
buffer.append(0, &level_str, Style::Level(level.clone())); | |||
buffer.append(0, &level_str, Style::Level(*level)); |
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 might want to leave it for another PR but level
should probably be Level
, not &Level
.
@petrochenkov and/or @estebank might know more about what's happening in this code though.
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 think at some point Level
wasn't Copy
, this is probably just a leftover from that.
@@ -691,7 +691,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { | |||
let root_place_projection = self.infcx.tcx.intern_place_elems(root_place.projection); | |||
|
|||
if self.access_place_error_reported.contains(&( | |||
Place { local: root_place.local.clone(), projection: root_place_projection }, | |||
Place { local: *root_place.local, projection: root_place_projection }, |
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.
cc @matthewjasper Why is there a reference to a Local
here - is it a mutable reference perhaps?
@@ -883,7 +883,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> { | |||
// Check is_empty() first because it's the common case, and doing that | |||
// way we avoid the clone() call. | |||
if !self.access_place_error_reported.is_empty() | |||
&& self.access_place_error_reported.contains(&(place_span.0.clone(), place_span.1)) | |||
&& self.access_place_error_reported.contains(&(*place_span.0, place_span.1)) |
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 @spastorino Maybe we need to consider passing Place
by value more often?
(it's a pair of an integer and a pointer, so it should be really compact)
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.
That doesn't work if there are subslices of the projection involved. We do have a PlaceRef type for exactly that use case though
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.
Yeah, except in the cases @oli-obk mentions I'd change most of the uses to take Place
by value. I need to do a bunch of cleanups still :).
4dac326
to
8cc79ab
Compare
src/librustc/mir/mod.rs
Outdated
Index(()) => Index(()), | ||
elem => elem.clone(), | ||
elem => *elem, |
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.
This entire .map(|elem| ...)
feels like .copied()
.
So really, projs
is just self.projs.clone()
.
Or better, self.projs.fold_with(folder)
(and derive/impl TypeFoldable
on ProjectionElem
if it doesn't already have that - it should, though).
src/librustc/mir/mod.rs
Outdated
@@ -2866,7 +2866,7 @@ impl<'tcx> TypeFoldable<'tcx> for PlaceElem<'tcx> { | |||
Deref => Deref, | |||
Field(f, ty) => Field(*f, ty.fold_with(folder)), | |||
Index(v) => Index(v.fold_with(folder)), | |||
elem => elem.clone(), | |||
elem => *elem, |
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.
Actually, the way this is structured is probably a bad idea and should be exhaustive, hmpf.
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.
--- a/src/librustc/mir/mod.rs
+++ b/src/librustc/mir/mod.rs
@@ -2466,7 +2466,13 @@ impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection {
Deref => Deref,
Field(f, ()) => Field(*f, ()),
Index(()) => Index(()),
- elem => *elem,
+ Downcast(symbol, variantidx) => Downcast(*symbol, *variantidx),
+ ConstantIndex { offset, min_length, from_end } => {
+ ConstantIndex { offset: *offset, min_length: *min_length, from_end: *from_end }
+ }
+ Subslice { from, to, from_end } => {
+ Subslice { from: *from, to: *to, from_end: *from_end }
+ }
})
.collect();
8cc79ab
to
c3d79c0
Compare
c3d79c0
to
6a722ac
Compare
@bors r+ Thanks! |
📌 Commit 6a722acfa9700993dabea1ae4f766cc208cbf94c has been approved by |
☔ The latest upstream changes (presumably #68407) made this pull request unmergeable. Please resolve the merge conflicts. |
6a722ac
to
f7dcdcc
Compare
@bors r+ |
📌 Commit f7dcdcc has been approved by |
⌛ Testing commit f7dcdcc with merge fa4004a3d536df6cda05dd0a48c9d65eb5b40172... |
@bors retry Yielding priority to the stable release. |
don't clone types that are copy, round two. Apparently fixing some of these issues makes clippy find even more so I did a couple of rounds now. r? @eddyb
Apparently fixing some of these issues makes clippy find even more so I did a couple of rounds now.
r? @eddyb