about summary refs log tree commit diff
path: root/compiler/rustc_middle/src
AgeCommit message (Collapse)AuthorLines
2022-12-16Auto merge of #103880 - b-naber:field-ty-mir, r=lcnrbors-13/+45
Use non-ascribed type as field's type in mir Fixes https://github.com/rust-lang/rust/issues/96514 r? `@lcnr`
2022-12-16Make a field only as public as it needs to beOli Scherer-1/+1
2022-12-16Rename ConstS to ConstDataOli Scherer-16/+16
2022-12-16Auto merge of #105717 - compiler-errors:anonymize, r=jackh726bors-30/+0
always use `anonymize_bound_vars` Unless this is perf-sensitive, it's probably best to always use one anonymize function that does the right thing for all bound vars. r? types
2022-12-15Auto merge of #105760 - matthiaskrgr:rollup-r8beo9w, r=matthiaskrgrbors-759/+752
Rollup of 8 pull requests Successful merges: - #105481 (Start improving monomorphization items stats) - #105674 (Point at method chains on `E0271` errors) - #105679 (Suggest constraining type parameter with `Clone`) - #105694 (Don't create dummy if val has escaping bounds var) - #105727 (Tweak output for bare `dyn Trait` in arguments) - #105739 (Migrate Jump to def links background to CSS variable) - #105743 (`SimplifiedType` cleanups) - #105758 (Move `TypeckResults` to separate module) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-12-15Rollup merge of #105758 - Nilstrieb:typeck-results-mod, r=compiler-errorsMatthias Krüger-706/+724
Move `TypeckResults` to separate module `ty::context` is really big and the typeck results aren't directly related to `TyCtxt`, so move them to a separate module. Also contains a small drive-by macro "improvement".
2022-12-15Rollup merge of #105743 - nnethercote:SimplifiedType-cleanups, r=lcnrMatthias Krüger-52/+12
`SimplifiedType` cleanups r? `@lcnr`
2022-12-15Rollup merge of #105674 - estebank:iterator-chains, r=oli-obkMatthias Krüger-1/+7
Point at method chains on `E0271` errors Follow up to #105332. Fix #33941. CC #9082. r? `@oli-obk`
2022-12-15Rollup merge of #105481 - lqd:mono-stats, r=wesleywiserMatthias Krüger-0/+9
Start improving monomorphization items stats As described in [this zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Compile-time.20case-study.3A.20AWS.20crates/near/314560832), some stats about monomorphization collection would be interesting to have, in a different form than `-Zprint-mono-items`: to have some visibility into the cost of the mono items, we'd like to know how many are instantiated and what is their estimated size. That can be a proxy to analyze sources of slow compile times, although in the future, we'd also like to add more realistic stats from the actual backend's lowering. This PR adds a new `-Z dump-mono-stats` flag which will output some stats in a `{crate_name}.mono-items.md` file (the flag optionally takes an output directory parameter, for easier use within a workspace than printing to stdout). For example, ```rust fn compute<T>(collection: Vec<T>) -> usize { collection.len() + 19 - 0 * 9 - 18 - 1 * 1 // random code to increase the function's size } fn main() { dbg!(compute(vec![0u8, 1, 2])); dbg!(compute(vec![0u64, 1, 2])); dbg!(compute(vec!["0", "1", "2", "3"])); } ``` will output a file with this markdown table (abridged for readability), for a debug build: | Item | Instantiation count | Estimated Cost Per Instantiation | Total Estimated Cost | | --- | ---: | ---: | ---: | | alloc::alloc::box_free | 3 | 122 | 366 | | std::alloc::Global::alloc_impl | 1 | 284 | 284 | | alloc::raw_vec::RawVec::<T, A>::current_memory | 3 | 82 | 246 | | std::ptr::align_offset | 1 | 222 | 222 | | std::slice::hack::into_vec | 3 | 67 | 201 | | <std::vec::Vec<T, A> as std::ops::Drop>::drop | 3 | 66 | 198 | | std::ptr::mut_ptr::<impl *mut T>::is_null | 4 | 47 | 188 | | main | 1 | 163 | 163 | | std::ptr::NonNull::<T>::new_unchecked | 4 | 37 | 148 | ... <details> <summary>Click for full output</summary> | Item | Instantiation count | Estimated Cost Per Instantiation | Total Estimated Cost | | --- | ---: | ---: | ---: | | alloc::alloc::box_free | 3 | 122 | 366 | | std::alloc::Global::alloc_impl | 1 | 284 | 284 | | alloc::raw_vec::RawVec::<T, A>::current_memory | 3 | 82 | 246 | | std::ptr::align_offset | 1 | 222 | 222 | | std::slice::hack::into_vec | 3 | 67 | 201 | | <std::vec::Vec<T, A> as std::ops::Drop>::drop | 3 | 66 | 198 | | std::ptr::mut_ptr::<impl *mut T>::is_null | 4 | 47 | 188 | | main | 1 | 163 | 163 | | std::ptr::NonNull::<T>::new_unchecked | 4 | 37 | 148 | | std::boxed::Box::<T, A>::into_unique | 3 | 48 | 144 | | std::boxed::Box::<T, A>::leak | 3 | 39 | 117 | | std::alloc::Layout::array::inner | 1 | 107 | 107 | | std::ptr::align_offset::mod_inv | 1 | 103 | 103 | | std::boxed::Box::<T, A>::into_raw_with_allocator | 3 | 31 | 93 | | std::fmt::Arguments::<'a>::new_v1 | 1 | 80 | 80 | | <alloc::raw_vec::RawVec<T, A> as std::ops::Drop>::drop | 3 | 26 | 78 | | alloc::raw_vec::RawVec::<T, A>::from_raw_parts_in | 3 | 26 | 78 | | alloc::alloc::exchange_malloc | 1 | 75 | 75 | | std::ptr::const_ptr::<impl *const T>::is_null | 1 | 75 | 75 | | std::ptr::const_ptr::<impl *const T>::is_aligned_to | 1 | 64 | 64 | | compute | 3 | 20 | 60 | | std::ptr::const_ptr::<impl *const T>::align_offset | 1 | 55 | 55 | | std::ptr::read | 1 | 52 | 52 | | <std::alloc::Global as std::alloc::Allocator>::deallocate | 1 | 50 | 50 | | std::ptr::mut_ptr::<impl *mut T>::guaranteed_eq | 1 | 48 | 48 | | std::fmt::ArgumentV1::<'a>::new_display | 2 | 22 | 44 | | std::ptr::Alignment::new_unchecked | 1 | 42 | 42 | | core::fmt::num::<impl std::fmt::Debug for usize>::fmt | 1 | 40 | 40 | | std::result::Result::<T, E>::unwrap_unchecked | 1 | 37 | 37 | | std::cmp::Ord::min | 1 | 32 | 32 | | std::cmp::impls::<impl std::cmp::Ord for usize>::cmp | 1 | 31 | 31 | | std::intrinsics::is_aligned_and_not_null | 1 | 27 | 27 | | std::rt::lang_start | 1 | 27 | 27 | | std::ptr::NonNull::<T>::new | 1 | 24 | 24 | | std::fmt::ArgumentV1::<'a>::new_debug | 1 | 22 | 22 | | std::fmt::Arguments::<'a>::new_v1_formatted | 1 | 19 | 19 | | std::rt::lang_start::{closure#0} | 1 | 17 | 17 | | std::sys_common::backtrace::__rust_begin_short_backtrace | 1 | 16 | 16 | | std::slice::<impl [T]>::into_vec | 3 | 5 | 15 | | <std::ptr::NonNull<T> as std::convert::From<std::ptr::Unique<T>>>::from | 1 | 14 | 14 | | <&T as std::fmt::Debug>::fmt | 1 | 12 | 12 | | <&T as std::fmt::Display>::fmt | 1 | 12 | 12 | | std::vec::Vec::<T, A>::len | 3 | 2 | 6 | | <T as std::convert::Into<U>>::into | 1 | 5 | 5 | | <T as std::convert::From<T>>::from | 1 | 2 | 2 | | <() as std::process::Termination>::report | 1 | 2 | 2 | | std::hint::unreachable_unchecked | 1 | 2 | 2 | | core::fmt::UnsafeArg::new | 1 | 1 | 1 | </details> Since we discussed it together, r? `@wesleywiser.`
2022-12-15Auto merge of #105356 - JakobDegen:more-custom-mir, r=oli-obkbors-0/+5
Custom MIR: Many more improvements Commits are each atomic changes, best reviewed one at a time, with the exception that the last commit includes all the documentation. ### First commit Unsafetyck was not correctly disabled before for `dialect = "built"` custom MIR. This is fixed and a regression test is added. ### Second commit Implements `Discriminant`, `SetDiscriminant`, and `SwitchInt`. ### Third commit Implements indexing, field, and variant projections. ### Fourth commit Documents the previous commits and everything else. There is some amount of weirdness here due to having to beat Rust syntax into cooperating with MIR concepts, but it hopefully should not be too much. All of it is documented. r? `@oli-obk`
2022-12-15Move `TypeckResults` to seperate moduleNilstrieb-684/+708
2022-12-15Small cleanup in parameterizedNilstrieb-22/+16
2022-12-15Shorten trimmed display of closuresEsteban Küber-1/+7
When `with_forced_trimmed_paths` is used, only print filename and start of the closure's span, to reduce their verbosity.
2022-12-15Rollup merge of #105627 - compiler-errors:dyn-auto-suggestable, r=davidtwcoMatthias Krüger-13/+2
Auto traits in `dyn Trait + Auto` are suggestable Not sure why I had made the `IsSuggestableVisitor` have that rule to not consider `dyn Trait + Auto` to be suggestable. It's possible that this was done because of the fact that we don't print the right parentheses for `&(dyn Trait + Auto)`, but that's a problem with printing these types in general that we probably have tracked somewhere else...
2022-12-15Merge `SimplifiedTypeGen<D>` into `SimplifiedType`.Nicholas Nethercote-22/+12
`SimplifiedTypeGen<DefId>` is the only instantiation used, so we don't need the generic parameter.
2022-12-15Remove `SimplifiedTypeGen::map_def`.Nicholas Nethercote-30/+0
It's unused.
2022-12-14address reviewb-naber-1/+8
2022-12-14add helper to get DefId from MonoItemRémy Rakic-0/+9
2022-12-14always use anonymize_bound_varsMichael Goulet-30/+0
2022-12-14Fix rustdocOli Scherer-1/+1
2022-12-14Auto traits in dyn are suggestableMichael Goulet-13/+2
2022-12-14Debug assertions hate this trickOli Scherer-3/+3
2022-12-14Fix some comments and only get the generics in debug modeOli Scherer-27/+23
2022-12-14Remove TraitRef::newOli Scherer-20/+6
2022-12-14Prevent the creation of `TraitRef` without dedicated methodsOli Scherer-8/+13
2022-12-14Ensure no one constructs `AliasTy`s themselvesOli Scherer-13/+16
2022-12-14Remove one more usage of `mk_substs_trait`Oli Scherer-1/+1
2022-12-14Remove many more cases of `mk_substs_trait` that can now use the iterator ↵Oli Scherer-1/+17
scheme`
2022-12-14Let `mk_fn_def` take an iterator instead to simplify some call sitesOli Scherer-5/+13
2022-12-14Rename to match similar methodsOli Scherer-3/+3
2022-12-14Guard `AliasTy` creation against passing the wrong number of substsOli Scherer-12/+22
2022-12-14Fix unsafetyck disabling for custom MIRJakob Degen-0/+5
2022-12-14some fixes/improvements to mir::visit moduleTshepang Mbambo-4/+4
2022-12-14Auto merge of #104986 - compiler-errors:opaques, r=oli-obkbors-152/+149
Combine `ty::Projection` and `ty::Opaque` into `ty::Alias` Implements https://github.com/rust-lang/types-team/issues/79. This PR consolidates `ty::Projection` and `ty::Opaque` into a single `ty::Alias`, with an `AliasKind` and `AliasTy` type (renamed from `ty::ProjectionTy`, which is the inner data of `ty::Projection`) defined as so: ``` enum AliasKind { Projection, Opaque, } struct AliasTy<'tcx> { def_id: DefId, substs: SubstsRef<'tcx>, } ``` Since we don't have access to `TyCtxt` in type flags computation, and because repeatedly calling `DefKind` on the def-id is expensive, these two types are distinguished with `ty::AliasKind`, conveniently glob-imported into `ty::{Projection, Opaque}`. For example: ```diff match ty.kind() { - ty::Opaque(..) => + ty::Alias(ty::Opaque, ..) => {} _ => {} } ``` This PR also consolidates match arms that treated `ty::Opaque` and `ty::Projection` identically. r? `@ghost`
2022-12-13Rollup merge of #105628 - spastorino:small-doc-fixes, r=compiler-errorsMatthias Krüger-1/+1
Small doc fixes r? `@compiler-errors`
2022-12-13Address nitsMichael Goulet-8/+3
Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2022-12-13nit: docsMichael Goulet-3/+12
2022-12-13Combine identical alias armsMichael Goulet-45/+26
2022-12-13Combine projection and opaque into aliasMichael Goulet-71/+81
2022-12-13squash OpaqueTy and ProjectionTy into AliasTyMichael Goulet-65/+59
2022-12-13ProjectionTy.item_def_id -> ProjectionTy.def_idMichael Goulet-42/+34
2022-12-13Use ty::OpaqueTy everywhereMichael Goulet-18/+24
2022-12-13make Opaque have one field: OpaqueTyMichael Goulet-1/+11
2022-12-13Auto merge of #105612 - oli-obk:bind_rustdoc, r=GuillaumeGomezbors-1/+12
use ty::Binder in rustdoc instead of `skip_binder` r? `@GuillaumeGomez` this is a preliminary cleanup required to be able to normalize correctly/conveniently in rustdoc
2022-12-13Make InternalSubsts rust docs a bit clearerSantiago Pastorino-1/+1
2022-12-13Remove instantiate_type_schemeMichael Goulet-3/+3
2022-12-13EarlyBinder nitsMichael Goulet-2/+9
2022-12-13Fast path some binder relationsMichael Goulet-5/+5
2022-12-12Rollup merge of #105593 - jruderman:patch-3, r=Dylan-DPCMatthias Krüger-1/+1
Fix typo in comment: length_limit
2022-12-12Avoid trying to normalize unnormalizable typesOli Scherer-1/+4