about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2023-02-16Auto merge of #108020 - nnethercote:opt-mk_region, r=compiler-errorsbors-43/+133
Optimize `mk_region` PR #107869 avoiding some interning under `mk_ty` by special-casing `Ty` variants with simple (integer) bodies. This PR does something similar for regions. r? `@compiler-errors`
2023-02-16Replace some `then`s with some `then_some`sMaybe Waffle-2/+2
2023-02-16`if $c:expr { Some($r:expr) } else { None }` =>> `$c.then(|| $r)`Maybe Waffle-27/+21
2023-02-16Add some comments and use inline(always) on query_provided_to_valueJohn Kåre Alsaker-1/+10
2023-02-16Move provider fields back to rustc_query_implJohn Kåre Alsaker-18/+2
2023-02-16Use dropless arena when possibleJohn Kåre Alsaker-1/+8
2023-02-16Factor query arena allocation out from query cachesJohn Kåre Alsaker-22/+82
2023-02-16Auto merge of #108116 - Dylan-DPC:rollup-h3n2vxl, r=Dylan-DPCbors-1/+1
Rollup of 6 pull requests Successful merges: - #106372 (Use id-based thread parking on SOLID) - #108050 (Fix index out of bounds ICE in `point_at_expr_source_of_inferred_type`) - #108084 (Constify `RangeBounds`, `RangeX::contains` and `RangeX::is_empty` (where applicable).) - #108101 (don't clone types that are copy) - #108102 (simplify some refs) - #108103 (be nice and don't slice) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-16Rollup merge of #108102 - matthiaskrgr:ref, r=compiler-errorsDylan DPC-1/+1
simplify some refs
2023-02-16Auto merge of #107449 - saethlin:enable-copyprop, r=oli-obkbors-0/+1
Enable CopyProp r? `@tmiasko` `@rustbot` label +A-mir-opt
2023-02-16A bit more work on late-bound constsMichael Goulet-9/+22
2023-02-16Be better about bound varsMichael Goulet-2/+2
2023-02-16Make things actually workMichael Goulet-2/+2
2023-02-16Rename some region-specific stuffMichael Goulet-14/+14
2023-02-16Auto merge of #108096 - matthiaskrgr:rollup-ncexzf6, r=matthiaskrgrbors-26/+26
Rollup of 10 pull requests Successful merges: - #107034 (Migrating rustc_infer to session diagnostics (part 4)) - #107972 (Fix unintentional UB in ui tests) - #108010 (Make `InferCtxt::can_eq` and `InferCtxt::can_sub` return booleans) - #108021 (make x look for x.py if shell script does not exist) - #108047 (Use `target` instead of `machine` for mir interpreter integer handling.) - #108049 (Don't suggest `#[doc(hidden)]` trait methods with matching return type) - #108066 (Better names for illegal impl trait positions) - #108076 (rustdoc: Use more let chain) - #108088 (clarify correctness of `black_box`) - #108094 (Demonstrate I/O in File examples) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-15simplify some refsMatthias Krüger-1/+1
2023-02-15Auto merge of #108012 - compiler-errors:issue-107999, r=oli-obkbors-5/+4
Don't ICE in `might_permit_raw_init` if reference is polymorphic Emitting optimized MIR for a polymorphic function may require computing layout of a type that isn't (yet) known. This happens in the instcombine pass, for example. Let's fail gracefully in that condition. cc `@saethlin` fixes #107999
2023-02-15Rollup merge of #108047 - oli-obk:machine->🞋, r=RalfJungMatthias Krüger-26/+26
Use `target` instead of `machine` for mir interpreter integer handling. The naming of `machine` only makes sense from a mir interpreter internals perspective, but outside users talk about the `target` platform. As per https://github.com/rust-lang/rust/pull/108029#issuecomment-1429791015 r? `@RalfJung`
2023-02-15Copy `ty::AssocItem` all other the placeMaybe Waffle-14/+10
2023-02-15Remove `arena_cache` modifier from queries which return `Copy` typesMaybe Waffle-2/+1
2023-02-15Auto merge of #108006 - cjgillot:def-impl, r=oli-obkbors-3/+3
Avoid accessing HIR when it can be avoided Experiment to see if it helps some incremental cases. Will be rebased once https://github.com/rust-lang/rust/pull/107942 gets merged. r? `@ghost`
2023-02-15Use target instead of machine for mir interpreter integer handling.Oli Scherer-26/+26
The naming of `machine` only makes sense from a mir interpreter internals perspective, but outside users talk about the `target` platform
2023-02-15Auto merge of #108070 - Dylan-DPC:rollup-v6xw7vk, r=Dylan-DPCbors-3/+11
Rollup of 7 pull requests Successful merges: - #105300 (rework min_choice algorithm of member constraints) - #107163 (Remove some superfluous type parameters from layout.rs.) - #107173 (Suggest the correct array length on mismatch) - #107411 (Handle discriminant in DataflowConstProp) - #107968 (Enable `#[thread_local]` on armv6k-nintendo-3ds) - #108032 (Un📦ing the Resolver) - #108060 (Revert to using `RtlGenRandom` as a fallback) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-15Rollup merge of #107411 - cjgillot:dataflow-discriminant, r=oli-obkDylan DPC-0/+8
Handle discriminant in DataflowConstProp cc ``@jachris`` r? ``@JakobDegen`` This PR attempts to extend the DataflowConstProp pass to handle propagation of discriminants. We handle this by adding 2 new variants to `TrackElem`: `TrackElem::Variant` for enum variants and `TrackElem::Discriminant` for the enum discriminant pseudo-place. The difficulty is that the enum discriminant and enum variants may alias each another. This is the issue of the `Option<NonZeroUsize>` test, which is the equivalent of https://github.com/rust-lang/unsafe-code-guidelines/issues/84 with a direct write. To handle that, we generalize the flood process to flood all the potentially aliasing places. In particular: - any write to `(PLACE as Variant)`, either direct or through a projection, floods `(PLACE as OtherVariant)` for all other variants and `discriminant(PLACE)`; - `SetDiscriminant(PLACE)` floods `(PLACE as Variant)` for each variant. This implies that flooding is not hierarchical any more, and that an assignment to a non-tracked place may need to flood a tracked place. This is handled by `for_each_aliasing_place` which generalizes `preorder_invoke`. As we deaggregate enums by putting `SetDiscriminant` last, this allows to propagate the value of the discriminant. This refactor will allow to make https://github.com/rust-lang/rust/pull/107009 able to handle discriminants too.
2023-02-15Rollup merge of #107163 - mikebenfield:parameters-pr, r=TaKO8KiDylan DPC-3/+3
Remove some superfluous type parameters from layout.rs. Specifically remove V, which can always be VariantIdx, and F, which can always be Layout.
2023-02-15Auto merge of #107940 - BoxyUwU:const_ty_assertion_use_semantic_equality, ↵bors-20/+7
r=compiler-errors use semantic equality for const param type equality assertion Fixes #107898 See added test for what caused this ICE --- The current in assertion in `relate.rs` is rather inadequate when keeping in mind future expansions to const generics: - it will ICE when there are infer vars in a projection in a const param ty - it will spurriously return false when either ty has infer vars because of using `==` instead of `infcx.at(..).eq` - i am also unsure if it would be possible with `adt_const_params` to craft a situation where the const param type is not wf causing `normalize_erasing_regions` to `bug!` when we would have emitted a diagnostic. This impl feels pretty Not Great to me although i am not sure what a better idea would be. - We have to have the logic behind a query because neither `relate.rs` or `combine.rs` have access to trait solving machinery (without evaluating nested obligations this assert will become _far_ less useful under lazy norm, which consts are already doing) - `relate.rs` does not have access to canonicalization machinery which is necessary in order to have types potentially containing infer vars in query arguments. We could possible add a method to `TypeRelation` to do this assertion rather than a query but to avoid implementing the same logic over and over we'd probably end up with the logic in a free function somewhere in `rustc_trait_selection` _anyway_ so I don't think that would be much better. We could also just remove this assertion, it should not actually be necessary for it to be present. It has caught some bugs in the past though so if possible I would like to keep it. r? `@compiler-errors`
2023-02-14Make permit_uninit/zero_init fallibleMichael Goulet-5/+4
2023-02-15Pre-intern some `ReVar`s and `ReLateBound`s.Nicholas Nethercote-4/+59
2023-02-15Add specialized variants of `mk_region`.Nicholas Nethercote-35/+77
Much like there are specialized variants of `mk_ty`. This will enable some optimization in the next commit. Also rename the existing `re_error*` functions as `mk_re_error*`, for consistency.
2023-02-15Remove `reuse_or_mk_region`.Nicholas Nethercote-8/+1
It's not used on any hot paths, and so has little perf benefit, and it interferes with the optimizations in the following commits.
2023-02-14Auto merge of #108056 - matthiaskrgr:rollup-oa6bxvh, r=matthiaskrgrbors-47/+23
Rollup of 9 pull requests Successful merges: - #107573 (Update the minimum external LLVM to 14) - #107626 (Fix `x fix` on the standard library itself) - #107673 (update ICU4X to 1.1.0) - #107733 (Store metrics from `metrics.json` to CI PGO timer) - #108007 (Use `is_str` instead of string kind comparison) - #108033 (add an unstable `#[rustc_coinductive]` attribute) - #108039 (Refactor refcounted structural_impls via functors) - #108040 (Use derive attributes for uninteresting traversals) - #108044 (interpret: rename Pointer::from_addr → from_addr_invalid) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-14Add `of_trait` to DefKind::Impl.Camille GILLOT-3/+3
2023-02-14Rollup merge of #108044 - RalfJung:from-addr-invalid, r=oli-obkMatthias Krüger-4/+6
interpret: rename Pointer::from_addr → from_addr_invalid This function corresponds to `ptr::invalid` in the standard library; the previous name was not clear enough IMO.
2023-02-14Rollup merge of #108040 - eggyal:attributes_for_uninteresting_traversals, ↵Matthias Krüger-17/+2
r=oli-obk Use derive attributes for uninteresting traversals It appears that visiting and folding was implemented on `BitMatrix` solely so that the derive macros could be used on `GeneratorLayout`, however such implementation would not necessarily be correct for other uses (if there were any). Adding attributes to the derive macro is more correct and potentially more generally useful. r? ``@oli-obk``
2023-02-14Rollup merge of #108029 - oli-obk:🞋_usize, r=RalfJungMatthias Krüger-12/+20
s/eval_usize/eval_target_usize/ for clarity r? `@nnethercote` as discussed in https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/.60Const.60.20and.20.60usize.60.2F.60u64.60 it is unclear what `usize` means and why we use a `u64` for something talking about `usize`. This renaming should make it clear that we're talking about `usize`s on the target platform, irrespective of the compiler host platform.
2023-02-14Pass `DepContext` and `QueryContext` by value when practicalJohn Kåre Alsaker-2/+2
2023-02-14Use derive attributes for uninteresting traversalsAlan Egerton-17/+2
2023-02-14interpret: rename Pointer::from_addr → from_addr_invalidRalf Jung-4/+6
2023-02-14add a `#[rustc_coinductive]` attributelcnr-26/+15
2023-02-14s/eval_usize/eval_target_usize/ for clarityOli Scherer-12/+20
2023-02-14Auto merge of #107765 - petrochenkov:nomoclone, r=oli-obkbors-0/+6
rustc/rustdoc: Perform name resolver cleanups enabled by #94857 Unblocks https://github.com/rust-lang/rust/pull/105462. r? `@oli-obk`
2023-02-13Rollup merge of #107902 - vincenzopalazzo:macros/async_fn_suggestion, ↵Matthias Krüger-1/+1
r=compiler-errors fix: improve the suggestion on future not awaited Considering the following code ```rust fn foo() -> u8 { async fn async_fn() -> u8 { 22 } async_fn() } fn main() {} ``` the error generated before this commit from the compiler is ``` ➜ rust git:(macros/async_fn_suggestion) ✗ rustc test.rs --edition 2021 error[E0308]: mismatched types --> test.rs:4:5 | 1 | fn foo() -> u8 { | -- expected `u8` because of return type ... 4 | async_fn() | ^^^^^^^^^^ expected `u8`, found opaque type | = note: expected type `u8` found opaque type `impl Future<Output = u8>` help: consider `await`ing on the `Future` | 4 | async_fn().await | ++++++ error: aborting due to previous error ``` In this case the error is nor perfect, and can confuse the user that do not know that the opaque type is the future. So this commit will propose (and conclude the work start in https://github.com/rust-lang/rust/issues/80658) to change the string `opaque type` to `future` when applicable and also remove the Expected vs Received note by adding a more specific one regarding the async function that return a future type. So the new error emitted by the compiler is ``` error[E0308]: mismatched types --> test.rs:4:5 | 1 | fn foo() -> u8 { | -- expected `u8` because of return type ... 4 | async_fn() | ^^^^^^^^^^ expected `u8`, found future | note: calling an async function returns a future --> test.rs:4:5 | 4 | async_fn() | ^^^^^^^^^^ help: consider `await`ing on the `Future` | 4 | async_fn().await | ++++++ error: aborting due to previous error ``` Fixes https://github.com/rust-lang/rust/issues/80658 It remains to rework the case described in the following issue https://github.com/rust-lang/rust/issues/107899 but I think this deserves its own PR after we discuss a little bit how to handle these kinds of cases. r? `@eholk` `@rustbot` label +I-async-nominated Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-02-13fix: improve the suggestion on future not awaitedVincenzo Palazzo-1/+1
Considering the following code ```rust fn foo() -> u8 { async fn async_fn() -> u8 { 22 } async_fn() } fn main() {} ``` the error generated before this commit from the compiler is ``` ➜ rust git:(macros/async_fn_suggestion) ✗ rustc test.rs --edition 2021 error[E0308]: mismatched types --> test.rs:4:5 | 1 | fn foo() -> u8 { | -- expected `u8` because of return type ... 4 | async_fn() | ^^^^^^^^^^ expected `u8`, found opaque type | = note: expected type `u8` found opaque type `impl Future<Output = u8>` help: consider `await`ing on the `Future` | 4 | async_fn().await | ++++++ error: aborting due to previous error ``` In this case the error is nor perfect, and can confuse the user that do not know that the opaque type is the future. So this commit will propose (and conclude the work start in https://github.com/rust-lang/rust/issues/80658) to change the string `opaque type` to `future` when applicable and also remove the Expected vs Received note by adding a more specific one regarding the async function that return a future type. So the new error emitted by the compiler is ``` error[E0308]: mismatched types --> test.rs:4:5 | 1 | fn foo() -> u8 { | -- expected `u8` because of return type ... 4 | async_fn() | ^^^^^^^^^^ expected `u8`, found future | note: calling an async function returns a future --> test.rs:4:5 | 4 | async_fn() | ^^^^^^^^^^ help: consider `await`ing on the `Future` | 4 | async_fn().await | ++++++ error: aborting due to previous error ``` Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-02-13Rename folder traits' `tcx` method to `interner`Alan Egerton-31/+35
2023-02-13Move folding and visiting traits into type libraryAlan Egerton-755/+27
2023-02-13Make atomic structural impls generic over InternerAlan Egerton-54/+82
2023-02-13Make folding traits generic over the InternerAlan Egerton-99/+129
2023-02-13Make visiting traits generic over the InternerAlan Egerton-66/+80
2023-02-13Project Binder and Predicate from Interner traitAlan Egerton-0/+2
2023-02-13Move TypeVisitableExt from ir moduleAlan Egerton-130/+127