-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Introduce a no-op PlaceMention
statement for let _ =
.
#102256
Changes from all commits
be758ef
4462bb5
e107194
a5ef6ba
b34a8a2
45f2a1a
09dc10c
2eccd52
684de04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -556,6 +556,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | |
|
||
_ => { | ||
let place_builder = unpack!(block = self.as_place_builder(block, initializer)); | ||
|
||
if let Some(place) = place_builder.try_to_place(self) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess it's definitely not wrong to do this here, but I feel like ideally the code is structured in such a way that we can actually only do this for cases where the place is otherwise unused by the pattern. Looked a bit at the code myself and decided that it is hard to understand and that I don't have the energy to refactor mir builder rn There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, everything would go through |
||
let source_info = self.source_info(initializer.span); | ||
self.cfg.push_place_mention(block, source_info, place); | ||
} | ||
|
||
self.place_into_pattern(block, &irrefutable_pat, place_builder, true) | ||
} | ||
} | ||
|
@@ -576,6 +582,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { | |
false, | ||
&mut [&mut candidate], | ||
); | ||
|
||
// For matches and function arguments, the place that is being matched | ||
// can be set when creating the variables. But the place for | ||
// let PATTERN = ... might not even exist until we do the assignment. | ||
|
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.
we use
super_statement
here so if the place were to contain some operand which isn't allowed in const contexts this would change behavior. The only thing I was able to think of is the following which is already rejected, so this seems fine 🤷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 are right. This would introduce an extra diagnostic for "dereferencing raw mutable pointers in constant functions is unstable". Exactly like unsafeck.
As everything else around raw mutable pointers is already forbidden, I don't think this can break code. Can it?
Added a test.