about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
AgeCommit message (Collapse)AuthorLines
2023-10-17[RFC 3127 - Trim Paths]: Condition remapped filepath on remap scopesUrgau-1/+9
2023-10-16docs: add Rust logo to more compiler cratesMichael Howell-0/+3
c6e6ecb1afea9695a42d0f148ce153536b279eb5 added it to some of the compiler's crates, but avoided adding it to all of them to reduce bit-rot. This commit adds to more.
2023-10-16Auto merge of #116550 - nnethercote:rustc-features-more, r=Nilstriebbors-1/+1
Cleanup `rustc_features` some more The sequel to #116437. r? `@Nilstrieb`
2023-10-16Auto merge of #114330 - RalfJung:dagling-ptr-deref, r=oli-obkbors-326/+306
don't UB on dangling ptr deref, instead check inbounds on projections This implements https://github.com/rust-lang/reference/pull/1387 in Miri. See that PR for what the change is about. Detecting dangling references in `let x = &...;` is now done by validity checking only, so some tests need to have validity checking enabled. There is no longer inherently a "nodangle" check in evaluating the expression `&*ptr` (aside from the aliasing model). r? `@oli-obk` Based on: - https://github.com/rust-lang/reference/pull/1387 - https://github.com/rust-lang/rust/pull/115524
2023-10-16Auto merge of #116724 - RalfJung:alloc-bytes, r=oli-obkbors-11/+0
interpret: clean up AllocBytes Fixes https://github.com/rust-lang/miri/issues/2836 Nothing has moved here in half a year, so let's just remove these unused stubs -- they need a proper re-design anyway. r? `@oli-obk`
2023-10-16Rename `ACTIVE_FEATURES` as `UNSTABLE_FEATURES`.Nicholas Nethercote-1/+1
It's a better name, and lets "active features" refer to the features that are active in a particular program, due to being declared or enabled by the edition. The commit also renames `Features::enabled` as `Features::active` to match this; I changed my mind and have decided that "active" is a little better thatn "enabled" for this, particularly because a number of pre-existing comments use "active" in this way. Finally, the commit renames `Status::Stable` as `Status::Accepted`, to match `ACCEPTED_FEATURES`.
2023-10-15separate bounds-check from alignment checkRalf Jung-112/+76
2023-10-15more precise error for 'based on misaligned pointer' caseRalf Jung-24/+26
2023-10-15avoid computing misalignment if we won't act on itRalf Jung-6/+11
2023-10-15place evaluation: require the original pointer to be aligned if an access ↵Ralf Jung-205/+178
happens
2023-10-15avoid re-checking the offset while iterating an array/sliceRalf Jung-15/+54
2023-10-15don't UB on dangling ptr deref, instead check inbounds on projectionsRalf Jung-52/+49
2023-10-15Auto merge of #116688 - compiler-errors:rustfmt-up, r=WaffleLapkin,Nilstriebbors-17/+24
Format all the let-chains in compiler crates Since rust-lang/rustfmt#5910 has landed, soon we will have support for formatting let-chains (as soon as rustfmt syncs and beta gets bumped). This PR applies the changes [from master rustfmt to rust-lang/rust eagerly](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/out.20formatting.20of.20prs/near/374997516), so that the next beta bump does not have to deal with a 200+ file diff and can remain concerned with other things like `cfg(bootstrap)` -- #113637 was a pain to land, for example, because of let-else. I will also add this commit to the ignore list after it has landed. The commands that were run -- I'm not great at bash-foo, but this applies rustfmt to every compiler crate, and then reverts the two crates that should probably be formatted out-of-tree. ``` ~/rustfmt $ ls -1d ~/rust/compiler/* | xargs -I@ cargo run --bin rustfmt -- `@/src/lib.rs` --config-path ~/rust --edition=2021 # format all of the compiler crates ~/rust $ git checkout HEAD -- compiler/rustc_codegen_{gcc,cranelift} # revert changes to cg-gcc and cg-clif ``` cc `@rust-lang/rustfmt` r? `@WaffleLapkin` or `@Nilstrieb` who said they may be able to review this purely mechanical PR :> cc `@Mark-Simulacrum` and `@petrochenkov,` who had some thoughts on the order of operations with big formatting changes in https://github.com/rust-lang/rust/pull/95262#issue-1178993801. I think the situation has changed since then, given that let-chains support exists on master rustfmt now, and I'm fairly confident that this formatting PR should land even if *bootstrap* rustfmt doesn't yet format let-chains in order to lessen the burden of the next beta bump.
2023-10-14Rollup merge of #116576 - eduardosm:const-eval-wasm-target-features, r=RalfJungGuillaume Gomez-4/+6
const-eval: allow calling functions with targat features disabled at compile time in WASM This is not unsafe on WASM, see https://github.com/rust-lang/rust/pull/84988 r? `@RalfJung` Fixes https://github.com/rust-lang/rust/issues/116516
2023-10-14const-eval: allow calling functions with targat features disabled at compile ↵Eduardo Sánchez Muñoz-4/+6
time in WASM This is not unsafe on WASM, see https://github.com/rust-lang/rust/pull/84988
2023-10-14interpret: clean up AllocBytesRalf Jung-11/+0
2023-10-14Auto merge of #116015 - EvanMerlock:master, r=oli-obkbors-15/+23
const_eval: allow function pointer signatures containing &mut T in const contexts potentially fixes #114994 We utilize a `TypeVisitor` here in order to more easily handle control flow. - In the event the typekind the Visitor sees is a function pointer, we skip over it - However, otherwise we do one of two things: - If we find a mutable reference, check it, then continue visiting types - If we find any other type, continue visiting types This means we will check if the function pointer _itself_ is mutable, but not if any of the types _within_ are.
2023-10-14Auto merge of #115524 - RalfJung:misalign, r=wesleywiserbors-105/+29
const-eval: make misalignment a hard error It's been a future-incompat error (showing up in cargo's reports) since https://github.com/rust-lang/rust/pull/104616, Rust 1.68, released in March. That should be long enough. The question for the lang team is simply -- should we move ahead with this, making const-eval alignment failures a hard error? (It turns out some of them accidentally already were hard errors since #104616. But not all so this is still a breaking change. Crater found no regression.)
2023-10-13Format all the let chains in compilerMichael Goulet-17/+24
2023-10-13add some comments and some cleanup around Miri intptrcastRalf Jung-0/+10
2023-10-10Auto merge of #116551 - RalfJung:nondet-nan, r=oli-obkbors-9/+51
miri: make NaN generation non-deterministic This implements the [LLVM semantics for NaN generation](https://llvm.org/docs/LangRef.html#behavior-of-floating-point-nan-values). I will soon submit an RFC to make this also officially the Rust semantics, but it has been our de-facto semantics for a long time so there's no reason Miri has to wait for that RFC. This PR just better aligns Miri with codegen. This PR does that just for the operations that have MIR primitives; a future PR will adjust the intrinsics.
2023-10-09float-to-float casts also have non-deterministic NaN resultsRalf Jung-7/+29
2023-10-09ensure unary minus propagates NaN payloads exactlyRalf Jung-0/+1
2023-10-08miri: make NaN generation non-deterministicRalf Jung-5/+24
2023-10-07Auto merge of #115583 - RalfJung:packed-unsized, r=lcnrbors-1/+9
fix detecting references to packed unsized fields Fixes https://github.com/rust-lang/rust/issues/115396 This is a breaking change, but permitted as a soundness fix.
2023-10-06Rollup merge of #116277 - RalfJung:post-mono, r=oli-obkJubilee-13/+20
dont call mir.post_mono_checks in codegen It seems like all tests are still passing when I remove this... let's see what CI says.
2023-10-06Auto merge of #114811 - estebank:impl-ambiguity, r=wesleywiserbors-1/+1
Show more information when multiple `impl`s apply - When there are `impl`s without type params, show only those (to avoid showing overly generic `impl`s). ``` error[E0283]: type annotations needed --> $DIR/multiple-impl-apply.rs:34:9 | LL | let y = x.into(); | ^ ---- type must be known at this point | note: multiple `impl`s satisfying `_: From<Baz>` found --> $DIR/multiple-impl-apply.rs:14:1 | LL | impl From<Baz> for Bar { | ^^^^^^^^^^^^^^^^^^^^^^ ... LL | impl From<Baz> for Foo { | ^^^^^^^^^^^^^^^^^^^^^^ = note: required for `Baz` to implement `Into<_>` help: consider giving `y` an explicit type | LL | let y: /* Type */ = x.into(); | ++++++++++++ ``` - Lower the importance of `T: Sized`, `T: WellFormed` and coercion errors, to prioritize more relevant errors. The pre-existing deduplication logic deals with hiding redundant errors better that way, and we show errors with more metadata that is useful to the user. - Show `<SelfTy as Trait>::assoc_fn` suggestion in more cases. ``` error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type --> $DIR/cross-return-site-inference.rs:38:16 | LL | return Err(From::from("foo")); | ^^^^^^^^^^ cannot call associated function of trait | help: use a fully-qualified path to a specific available implementation | LL | return Err(</* self type */ as From>::from("foo")); | +++++++++++++++++++ + ``` Fix #88284.
2023-10-04Remove mir::LocalDecl::internal.Camille GILLOT-1/+1
2023-10-04Reorder fullfillment errors to keep more interesting ones firstEsteban Küber-1/+1
In `report_fullfillment_errors` push back `T: Sized`, `T: WellFormed` and coercion errors to the end of the list. The pre-existing deduplication logic eliminates redundant errors better that way, keeping the resulting output with fewer errors than before, while also having more detail.
2023-10-03Auto merge of #116376 - matthiaskrgr:rollup-b3d14gq, r=matthiaskrgrbors-20/+30
Rollup of 5 pull requests Successful merges: - #115863 (Add check_unused_messages in tidy) - #116210 (Ensure that `~const` trait bounds on associated functions are in const traits or impls) - #116358 (Rename both of the `Match` relations) - #116371 (Remove unused features from `rustc_llvm`.) - #116374 (Print normalized ty) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-03Auto merge of #115025 - ouz-a:ouz_testing, r=lcnrbors-10/+50
Make subtyping explicit in MIR This adds new mir-opt that pushes new `ProjectionElem` called `ProjectionElem::Subtype(T)` to `Rvalue` of a subtyped assignment so we can unsoundness issues like https://github.com/rust-lang/rust/issues/107205 Addresses https://github.com/rust-lang/rust/issues/112651 r? `@lcnr`
2023-10-03print normalized tyouz-a-20/+30
2023-10-02have better explanation for `relate_types`ouz-a-3/+3
2023-10-02change is_subtype to relate_typesouz-a-11/+26
2023-10-02Add docs, remove code, change subtyper codeouz-a-28/+21
2023-10-02subtyping_projectionsouz-a-1/+33
2023-10-01Auto merge of #115670 - Zoxc:outline-panic-macro-1, r=Mark-Simulacrumbors-4/+4
Partially outline code inside the panic! macro This outlines code inside the panic! macro in some cases. This is split out from https://github.com/rust-lang/rust/pull/115562 to exclude changes to rustc.
2023-09-30dont call mir.post_mono_checks in codegenRalf Jung-13/+20
2023-09-28Add a mir validation check to prevent OpaqueCast after analysis passes finishOli Scherer-0/+8
2023-09-28Skip reinterning if nothing changedOli Scherer-1/+3
2023-09-28Strip `OpaqueCast` during `RevealAll`.Oli Scherer-1/+1
2023-09-26const-eval: make misalignment a hard errorRalf Jung-105/+29
2023-09-26subst -> instantiatelcnr-5/+6
2023-09-23Remove GeneratorWitness and rename GeneratorWitnessMIR.Camille GILLOT-8/+3
2023-09-22fix(const_eval): correctly check const type for function pointersEvan Merlock-15/+23
- uses TypeReader for resolving local/return ty to support case where function pointer is before another type in a compound type
2023-09-22Have a single struct for queries and hookOli Scherer-4/+3
2023-09-22Add a way to decouple the implementation and the declaration of a TyCtxt method.Oli Scherer-7/+8
2023-09-21Auto merge of #116010 - RalfJung:more-typed-immediates, r=oli-obkbors-177/+183
interpret: more consistently use ImmTy in operators and casts The diff in src/tools/miri/src/shims/x86/sse2.rs should hopefully suffice to explain why this is nicer. :)
2023-09-21Rollup merge of #115972 - RalfJung:const-consistency, r=oli-obkGuillaume Gomez-16/+16
rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::Const Also, be more consistent with the `to/eval_bits` methods... we had some that take a type and some that take a size, and then sometimes the one that takes a type is called `bits_for_ty`. Turns out that `ty::Const`/`mir::ConstKind` carry their type with them, so we don't need to even pass the type to those `eval_bits` functions at all. However this is not properly consistent yet: in `ty` we have most of the methods on `ty::Const`, but in `mir` we have them on `mir::ConstKind`. And indeed those two types are the ones that correspond to each other. So `mir::ConstantKind` should actually be renamed to `mir::Const`. But what to do with `mir::Constant`? It carries around a span, that's really more like a constant operand that appears as a MIR operand... it's more suited for `syntax.rs` than `consts.rs`, but the bigger question is, which name should it get if we want to align the `mir` and `ty` types? `ConstOperand`? `ConstOp`? `Literal`? It's not a literal but it has a field called `literal` so it would at least be consistently wrong-ish... ``@oli-obk`` any ideas?
2023-09-21Prevent promotion of const fn calls in inline constsOli Scherer-2/+2