Matthias Krüger
b68e994503
Rollup merge of #105973 - oli-obk:simplify_callee_checks, r=jackh726
...
Avoid going through the happy path in case of non-fn builtin calls
No functional change, just doing an early return. The removed comment is not applicable anymore, not every node needs type bindings in the error case. At best this would have been needed to avoid ICEs, but afaict this can't happen anymore today, as we do fallible checks.
2022-12-20 23:35:17 +01:00
Oli Scherer
f1ef038ae4
use track_caller
to show where the panic is actually from
2022-12-20 14:13:29 +00:00
Oli Scherer
8b5a96ec45
Some tracing cleanups
2022-12-20 13:39:48 +00:00
bors
eb9e5e711d
Auto merge of #105880 - Nilstrieb:make-newtypes-less-not-rust, r=oli-obk
...
Improve syntax of `newtype_index`
This makes it more like proper Rust and also makes the implementation a lot simpler.
Mostly just turns weird flags in the body into proper attributes.
It should probably also be converted to an attribute macro instead of function-like, but that can be done in a future PR.
2022-12-20 07:27:01 +00:00
bors
696563efc5
Auto merge of #105905 - lqd:revert-103880, r=jackh726
...
Revert #103880 "Use non-ascribed type as field's type in mir"
This PR prepares a revert for #103880 to fix #105809 , #105881 , #105886 and others (like the duplicates of the first one), in case an actual fix can't get done today.
I've also added the MCVE from #105809 . There is no MCVE for the #105881 and #105886 ICEs yet however, so there are no tests for them here, although we'll need one before relanding the original changes.
Were this PR to land, it would also reopen #96514 as it was fixed by the original PR.
Opening as draft to allow time for a possible fix.
r? `@jackh726`
2022-12-19 22:37:12 +00:00
bors
935dc07218
Auto merge of #103600 - compiler-errors:early-binder-nits, r=spastorino
...
Address some `EarlyBinder` nits
2022-12-19 19:21:35 +00:00
Rémy Rakic
8275d115fb
Revert "Auto merge of #103880 - b-naber:field-ty-mir, r=lcnr"
...
This reverts commit 03770f0e2b
, reversing
changes made to 01ef4b21dc
.
2022-12-19 15:31:20 +00:00
Dylan DPC
a9005b6cc0
Rollup merge of #105864 - matthiaskrgr:compl, r=Nilstrieb
...
clippy::complexity fixes
filter_next
needless_question_mark
bind_instead_of_map
manual_find
derivable_impls
map_identity
redundant_slicing
skip_while_next
unnecessary_unwrap
needless_bool
r? `@compiler-errors`
2022-12-19 14:41:35 +05:30
Matthias Krüger
1da4a49912
clippy::complexity fixes
...
filter_next
needless_question_mark
bind_instead_of_map
manual_find
derivable_impls
map_identity
redundant_slicing
skip_while_next
unnecessary_unwrap
needless_bool
2022-12-19 00:04:28 +01:00
Matthias Krüger
ebe3563764
Rollup merge of #105873 - matthiaskrgr:clippy_fmt, r=Nilstrieb
...
use &str / String literals instead of format!()
2022-12-18 23:03:07 +01:00
Nilstrieb
8bfd6450c7
A few small cleanups for newtype_index
...
Remove the `..` from the body, only a few invocations used it and it's
inconsistent with rust syntax.
Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18 21:47:28 +01:00
Nilstrieb
d679764fb6
Make #[debug_format]
an attribute in newtype_index
...
This removes the `custom` format functionality as its only user was
trivially migrated to using a normal format.
If a new use case for a custom formatting impl pops up, you can add it
back.
2022-12-18 21:37:38 +01:00
Nilstrieb
91c3c2040c
Make #[max]
an attribute in newtype_index
2022-12-18 21:22:14 +01:00
Nilstrieb
b4d739ef12
Use #[derive]
instead of custom syntax in all newtype_index
2022-12-18 20:53:08 +01:00
Matthias Krüger
22379779b5
Rollup merge of #105875 - matthiaskrgr:needless_borrowed_reference, r=oli-obk
...
don't destuct references just to reborrow
2022-12-18 18:57:05 +01:00
Matthias Krüger
a108d55ce6
don't restuct references just to reborrow
2022-12-18 17:04:32 +01:00
Matthias Krüger
0aa4cde747
avoid .into() conversion to identical types
2022-12-18 16:20:32 +01:00
Matthias Krüger
3af7df91fc
use &str / String literals instead of format!()
2022-12-18 16:17:46 +01:00
Matthias Krüger
9b6605dcc4
Rollup merge of #105770 - oli-obk:deref_all_the_things, r=compiler-errors
...
Rename ConstS to ConstData
just a style nit to get it in sync with all the other interned datastructures
2022-12-17 09:25:53 +01:00
Matthias Krüger
505848a935
Rollup merge of #105493 - WaffleLapkin:unchoke-r-a, r=Nilstrieb
...
Help rust-analyzer normalize query return types
See [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Frust-analyzer/topic/rustc.20query.20types.20are.20not.20normalized.20since.20recently/near/312686086 ), since https://github.com/rust-lang/rust/pull/103808 , rust analyzer doesn't normalize return types of queries. This is because r-a doesn't support associated type defaults (yet).
The easiest fix is to not use associated type defaults (duh), which this PR does.
r? `@cjgillot`
2022-12-17 00:45:50 +01:00
Maybe Waffle
452c745518
Add a comment warning against using associated type defaults <3
2022-12-16 15:10:48 +00:00
bors
03770f0e2b
Auto merge of #103880 - b-naber:field-ty-mir, r=lcnr
...
Use non-ascribed type as field's type in mir
Fixes https://github.com/rust-lang/rust/issues/96514
r? `@lcnr`
2022-12-16 12:47:49 +00:00
Oli Scherer
b170669917
Make a field only as public as it needs to be
2022-12-16 10:09:23 +00:00
Oli Scherer
02cbc017d7
Rename ConstS to ConstData
2022-12-16 10:02:51 +00:00
bors
a803f313fd
Auto merge of #105717 - compiler-errors:anonymize, r=jackh726
...
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-16 06:45:08 +00:00
bors
7a6af2711b
Auto merge of #105760 - matthiaskrgr:rollup-r8beo9w, r=matthiaskrgr
...
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-15 22:53:03 +00:00
Matthias Krüger
2e03ff1b35
Rollup merge of #105758 - Nilstrieb:typeck-results-mod, r=compiler-errors
...
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-15 22:03:01 +01:00
Matthias Krüger
0f90ea9a61
Rollup merge of #105743 - nnethercote:SimplifiedType-cleanups, r=lcnr
...
`SimplifiedType` cleanups
r? `@lcnr`
2022-12-15 22:03:01 +01:00
Matthias Krüger
622f56065e
Rollup merge of #105674 - estebank:iterator-chains, r=oli-obk
...
Point at method chains on `E0271` errors
Follow up to #105332 . Fix #33941 . CC #9082 .
r? `@oli-obk`
2022-12-15 22:02:58 +01:00
Matthias Krüger
863d1f653a
Rollup merge of #105481 - lqd:mono-stats, r=wesleywiser
...
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-15 22:02:57 +01:00
bors
ec56537c43
Auto merge of #105356 - JakobDegen:more-custom-mir, r=oli-obk
...
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-15 19:59:48 +00:00
Nilstrieb
651e41c14c
Move TypeckResults
to seperate module
2022-12-15 20:45:35 +01:00
Nilstrieb
153419b78f
Small cleanup in parameterized
2022-12-15 20:41:07 +01:00
Esteban Küber
4d4d4786f9
Shorten trimmed display of closures
...
When `with_forced_trimmed_paths` is used, only print filename and start
of the closure's span, to reduce their verbosity.
2022-12-15 11:13:44 -08:00
Matthias Krüger
a2c9f2a5e0
Rollup merge of #105627 - compiler-errors:dyn-auto-suggestable, r=davidtwco
...
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-15 12:46:01 +01:00
Nicholas Nethercote
5258b655a2
Merge SimplifiedTypeGen<D>
into SimplifiedType
.
...
`SimplifiedTypeGen<DefId>` is the only instantiation used, so we don't
need the generic parameter.
2022-12-15 15:13:19 +11:00
Nicholas Nethercote
2a5aabdfc2
Remove SimplifiedTypeGen::map_def
.
...
It's unused.
2022-12-15 15:04:09 +11:00
b-naber
ff41359e65
address review
2022-12-14 21:32:42 +01:00
Rémy Rakic
74f4da44a5
add helper to get DefId from MonoItem
2022-12-14 20:17:52 +00:00
Michael Goulet
3eb5b62898
always use anonymize_bound_vars
2022-12-14 20:06:25 +00:00
Oli Scherer
b41a483e8a
Fix rustdoc
2022-12-14 18:55:55 +00:00
Michael Goulet
cfa6a93a36
Auto traits in dyn are suggestable
2022-12-14 18:39:39 +00:00
Oli Scherer
18373fae35
Debug assertions hate this trick
2022-12-14 15:37:47 +00:00
Oli Scherer
49536667ff
Fix some comments and only get the generics in debug mode
2022-12-14 15:36:39 +00:00
Oli Scherer
0ae3da34c3
Remove TraitRef::new
2022-12-14 15:36:39 +00:00
Oli Scherer
6af3638709
Prevent the creation of TraitRef
without dedicated methods
2022-12-14 15:36:39 +00:00
Oli Scherer
a5cd3bde95
Ensure no one constructs AliasTy
s themselves
2022-12-14 15:36:39 +00:00
Oli Scherer
4ffe3bdf99
Remove one more usage of mk_substs_trait
2022-12-14 15:36:39 +00:00
Oli Scherer
1bf80249ae
Remove many more cases of mk_substs_trait
that can now use the iterator scheme`
2022-12-14 15:36:39 +00:00
Oli Scherer
0fe86aa977
Let mk_fn_def
take an iterator instead to simplify some call sites
2022-12-14 15:36:39 +00:00