summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2022-01-06rustc_middle: Add a method for getting a `SimplifiedType` definition/IDVadim Petrochenkov-6/+17
Import `SimplifiedType` more
2022-01-03revert #92254 "Bump gsgdt to 0.1.3"Krasimir Georgiev-1/+1
gsgdt 0.1.3 was yanked: https://github.com/rust-lang/rust/pull/92254#issuecomment-1004269481
2022-01-03Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievinkMatthias Krüger-6/+1
Remove `NullOp::Box` Follow up of #89030 and MCP rust-lang/compiler-team#460. ~1 month later nothing seems to be broken, apart from a small regression that #89332 (1aac85bb716c09304b313d69d30d74fe7e8e1a8e) shows could be regained by remvoing the diverging path, so it shall be safe to continue and remove `NullOp::Box` completely. r? `@jonas-schievink` `@rustbot` label T-compiler
2021-12-29Refactor variance diagnostics to work with more typesAaron Hill-31/+38
Instead of special-casing mutable pointers/references, we now support general generic types (currently, we handle `ty::Ref`, `ty::RawPtr`, and `ty::Adt`) When a `ty::Adt` is involved, we show an additional note explaining which of the type's generic parameters is invariant (e.g. the `T` in `Cell<T>`). Currently, we don't explain *why* a particular generic parameter ends up becoming invariant. In the general case, this could require printing a long 'backtrace' of types, so doing this would be more suitable for a follow-up PR. We still only handle the case where our variance switches to `ty::Invariant`.
2021-12-29Auto merge of #92244 - petrochenkov:alltraits, r=cjgillotbors-5/+11
rustc_metadata: Encode list of all crate's traits into metadata While working on https://github.com/rust-lang/rust/pull/88679 I noticed that rustdoc is casually doing something quite expensive, something that is used only for error reporting in rustc - collecting all traits from all crates in the dependency tree. This PR trades some minor extra time spent by metadata encoder in rustc for major gains for rustdoc (and for rustc runs with errors, which execute the `all_traits` query for better diagnostics).
2021-12-28rustc_metadata: Encode list of all crate's traits into metadataVadim Petrochenkov-5/+11
2021-12-24Bump `gsgdt` to 0.1.3Krasimir Georgiev-1/+1
No functional changes intended. The 0.1.2 -> 0.1.3 commit https://github.com/vn-ki/gsgdt-rs/commit/3e1dcec5398d281e1b33afb41e43dfb248321a1d renames `Node::new` to `Node::from_list`.
2021-12-24Auto merge of #91342 - RalfJung:fn-abi, r=eddyb,oli-obkbors-5/+13
CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibility This makes use of the `FnAbi` type in CTFE/Miri, which `@eddyb` has been saying for years is what we should do.^^ `FnAbi` is used to - determine which arguments to skip (rather than the previous heuristic of skipping ZST arguments with the Rust ABI) - impose further restrictions on whether caller and callee are consistent in how a given argument is passed I was hoping it would also simplify the code, but that is not the case -- the previous type compatibility checks are still required (AFAIK), only the ZST skipping is gone and that took barely any code. We also need some hacks because `FnAbi` assumes a certain way of implementing `caller_location` (by passing extra arguments), but Miri can just read the caller location from the call stack so it doesn't need those arguments. (The fact that every backend has to separately implement support for these arguments seems suboptimal -- looks like this might have been better implemented on the MIR level.) To avoid having to implement those unnecessary arguments in Miri, we just compute *whether* the argument is present on the caller/callee side, but don't actually pass that argument around. I have no idea if this looks the way `@eddyb` thinks it should look... but it makes Miri's test suite pass. ;) One of rustc's tests fails unfortunately (`ui/const-generics/issues/issue-67739.rs`), some const generic code that is evaluated too early -- I think that should raise `TooGeneric` but instead it ICEs. My assumption is this is some FnAbi code that has not been properly tested on polymorphic code, but it might also be me calling that FnAbi code the wrong way. r? `@oli-obk` `@eddyb` Fixes https://github.com/rust-lang/rust/issues/56166 Miri PR at https://github.com/rust-lang/miri/pull/1928
2021-12-23Rollup merge of #92203 - Aaron1011:mir-adt-def, r=oli-obkMatthias Krüger-18/+16
Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt` The `AggregateKind` enum ends up in the final mir `Body`. Currently, any changes to `AdtDef` (regardless of how significant they are) will legitimately cause the overall result of `optimized_mir` to change, invalidating any codegen re-use involving that mir. This will get worse once we start hashing the `Span` inside `FieldDef` (which is itself contained in `AdtDef`). To try to reduce these kinds of invalidations, this commit changes `AggregateKind::Adt` to store just the `DefId`, instead of the full `AdtDef`. This allows the result of `optimized_mir` to be unchanged if the `AdtDef` changes in a way that doesn't actually affect any of the MIR we build.
2021-12-23Auto merge of #92167 - pierwill:chalk-update, r=jackh726bors-30/+31
Update chalk to 0.75.0 - Compute flags in `intern_ty` - Remove `tracing-serde` from `PERMITTED_DEPENDENCIES` - Bump `tracing-tree` to 0.2.0 - Bump `tracing-subscriber` to 0.3.3
2021-12-22Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt`Aaron Hill-18/+16
The `AggregateKind` enum ends up in the final mir `Body`. Currently, any changes to `AdtDef` (regardless of how significant they are) will legitimately cause the overall result of `optimized_mir` to change, invalidating any codegen re-use involving that mir. This will get worse once we start hashing the `Span` inside `FieldDef` (which is itself contained in `AdtDef`). To try to reduce these kinds of invalidations, this commit changes `AggregateKind::Adt` to store just the `DefId`, instead of the full `AdtDef`. This allows the result of `optimized_mir` to be unchanged if the `AdtDef` changes in a way that doesn't actually affect any of the MIR we build.
2021-12-22Remove `PartialOrd` and `Ord` from `LocalDefId`pierwill-10/+7
Implement `Ord`, `PartialOrd` for SpanData
2021-12-22Update chalk to 0.75.0pierwill-30/+31
- Compute flags in `intern_ty` - Remove tracing-serde from PERMITTED_DEPENDENCIES - Disable `tracing-full` feature in `chalk-solve` - Bump tracing-tree to 0.2.0
2021-12-21Auto merge of #92149 - fee1-dead:cache-fix, r=oli-obkbors-0/+9
Fix bad caching of `~const Drop` bounds Fixes #92111.
2021-12-21Fix bad caching of `~const Drop` boundsDeadbeef-0/+9
2021-12-20Bail if printing item named `_` in `try_print_visible_def_path`Michael Goulet-16/+28
2021-12-20better name for AdjustForForeignAbiError error variant in InterpErrorRalf Jung-4/+5
2021-12-20try to fix ICE in fn_abi_of_instanceRalf Jung-4/+7
2021-12-20CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibilityRalf Jung-1/+5
2021-12-20Auto merge of #91924 - Aaron1011:serialize-adt-def, r=michaelwoeristerbors-28/+23
Fully serialize AdtDef This avoids needing to invoke the `adt_def` query during the decoding of another query's result. Split out from https://github.com/rust-lang/rust/pull/91919 See https://github.com/rust-lang/rust/issues/91696#issuecomment-993043710
2021-12-20Eliminate `ObligationCauseData`.Nicholas Nethercote-43/+41
This makes `Obligation` two words bigger, but avoids allocating a lot of the time. I previously tried this in #73983 and it didn't help much, but local timings look more promising now.
2021-12-19Auto merge of #92099 - matthiaskrgr:rollup-4gwv67m, r=matthiaskrgrbors-111/+117
Rollup of 7 pull requests Successful merges: - #91141 (Revert "Temporarily rename int_roundings functions to avoid conflicts") - #91984 (Remove `in_band_lifetimes` from `rustc_middle`) - #92028 (Sync portable-simd to fix libcore build for AVX-512 enabled targets) - #92042 (Enable `#[thread_local]` for all windows-msvc targets) - #92071 (Update example code for Vec::splice to change the length) - #92077 (rustdoc: Remove unused `collapsed` field) - #92081 (rustdoc: Remove unnecessary `need_backline` function) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-19Rollup merge of #91984 - Aaron1011:rustc-middle-lifetime, r=oli-obkMatthias Krüger-111/+117
Remove `in_band_lifetimes` from `rustc_middle` See #91867 This was mostly straightforward. In several places, I take advantage of the fact that lifetimes are non-hygenic: a macro declares the 'tcx' lifetime, which is then used in types passed in as macro arguments.
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-13/+12
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-19Rollup merge of #91932 - Kixiron:randomize-seed, r=nagisaMatthias Krüger-8/+15
Add user seed to `-Z randomize-layout` Allows users of -`Z randomize-layout` to provide `-Z layout-seed=<seed>` in order to further randomizing type layout randomization. Extension of [compiler-team/#457](https://github.com/rust-lang/compiler-team/issues/457), allows users to change struct layouts without changing code and hoping that item path hashes change, aiding in detecting layout errors
2021-12-18Rollup merge of #92032 - petrochenkov:extblockpath, r=oli-obkMatthias Krüger-16/+12
hir: Do not introduce dummy type names for `extern` blocks in def paths Use a separate nameless `DefPathData` variant instead. Extracted from https://github.com/rust-lang/rust/pull/91795.
2021-12-18Rollup merge of #92022 - woodenarrow:br_expected_bool, r=estebankMatthias Krüger-9/+1
Eliminate duplicate codes of expected_found_bool The function expected_found_bool is the same as ExpectedFound::new. So use ExpectedFound::new to replace expected_found_bool to eliminate duplicate codes. ![image](https://user-images.githubusercontent.com/95843988/146486722-c910eccd-a36c-4dc5-8b36-214aab058e38.png)
2021-12-18hir: Do not introduce dummy type names for `extern` blocks in def pathsVadim Petrochenkov-16/+12
Use a separate nameless `DefPathData` variant instead
2021-12-17Add a temporary hack before env fix lands in bootstrapDeadbeef-4/+17
2021-12-17Eliminate duplicate codes of expected_found_boollzh-9/+1
2021-12-17Auto merge of #91672 - b-naber:merge-normalize-erasing-regions-queries, ↵bors-23/+7
r=jackh726 Implement normalize_erasing_regions queries in terms of 'try' version Attempt to lessen performance regression caused by https://github.com/rust-lang/rust/pull/91255 r? `@jackh726`
2021-12-16Only cache local adt_def results on diskAaron Hill-1/+1
An `AdtDef` contains `Span`s, and we don't appear to actually encode the `SourceFile` for foreign spans in the incremental cache in some cases.
2021-12-15Run x.py fmtAaron Hill-2/+8
2021-12-15Remove `in_band_lifetimes` from `rustc_middle`Aaron Hill-111/+111
See #91867 This was mostly straightforward. In several places, I take advantage of the fact that lifetimes are non-hygenic: a macro declares the 'tcx' lifetime, which is then used in types passed in as macro arguments.
2021-12-15Auto merge of #86986 - lcnr:simplify_type, r=nikomatsakis,oli-obkbors-49/+78
extend `simplify_type` might cause a slight perf inprovement and imo more accurately represents what types there are. considering that I was going to use this in #85048 it seems like we might need this in the future anyways :shrug:
2021-12-15Cache adt_def query result on diskAaron Hill-2/+5
2021-12-15Fully serialize AdtDefAaron Hill-26/+18
This avoids needing to invoke the `adt_def` query during the decoding of another query's result.
2021-12-15Rollup merge of #91920 - Aaron1011:pred-stable-cmp, r=oli-obkMatthias Krüger-1/+1
Use `tcx.def_path_hash` in `ExistentialPredicate.stable_cmp` This avoids a needless query invocation
2021-12-15Rollup merge of #91898 - compiler-errors:dont_suggest_closure_return_type, ↵Matthias Krüger-10/+54
r=lcnr Make `TyS::is_suggestable` check for non-suggestable types structually Not sure if I went overboard checking substs in dyn types, etc. Let me know if I should simplify this function. Fixes #91832
2021-12-15Rollup merge of #91880 - matthiaskrgr:clippy_perf_dec, r=jyn514Matthias Krüger-10/+10
fix clippy::single_char_pattern perf findings
2021-12-15Remove unnecessary sigils around `Ident::as_str()` calls.Nicholas Nethercote-1/+1
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-6/+6
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-6/+5
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-15Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcmMatthias Krüger-1/+0
Stabilize `iter::zip` Hello all! As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue. As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been used in many places across the rust compiler and standard library since March without any issues. For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).
2021-12-15Rollup merge of #90939 - estebank:wg-af-polish, r=tmandryMatthias Krüger-0/+6
Tweak errors coming from `for`-loop, `?` and `.await` desugaring * Suggest removal of `.await` on non-`Future` expression * Keep track of obligations introduced by desugaring * Remove span pointing at method for obligation errors coming from desugaring * Point at called local sync `fn` and suggest making it `async` ``` error[E0277]: `()` is not a future --> $DIR/unnecessary-await.rs:9:10 | LL | boo().await; | -----^^^^^^ `()` is not a future | | | this call returns `()` | = help: the trait `Future` is not implemented for `()` help: do not `.await` the expression | LL - boo().await; LL + boo(); | help: alternatively, consider making `fn boo` asynchronous | LL | async fn boo () {} | +++++ ``` Fix #66731.
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-14Minor cleanupChase Wilson-7/+7
2021-12-14Make TyS::is_suggestable more structualMichael Goulet-10/+54
2021-12-14Added -Z layout_seed for allowing user-defined randomization seedsChase Wilson-1/+8
2021-12-14Use `tcx.def_path_hash` in `ExistentialPredicate.stable_cmp`Aaron Hill-1/+1
This avoids a needless query invocation