Conversation
src/librustc/mir/interpret/value.rs
Outdated
There was a problem hiding this comment.
Should this be Pointer? Or is there a real usecase of ByRef pointing to a non-allocation?
There was a problem hiding this comment.
yes, it's used to preserve zst identity
There was a problem hiding this comment.
But this is Value, which means the address shouldn't be observable, only the value behind the pointer.
src/librustc/mir/interpret/value.rs
Outdated
src/librustc/mir/interpret/value.rs
Outdated
There was a problem hiding this comment.
Should primval be replaced with scalar?
src/librustc/mir/interpret/value.rs
Outdated
There was a problem hiding this comment.
You could at least wrap layout::Integer for signed and unsigned integers, if you want to keep ScalarKind at all (as opposed to reusing layout::Primitive).
src/librustc/ty/sty.rs
Outdated
There was a problem hiding this comment.
I'm not sure this is a good idea...
src/librustc/mir/mod.rs
Outdated
There was a problem hiding this comment.
Since this is for printing, could you pass in 128? There are certainly 128 defined bits, trivially.
There was a problem hiding this comment.
Oh this is used for sign extension o_O.
There was a problem hiding this comment.
I will still be passing this as a Scalar, because the function is also called elsewhere with other variants, but I fixed the sign extension thing
There was a problem hiding this comment.
Can't this use .to_value_with_len?
|
☔ The latest upstream changes (presumably #50866) made this pull request unmergeable. Please resolve the merge conflicts. |
85638ee to
ca34069
Compare
src/librustc/mir/mod.rs
Outdated
There was a problem hiding this comment.
Please call this bits, or, better, keep the name but do size.bits() as u8 at use sites.
src/librustc/mir/mod.rs
Outdated
There was a problem hiding this comment.
Can you remove all the defined pattern-matching in here?
src/librustc/mir/mod.rs
Outdated
There was a problem hiding this comment.
In fact, this specific one can ignore even whether the value is a Value::Scalar.
src/librustc/ty/layout.rs
Outdated
There was a problem hiding this comment.
Please use impl<'a, 'tcx> TyCtxt<'a, 'tcx, '_> if you don't want to name the lifetime.
There was a problem hiding this comment.
I tried that, that doesn't compile
There was a problem hiding this comment.
Doesn't it need a feature-gate? in_band_lifetimes I think?
src/librustc/ty/layout.rs
Outdated
There was a problem hiding this comment.
Looking at this, this sort of thing probably needs to always use bitcast after LLVMConstPtrToInt, in case the latter is needed at all. You should add a test for an union used to convert a reference into a f32 / f64 (depending on #[cfg(target_pointer_width)]), which I highly suspect trips a LLVM assertion in the current state of the code.
src/librustc_mir/hair/cx/mod.rs
Outdated
There was a problem hiding this comment.
Can't this use some truncate function from miri?
There was a problem hiding this comment.
won't fix in this PR, there's an issue open for cleaning up this kind of code: #49937
src/librustc_mir/hair/cx/mod.rs
Outdated
There was a problem hiding this comment.
Can't this use with_len or something?
src/librustc_mir/hair/cx/mod.rs
Outdated
There was a problem hiding this comment.
Is this a true clamping operation (i.e. saturating), or a truncation? I actually expect truncation.
src/librustc_mir/hair/pattern/mod.rs
Outdated
There was a problem hiding this comment.
Note that this unwrap can fail - we should be matching on Option<Ordering> below and explicitly list all the possible cases - currently the _ success at the end of the match would catch None which would be bad.
src/librustc_mir/hair/pattern/mod.rs
Outdated
There was a problem hiding this comment.
You're comparing defined again. At most these should <= relationships, not ==.
There was a problem hiding this comment.
That is, each of defined_a and defined_b should be larger or equal to pointer_size.bits() - why not use to_bits with usize instead?
src/librustc_mir/hair/pattern/mod.rs
Outdated
There was a problem hiding this comment.
Would be better to cast alloc_a.bytes.len() to u128.
src/librustc_mir/interpret/memory.rs
Outdated
There was a problem hiding this comment.
This seems wrong, shouldn't be <?
There was a problem hiding this comment.
Also, please cast the small type to the large one for comparisons.
src/librustc_mir/interpret/memory.rs
Outdated
There was a problem hiding this comment.
It's a truncation, shouldn't be necessary nowadays.
src/librustc_mir/interpret/memory.rs
Outdated
There was a problem hiding this comment.
I'd write size.bits() != 0 here instead.
src/librustc_mir/interpret/memory.rs
Outdated
There was a problem hiding this comment.
How is it possible to get a Value::Scalar(Scalar::undef()) for a type with an Abi::ScalarPair?
There was a problem hiding this comment.
by reading a fat pointer from undefined bytes I'd presume
There was a problem hiding this comment.
That should produce a ScalarPair with two undefs.
src/librustc_target/abi/mod.rs
Outdated
There was a problem hiding this comment.
For the record, I disagree with this, in general rustc's typesystem should not include rustc_target::abi types.
|
@bors r=eddyb |
|
📌 Commit 50d3783 has been approved by |
|
⌛ Testing commit 50d3783 with merge 53fc7286e4ea16cc5909e0ad96d16e714501132c... |
|
💔 Test failed - status-appveyor |
|
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 r=eddyb |
|
📌 Commit 5f599bb has been approved by |
|
☀️ Test successful - status-appveyor, status-travis |
| let place = self.eval_place(place)?; | ||
| let discr_val = self.read_discriminant_value(place, ty)?; | ||
| self.write_primval(dest, PrimVal::Bytes(discr_val), dest_ty)?; | ||
| let defined = self.layout_of(ty).unwrap().size.bits() as u8; |
There was a problem hiding this comment.
I believe this causes #51086. ty is the enum of which the discriminant is taken. This should have been dest_ty
rustc_target: inline abi::FloatTy into abi::Primitive. This effectively undoes a small part of @oli-obk's rust-lang#50967, now that the rest of the compiler doesn't use the `FloatTy` definition from `rustc_target`, post-rust-lang#65884.
r? @eddyb
cc @Zoxc
based on #50916