about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
AgeCommit message (Collapse)AuthorLines
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
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-16/+16
2023-09-21try to avoid some layout_of callsRalf Jung-35/+34
2023-09-20stronger consistency check in ImmTy::from_immediateRalf Jung-3/+11
2023-09-20interpret: less debug-printing of typesRalf Jung-39/+29
2023-09-20interpret: more consistently use ImmTy in operators and castsRalf Jung-115/+124
2023-09-20the Const::eval_bits methods don't need to be given the TyRalf Jung-1/+1
2023-09-19adjust constValue::Slice to work for arbitrary slice typesRalf Jung-27/+38
2023-09-19move ConstValue into mirRalf Jung-31/+27
this way we have mir::ConstValue and ty::ValTree as reasonably parallel
2023-09-18Auto merge of #115748 - RalfJung:post-mono, r=oli-obkbors-96/+39
move required_consts check to general post-mono-check function This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants. Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) https://github.com/rust-lang/rust/issues/115709: ensuring that all locals are dynamically sized. I didn't expect this to change diagnostics, but it's just cycle errors that change. r? `@oli-obk`
2023-09-15make interpreter type Debug impl independent of Ty debug implRalf Jung-4/+17
2023-09-14don't point at const usage site for resolution-time errorsRalf Jung-22/+2
also share the code that emits the actual error
2023-09-14move required_consts check to general post-mono-check functionRalf Jung-79/+42
2023-09-14Auto merge of #115804 - RalfJung:valtree-to-const-val, r=oli-obkbors-51/+52
consistently pass ty::Const through valtrees Some drive-by things extracted from https://github.com/rust-lang/rust/pull/115748.
2023-09-14don't force all slice-typed ConstValue to be ConstValue::SliceRalf Jung-36/+29
2023-09-14valtree_to_const_value: add fast-path for Scalar tuples/structsRalf Jung-1/+16
2023-09-14make it more clear which functions create fresh AllocIdRalf Jung-10/+7
2023-09-14cleanup op_to_const a bit; rename ConstValue::ByRef → IndirectRalf Jung-27/+14
2023-09-14use AllocId instead of Allocation in ConstValue::ByRefRalf Jung-12/+12
2023-09-14a bit of cleanup in valtree_to_const_valueRalf Jung-51/+37
2023-09-13Auto merge of #115820 - matthiaskrgr:rollup-kyglvpu, r=matthiaskrgrbors-55/+11
Rollup of 6 pull requests Successful merges: - #115736 (Remove `verbose_generic_activity_with_arg`) - #115771 (cleanup leftovers of const_err lint) - #115798 (add helper method for finding the one non-1-ZST field) - #115812 (Merge settings.css into rustdoc.css) - #115815 (fix: return early when has tainted in mir pass) - #115816 (Disabled socketpair for Vita) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-13Rollup merge of #115798 - RalfJung:non_1zst_field, r=wesleywiserMatthias Krüger-32/+7
add helper method for finding the one non-1-ZST field
2023-09-13Rollup merge of #115771 - RalfJung:no-more-const-err-lint, r=oli-obkMatthias Krüger-23/+4
cleanup leftovers of const_err lint Some code / comments seem to not have been updated when const_err was turned into a hard error, so we can do a bit of cleanup here. r? `@oli-obk`
2023-09-12Introduce Machine::POST_MONO_CHECKS.Camille GILLOT-4/+9
2023-09-12add helper method for finding the one non-1-ZST fieldRalf Jung-32/+7
2023-09-12cleanup leftovers of const_err lintRalf Jung-23/+4
2023-09-12Auto merge of #115705 - cjgillot:const-prop-aggregate, r=oli-obkbors-5/+6
Read from non-scalar constants and statics in dataflow const-prop DataflowConstProp is designed to handle scalar values. When MIR features an assignment from a non-scalar constant, we need to manually decompose it into the custom state space. This PR tweaks interpreter callbacks to allow reusing `eval_mir_constant` without having a stack frame to get a span from. r? `@oli-obk` cc `@jachris`