about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
AgeCommit message (Collapse)AuthorLines
2021-10-08Auto merge of #89619 - michaelwoerister:incr-vtables, r=nagisabors-1/+1
Turn vtable_allocation() into a query This PR removes the untracked vtable-const-allocation cache from the `tcx` and turns the `vtable_allocation()` method into a query. The change is pretty straightforward and should be backportable without too much effort. Fixes https://github.com/rust-lang/rust/issues/89598.
2021-10-07Turn tcx.vtable_allocation() into a query.Michael Woerister-1/+1
2021-10-05Auto merge of #89266 - cjgillot:session-ich, r=michaelwoeristerbors-1/+1
Move ICH to rustc_query_system Based on https://github.com/rust-lang/rust/pull/89183 The StableHashingContext does not need to be in rustc_middle. This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-04Rollup merge of #89482 - hkmatsumoto:patch-diagnostics, r=joshtriplettManish Goregaokar-1/+1
Follow the diagnostic output style guide Detected by #89455.
2021-10-04Rollup merge of #89508 - jhpratt:stabilize-const_panic, r=joshtriplettJubilee-19/+0
Stabilize `const_panic` Closes #51999 FCP completed in #89006 ```@rustbot``` label +A-const-eval +A-const-fn +T-lang cc ```@oli-obk``` for review (not `r?`'ing as not on lang team)
2021-10-04Stabilize `const_panic`Jacob Pratt-19/+0
2021-10-03Remove re-export.Camille GILLOT-1/+1
2021-10-03Practice diagnostic message conventionHirochika Matsumoto-2/+2
2021-10-03Follow the diagnostic output style guideHirochika Matsumoto-1/+1
2021-10-01Rollup merge of #88963 - fee1-dead:const-iterator, r=oli-obkManish Goregaokar-23/+3
Coerce const FnDefs to implement const Fn traits You can now pass a FnDef to a function expecting `F` where `F: ~const FnTrait`. r? ``@oli-obk`` ``@rustbot`` label T-compiler F-const_trait_impl
2021-09-29CTFE: extra assertions for Aggregate rvalues; remove unnecessarily eager ↵Ralf Jung-7/+9
special case
2021-09-29remove outdated commentRalf Jung-1/+0
2021-09-25Report heap allocation instead of non-const fn for exchange_malloc callGary Guo-0/+5
2021-09-25Introduce `Rvalue::ShallowInitBox`Gary Guo-1/+11
2021-09-20Enable 2021 compatibility lints for all in-tree codeMark Rousskov-1/+1
This just applies the suggested fixes from the compatibility warnings, leaving any that are in practice spurious in. This is primarily intended to provide a starting point to identify possible fixes to the migrations (e.g., by avoiding spurious warnings). A secondary commit cleans these up where they are false positives (as is true in many of the cases).
2021-09-19Rollup merge of #89021 - ↵Yuki Okushi-5/+44
WaffleLapkin:separate_error_for_dyn_trait_in_const_fn, r=estebank Add a separate error for `dyn Trait` in `const fn` Previously "trait bounds other than `Sized` on const fn parameters are unstable" error was used for both trait bounds (`<T: Trait>`) and trait objects (`dyn Trait`). This was pretty confusing. This PR adds a separate error for trait objects: "trait objects in const fn are unstable". The error for trait bounds is otherwise intact. This is follow up to #88907 r? ``@estebank`` ``@rustbot`` label: +A-diagnostics
2021-09-18Start block is not allowed to have basic block predecessorsTomasz Miąsko-1/+4
2021-09-18Auto merge of #88965 - fee1-dead:const-drop-1, r=oli-obkbors-1/+11
Fast reject for NeedsNonConstDrop Hopefully fixes the regression in #88558. I've always wanted to help with the performance of rustc, but it doesn't feel the same when you are fixing a regression caused by your own PR... r? `@oli-obk`
2021-09-17Rollup merge of #88954 - nbdd0121:panic3, r=oli-obkGuillaume Gomez-2/+21
Allow `panic!("{}", computed_str)` in const fn. Special-case `panic!("{}", arg)` and translate it to `panic_display(&arg)`. `panic_display` will behave like `panic_any` in cosnt eval and behave like `panic!(format_args!("{}", arg))` in runtime. This should bring Rust 2015 and 2021 to feature parity in terms of `const_panic`; and hopefully would unblock the stabilisation of #51999. `@rustbot` modify labels: +T-compiler +T-libs +A-const-eval +A-const-fn r? `@oli-obk`
2021-09-17Auto merge of #88934 - tmiasko:trace-log, r=davidtwcobors-4/+5
Avoid unnecessary formatting when trace log level is disabled
2021-09-16Add a separate error for `dyn Trait` in `const fn`Waffle-5/+44
Previously "trait bounds other than `Sized` on const fn parameters are unstable" error was used for both trait bounds (<T: Trait>) and trait objects (dyn Trait). This was pretty confusing. This patch adds a separeta error for trait objects: "trait objects in const fn are unstable". The error for trait bounds is otherwise intact.
2021-09-15Rollup merge of #88933 - tmiasko:remove-min-align-of, r=oli-obkManish Goregaokar-7/+2
Remove implementation of `min_align_of` intrinsic Since #88839 `min_align_of` is lowered to AlignOf operator.
2021-09-15Rollup merge of #88907 - ↵Manish Goregaokar-2/+11
WaffleLapkin:targeted_const_fn_with_a_bound_in_impl_block_error, r=estebank Highlight the `const fn` if error happened because of a bound on the impl block Currently, for the following code, the compiler produces the errors like the following: ```rust struct Type<T>(T); impl<T: Clone> Type<T> { const fn f() {} } ``` ```text error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable --> ./test.rs:3:6 | 3 | impl<T: Clone> Type<T> { | ^ | = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable ``` This can be confusing (especially to newcomers) since the error mentions "const fn parameters", but highlights only the impl. This PR adds function highlighting, changing the error to the following: ```text error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable --> ./test.rs:3:6 | 3 | impl<T: Clone> Type<T> { | ^ 4 | pub const fn f() {} | ---------------- function declared as const here | = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable ``` --- I've originally wanted to point directly to `const` token, but couldn't find a way to get it's span. It seems like this span is lost during the AST -> HIR lowering. Also, since the errors for object casts in `const fn`s (`&T` -> `&dyn Trait`) seem to trigger the same error, this PR accidentally changes these errors too. Not sure if it's desired or how to fix this. P.S. it's my first time contributing to diagnostics, so feedback is very appreciated! --- r? ```@estebank``` ```@rustbot``` label: +A-diagnostics
2021-09-15Allow `panic!("{}", computed_str)` in const fn.Gary Guo-2/+21
2021-09-15Fast reject for NeedsNonConstDropDeadbeef-1/+11
2021-09-15Coerce const FnDefs to implement const Fn traitsDeadbeef-2/+1
2021-09-15Move is_const_fn to under TyCtxtDeadbeef-22/+3
2021-09-15Auto merge of #88558 - fee1-dead:const-drop, r=oli-obkbors-44/+62
Const drop The changes are pretty primitive at this point. But at least it works. ^-^ Problems with the current change that I can think of now: - [x] `~const Drop` shouldn't change anything in the non-const world. - [x] types that do not have drop glues shouldn't fail to satisfy `~const Drop` in const contexts. `struct S { a: u8, b: u16 }` This might not fail for `needs_non_const_drop`, but it will fail in `rustc_trait_selection`. - [x] The current change accepts types that have `const Drop` impls but have non-const `Drop` glue. Fixes #88424. Significant Changes: - `~const Drop` is no longer treated as a normal trait bound. In non-const contexts, this bound has no effect, but in const contexts, this restricts the input type and all of its transitive fields to either a) have a `const Drop` impl or b) can be trivially dropped (i.e. no drop glue) - `T: ~const Drop` will not be linted like `T: Drop`. - Instead of recursing and iterating through the type in `rustc_mir::transform::check_consts`, we use the trait system to special case `~const Drop`. See [`rustc_trait_selection::...::candidate_assembly#assemble_const_drop_candidates`](https://github.com/fee1-dead/rust/blob/const-drop/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L817) and others. Changes not related to `const Drop`ping and/or changes that are insignificant: - `Node.constness_for_typeck` no longer returns `hir::Constness::Const` for type aliases in traits. This was previously used to hack how we determine default bound constness for items. But because we now use an explicit opt-in, it is no longer needed. - Removed `is_const_impl_raw` query. We have `impl_constness`, and the only existing use of that query uses `HirId`, which means we can just operate it with hir. - `ty::Destructor` now has a field `constness`, which represents the constness of the destructor. r? `@oli-obk`
2021-09-14Remove implementation of `min_align_of` intrinsicTomasz Miąsko-7/+2
Since 88839 `min_align_of` is lowered to AlignOf operator.
2021-09-14Avoid unnecessary formatting when trace log level is disabledTomasz Miąsko-4/+5
2021-09-13Highlight the const function if error happened because of a bound on the ↵Waffle-2/+11
impl block Currently, for the following code, the compiler produces the errors like the following error: ```rust struct Type<T> impl<T: Clone> Type<T> { fn const f() {} } ``` ```text error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable --> ./test.rs:3:6 | 3 | impl<T: Clone> Type<T> { | ^ | = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable ``` This can be confusing (especially to newcomers) since the error mentions "const fn parameters", but highlights only the impl. This commits adds function highlighting, changing the error to the following: ```text error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable --> ./test.rs:3:6 | 3 | impl<T: Clone> Type<T> { | ^ 4 | pub const fn f() {} | ---------------- function declared as const here | = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information = help: add `#![feature(const_fn_trait_bound)]` to the crate attributes to enable ```
2021-09-12Auto merge of #88839 - nbdd0121:alignof, r=nagisabors-9/+12
Introduce NullOp::AlignOf This PR introduces `Rvalue::NullaryOp(NullOp::AlignOf, ty)`, which will be lowered from `align_of`, similar to `size_of` lowering to `Rvalue::NullaryOp(NullOp::SizeOf, ty)`. The changes are originally part of #88700 but since it's not dependent on other changes and could have performance impact on its own, it's separated into its own PR.
2021-09-13Introduce NullOp::AlignOfGary Guo-9/+12
2021-09-09Rename `(un)signed` to `(un)signed_int`Andreas Liljeqvist-2/+2
2021-09-09Move `unsigned_max` etc into `Size` againAndreas Liljeqvist-6/+4
2021-09-09Remove cloneAndreas Liljeqvist-1/+1
2021-09-09Make `abi::Abi` `Copy` and remove a *lot* of refsAndreas Liljeqvist-16/+13
fix fix Remove more refs and clones fix more fix
2021-09-09Add methods for checking for full ranges to `Scalar` and `WrappingRange`Andreas Liljeqvist-15/+13
Move *_max methods back to util change to inline instead of inline(always) Remove valid_range_exclusive from scalar Use WrappingRange instead implement always_valid_for in a safer way Fix accidental edit
2021-09-09Add another test case + fmtDeadbeef-4/+2
2021-09-09fix precise live dropsDeadbeef-3/+3
2021-09-09do not require lang itemDeadbeef-1/+8
2021-09-09Use trait select logic instead of queryDeadbeef-10/+33
2021-09-09fmtDeadbeef-2/+4
2021-09-09Const droppingDeadbeef-13/+13
2021-09-09Remove unused queryDeadbeef-22/+10
2021-09-08Bump stage0 compiler to 1.56Mark Rousskov-1/+0
2021-09-08Rebase fallout.Camille GILLOT-0/+1
2021-09-07Rename rustc_mir to rustc_const_eval.Camille GILLOT-0/+14813