| Age | Commit message (Collapse) | Author | Lines |
|
Use `use_verbose` for `mir::Constant`
Fixes #79799.
|
|
|
|
|
|
un-update itertools
improve predecessor amount short-circuiting
cleanup and comments
somewhat improved drawing
|
|
Fix `unused_unsafe` around `await`
Enables `unused_unsafe` lint for `unsafe { future.await }`.
The existing test for this is `unsafe { println!() }`, so I assume that `println!` used to contain compiler-generated unsafe but this is no longer true, and so the existing test is broken. I replaced the test with `unsafe { ...await }`. I believe `await` is currently the only instance of compiler-generated unsafe.
Reverts some parts of #85421, but the issue predates that PR.
|
|
|
|
Add MIR pass to lower call to `core::slice::len` into `Len` operand
During some larger experiment with range analysis I've found that code like `let l = slice.len()` produces different MIR then one found in bound checks. This optimization pass replaces terminators that are calls to `core::slice::len` with just a MIR operand and Goto terminator.
It uses some heuristics to remove the outer borrow that is made to call `core::slice::len`, but I assume it can be eliminated, just didn't find how.
Would like to express my gratitude to `@oli-obk` who helped me a lot on Zullip
|
|
|
|
add various coments to explain how the TAIT code works
r? `@oli-obk`
|
|
Use `map_or` instead of open-coding it
`@rustbot` modify labels +C-cleanup +T-compiler
|
|
|
|
|
|
Remove some last remants of {push,pop}_unsafe!
These macros have already been removed, but there was still some code handling these macros. That code is now removed.
|
|
|
|
Rollup of 7 pull requests
Successful merges:
- #85663 (Document Arc::from)
- #85802 (Rename IoSlice(Mut)::advance to advance_slice and add IoSlice(Mut)::advance)
- #85970 (Remove methods under Implementors on trait pages)
- #86340 (Use better error message for hard errors in CTFE)
- #86343 (Do not emit invalid suggestions on multiple mutable borrow errors)
- #86355 (Remove invalid suggestions for assoc consts on placeholder type error)
- #86389 (Make `sum()` and `product()` documentation hyperlinks refer to `Iterator` methods.)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
|
|
Do not emit invalid suggestions on multiple mutable borrow errors
Fixes #85581
|
|
Use better error message for hard errors in CTFE
I noticed this while working on #86255: currently the same message is used for hard errors and soft errors in CTFE. This changes the error messages to make hard errors use a message that indicates the reality of the situation correctly, since usage of the constant is never allowed when there was a hard error evaluating it. This doesn't affect the behaviour of these error messages, only the content.
This changes the error logic to check if the error should be hard or soft where it is generated, instead of where it is emitted, to allow this distinction in error messages.
|
|
Replace parent substs of associated types with inference vars in borrow checker
Fixes https://github.com/rust-lang/rust/issues/83190
Fixes https://github.com/rust-lang/rust/issues/78450
When we normalize an associated type that refers to an opaque type, it can happen that the substs of the associated type do not occur in the projection (they are parent substs). We previously didn't replace those substs with inference vars, which left a concrete region after all regions should have already been replaced with inference vars and triggered a `delay_span_bug`. After we normalize the opaque type, we now try to replace any remaining concrete regions with inference vars.
|
|
Normalization can pull in named regions from the parameter
environment. We need to be prepared for that in the opaque
types code.
|
|
|
|
Stop returning a value from `report_assert_as_lint`
This function only ever returns `None`. Make that explicity by not returning a value at all.
`@rustbot` modify labels +C-cleanup +T-compiler
|
|
Allow whitespace in dump_mir filter
At least on my system this is necessary to get more complex filters with spaces like in https://rustc-dev-guide.rust-lang.org/mir/debugging.html working.
|
|
Refactor vtable codegen
This refactor the codegen of vtables of miri interpreter, llvm, cranelift codegen backends.
This is preparation for the implementation of trait upcasting feature. cc #65991
Note that aside from code reorganization, there's an internal behavior change here that now InstanceDef::Virtual's index now include the three metadata slots, and now the first method is with index 3.
cc `@RalfJung` `@bjorn3`
|
|
|
|
This function only ever returns `None`. Make that explicity by not returning a value at all.
|
|
Currently the same message is used for hard errors and soft errors. This
makes hard errors use a message that indicates the reality of the
situation correctly, since usage of the constant is never allowed when
there was a hard error evaluating it.
|
|
representation.
|
|
`with_no_trimmed_paths`
|
|
|
|
They were "freeform const UB" error message, but could reach validation
and trigger ICEs there. We now catch them during validation to avoid
that.
|
|
Detect incorrect vtable alignment during const eval
This PR fixes #86132 by detecting invalid alignment values for trait objects in the interpreter, and emitting an error about this conversion failure, to avoid the ICE.
I've noticed that the error emitted at https://github.com/rust-lang/rust/blob/a50d72158e08e02cfc051b863017bdbd2c45b637/compiler/rustc_mir/src/interpret/traits.rs#L163-L166 doesn't seem to be present in the const-ub tests, so I've tried adding a test that triggers both of these cases: one for the invalid size, and another for the invalid alignment that #86132 tracks (I have found different magic values triggering different `Align::from_bytes` errors than the "power of 2" one, if need be).
However, when doing that, I *cannot* for the life of me figure out the correct incantation to make these 2 errors trigger with the "it is undefined behavior to use this value" message rather than the "any use of this value will cause an error" lint.
I've tried Oli's suggestions of different values, tuples and arrays, using the transparent wrapper trick from the other tests and I was only able to trigger the regular const-ub errors about the size of the vtable, or that the drop pointer was invalid. Maybe these "type validation failed" errors happen before this part of the interpreter is reached and there just needs some magic incorrect values to bypass them, I don't know.
Since this fixes an ICE, and if the constants are indeed used, these 2 tests will turn into a hard error, I thought I'd open the PR anyways. And if ```@RalfJung``` you know of a way I could manage that (if you think that these tests are worth checking that the `throw_ub_format!` does indeed create const-ub errors as we expect) I'd be grateful.
For that reason, r? ```@RalfJung``` and cc ```@oli-obk.```
|
|
Do not suggest ampmut if rhs is already mutable
Removes invalid suggestion in #85765, although it should highlight the user type instead of the local variable.
Looking at the comments of this line:
https://github.com/rust-lang/rust/blob/84b1005bfd22e2cb2a4c13b0b81958fe72628354/compiler/rustc_mir_build/src/build/matches/mod.rs#L2107
It was intentionally set to `None`, causing it to highlight the local variable instead. I am not sure if I will be able to fix it.
Fixes #85765
|
|
Disallow non-monomorphic calls to `needs_drop` in interpreter
otherwise evaluation could change after further substitutions.
|
|
also add tests for these 2 kinds of errors for size and alignment,
as the existing size check wasn't apparently tested
|
|
Create different inference variables for different defining uses of TAITs
Fixes #73481
r? `@nikomatsakis`
cc `@oli-obk`
|
|
Peephole optimize `x == false` and `x != true`
This adds peephole optimizations to make `x == false`, `false == x`, `x != true`, and `true != x` get optimized to `!x` in the `instcombine` MIR pass. That pass currently handles `x == true` -> `x` already.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Replace a `match` with an `if let`
Seems like a better fit here and saves one level of indentation.
`@rustbot` modify labels +C-cleanup +T-compiler
|
|
These macros have already been removed, but there was still some code
handling these macros. That code is now removed.
|
|
|
|
|
|
otherwise evaluation could change after further substitutions.
|