about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
AgeCommit message (Collapse)AuthorLines
2024-03-11Remove unused impls from some subdiagnostics.Nicholas Nethercote-1/+1
2024-03-10Rollup merge of #122290 - RalfJung:mir-printing, r=compiler-errorsMatthias Krüger-1/+1
MIR printing: print the path of uneval'd const Currently it just prints `const _` which makes it impossible to say which constant is being referred to. Also refer to promoteds in a consistent way; previously MIR printing would do ``` promoted[0] in C1: &Option<Cell<i32>> = { // ... } ``` Now that should be ``` const C1::promoted[0]: &Option<Cell<i32>> = { // ... } ``` We don't seem to have a test for that so I tried it by hand, it seems to work: ``` const main::promoted[12]: &[&str; 3] = { let mut _0: &[&str; 3]; let mut _1: [&str; 3]; let mut _2: &str; let mut _3: &str; let mut _4: &str; let mut _5: &str; bb0: { _3 = const "b"; _2 = &(*_3); _5 = const "c"; _4 = &(*_5); _1 = [const "a", move _2, move _4]; _0 = &_1; return; } } ```
2024-03-10Rollup merge of #122286 - RalfJung:resolve, r=compiler-errorsMatthias Krüger-4/+2
use Instance::expect_resolve() instead of unwraping Instance::resolve()
2024-03-10MIR printing: print the path of uneval'd const; refer to promoteds in a ↵Ralf Jung-1/+1
consistent way
2024-03-10use Instance::expect_resolve() instead of unwraping Instance::resolve()Ralf Jung-4/+2
2024-03-10Rollup merge of #121860 - mu001999:master, r=NilstriebMatthias Krüger-3/+0
Add a tidy check that checks whether the fluent slugs only appear once As ``````@Nilstrieb`````` said in https://github.com/rust-lang/rust/pull/121828#issuecomment-1972622855: > Might make sense to have a tidy check that checks whether the fluent slugs only appear once in the source code and lint for that there's a tidy check already for sorting We can get the tidy check error: ``` tidy check tidy error: /path/to/rust/compiler/rustc_const_eval/messages.ftl: message `const_eval_invalid_align` is not used tidy error: /path/to/rust/compiler/rustc_lint/messages.ftl: message `lint_trivial_untranslatable_diag` is not used tidy error: /path/to/rust/compiler/rustc_parse/messages.ftl: message `parse_invalid_literal_suffix` is not used tidy error: /path/to/rust/compiler/rustc_infer/messages.ftl: message `infer_need_type_info_in_coroutine` is not used tidy error: /path/to/rust/compiler/rustc_passes/messages.ftl: message `passes_expr_not_allowed_in_context` is not used tidy error: /path/to/rust/compiler/rustc_passes/messages.ftl: message `passes_layout` is not used tidy error: /path/to/rust/compiler/rustc_parse/messages.ftl: message `parse_not_supported` is not used ``` r? ``````@Nilstrieb``````
2024-03-10remove unnecessary frame parameter from after_local_allocatedRalf Jung-4/+4
2024-03-10Auto merge of #121662 - saethlin:precondition-unification, r=RalfJungbors-6/+12
Distinguish between library and lang UB in assert_unsafe_precondition As described in https://github.com/rust-lang/rust/pull/121583#issuecomment-1963168186, `assert_unsafe_precondition` now explicitly distinguishes between language UB (conditions we explicitly optimize on) and library UB (things we document you shouldn't do, and maybe some library internals assume you don't do). `debug_assert_nounwind` was originally added to avoid the "only at runtime" aspect of `assert_unsafe_precondition`. Since then the difference between the macros has gotten muddied. This totally revamps the situation. Now _all_ preconditions shall be checked with `assert_unsafe_precondition`. If you have a precondition that's only checkable at runtime, do a `const_eval_select` hack, as done in this PR. r? RalfJung
2024-03-09interpret: do not call machine read hooks during validationRalf Jung-12/+45
2024-03-09remove some frame parameters that are no longer neededRalf Jung-17/+17
2024-03-09remove a machine hook that is no longer usedRalf Jung-24/+0
2024-03-09interpret: ensure that Place is never used for a different frameRalf Jung-33/+46
2024-03-09Only enable library UB checks in const-eval/Miri when debug_assertions are ↵Ben Kimock-1/+1
enabled Co-authored-by: Ralf Jung <post@ralfj.de>
2024-03-09interpret: pass Size and Align to before_memory_deallocationRalf Jung-2/+4
2024-03-09miri: do not apply aliasing restrictions to Box with custom allocatorRalf Jung-7/+11
2024-03-08Distinguish between library and lang UB in assert_unsafe_preconditionBen Kimock-6/+12
2024-03-08Rollup merge of #122076 - WaffleLapkin:mplace-args, r=RalfJungMatthias Krüger-26/+52
Tweak the way we protect in-place function arguments in interpreters Use `MPlaceTy` instead of `PlaceTy` in `FnArg` and ignore (copy) locals in an earlier step ("Locals that don't have their address taken are as protected as they can ever be"). This seems to be crucial for tail call support (as they can't refer to caller's locals which are killed when replacing the stack frame). r? `@RalfJung` cc `@oli-obk` see https://github.com/rust-lang/rust/pull/121273#issuecomment-1980210690
2024-03-08Tweak the way we protect in-place function arguments in interpretersMaybe Waffle-26/+52
Use `MPlaceTy` instead of `PlaceTy` in `FnArg` and ignore (copy) locals in an earlier step ("Locals that don't have their address taken are as protected as they can ever be"). This seems to be crucial for tail call support (as they can't refer to caller's locals which are killed when replacing the stack frame).
2024-03-08Rollup merge of #122183 - RalfJung:read-discriminant-uninhabited-variant, ↵Matthias Krüger-1/+7
r=tmiasko interpret: update comment about read_discriminant on uninhabited variants
2024-03-08Rollup merge of #122173 - compiler-errors:ptr-equality-in-ctfe, r=lcnrMatthias Krüger-1/+0
Don't ICE in CTFE if raw/fn-ptr types differ Fixes #121688 r? lcnr
2024-03-08interpret: update comment about read_discriminant on uninhabited variantsRalf Jung-1/+7
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-16/+11
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``
2024-03-08Don't ICE in CTFE if raw/fn-ptr types differMichael Goulet-1/+0
2024-03-07Auto merge of #121985 - RalfJung:interpret-return-place, r=oli-obkbors-31/+27
interpret: avoid a long-lived PlaceTy in stack frames `PlaceTy` uses a representation that's not very stable under changes to the stack. I'd feel better if we didn't have one in the long-term machine state. r? `@oli-obk`
2024-03-06Rollup merge of #121382 - nnethercote:rework-untranslatable_diagnostic-lint, ↵Matthias Krüger-0/+4
r=davidtwco Rework `untranslatable_diagnostic` lint Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This PR changes it to check calls to any function with an `impl Into<{D,Subd}iagnosticMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. It also lets us add `#[rustc_lint_diagnostics]` to a number of functions that don't have an `impl Into<{D,Subd}iagnosticMessage>`, such as `Diag::span`. r? ``@davidtwco``
2024-03-06Rewrite the `untranslatable_diagnostic` lint.Nicholas Nethercote-0/+4
Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This commit changes it to check calls to any function with an `impl Into<{D,Subd}iagMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. The commit also adds `#[allow(rustc::untranslatable_diagnostic)`] attributes to places that need it that are caught by the improved lint. These places that might be easy to convert to translatable diagnostics. Finally, it also: - Expands and corrects some comments. - Does some minor formatting improvements. - Adds missing `DecorateLint` cases to `tests/ui-fulldeps/internal-lints/diagnostics.rs`.
2024-03-06Auto merge of #122045 - matthiaskrgr:rollup-5l3vpn7, r=matthiaskrgrbors-8/+3
Rollup of 9 pull requests Successful merges: - #121065 (Add basic i18n guidance for `Display`) - #121744 (Stop using Bubble in coherence and instead emulate it with an intercrate check) - #121829 (Dummy tweaks (attempt 2)) - #121857 (Implement async closure signature deduction) - #121894 (const_eval_select: make it safe but be careful with what we expose on stable for now) - #122014 (Change some attributes to only_local.) - #122016 (will_wake tests fail on Miri and that is expected) - #122018 (only set noalias on Box with the global allocator) - #122028 (Remove some dead code) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-05Rollup merge of #122018 - RalfJung:box-custom-alloc, r=oli-obkMatthias Krüger-8/+3
only set noalias on Box with the global allocator As discovered in https://github.com/rust-lang/miri/issues/3341, `noalias` and custom allocators don't go well together. rustc can now check whether a Box uses the global allocator. This replaces the previous ad-hoc and rather unprincipled check for a zero-sized allocator. This is the rustc part of fixing that; Miri will also need a patch.
2024-03-05Convert `TypeVisitor` and `DefIdVisitor` to use `VisitorResult`Jason Newcomb-6/+6
2024-03-05only set noalias on Box with the global allocatorRalf Jung-8/+3
2024-03-05Rollup merge of #121997 - RalfJung:cast-float-ty, r=compiler-errorsMatthias Krüger-23/+35
interpret/cast: make more matches on FloatTy properly exhaustive Actually implementing these is pretty trivial (at least once all the scalar methods are added, which happens in https://github.com/rust-lang/rust/pull/121926), but I'm staying consistent with the other f16/f128 PRs. Also adding adding all the tests to Miri would be quite a lot of work. There's probably some way to reduce the code duplication here with more use of generics... but that's a future refactor.^^ r? ```@tgross35```
2024-03-05Rename `DiagnosticMessage` as `DiagMessage`.Nicholas Nethercote-14/+11
2024-03-04consistently use MPlaceTy for return placesRalf Jung-31/+20
2024-03-04typoRalf Jung-1/+1
Co-authored-by: Rémy Rakic <remy.rakic+github@gmail.com>
2024-03-04interpret/cast: make more matches on FloatTy properly exhaustiveRalf Jung-23/+35
2024-03-04interpret: avoid a long-lived PlaceTy in stack framesRalf Jung-3/+10
2024-03-02Rollup merge of #121731 - oli-obk:eager_opaque_checks, r=compiler-errorsGuillaume Boisseau-22/+3
Now that inlining, mir validation and const eval all use reveal-all, we won't be constraining hidden types here anymore r? `@compiler-errors` one bubble down, two more to go the test is unrelated, just something I noticed would be good to test in both the old solver and the new.
2024-03-03Remove unused fluent messagesr0cky-3/+0
2024-03-02add comment and test: we do not do value-based reasoning for promotion of unionsRalf Jung-0/+1
2024-03-01Auto merge of #121728 - tgross35:f16-f128-step1-ty-updates, r=compiler-errorsbors-0/+2
Add stubs in IR and ABI for `f16` and `f128` This is the very first step toward the changes in https://github.com/rust-lang/rust/pull/114607 and the [`f16` and `f128` RFC](https://rust-lang.github.io/rfcs/3453-f16-and-f128.html). It adds the types to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`, and just propagates those out as `unimplemented!` stubs where necessary. These types do not parse yet so there is no feature gate, and it should be okay to use `unimplemented!`. The next steps will probably be AST support with parsing and the feature gate. r? `@compiler-errors` cc `@Nilstrieb` suggested breaking the PR up in https://github.com/rust-lang/rust/pull/120645#issuecomment-1925900572
2024-02-29Rollup merge of #121782 - RalfJung:mutable-ref-in-static, r=oli-obkMatthias Krüger-20/+8
allow statics pointing to mutable statics Fixes https://github.com/rust-lang/rust/issues/120450 for good. We can even simplify our checks: no need to specifically go looking for mutable references in const, we can just reject any reference that points to something mutable. r? `@oli-obk`
2024-02-29allow statics pointing to mutable staticsRalf Jung-20/+8
2024-02-28Auto merge of #121489 - nnethercote:diag-renaming, r=davidtwcobors-58/+56
Diagnostic renaming Renaming various diagnostic types from `Diagnostic*` to `Diag*`. Part of https://github.com/rust-lang/compiler-team/issues/722. There are more to do but this is enough for one PR. r? `@davidtwco`
2024-02-28Add `f16` and `f128` to `rustc_type_ir::FloatTy` and `rustc_abi::Primitive`Trevor Gross-0/+2
Make changes necessary to support these types in the compiler.
2024-02-28Now that inlining, mir validation and const eval all use reveal-all, we ↵Oli Scherer-22/+3
won't be constraining hidden types here anymore
2024-02-28Rename `DiagnosticImportance` as `DiagImportance`.Nicholas Nethercote-16/+14
2024-02-28Rename `DiagnosticArg{,Map,Name,Value}` as `DiagArg{,Map,Name,Value}`.Nicholas Nethercote-9/+9
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-35/+35
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-27Split rustc_type_ir to avoid rustc_ast from depending on itOli Scherer-4/+2
2024-02-24Auto merge of #121549 - matthiaskrgr:rollup-1hvu3lb, r=matthiaskrgrbors-8/+12
Rollup of 7 pull requests Successful merges: - #121435 (Account for RPITIT in E0310 explicit lifetime constraint suggestion) - #121490 (Rustdoc: include crate name in links for local primitives) - #121520 (delay cloning of iterator items) - #121522 (check that simd_insert/extract indices are in-bounds) - #121531 (Ignore less tests in debug builds) - #121539 (compiler/rustc_target/src/spec/base/apple/tests.rs: Avoid unnecessary large move) - #121542 (update stdarch) r? `@ghost` `@rustbot` modify labels: rollup