about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2023-04-26Remove QueryEngine traitJohn Kåre Alsaker-101/+109
2023-04-26Move on_disk_cache.rsJohn Kåre Alsaker-0/+1064
2023-04-26Derive `Type{Foldable,Visitable}` for `UserTypeProjection`.Nicholas Nethercote-24/+3
Because the derived versions are good enough.
2023-04-26Remove unused `TypeFoldable`/`TypeVisitable` impls.Nicholas Nethercote-28/+6
2023-04-26Auto merge of #110634 - saethlin:pointy-decoder, r=cjgillotbors-0/+10
Rewrite MemDecoder around pointers not a slice This is basically https://github.com/rust-lang/rust/pull/109910 but I'm being a lot more aggressive. The pointer-based structure means that it makes a lot more sense to absorb more complexity into `MemDecoder`, most of the diff is just complexity moving from one place to another. The primary argument for this structure is that we only incur a single bounds check when doing multi-byte reads from a `MemDecoder`. With the slice-based implementation we need to do those with `data[position..position + len]` , which needs to account for `position + len` wrapping. It would be possible to dodge the first bounds check if we stored a slice that starts at `position`, but that would require updating the pointer and length on every read. This PR also embeds the failure path in a separate function, which means that this PR should subsume all the perf wins observed in https://github.com/rust-lang/rust/pull/109867.
2023-04-26Make some region folders a little stricter.Nicholas Nethercote-1/+7
Because certain regions cannot occur in them.
2023-04-25Auto merge of #110811 - compiler-errors:vars-are-question-mark, r=WaffleLapkinbors-2/+2
Use `?0` notation for ty/ct/int/float/region vars Aligns the notation for infer vars that T-types and friends most often uses for inference variables with the notation in the compiler (which is kinda a sigil nightmare IMO: `_#`) by adopting `?0` style infer vars. This mostly affects debug output since verbose infer vars shouldn't show up in user-facing places. Does this need an MCP? It's debug output, so I'm thinking no, but happy to open one. :thinking: r? types
2023-04-25Fix lifetime suggestion for type aliases with objects in themMichael Goulet-3/+5
2023-04-25vars are ?Michael Goulet-2/+2
2023-04-25Rollup merge of #110671 - compiler-errors:polarity, r=lcnrMatthias Krüger-0/+5
Consider polarity in new solver It's kinda ugly to have a polarity check in all of the builtin impls -- I guess I could consider the polarity at the top of assemble-builtin but that would require adding a polarity fn to `GoalKind`... :shrug: putting this up just so i dont forget, since it's needed to bootstrap core during coherence (this alone does not allow core to bootstrap though, additional work is needed!) r? ``@lcnr``
2023-04-25Rollup merge of #110615 - WaffleLapkin:impl_tag, r=cjgillotMatthias Krüger-23/+7
Add `impl_tag!` macro to implement `Tag` for tagged pointer easily r? `@Nilstrieb` This should also lifts the need to think about safety from the callers (`impl_tag!` is robust (ish, see the macro issue)) and removes the possibility of making a "weird" `Tag` impl.
2023-04-25Rollup merge of #110556 - kylematsuda:earlybinder-explicit-item-bounds, ↵Matthias Krüger-10/+15
r=compiler-errors Switch to `EarlyBinder` for `explicit_item_bounds` Part of the work to finish https://github.com/rust-lang/rust/issues/105779. This PR adds `EarlyBinder` to the return type of the `explicit_item_bounds` query and removes `bound_explicit_item_bounds`. r? `@compiler-errors` (hope it's okay to request you, since you reviewed #110299 and #110498 :smiley:)
2023-04-25Rename `TraitRef::{_use_mk_trait_ref_instead => _use_trait_ref_new_instead}`Maybe Waffle-3/+3
2023-04-25Remove `tcx.mk_trait_ref`Maybe Waffle-18/+0
2023-04-25Replace `tcx.mk_trait_ref` with `ty::TraitRef::new`Maybe Waffle-11/+19
2023-04-25Move `TraitRef` constructors to the topMaybe Waffle-14/+14
In rust `new`-ish functions are usually the first ones in an `impl` block
2023-04-25Add `ty::TraitRef::{new, from_lang_item}`Maybe Waffle-1/+20
2023-04-25Revert "Remove #[alloc_error_handler] from the compiler and library"Matthias Krüger-0/+11
This reverts commit abc0660118cc95f47445fd33502a11dd448f5968.
2023-04-24Consider polarity in new solverMichael Goulet-0/+5
2023-04-25Rollup merge of #110750 - scottmcm:vardebug-size, r=cjgillotYuki Okushi-0/+2
Add size asserts for MIR `SourceScopeData` & `VarDebugInfo` There's vectors of both of these in `mir::Body`, so might as well track them. (I was pondering adding something to one or the other, so wanted this to see the memory impact.)
2023-04-24Switch `impl_tag!` from explicit tags to `${index()}`Maybe Waffle-4/+5
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-21/+21
2023-04-24Rollup merge of #110514 - compiler-errors:remove-find_map_relevant_impl, ↵Matthias Krüger-59/+40
r=b-naber Remove `find_map_relevant_impl` Fixes #108895
2023-04-23Add size asserts for MIR `SourceScopeData` & `VarDebugInfo`Scott McMurray-0/+2
There's vectors of both of these in `mir::Body`, so might as well track them.
2023-04-23Rewrite MemDecoder around pointers not a sliceBen Kimock-0/+10
2023-04-23Auto merge of #108118 - oli-obk:lazy_typeck, r=cjgillotbors-49/+59
Run various queries from other queries instead of explicitly in phases These are just legacy leftovers from when rustc didn't have a query system. While there are more cleanups of this sort that can be done here, I want to land them in smaller steps. This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can invoke e.g. const eval which invokes borrowck, which invokes typeck, ...
2023-04-22Auto merge of #109507 - Amanieu:panic-oom-payload, r=davidtwcobors-11/+0
Report allocation errors as panics OOM is now reported as a panic but with a custom payload type (`AllocErrorPanicPayload`) which holds the layout that was passed to `handle_alloc_error`. This should be review one commit at a time: - The first commit adds `AllocErrorPanicPayload` and changes allocation errors to always be reported as panics. - The second commit removes `#[alloc_error_handler]` and the `alloc_error_hook` API. ACP: https://github.com/rust-lang/libs-team/issues/192 Closes #51540 Closes #51245
2023-04-22Auto merge of #104844 - cjgillot:mention-eval-place, r=jackh726,RalfJungbors-3/+2
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 #110666 - JohnTitor:rollup-3pwilte, r=JohnTitorbors-30/+16
Rollup of 7 pull requests Successful merges: - #109949 (rustdoc: migrate `document_type_layout` to askama) - #110622 (Stable hash tag (discriminant) of `GenericArg`) - #110635 (More `IS_ZST` in `library`) - #110640 (compiler/rustc_target: Raise m68k-linux-gnu baseline to 68020) - #110657 (nit: consistent naming for SimplifyConstCondition) - #110659 (rustdoc: clean up JS) - #110660 (Print ty placeholders pretty) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-04-22Rollup merge of #110660 - compiler-errors:placeholders-pretty, ↵Yuki Okushi-1/+15
r=wesleywiser,BoxyUwU Print ty placeholders pretty Makes anon placeholders print like `!0` instead of `Placeholder { ... }`. ``` rustc_trait_selection::solve::compute_well_formed_goal goal=Goal{ predicate: !0, param_env: ParamEnv{ caller_bounds: [ Binder(TraitPredicate(<!0 as std::marker::Copy>, polarity: Positive), []), Binder(TraitPredicate(<!0 as std::clone::Clone>, polarity: Positive), []), Binder(TraitPredicate(<!0 as std::marker::Sized>, polarity: Positive), []), ], reveal: UserFacing, constness: NotConst, } } ``` cc `@BoxyUwU` who might care about this formatting decision
2023-04-22Rollup merge of #110622 - WaffleLapkin:hashtag#, r=compiler-errorsYuki Okushi-29/+1
Stable hash tag (discriminant) of `GenericArg` This is a continuation of my quest of removing `transmute` if generic args and types (#110496, #110599). r? `@compiler-errors`
2023-04-22Print ty placeholders prettyMichael Goulet-1/+15
2023-04-22Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkinbors-7/+55
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-21Make `check_match` and `check_liveness` take a `LocalDefId`Oli Scherer-2/+2
2023-04-21Allow `LocalDefId` as the argument to `def_path_str`Oli Scherer-43/+57
2023-04-21Leave it to the query system to invoke the typeck query instead of invoking ↵Oli Scherer-4/+0
it eagerly. Later queries that are run on all body owners will invoke typeck as they need information from its result to perform their own logic
2023-04-21Actually keep `PlaceMention` if requested.Camille GILLOT-2/+0
2023-04-21Evaluate place expression in `PlaceMention`.Camille GILLOT-1/+2
2023-04-21Changes from reviewKyle Matsuda-1/+1
2023-04-21rustc_metadata: Split `children` into multiple tablesVadim Petrochenkov-2/+3
instead of merging everything into a single bag. If it's acceptable from performance point of view, then it's more clear to keep this stuff organized more in accordance with its use.
2023-04-21test improvementsDrMeepster-1/+5
2023-04-21intern offsetof fieldsDrMeepster-7/+29
2023-04-21offset_ofDrMeepster-3/+25
2023-04-21Auto merge of #96840 - cjgillot:query-feed, r=oli-obkbors-522/+141
Allow to feed a value in another query's cache and remove `WithOptConstParam` I used it to remove `WithOptConstParam` queries, as an example. The idea is that a query (here `typeck(function)`) can write into another query's cache (here `type_of(anon const)`). The dependency node for `type_of` would depend on all the current dependencies of `typeck`. There is still an issue with cycles: if `type_of(anon const)` is accessed before `typeck(function)`, we will still have the usual cycle. The way around this issue is to `ensure` that `typeck(function)` is called before accessing `type_of(anon const)`. When replayed, we may the following cases: - `typeck` is green, in that case `type_of` is green too, and all is right; - `type_of` is green, `typeck` may still be marked as red (it depends on strictly more things than `type_of`) -> we verify that the saved value and the re-computed value of `type_of` have the same hash; - `type_of` is red, then `typeck` is red -> it's the caller responsibility to ensure `typeck` is recomputed *before* `type_of`. As `anon consts` have their own `DefPathData`, it's not possible to have the def-id of the anon-const point to something outside the original function, but the general case may have to be resolved before using this device more broadly. There is an open question about loading from the on-disk cache. If `typeck` is loaded from the on-disk cache, the side-effect does not happen. The regular `type_of` implementation can go and fetch the correct value from the decoded `typeck` results, and the dep-graph will check that the hashes match, but I'm not sure we want to rely on this behaviour. I specifically allowed to feed the value to `type_of` from inside a call to `type_of`. In that case, the dep-graph will check that the fingerprints of both values match. This implementation is still very sensitive to cycles, and requires that we call `typeck(function)` before `typeck(anon const)`. The reason is that `typeck(anon const)` calls `type_of(anon const)`, which calls `typeck(function)`, which feeds `type_of(anon const)`, and needs to build the MIR so needs `typeck(anon const)`. The latter call would not cycle, since `type_of(anon const)` has been set, but I'd rather not remove the cycle check.
2023-04-20Derive `HashStable` on `GenericArgKind` instead of implementing it by handMaybe Waffle-29/+1
2023-04-20Use `impl Tag for $T` syntax for `impl_tag!`Maybe Waffle-1/+1
2023-04-20add subst_identity_iter and subst_identity_iter_copied methods on ↵Kyle Matsuda-1/+13
EarlyBinder; use this to simplify some EarlyBinder noise around explicit_item_bounds calls
2023-04-20add EarlyBinder to output of explicit_item_bounds; replace ↵Kyle Matsuda-10/+3
bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query
2023-04-20change usages of explicit_item_bounds to bound_explicit_item_boundsKyle Matsuda-1/+1
2023-04-20Give more descriptive names to queries.Camille GILLOT-1/+1