summary refs log tree commit diff
path: root/compiler/rustc_middle/src/ty
AgeCommit message (Collapse)AuthorLines
2022-01-06rustc_middle: Add a method for getting a `SimplifiedType` definition/IDVadim Petrochenkov-2/+15
Import `SimplifiedType` more
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-28rustc_metadata: Encode list of all crate's traits into metadataVadim Petrochenkov-0/+6
2021-12-24Auto merge of #91342 - RalfJung:fn-abi, r=eddyb,oli-obkbors-4/+7
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-22Remove `PartialOrd` and `Ord` from `LocalDefId`pierwill-1/+1
Implement `Ord`, `PartialOrd` for SpanData
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-20try to fix ICE in fn_abi_of_instanceRalf Jung-4/+7
2021-12-20Auto merge of #91924 - Aaron1011:serialize-adt-def, r=michaelwoeristerbors-27/+21
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-1/+1
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-76/+81
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-76/+81
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-3/+3
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-17Eliminate duplicate codes of expected_found_boollzh-9/+1
2021-12-17Auto merge of #91672 - b-naber:merge-normalize-erasing-regions-queries, ↵bors-2/+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-15Run x.py fmtAaron Hill-1/+5
2021-12-15Remove `in_band_lifetimes` from `rustc_middle`Aaron Hill-76/+77
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/+4
2021-12-15Fully serialize AdtDefAaron Hill-25/+17
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-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-1/+1
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-2/+2
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-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
2021-12-14add some commentslcnr-32/+33
2021-12-14replace `DefId` with `D` in `SimplifiedType`lcnr-2/+2
2021-12-14extend `simplify_type`lcnr-17/+45
2021-12-13get rid of normalize_generic_arg... queriesb-naber-2/+7
2021-12-13Avoid cloning refcounted types during foldingAlan Egerton-6/+67
2021-12-12Auto merge of #91549 - fee1-dead:const_env, r=spastorinobors-70/+112
Eliminate ConstnessAnd again Closes #91489. Closes #89432. Reverts #91491. Reverts #89450. r? `@spastorino`
2021-12-12Auto merge of #90207 - BoxyUwU:stabilise_cg_defaults, r=lcnrbors-4/+2
Stabilise `feature(const_generics_defaults)` `feature(const_generics_defaults)` is complete implementation wise and has a pretty extensive test suite so I think is ready for stabilisation. needs stabilisation report and maybe an RFC :sweat_smile: r? `@lcnr` cc `@rust-lang/project-const-generics`
2021-12-12Small performance tweaksDeadbeef-0/+4
2021-12-12Remap more env constness for queriesDeadbeef-0/+4
2021-12-12Query modifierDeadbeef-0/+20
2021-12-12Revert "Auto merge of #91491 - spastorino:revert-91354, r=oli-obk"Deadbeef-70/+79
This reverts commit ff2439b7b9bafcfdff86b7847128014699df8442, reversing changes made to 2a9e0831d6603d87220cedd1b1293e2eb82ef55c.
2021-12-12Fix #91489Deadbeef-0/+5
2021-12-11Auto merge of #91769 - estebank:type-trait-bound-span-2, r=oli-obkbors-4/+2
Tweak assoc type obligation spans * Point at RHS of associated type in obligation span * Point at `impl` assoc type on projection error * Reduce verbosity of recursive obligations * Point at source of binding lifetime obligation * Tweak "required bound" note * Tweak "expected... found opaque (return) type" labels * Point at set type in impl assoc type WF errors r? `@oli-obk` This is a(n uncontroversial) subset of #85799.
2021-12-11Auto merge of #91799 - matthiaskrgr:rollup-b38xx6i, r=matthiaskrgrbors-34/+22
Rollup of 6 pull requests Successful merges: - #83174 (Suggest using a temporary variable to fix borrowck errors) - #89734 (Point at capture points for non-`'static` reference crossing a `yield` point) - #90270 (Make `Borrow` and `BorrowMut` impls `const`) - #90741 (Const `Option::cloned`) - #91548 (Add spin_loop hint for RISC-V architecture) - #91721 (Minor improvements to `future::join!`'s implementation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-12-11Rollup merge of #91640 - cjgillot:in-band-collect, r=oli-obkMatthias Krüger-7/+11
Simplify collection of in-band lifetimes Split from https://github.com/rust-lang/rust/pull/91403 r? ````@oli-obk````
2021-12-11Rollup merge of #91617 - nnethercote:improve-List-readability, r=lcnrMatthias Krüger-51/+89
Improve the readability of `List<T>`. This commit does the following. - Expands on some of the things already mentioned in comments. - Describes the uniqueness assumption, which is critical but wasn't mentioned at all. - Rewrites `empty()` into a clearer form, as provided by Daniel Henry-Mantilla on Zulip. - Reorders things slightly so that more important things are higher up, and incidental things are lower down, which makes reading the code easier. r? ````@lcnr````
2021-12-11Tweak assoc type obligation spansEsteban Kuber-4/+2
* Point at RHS of associated type in obligation span * Point at `impl` assoc type on projection error * Reduce verbosity of recursive obligations * Point at source of binding lifetime obligation * Tweak "required bound" note * Tweak "expected... found opaque (return) type" labels * Point at set type in impl assoc type WF errors
2021-12-10remove feature gate and cleanup codeEllen-4/+2