summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2021-11-25Auto merge of #90580 - cjgillot:no-ee-upvar, r=Aaron1011bors-1/+0
Remove eval_always from upvars. Split off https://github.com/rust-lang/rust/pull/86056 r? `@ghost`
2021-11-25Rollup merge of #91162 - RalfJung:miri-shift-truncation, r=oli-obkMatthias Krüger-0/+8
explain why CTFE/Miri perform truncation on shift offset Closes https://github.com/rust-lang/miri/issues/1920
2021-11-25Rollup merge of #91096 - compiler-errors:elaborate_opaque_trait, r=estebankMatthias Krüger-75/+280
Print associated types on opaque `impl Trait` types This PR generalizes #91021, printing associated types for all opaque `impl Trait` types instead of just special-casing for future. before: ``` error[E0271]: type mismatch resolving `<impl Iterator as Iterator>::Item == u32` ``` after: ``` error[E0271]: type mismatch resolving `<impl Iterator<Item = usize> as Iterator>::Item == u32` ``` --- Questions: 1. I'm kinda lost in binders hell with this one. Is all of the `rebind`ing necessary? 2. Is there a map collection type that will give me a stable iteration order? Doesn't seem like TraitRef is Ord, so I can't just sort later.. 3. I removed the logic that suppresses printing generator projection types. It creates outputs like this [gist](https://gist.github.com/compiler-errors/d6f12fb30079feb1ad1d5f1ab39a3a8d). Should I put that back? 4. I also added spaces between traits, `impl A+B` -> `impl A + B`. I quite like this change, but is there a good reason to keep it like that? r? ````@estebank````
2021-11-24Auto merge of #90579 - cjgillot:no-ee-ii, r=Aaron1011bors-5/+1
Remove eval_always for inherent_impls. Split off https://github.com/rust-lang/rust/pull/86056 r? `@ghost`
2021-11-23document BinOp behavior quirks in the corresponding enumRalf Jung-0/+8
2021-11-23Fix printing unit return ty, don't elaborate FnOnce unless we see itMichael Goulet-7/+16
2021-11-23Suppress noisy generator associated typeMichael Goulet-4/+14
2021-11-23Elaborate trait generics and associated typesMichael Goulet-74/+210
2021-11-23Add supertraits method to rustc_middleMichael Goulet-0/+50
2021-11-23Derive Ord and PartialOrd for TraitRefMichael Goulet-1/+1
2021-11-23Rollup merge of #91148 - jhpratt:use-default-enum, r=petrochenkovMatthias Krüger-7/+3
Use `derive_default_enum` in the compiler Let's get this feature some real-world love. ``@rustbot`` label: +C-cleanup +S-waiting-on-review
2021-11-23Rollup merge of #90856 - ↵Matthias Krüger-8/+53
ken-matsui:suggestion-to-wrap-vec-allocator-api-in-tuple, r=davidtwco Suggestion to wrap inner types using 'allocator_api' in tuple This PR provides a suggestion to wrap the inner types in tuple when being along with 'allocator_api'. Closes https://github.com/rust-lang/rust/issues/83250 ```rust fn main() { let _vec: Vec<u8, _> = vec![]; //~ ERROR use of unstable library feature 'allocator_api' } ``` ```diff error[E0658]: use of unstable library feature 'allocator_api' --> $DIR/suggest-vec-allocator-api.rs:2:23 | LL | let _vec: Vec<u8, _> = vec![]; - | ^ + | ----^ + | | + | help: consider wrapping the inner types in tuple: `(u8, _)` | = note: see issue #32838 <https://github.com/rust-lang/rust/issues/32838> for more information = help: add `#![feature(allocator_api)]` to the crate attributes to enable ```
2021-11-24Suggestion to wrap inner types using `allocator_api` in tupleKen Matsui-8/+53
2021-11-22Use `derive_default_enum` in the compilerJacob Pratt-7/+3
2021-11-21Simplify for loop desugarCameron Steffen-1/+1
2021-11-20Add space in opaque `impl Trait`Michael Goulet-3/+3
2021-11-20Rollup merge of #91021 - compiler-errors:print_future_output, r=estebankMatthias Krüger-11/+55
Elaborate `Future::Output` when printing opaque `impl Future` type I would love to see the `Output =` type when printing type errors involving opaque `impl Future`. [Test code](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a800b481edd31575fbcaf5771a9c3678) Before (cut relevant part of output): ``` note: while checking the return type of the `async fn` --> /home/michael/test.rs:5:19 | 5 | async fn bar() -> usize { | ^^^^^ checked the `Output` of this `async fn`, found opaque type = note: expected type `usize` found opaque type `impl Future` ``` After: ``` note: while checking the return type of the `async fn` --> /home/michael/test.rs:5:19 | 5 | async fn bar() -> usize { | ^^^^^ checked the `Output` of this `async fn`, found opaque type = note: expected type `usize` found opaque type `impl Future<Output = usize>` ``` Note the "found opaque type `impl Future<Output = usize>`" in the new output. ---- Questions: 1. We skip printing the output type when it's a projection, since I have been seeing some types like `impl Future<Output = <[static generator@/home/michael/test.rs:2:11: 2:21] as Generator<ResumeTy>>::Return>` which are not particularly helpful and leak implementation detail. * Am I able to normalize this type within `rustc_middle::ty::print::pretty`? Alternatively, can we normalize it when creating the diagnostic? Otherwise, I'm fine with skipping it and falling back to the old output. * Should I suppress any other types? I didn't encounter anything other than this generator projection type. 2. Not sure what the formatting of this should be. Do I include spaces in `Output = `?
2021-11-20Rollup merge of #90999 - RalfJung:miri_simd, r=oli-obkMatthias Krüger-0/+5
fix CTFE/Miri simd_insert/extract on array-style repr(simd) types The changed test would previously fail since `place_index` would just return the only field of `f32x4`, i.e., the array -- rather than *indexing into* the array which is what we have to do. The new helper methods will also be needed for https://github.com/rust-lang/miri/issues/1912. r? ``````@oli-obk``````
2021-11-19Auto merge of #90996 - the8472:obligation-hashes2, r=matthewjasperbors-1/+10
Optimize `impl Hash for ObligationCauseData` by not hashing `ObligationCauseCode` variant fields Split out from #90913 since it's a [clear performance win](https://perf.rust-lang.org/compare.html?start=ad442399756573dccacb314b6bf8079964bcc72a&end=223f5e877fe93b5f437c2d703f883797913cd2b7) and should be easier to review. It speeds up hashing for `Obligation` [deduplication](https://github.com/rust-lang/rust/blob/c9c4b5d7276297679387189d96a952f2b760e7ad/compiler/rustc_trait_selection/src/traits/select/mod.rs#L2355-L2356) by only hashing the discriminant of the `ObligationCauseCode` enum instead of its contents. That shouldn't affect hash quality much since there are several other fields in `Obligation` which should be unique enough, especially the predicate itself which is hashed as an interned pointer.
2021-11-19Rollup merge of #90990 - nnethercote:arenas-cleanup, r=oli-obkYuki Okushi-24/+24
Arenas cleanup I was looking closely at the arenas code and here are some small improvement to readability.
2021-11-18Print output ty for opaque future tyMichael Goulet-11/+55
2021-11-19Add some comments.Nicholas Nethercote-1/+1
Also use `Default::default()` in one `TypedArena::default()`, for consistency with `DroplessArena::default()`.
2021-11-18fix CTFE/Miri simd_insert/extract on array-style repr(simd) typesRalf Jung-0/+5
2021-11-18rustc: Remove `#[rustc_synthetic]`Vadim Petrochenkov-18/+3
This function parameter attribute was introduced in https://github.com/rust-lang/rust/pull/44866 as an intermediate step in implementing `impl Trait`, it's not necessary or used anywhere by itself.
2021-11-17Remove unnecessary lifetime argument from arena macros.Nicholas Nethercote-23/+23
Because it's always `'tcx`. In fact, some of them use a mixture of passed-in `$tcx` and hard-coded `'tcx`, so no other lifetime would even work. This makes the code easier to read.
2021-11-16Auto merge of #90919 - nnethercote:rm-DropArena, r=Mark-Simulacrumbors-10/+5
Remove `DropArena`. Most arena-allocate types that impl `Drop` get their own `TypedArena`, but a few infrequently used ones share a `DropArena`. This sharing adds complexity but doesn't help performance or memory usage. Perhaps it was more effective in the past prior to some other improvements to arenas. This commit removes `DropArena` and the sharing of arenas via the `few` attribute of the `arena_types` macro. This change removes over 100 lines of code and nine uses of `unsafe` (one of which affects the parallel compiler) and makes the remaining code easier to read.
2021-11-16Rollup merge of #90910 - RalfJung:const-discriminant-empty-enum, r=petrochenkovYuki Okushi-1/+3
fix getting the discriminant of a zero-variant enum Fixes https://github.com/rust-lang/rust/issues/89765
2021-11-15Remove `DropArena`.Nicholas Nethercote-10/+5
Most arena-allocate types that impl `Drop` get their own `TypedArena`, but a few infrequently used ones share a `DropArena`. This sharing adds complexity but doesn't help performance or memory usage. Perhaps it was more effective in the past prior to some other improvements to arenas. This commit removes `DropArena` and the sharing of arenas via the `few` attribute of the `arena_types` macro. This change removes over 100 lines of code and nine uses of `unsafe` (one of which affects the parallel compiler) and makes the remaining code easier to read.
2021-11-14Simplify ObligationCauseData hash to skip ObligationCauseCodeThe8472-1/+10
selection deduplicates obligations through a hashset at some point, computing the hashes for ObligationCauseCode appears to dominate the hashing cost. bodyid + span + discriminant hash hopefully will sufficiently unique unique enough.
2021-11-14fix getting the discriminant of a zero-variant enumRalf Jung-1/+3
2021-11-11Use `associated_item_def_ids` moreMatthew Jasper-6/+6
2021-11-11Auto merge of #90648 - matthewjasper:assoc-item-cleanup, r=cjgillotbors-2/+0
Assoc item cleanup This removes some fields from ObligationCauseCode Split out of #90639
2021-11-11Auto merge of #89550 - lcnr:coherence-specialization, r=nikomatsakisbors-5/+8
do not emit overlap errors for impls failing the orphan check this should finally allow us to merge #86986, see https://github.com/rust-lang/rust/pull/86986#discussion_r716059345 for more details. r? `@nikomatsakis` cc `@eddyb`
2021-11-10Rollup merge of #90742 - est31:add_assign, r=davidtwcoMatthias Krüger-1/+1
Use AddAssign impl
2021-11-10no overlap errors after failing the orphan checklcnr-5/+8
2021-11-09Add `ty::Visibility::is_public()`inquisitivecrystal-1/+5
2021-11-09Use AddAssign implest31-1/+1
2021-11-09Rollup merge of #90035 - SparrowLii:rfc2528, r=jackh726Matthias Krüger-0/+4
implement rfc-2528 type_changing-struct-update This PR implement rfc2528-type_changing-struct-update. The main change process is as follows: 1. Move the processing part of `base_expr` into `check_expr_struct_fields` to avoid returning `remaining_fields` (a relatively complex hash table) 2. Before performing the type consistency check(`check_expr_has_type_or_error`), if the `type_changing_struct_update` feature is set, enter a different processing flow, otherwise keep the original flow 3. In the case of the same structure definition, check each field in `remaining_fields`. If the field in `base_expr` is not the suptype of the field in `adt_ty`, an error(`FeildMisMatch`) will be reported. The MIR part does not need to be changed, because only the items contained in `remaining_fields` will be extracted from `base_expr` when MIR is generated. This means that fields with different types in `base_expr` will not be used Updates #86618 cc `@nikomatsakis`
2021-11-09Rollup merge of #89561 - nbdd0121:const_typeck, r=nikomatsakisMatthias Krüger-26/+173
Type inference for inline consts Fixes #78132 Fixes #78174 Fixes #81857 Fixes #89964 Perform type checking/inference of inline consts in the same context as the outer def, similar to what is currently done to closure. Doing so would require `closure_base_def_id` of the inline const to return the outer def, and since `closure_base_def_id` can be called on non-local crate (and thus have no HIR available), a new `DefKind` is created for inline consts. The type of the generated anon const can capture lifetime of outer def, so we couldn't just use the typeck result as the type of the inline const's def. Closure has a similar issue, and it uses extra type params `CK, CS, U` to capture closure kind, input/output signature and upvars. I use a similar approach for inline consts, letting it have an extra type param `R`, and then `typeof(InlineConst<[paremt generics], R>)` would just be `R`. In borrowck region requirements are also propagated to the outer MIR body just like it's currently done for closure. With this PR, inline consts in expression position are quitely usable now; however the usage in pattern position is still incomplete -- since those does not remain in the MIR borrowck couldn't verify the lifetime there. I have left an ignored test as a FIXME. Some disucssions can be found on [this Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/260443-project-const-generics/topic/inline.20consts.20typeck). cc `````@spastorino````` `````@lcnr````` r? `````@nikomatsakis````` `````@rustbot````` label A-inference F-inline_const T-compiler
2021-11-08Don't abort compilation after giving a lint errorJoshua Nelson-2/+6
The only reason to use `abort_if_errors` is when the program is so broken that either: 1. later passes get confused and ICE 2. any diagnostics from later passes would be noise This is never the case for lints, because the compiler has to be able to deal with `allow`-ed lints. So it can continue to lint and compile even if there are lint errors.
2021-11-07Remove some fields from `ObligationCauseCode`Matthew Jasper-2/+0
2021-11-07Rename functions reflect that inline const is also "typeck_child"Gary Guo-10/+11
2021-11-07Implement type inference for inline constsGary Guo-22/+159
In most cases it is handled in the same way as closures.
2021-11-07Give inline const separate DefKindGary Guo-3/+12
2021-11-06Auto merge of #90661 - matthiaskrgr:rollup-1umbdlx, r=matthiaskrgrbors-7/+11
Rollup of 6 pull requests Successful merges: - #90487 (Add a chapter on reading Rustdoc output) - #90508 (Apply adjustments for field expression even if inaccessible) - #90627 (Suggest dereference of `Box` when inner type is expected) - #90642 (use matches!() macro in more places) - #90646 (type error go brrrrrrrr) - #90649 (Run reveal_all on MIR when inlining is activated.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-06Rollup merge of #90646 - BoxyUwU:funky_ice, r=estebankMatthias Krüger-2/+6
type error go brrrrrrrr Fixes #90444 when we relate something like: `fn(fn((), (), u32))` with `fn(fn((), (), ()))` we relate the inner fn ptrs: `fn((), (), u32)` with `fn((), (), ())` yielding a `TypeError::ArgumentSorts(_, 2)` which we then use as the `TypeError` for the `fn(fn(..))` which later causes the ICE as the `2` does not correspond to any input or output types in `fn(_)` r? `@estebank`
2021-11-06Auto merge of #90655 - the8472:drain-dot-dot, r=jyn514bors-1/+1
Replace some uses of vec.drain(..) with vec.into_iter() IntoIter should optimize better than Drain
2021-11-06Replace some uses of vec.drain(..) with vec.into_iter()The8472-1/+1
IntoIter should optimize better than Drain
2021-11-06use matches!() macro in more placesMatthias Krüger-5/+5
2021-11-06type error go brrrrrrrrEllen-2/+6