summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
AgeCommit message (Collapse)AuthorLines
2023-06-03unique borrows are mutating useslcnr-3/+1
2023-05-27Rollup merge of #111952 - cjgillot:drop-replace, r=WaffleLapkinGuillaume Gomez-1/+1
Remove DesugaringKind::Replace. A simple boolean flag is enough.
2023-05-25Remove DesugaringKind::Replace.Camille GILLOT-1/+1
2023-05-25Manually add inlined frames in the interpreter stacktrace.Camille GILLOT-1/+14
2023-05-25Remove ExpnKind::Inlined.Camille GILLOT-5/+1
2023-05-25Move DefiningAnchorMichael Goulet-2/+2
2023-05-24Use `is_some_and`/`is_ok_and` in less obvious spotsMaybe Waffle-1/+1
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-2/+2
2023-05-23Rollup merge of #111486 - fmease:pp-inh-proj, r=petrochenkovMatthias Krüger-1/+2
Pretty-print inherent projections correctly Previously, we were trying to pretty-print inherent projections with `Printer::print_def_path` which is incorrect since it expects the substitutions to be of a certain format (parents substs followed by own substs) which doesn't hold for inherent projections (self type subst followed by own substs). Now we print inherent projections manually. Fixes #111390. Fixes #111397. Lacking tests! Is there a test suite / compiletest flags for the pretty-printer? In most if not all cases, inherent projections are normalized away before they get the chance to appear in diagnostics. If I were to create regression tests for linked issues, they would need to be `mir-opt` tests to exercise `-Zdump-mir=all` (right?) which doesn't feel quite adequate to me. `@rustbot` label F-inherent_associated_types
2023-05-22properly pretty-print inherent projectionsLeón Orell Valerian Liehr-1/+2
2023-05-17Finish move of query.rsJohn Kåre Alsaker-4/+4
2023-05-16Rollup merge of #111602 - tmiasko:erroneous-constant-used, r=oli-obkNilstrieb-8/+8
Suppress "erroneous constant used" for constants tainted by errors When constant evaluation fails because its MIR is tainted by errors, suppress note indicating that erroneous constant was used, since those errors have to be fixed regardless of the constant being used or not. Fixes #110891.
2023-05-15Rollup merge of #111578 - Zoxc:query-macro-move, r=cjgillotMatthias Krüger-2/+2
Move expansion of query macros in rustc_middle to rustc_middle::query This moves the expansion of `define_callbacks!` and `define_feedable!` from `rustc_middle::ty::query` to `rustc_middle::query`. This means that types used in queries are both imported and used in `rustc_middle::query` instead of being split between these modules. It also decouples `rustc_middle::ty::query` further from `rustc_middle` which is helpful since we want to move `rustc_middle::ty::query` to the query system crates.
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-2/+2
2023-05-15Suppress "erroneous constant used" for constants tainted by errorsTomasz Miąsko-8/+8
When constant evaluation fails because its MIR is tainted by errors, suppress note indicating that erroneous constant was used, since those errors have to be fixed regardless of the constant being used or not.
2023-05-14Start node has no immediate dominatorTomasz Miąsko-1/+1
Change the immediate_dominator return type to Option, and use None to indicate that node has no immediate dominator. Also fix the issue where the start node would be returned as its own immediate dominator.
2023-05-13Implement references VarDebugInfo.Camille GILLOT-1/+9
2023-05-06use EarlyBinder in tcx.(try_)subst_mir_and_normalize_erasing_regionsKyle Matsuda-1/+5
2023-05-04Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnrbors-1/+1
Replace `tcx.mk_trait_ref` with `TraitRef::new` First step in implementing https://github.com/rust-lang/compiler-team/issues/616 r? `@lcnr`
2023-05-04Rollup merge of #110943 - RalfJung:interpret-unsized-arg-ice, r=oli-obkDylan DPC-1/+7
interpret: fail more gracefully on uninit unsized locals r? `@oli-obk` Fixes https://github.com/rust-lang/rust/issues/68538
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-18/+18
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-05-02Auto merge of #109521 - tmiasko:const-prop-validation, r=wesleywiserbors-10/+8
Don't validate constants in const propagation Validation is neither necessary nor desirable. The constant validation is already omitted at mir-opt-level >= 3, so there there are not changes in MIR test output (the propagation of invalid constants is covered by an existing test in tests/mir-opt/const_prop/invalid_constant.rs).
2023-05-01Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naberMatthias Krüger-0/+3
Tweak await span to not contain dot Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue. Fixes #110761 This mostly touches a bunch of tests to tighten their `await` span.
2023-04-28Rollup merge of #110944 - RalfJung:offset, r=compiler-errorsMatthias Krüger-14/+29
share BinOp::Offset between CTFE and Miri r? ``@oli-obk``
2023-04-28share BinOp::Offset between CTFE and MiriRalf Jung-14/+29
2023-04-28interpret: fail more gracefully on uninit unsized localsRalf Jung-1/+7
2023-04-28Rollup merge of #110766 - m-ou-se:fmt-rt, r=jyn514Matthias Krüger-1/+1
More core::fmt::rt cleanup. - Removes the `V1` suffix from the `Argument` and `Flag` types. - Moves more of the format_args lang items into the `core::fmt::rt` module. (The only remaining lang item in `core::fmt` is `Arguments` itself, which is a public type.) Part of https://github.com/rust-lang/rust/issues/99012 Follow-up to https://github.com/rust-lang/rust/pull/110616
2023-04-27Don't call await a methodMichael Goulet-0/+3
2023-04-27rename `needs_subst` to `has_param`Boxy-3/+3
2023-04-27Use trimmed paths in constantant validation errorsTomasz Miąsko-10/+8
The constant validation errors are user facing and should always be emitted to the user - use trimmed path when constructing them.
2023-04-26Add new `ToPredicate` impls and `TraitRef` methods to remove some ↵Maybe Waffle-7/+2
`ty::Binber::dummy` calls
2023-04-26Switch `ty::TraitRef::from_lang_item` from using `TyCtxtAt` to `TyCtxt` and ↵Maybe Waffle-1/+2
a `Span`
2023-04-25Lower `intrinsics::offset` to `mir::BinOp::Offset`Scott McMurray-12/+13
They're semantically the same, so this means the backends don't need to handle the intrinsic and means fewer MIR basic blocks in pointer arithmetic code.
2023-04-25Replace `tcx.mk_trait_ref` with `ty::TraitRef::new`Maybe Waffle-2/+6
2023-04-24Remove "V1" from ArgumentsV1 and FlagsV1.Mara Bos-1/+1
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-4/+4
2023-04-22Auto merge of #104844 - cjgillot:mention-eval-place, r=jackh726,RalfJungbors-10/+9
Evaluate place expression in `PlaceMention` https://github.com/rust-lang/rust/pull/102256 introduces a `PlaceMention(place)` MIR statement which keep trace of `let _ = place` statements from surface rust, but without semantics. This PR proposes to change the behaviour of `let _ =` patterns with respect to the borrow-checker to verify that the bound place is live. Specifically, consider this code: ```rust let _ = { let a = 5; &a }; ``` This passes borrowck without error on stable. Meanwhile, replacing `_` by `_: _` or `_p` errors with "error[E0597]: `a` does not live long enough", [see playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c448d25a7c205dc95a0967fe96bccce8). This PR *does not* change how `_` patterns behave with respect to initializedness: it remains ok to bind a moved-from place to `_`. The relevant test is `tests/ui/borrowck/let_underscore_temporary.rs`. Crater check found no regression. For consistency, this PR changes miri to evaluate the place found in `PlaceMention`, and report eventual dangling pointers found within it. r? `@RalfJung`
2023-04-22Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkinbors-8/+57
Add offset_of! macro (RFC 3308) Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented: * Nested field accesses (without array indexing) * DST support (for `Sized` fields) I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it. cc `@thomcc` (RFC author)
2023-04-21Actually keep `PlaceMention` if requested.Camille GILLOT-8/+1
2023-04-21Evaluate place expression in `PlaceMention`.Camille GILLOT-2/+8
2023-04-21minor tweaksDrMeepster-1/+1
2023-04-21intern offsetof fieldsDrMeepster-1/+1
2023-04-21offset_ofDrMeepster-7/+56
2023-04-20Remove WithOptconstParam.Camille GILLOT-22/+20
2023-04-19Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obkbors-2/+3
Rm const traits in libcore See [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/.60const.20Trait.60.20removal.20or.20rework) * [x] Bless ui tests * [ ] Re constify some unstable functions with workarounds if they are needed
2023-04-19Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwcobors-1/+1
Add `rustc_fluent_macro` to decouple fluent from `rustc_macros` Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-18Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillotbors-1/+1
Encode hashes as bytes, not varint In a few places, we store hashes as `u64` or `u128` and then apply `derive(Decodable, Encodable)` to the enclosing struct/enum. It is more efficient to encode hashes directly than try to apply some varint encoding. This PR adds two new types `Hash64` and `Hash128` which are produced by `StableHasher` and replace every use of storing a `u64` or `u128` that represents a hash. Distribution of the byte lengths of leb128 encodings, from `x build --stage 2` with `incremental = true` Before: ``` ( 1) 373418203 (53.7%, 53.7%): 1 ( 2) 196240113 (28.2%, 81.9%): 3 ( 3) 108157958 (15.6%, 97.5%): 2 ( 4) 17213120 ( 2.5%, 99.9%): 4 ( 5) 223614 ( 0.0%,100.0%): 9 ( 6) 216262 ( 0.0%,100.0%): 10 ( 7) 15447 ( 0.0%,100.0%): 5 ( 8) 3633 ( 0.0%,100.0%): 19 ( 9) 3030 ( 0.0%,100.0%): 8 ( 10) 1167 ( 0.0%,100.0%): 18 ( 11) 1032 ( 0.0%,100.0%): 7 ( 12) 1003 ( 0.0%,100.0%): 6 ( 13) 10 ( 0.0%,100.0%): 16 ( 14) 10 ( 0.0%,100.0%): 17 ( 15) 5 ( 0.0%,100.0%): 12 ( 16) 4 ( 0.0%,100.0%): 14 ``` After: ``` ( 1) 372939136 (53.7%, 53.7%): 1 ( 2) 196240140 (28.3%, 82.0%): 3 ( 3) 108014969 (15.6%, 97.5%): 2 ( 4) 17192375 ( 2.5%,100.0%): 4 ( 5) 435 ( 0.0%,100.0%): 5 ( 6) 83 ( 0.0%,100.0%): 18 ( 7) 79 ( 0.0%,100.0%): 10 ( 8) 50 ( 0.0%,100.0%): 9 ( 9) 6 ( 0.0%,100.0%): 19 ``` The remaining 9 or 10 and 18 or 19 are `u64` and `u128` respectively that have the high bits set. As far as I can tell these are coming primarily from `SwitchTargets`.
2023-04-18Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`Nilstrieb-1/+1
Fluent, with all the icu4x it brings in, takes quite some time to compile. `fluent_messages!` is only needed in further downstream rustc crates, but is blocking more upstream crates like `rustc_index`. By splitting it out, we allow `rustc_macros` to be compiled earlier, which speeds up `x check compiler` by about 5 seconds (and even more after the needless dependency on `serde_json` is removed from `rustc_data_structures`).
2023-04-18Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock-1/+1
2023-04-17Spelling - compilerJosh Soref-3/+3
* account * achieved * advising * always * ambiguous * analysis * annotations * appropriate * build * candidates * cascading * category * character * clarification * compound * conceptually * constituent * consts * convenience * corresponds * debruijn * debug * debugable * debuggable * deterministic * discriminant * display * documentation * doesn't * ellipsis * erroneous * evaluability * evaluate * evaluation * explicitly * fallible * fulfill * getting * has * highlighting * illustrative * imported * incompatible * infringing * initialized * into * intrinsic * introduced * javascript * liveness * metadata * monomorphization * nonexistent * nontrivial * obligation * obligations * offset * opaque * opportunities * opt-in * outlive * overlapping * paragraph * parentheses * poisson * precisely * predecessors * predicates * preexisting * propagated * really * reentrant * referent * responsibility * rustonomicon * shortcircuit * simplifiable * simplifications * specify * stabilized * structurally * suggestibility * translatable * transmuting * two * unclosed * uninhabited * visibility * volatile * workaround Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>