about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
AgeCommit message (Collapse)AuthorLines
2023-03-10Auto merge of #108977 - matthiaskrgr:rollup-1bnl1hu, r=matthiaskrgrbors-1/+1
Rollup of 9 pull requests Successful merges: - #108879 (Unconstrained terms should account for infer vars being equated) - #108936 (Rustdoc: don't hide anonymous reexport) - #108940 (Add myself to compiler reviewers list) - #108945 (Make some report and emit errors take DefIds instead of BodyIds) - #108946 (Document the resulting values produced when using `From<bool>` on floats) - #108956 (Make ptr::from_ref and ptr::from_mut in #106116 const.) - #108960 (Remove `body_def_id` from `Inherited`) - #108963 (only call git on git checkouts during bootstrap) - #108964 (Fix the docs for pointer method with_metadata_of) Failed merges: - #108950 (Directly construct Inherited in typeck.) r? `@ghost` `@rustbot` modify labels: rollup
2023-03-09Remove body_def_id from InheritedMichael Goulet-1/+1
2023-03-09Introduce a no-op PlaceMention statement for `let _ =`.Camille GILLOT-1/+10
2023-03-08Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiaskoMatthias Krüger-36/+3
Remove DropAndReplace terminator #107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-08Assume the frame has all the locals.Camille GILLOT-17/+13
2023-03-07remove leftover commentGiacomo Pasini-3/+0
2023-03-07Remove DropAndReplace terminatorGiacomo Pasini-33/+3
PR 107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-06Rollup merge of #108803 - cjgillot:const-prop-normalize, r=oli-obkMatthias Krüger-9/+2
Do not ICE when failing to normalize in ConstProp. There is no reason to delay a bug there, as we bubble up the failure as TooGeneric. Fixes https://github.com/rust-lang/rust/issues/97728
2023-03-06Rollup merge of #108790 - cjgillot:mono-cast, r=oli-obkMatthias Krüger-13/+22
Do not ICE when interpreting a cast between non-monomorphic types Fixes https://github.com/rust-lang/rust/issues/101596
2023-03-06Rollup merge of #108786 - saethlin:free-regions-check, r=oli-obkMatthias Krüger-0/+11
Check for free regions in MIR validation This turns https://github.com/rust-lang/rust/issues/108720 into a MIR validation failure that will reproduce without debug-assertions enabled. ``` error: internal compiler error: broken MIR in Item(WithOptConstParam { did: DefId(0:296 ~ futures_util[3805]::future::future::remote_handle::{impl#3}::poll), const_param_did: None }) (after pass ScalarReplacementOfAggregates) at bb0[0]: Free regions in optimized runtime-post-cleanup MIR --> /home/ben/.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/future/future/remote_handle.rs:96:13 | 96 | let this = self.project(); | ^^^^ ```
2023-03-06Rollup merge of #107801 - davidtwco:stability-implies-const, r=NilstriebMatthias Krüger-7/+22
const_eval: `implies_by` in `rustc_const_unstable` Fixes #107605. Extend support for `implies_by` (from `#[stable]` and `#[unstable]`) to `#[rustc_const_stable]` and `#[rustc_const_unstable]`. cc ``@steffahn``
2023-03-06Do not ICE when failing to normalize in ConstProp.Camille GILLOT-9/+2
2023-03-05Do not ICE when casting polymorphic values.Camille GILLOT-13/+22
2023-03-05Check for free regions in MIR validationBen Kimock-0/+11
2023-03-05Auto merge of #108351 - petrochenkov:rmdit, r=cjgillotbors-4/+2
rustc_middle: Remove trait `DefIdTree` This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-04Rollup merge of #108669 - Nilstrieb:query-my-uninitness, r=compiler-errorsDylan DPC-1/+5
Allow checking whether a type allows being uninitialized This is useful for clippy ([rust-lang/clippy#10407](https://github.com/rust-lang/rust-clippy/issues/10407)) and for the future `MaybeUninit::assume_init` panics (#100423).
2023-03-03Rollup merge of #108685 - est31:backticks_matchmaking, r=petrochenkovMatthias Krüger-3/+3
Match unmatched backticks in compiler/ Found with GNU grep: ``` grep -rEn '^(([^`]*`){2})*[^`]*`[^`]*$' compiler/ | rg -v '\s*[//]?.{1,2}```' ```
2023-03-03Don't put integers into backticks during formattingest31-2/+2
2023-03-03Match end user facing unmatched backticks in compiler/est31-2/+2
2023-03-02Rollup merge of #108022 - CraftSpider:align-bytes, r=oli-obkMatthias Krüger-21/+46
Support allocations with non-Box<[u8]> bytes This is prep work for allowing miri to support passing pointers to C code, which will require `Allocation`s to be correctly aligned. Currently, it just makes `Allocation` generic and plumbs the necessary changes through the right places. The follow-up to this will be adding a type in the miri interpreter which correctly aligns the bytes, using that for the Miri engine, then allowing Miri to pass pointers into these allocations to C calls. Based off of #100467, credit to ```@emarteca``` for the code
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-4/+2
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-02Allow checking whether a type allows being uninitializedNilstrieb-1/+5
This is useful for clippy and for the future `MaybeUninit::assume_init` panics.
2023-03-01Rollup merge of #108505 - Nilstrieb:further-unify-validity-intrinsics, ↵Matthias Krüger-62/+50
r=michaelwoerister Further unify validity intrinsics Also merges the inhabitedness check into the query to further unify the code paths. Depends on #108364
2023-02-27Auto merge of #108487 - cjgillot:no-typeck-mir, r=oli-obkbors-4/+2
Avoid invoking typeck from borrowck This PR attempts to reduce direct dependencies between typeck and MIR-related queries. The goal is to have all the information transit either through THIR or through dedicated queries that avoid depending on the whole `TypeckResults`. In a first commit, we store the type information that MIR building requires into THIR. This avoids edges between mir_built and typeck. In the second and third commit, we wrap informations around closures (upvars, kind origin and user-provided signature) to avoid borrowck depending on typeck information. There should be a single remaining borrowck -> typeck edge in the good path, due to inline consts.
2023-02-27Implement checked Shl/Shr at MIR building.Camille GILLOT-9/+0
2023-02-27Unify all validity check intrinsicsNilstrieb-62/+50
Also merges the inhabitedness check into the query to further unify the code paths.
2023-02-27Auto merge of #108175 - cjgillot:validate-storage, r=tmiaskobors-2/+20
MIR-Validate StorageLive. `StorageLive` statements on a local which already has storage is banned by miri. This check is easy enough, and can detect bugs in MIR opts.
2023-02-27Rollup merge of #108364 - Nilstrieb:validity-checks-refactor, r=compiler-errorsMatthias Krüger-11/+11
Unify validity checks into a single query Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check in #100423, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one. I am not entirely happy with the naming and key type and open for improvements. r? oli-obk
2023-02-26Access upvars through a query.Camille GILLOT-4/+2
2023-02-25Explain that this is UB catching instead of malformed MIR.Camille GILLOT-0/+7
2023-02-25MIR-Validate StorageLive.Camille GILLOT-2/+13
2023-02-24Rename many interner functions.Nicholas Nethercote-10/+11
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
2023-02-23Unify validity checks into a single queryNilstrieb-11/+11
Previously, there were two queries to check whether a type allows the 0x01 or zeroed bitpattern. I am planning on adding a further initness to check, truly uninit for MaybeUninit, which would make this three queries. This seems overkill for such a small feature, so this PR unifies them into one.
2023-02-22Auto merge of #108340 - eggyal:remove_traversal_trait_aliases, r=oli-obkbors-7/+11
Remove type-traversal trait aliases #107924 moved the type traversal (folding and visiting) traits into the type library, but created trait aliases in `rustc_middle` to minimise both the API churn for trait consumers and the arising boilerplate. As mentioned in that PR, an alternative approach of defining subtraits with blanket implementations of the respective supertraits was also considered at that time but was ruled out as not adding much value. Unfortunately, it has since emerged that rust-analyzer has difficulty with these trait aliases at present, resulting in a degraded contributor experience (see the recent [r-a has become useless](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/r-a.20has.20become.20useless) topic on the #t-compiler/help Zulip stream). This PR removes the trait aliases, and accordingly the underlying type library traits are now used directly; they are parameterised by `TyCtxt<'tcx>` rather than just the `'tcx` lifetime, and imports have been updated to reflect the fact that the trait aliases' explicitly named traits are no longer automatically brought into scope. These changes also roll-back the (no-longer required) workarounds to #107747 that were made in b409329c624b9e3bbd7d8e07697e2e9f861a45b6. Since this PR is just a find+replace together with the changes necessary for compilation & tidy to pass, it's currently just one mega-commit. Let me know if you'd like it broken up. r? `@oli-obk`
2023-02-22Remove type-traversal trait aliasesAlan Egerton-7/+11
2023-02-22errors: generate typed identifiers in each crateDavid Wood-9/+13
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-21Auto merge of #107728 - RalfJung:miri-dyn-star, r=RalfJung,oli-obkbors-71/+177
Miri: basic dyn* support As usual I am very unsure about the dynamic dispatch stuff, but it passes even the `Pin<&mut dyn* Trait>` test so that is something. TBH I think it was a mistake to make `dyn Trait` and `dyn* Trait` part of the same `TyKind` variant. Almost everywhere in Miri this lead to the wrong default behavior, resulting in strange ICEs instead of nice "unimplemented" messages. The two types describe pretty different runtime data layout after all. Strangely I did not need to do the equivalent of [this diff](https://github.com/rust-lang/rust/pull/106532#discussion_r1087095963) in Miri. Maybe that is because the unsizing logic matches on `ty::Dynamic(.., ty::Dyn)` already? In `unsized_info` I don't think the `target_dyn_kind` can be `DynStar`, since then it wouldn't be unsized! r? `@oli-obk` Cc `@eholk` (dyn-star) https://github.com/rust-lang/rust/issues/102425
2023-02-20Minimal changes to make miri workRune Tynan-8/+17
2023-02-20Fix alloc_base_addr typeRune Tynan-1/+1
2023-02-20Allow non-`Box` allocations in preparation for aligned const allocations for ↵Rune Tynan-20/+36
miri. Credit to emarteca for the code.
2023-02-20Revert most of the custom place computation, it was unnecessary.Oli Scherer-15/+10
2023-02-20Remove commented out codeOli Scherer-2/+0
2023-02-20Deduplicate some logic between dyn* and dynOli Scherer-46/+37
2023-02-20basic dyn* support for MiriRalf Jung-73/+195
2023-02-18Stop implementing _with_overflow intrinsics in codegen backends.Camille GILLOT-11/+0
2023-02-18Rename checked_binop_checks_overflow.Camille GILLOT-5/+6
2023-02-18Adapt interpreter.Camille GILLOT-15/+3
2023-02-18Fix CTFE interpreter.Camille GILLOT-1/+1
2023-02-18Adapt interpreter.Camille GILLOT-1/+7
2023-02-18Auto merge of #108112 - nnethercote:clarify-iterator-interners, ↵bors-1/+1
r=oli-obk,compiler-errors Clarify iterator interners I found the iterator interners very confusing. This PR clarifies things. r? `@compiler-errors`