about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
AgeCommit message (Collapse)AuthorLines
2023-08-16Make TerminatorEdge plural.Camille GILLOT-2/+2
2023-08-16Allow apply_terminator_effect to customize edges.Camille GILLOT-5/+8
2023-08-14Remove constness from `ImplSource::Param`Deadbeef-3/+2
2023-08-08Auto merge of #114637 - matthiaskrgr:rollup-544y8p5, r=matthiaskrgrbors-11/+2
Rollup of 11 pull requests Successful merges: - #106425 (Make ExitStatus implement Default) - #113480 (add aarch64-unknown-teeos target) - #113586 (Mention style for new syntax in tracking issue template) - #113593 (CFI: Fix error compiling core with LLVM CFI enabled) - #114612 (update llvm-wrapper include to silence deprecation warning) - #114613 (Prevent constant rebuilds of `rustc-main` (and thus everything else)) - #114615 (interpret: remove incomplete protection against invalid where clauses) - #114628 (Allowing re-implementation of mir_drops_elaborated query) - #114629 (tests: Uncomment now valid GAT code behind FIXME) - #114630 (Migrate GUI colors test to original CSS color format) - #114631 (add provisional cache test for new solver) r? `@ghost` `@rustbot` modify labels: rollup
2023-08-08Rollup merge of #114615 - RalfJung:interpret-invalid-where, r=lcnrMatthias Krüger-11/+2
interpret: remove incomplete protection against invalid where clauses Cc https://github.com/rust-lang/rust/issues/97477, https://github.com/rust-lang/project-const-generics/issues/37 r? ``@lcnr``
2023-08-08Auto merge of #114545 - fee1-dead-contrib:lower-impl-effect, r=oli-obkbors-12/+8
correctly lower `impl const` to bind to host effect param r? `@oli-obk`
2023-08-08interpret: remove incomplete protection against invalid where clausesRalf Jung-11/+2
2023-08-08Auto merge of #114520 - RalfJung:unsized-valtrees, r=oli-obkbors-121/+45
simplify handling of valtrees for unsized types
2023-08-07Rollup merge of #114382 - scottmcm:compare-bytes-intrinsic, r=cjgillotMatthias Krüger-0/+22
Add a new `compare_bytes` intrinsic instead of calling `memcmp` directly As discussed in #113435, this lets the backends be the place that can have the "don't call the function if n == 0" logic, if it's needed for the target. (I didn't actually *add* those checks, though, since as I understood it we didn't actually need them on known targets?) Doing this also let me make it `const` (unstable), which I don't think `extern "C" fn memcmp` can be. cc `@RalfJung` `@Amanieu`
2023-08-06Add a new `compare_bytes` intrinsic instead of calling `memcmp` directlyScott McMurray-0/+22
2023-08-07Rollup merge of #114542 - RalfJung:const-prop-nonsense, r=compiler-errorsMatthias Krüger-4/+5
interpret: use ConstPropNonsense for more const-prop induced issues
2023-08-06simplify handling of valtrees for unsized typesRalf Jung-82/+43
2023-08-06remove an unnecessary special case in valtree_into_mplaceRalf Jung-40/+3
2023-08-06Rollup merge of #114505 - ouz-a:cleanup_mir, r=RalfJungMatthias Krüger-1/+1
Add documentation to has_deref Documentation of `has_deref` needed some polish to be more clear about where it should be used and what's it's purpose. cc https://github.com/rust-lang/rust/issues/114401 r? `@RalfJung`
2023-08-06cleanup misinformation regarding has_derefouz-a-1/+1
2023-08-06lower impl const to bind to host effect paramDeadbeef-12/+8
2023-08-06interpret: use ConstPropNonsense for more const-prop induced issuesRalf Jung-4/+5
2023-08-04interpret: add mplace_to_ref helper methodRalf Jung-6/+14
2023-08-03Rollup merge of #114372 - RalfJung:const-pointer-as-int, r=oli-obkMatthias Krüger-161/+203
const validation: point at where we found a pointer but expected an integer Instead of validation just printing "unable to turn pointer into bytes", make this a regular validation error that says where in the value the bad pointer was found. Also distinguish "expected integer, got pointer" from "expected pointer, got partial pointer or mix of pointers". To avoid duplicating things too much I refactored the diagnostics for validity a bit, so that "got uninit, expected X" and "got pointer, expected X" can share the "X" part. Also all the errors emitted for validation are now grouped under `const_eval_validation` so that they are in a single group in the ftl file. r? `@oli-obk`
2023-08-03Rollup merge of #114363 - RalfJung:interpret-not-miri, r=jackh726Matthias Krüger-2/+2
avoid 'miri' when refering to the shared interpreter This is basically the rustc source code version of https://github.com/rust-lang/rustc-dev-guide/pull/1471.
2023-08-02const validation: point at where we found a pointer but expected an integerRalf Jung-161/+203
2023-08-02Remove constness from `TraitPredicate`Deadbeef-3/+3
2023-08-02avoid 'miri' when refering to the shared interpreterRalf Jung-2/+2
2023-08-02Rollup merge of #114079 - compiler-errors:closure-upvars, r=oli-obkNilstrieb-2/+3
Use `upvar_tys` in more places, make it return a list Just a cleanup that fell out of a PR that I was gonna write, but that PR kinda got stuck.
2023-08-02Auto merge of #114333 - RalfJung:dangling-ptr-offset, r=oli-obkbors-26/+33
Miri: fix error on dangling pointer inbounds offset We used to claim that the pointer was "dereferenced", but that is just not true. Can be reviewed commit-by-commit. The first commit is an unrelated rename that didn't seem worth splitting into its own PR. r? `@oli-obk`
2023-08-01Use upvar_tys in more places, make it a listMichael Goulet-2/+3
2023-08-01properly track why we checked whether a pointer is in-boundsRalf Jung-14/+22
also simplify the in-bounds checking in Miri's borrow trackers
2023-08-01rename deref_operand → deref_pointer and some Miri helper functionsRalf Jung-12/+11
2023-07-31fix alignment handling for Repeat expressionsRalf Jung-4/+4
2023-07-29Rollup merge of #113773 - compiler-errors:err-layout-bail, r=cjgillotMatthias Krüger-1/+4
Don't attempt to compute layout of type referencing error Leads to more ICEs and strange diagnostics than are worth it. Fixes #113760
2023-07-28Auto merge of #114134 - fee1-dead-contrib:rm-constness-from-param-env, r=oli-obkbors-30/+38
Remove `constness` from `ParamEnv` This should be replaced by keyword generics/effects. cc #110395 r? `@oli-obk`
2023-07-27Dont report CTFE errors that are due to references-error layoutsMichael Goulet-1/+4
2023-07-27bless clippyDeadbeef-5/+8
2023-07-27Remove `constness` from `ParamEnv`Deadbeef-25/+30
2023-07-27Rollup merge of #114123 - oli-obk:tait_wtf, r=WaffleLapkinGuillaume Gomez-6/+9
Turns out opaque types can have hidden types registered during mir validation See the newly added test's documentation for an explanation. fixes #114121
2023-07-27Turns out opaque types can have hidden types registered during mir validationOli Scherer-6/+9
2023-07-27Rollup merge of #114075 - matthiaskrgr:fmt_args_rustc_3, r=wesleywiserMatthias Krüger-69/+52
inline format!() args from rustc_codegen_llvm to the end (4) r? `@WaffleLapkin`
2023-07-26Auto merge of #113843 - wesleywiser:replace_rustc_apfloat, r=pnkfelixbors-1/+1
Replace in-tree `rustc_apfloat` with the new version of the crate Replace the in-tree version of `rustc_apfloat` with the new version of the crate which has been correctly licensed. The new crate incorporates upstream changes from LLVM since the original port was done including many correctness fixes and has been extensively fuzz tested to validate correctness. Fixes #100233 Fixes #102403 Fixes #113407 Fixes #113409 Fixes #55993 Fixes #93224 Closes #93225 Closes #109573
2023-07-26Replace in-tree `rustc_apfloat` with the new version of the crateWesley Wiser-1/+1
2023-07-26Auto merge of #114071 - RalfJung:interpret-generic-read-write, r=oli-obkbors-244/+276
interpret: make read/write methods generic Instead of always having to call `into()` to convert things to `PlaceTy`/`OpTy`, make the relevant methods generic. This also means that when we read from an `MPlaceTy`, we avoid creating an intermediate `PlaceTy`. This makes it feasible to remove the `Copy` from `MPlaceTy`. All the other `*Ty` interpreter types already had their `Copy` removed a while ago so this is only consistent. (And in fact we had one function that accidentally took `MPlaceTy` instead of `&MPlaceTy`.)
2023-07-26valtree: a bit of cleanupRalf Jung-15/+15
2023-07-25Rollup merge of #113661 - oli-obk:tait_wtf, r=lcnrMatthias Krüger-3/+8
Double check that hidden types match the expected hidden type Fixes https://github.com/rust-lang/rust/issues/113278 specifically, but I left a TODO for where we should also add some hardening. It feels a bit like papering over the issue, but at least this way we don't get unsoundness, but just surprising errors. Errors will be improved and given spans before this PR lands. r? `@compiler-errors` `@lcnr`
2023-07-25inline format!() args from rustc_codegen_llvm to the end (4)Matthias Krüger-69/+52
r? @WaffleLapkin
2023-07-25make MPlaceTy non-CopyRalf Jung-16/+16
2023-07-25interpret: make read functions generic over operand typeRalf Jung-81/+83
2023-07-25interpret: make write functions generic over the place typeRalf Jung-139/+169
2023-07-25Auto merge of #113393 - compiler-errors:next-solver-unsize-rhs, r=lcnrbors-3/+6
Normalize the RHS of an `Unsize` goal in the new solver `Unsize` goals are... tricky. Not only do they structurally match on their self type, but they're also structural on their other type parameter. I'm pretty certain that it is both incomplete and also just plain undesirable to not consider normalizing the RHS of an unsize goal. More practically, I'd like for this code to work: ```rust trait A {} trait B: A {} impl A for usize {} impl B for usize {} trait Mirror { type Assoc: ?Sized; } impl<T: ?Sized> Mirror for T { type Assoc = T; } fn main() { // usize: Unsize<dyn B> let x = Box::new(1usize) as Box<<dyn B as Mirror>::Assoc>; // dyn A: Unsize<dyn B> let y = x as Box<<dyn A as Mirror>::Assoc>; } ``` --- In order to achieve this, we add `EvalCtxt::normalize_non_self_ty` (naming modulo bikeshedding), which *must* be used for all non-self type arguments that are structurally matched in candidate assembly. Currently this is only necessary for `Unsize`'s argument, but I could see future traits requiring this (hopefully rarely) in the future. It uses `repeat_while_none` to limit infinite looping, and normalizes the self type until it is no longer an alias. Also, we need to fix feature gate detection for `trait_upcasting` and `unsized_tuple_coercion` when HIR typeck has unnormalized types. We can do that by checking the `ImplSource` returned by selection, which necessitates adding a new impl source for tuple upcasting.
2023-07-25Make everything builtin!Michael Goulet-3/+6
2023-07-25Auto merge of #114011 - RalfJung:place-projection, r=oli-obkbors-1145/+955
interpret: Unify projections for MPlaceTy, PlaceTy, OpTy For ~forever, we didn't really have proper shared code for handling projections into those three types. This is mostly because `PlaceTy` projections require `&mut self`: they might have to `force_allocate` to be able to represent a project part-way into a local. This PR finally fixes that, by enhancing `Place::Local` with an `offset` so that such an optimized place can point into a part of a place without having requiring an in-memory representation. If we later write to that place, we will still do `force_allocate` -- for now we don't have an optimized path in `write_immediate` that would avoid allocation for partial overwrites of immediately stored locals. But in `write_immediate` we have `&mut self` so at least this no longer pollutes all our type signatures. (Ironically, I seem to distantly remember that many years ago, `Place::Local` *did* have an `offset`, and I removed it to simplify things. I guess I didn't realize why it was so useful... I am also not sure if this was actually used to achieve place projection on `&self` back then.) The `offset` had type `Option<Size>`, where `None` represent "no projection was applied". This is needed because locals *can* be unsized (when they are arguments) but `Place::Local` cannot store metadata: if the offset is `None`, this refers to the entire local, so we can use the metadata of the local itself (which must be indirect); if a projection gets applied, since the local is indirect, it will turn into a `Place::Ptr`. (Note that even for indirect locals we can have `Place::Local`: when the local appears in MIR, we always start with `Place::Local`, and only check `frame.locals` later. We could eagerly normalize to `Place::Ptr` but I don't think that would actually simplify things much.) Having done all that, we can finally properly abstract projections: we have a new `Projectable` trait that has the basic methods required for projecting, and then all projection methods are implemented for anything that implements that trait. We can even implement it for `ImmTy`! (Not that we need that, but it seems neat.) The visitor can be greatly simplified; it doesn't need its own trait any more but it can use the `Projectable` trait. We also don't need the separate `Mut` visitor any more; that was required only to reflect that projections on `PlaceTy` needed `&mut self`. It is possible that there are some more `&mut self` that can now become `&self`... I guess we'll notice that over time. r? `@oli-obk`
2023-07-25add some sanity checks in write_immediate_no_validateRalf Jung-3/+28