summaryrefslogtreecommitdiff
path: root/compiler/rustc_const_eval/src
Commit message (Collapse)AuthorAgeFilesLines
* Finish move of query.rsJohn Kåre Alsaker2023-05-172-4/+4
|
* Rollup merge of #111602 - tmiasko:erroneous-constant-used, r=oli-obkNilstrieb2023-05-164-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.
| * Suppress "erroneous constant used" for constants tainted by errorsTomasz Miąsko2023-05-154-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.
* | Rollup merge of #111578 - Zoxc:query-macro-move, r=cjgillotMatthias Krüger2023-05-152-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.
| * Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker2023-05-152-2/+2
| |
* | Start node has no immediate dominatorTomasz Miąsko2023-05-141-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.
* Implement references VarDebugInfo.Camille GILLOT2023-05-131-1/+9
|
* use EarlyBinder in tcx.(try_)subst_mir_and_normalize_erasing_regionsKyle Matsuda2023-05-061-1/+5
|
* Auto merge of #110806 - WaffleLapkin:unmkI, r=lcnrbors2023-05-041-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`
| * Add new `ToPredicate` impls and `TraitRef` methods to remove some ↵Maybe Waffle2023-04-261-7/+2
| | | | | | | | `ty::Binber::dummy` calls
| * Switch `ty::TraitRef::from_lang_item` from using `TyCtxtAt` to `TyCtxt` and ↵Maybe Waffle2023-04-261-1/+2
| | | | | | | | a `Span`
| * Replace `tcx.mk_trait_ref` with `ty::TraitRef::new`Maybe Waffle2023-04-251-2/+6
| |
* | Rollup merge of #110943 - RalfJung:interpret-unsized-arg-ice, r=oli-obkDylan DPC2023-05-042-1/+7
|\ \ | | | | | | | | | | | | | | | | | | | | | interpret: fail more gracefully on uninit unsized locals r? `@oli-obk` Fixes https://github.com/rust-lang/rust/issues/68538
| * | interpret: fail more gracefully on uninit unsized localsRalf Jung2023-04-282-1/+7
| | |
* | | Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote2023-05-037-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.
* | | Auto merge of #109521 - tmiasko:const-prop-validation, r=wesleywiserbors2023-05-021-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).
| * | | Use trimmed paths in constantant validation errorsTomasz Miąsko2023-04-271-10/+8
| |/ / | | | | | | | | | | | | The constant validation errors are user facing and should always be emitted to the user - use trimmed path when constructing them.
* | | Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naberMatthias Krüger2023-05-011-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.
| * | | Don't call await a methodMichael Goulet2023-04-271-0/+3
| | | |
* | | | Rollup merge of #110944 - RalfJung:offset, r=compiler-errorsMatthias Krüger2023-04-282-14/+29
|\ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | share BinOp::Offset between CTFE and Miri r? ``@oli-obk``
| * | | | share BinOp::Offset between CTFE and MiriRalf Jung2023-04-282-14/+29
| | |/ / | |/| |
* | | | Rollup merge of #110766 - m-ou-se:fmt-rt, r=jyn514Matthias Krüger2023-04-281-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
| * | | Remove "V1" from ArgumentsV1 and FlagsV1.Mara Bos2023-04-241-1/+1
| | | |
* | | | rename `needs_subst` to `has_param`Boxy2023-04-271-3/+3
| |/ / |/| |
* | | Lower `intrinsics::offset` to `mir::BinOp::Offset`Scott McMurray2023-04-252-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.
* | Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle2023-04-244-4/+4
|/
* Auto merge of #104844 - cjgillot:mention-eval-place, r=jackh726,RalfJungbors2023-04-222-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`
| * Actually keep `PlaceMention` if requested.Camille GILLOT2023-04-211-8/+1
| |
| * Evaluate place expression in `PlaceMention`.Camille GILLOT2023-04-211-2/+8
| |
* | Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkinbors2023-04-224-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)
| * minor tweaksDrMeepster2023-04-211-1/+1
| |
| * intern offsetof fieldsDrMeepster2023-04-211-1/+1
| |
| * offset_ofDrMeepster2023-04-214-7/+56
| |
* | Remove WithOptconstParam.Camille GILLOT2023-04-208-22/+20
|/
* Auto merge of #110393 - fee1-dead-contrib:rm-const-traits, r=oli-obkbors2023-04-191-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
| * revive raw pointer comp errorDeadbeef2023-04-161-2/+3
| |
* | Auto merge of #110407 - Nilstrieb:fluent-macro, r=davidtwcobors2023-04-191-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`).
| * | Add `rustc_fluent_macro` to decouple fluent from `rustc_macros`Nilstrieb2023-04-181-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`).
* | | Auto merge of #110083 - saethlin:encode-hashes-as-bytes, r=cjgillotbors2023-04-181-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`.
| * | | Store hashes in special types so they aren't accidentally encoded as numbersBen Kimock2023-04-181-1/+1
| |/ /
* | | Spelling - compilerJosh Soref2023-04-172-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>
* | Rollup merge of #110394 - scottmcm:less-idx-new, r=WaffleLapkinMatthias Krüger2023-04-171-8/+9
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | Various minor Idx-related tweaks Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify. cc https://github.com/rust-lang/compiler-team/issues/606 r? `@WaffleLapkin`
| * | Various minor Idx-related tweaksScott McMurray2023-04-161-8/+9
| |/ | | | | | | Nothing particularly exciting here, but a couple of things I noticed as I was looking for more index conversions to simplify.
* | Auto merge of #109061 - saethlin:leak-backtraces, r=oli-obkbors2023-04-173-18/+18
|\ \ | | | | | | | | | | | | | | | | | | | | | Add a backtrace to Allocation, display it in leak reports This addresses https://github.com/rust-lang/miri/issues/2813 Information like this from diagnostics is indispensable for diagnosing problems that are difficult to reproduce such as https://github.com/rust-lang/miri-test-libstd/actions/runs/4395316008/jobs/7697019211#step:4:770 (which has not been reproduced or diagnosed).
| * | Report a backtrace for memory leaks under MiriBen Kimock2023-04-163-18/+18
| |/
* | Move some utils out of `rustc_const_eval`Nilstrieb2023-04-165-215/+1
|/ | | | | | | | This allows us to get rid of the `rustc_const_eval->rustc_borrowck` dependency edge which was delaying the compilation of borrowck. The added utils in `rustc_middle` are small and should not affect compile times there.
* Implement `Copy` for `LocationDetail`Maybe Waffle2023-04-131-1/+1
|
* Auto merge of #110249 - matthiaskrgr:rollup-7iig04q, r=matthiaskrgrbors2023-04-121-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rollup of 8 pull requests Successful merges: - #110153 (Fix typos in compiler) - #110165 (rustdoc: use CSS `overscroll-behavior` instead of JavaScript) - #110175 (Symbol cleanups) - #110203 (Remove `..` from return type notation) - #110205 (rustdoc: make settings radio and checks thicker, less contrast) - #110222 (Improve the error message when forwarding a matched fragment to another macro) - #110237 (Split out a separate feature gate for impl trait in associated types) - #110241 (tidy: Issue an error when UI test limits are too high) Failed merges: - #110218 (Remove `ToRegionVid`) r? `@ghost` `@rustbot` modify labels: rollup
| * Fix typos in compilerDaniPopes2023-04-101-1/+1
| |
* | Fix transmute intrinsic mir validation ICEJakob Degen2023-04-091-2/+10
|/