about summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis
AgeCommit message (Collapse)AuthorLines
2022-11-12Verify predicates on RPIT and async opaques.Camille GILLOT-20/+0
2022-11-12Make impl_trait_projections a feature gate.Camille GILLOT-8/+11
2022-11-12Inherit generics for impl-trait.Camille GILLOT-42/+84
2022-11-12Compute variance for opaques too.Camille GILLOT-2/+92
2022-11-12Auto merge of #104310 - Dylan-DPC:rollup-wgt1z4a, r=Dylan-DPCbors-105/+142
Rollup of 7 pull requests Successful merges: - #102049 (Add the `#[derive_const]` attribute) - #103970 (Unhide unknown spans) - #104206 (Remove `save_and_restore_in_snapshot_flag`, use `ObligationCtxt` more) - #104214 (Emit error in `collecting_trait_impl_trait_tys` on mismatched signatures) - #104267 (rustdoc: use checkbox instead of switch for settings toggles) - #104302 (Update cargo) - #104303 (UI tests can be assigned to T-compiler) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-12Rollup merge of #104214 - Nilstrieb:returns_impl_Ice, r=compiler-errorsDylan DPC-105/+142
Emit error in `collecting_trait_impl_trait_tys` on mismatched signatures Previously, a `delay_span_bug` was isssued, failing normalization. This create a `TyKind::Error` in the signature, which caused `compare_predicate_entailment` to swallow its signature mismatch error, causing ICEs because no error was emitted. fixes #104183 r? ``@compiler-errors``
2022-11-12Auto merge of #103530 - cjgillot:hir-lifetimes-direct, r=estebankbors-238/+124
Resolve lifetimes independently for each item-like. Now that the heavy-lifting is done on the AST and during lowering, we do not need to perform HIR lifetime resolution on a full item at once. Instead, we can treat each item-like independently, and look at `generics_of` the parent exceptionally for associated items.
2022-11-11Clean-up formatting.Camille GILLOT-5/+4
2022-11-11Visit opaque types during type collection too.Camille GILLOT-21/+20
2022-11-11Resolve lifetimes using the regular logic for RPIT.Camille GILLOT-37/+36
2022-11-11Resolve lifetimes independently for each item-like.Camille GILLOT-177/+66
2022-11-11Tweak signatures in rustc_middle::hir::map.Camille GILLOT-1/+1
2022-11-10Apply PR feedback.Ben Reeves-10/+9
2022-11-10Require `~const` qualifier on trait bounds in specializing impls if present ↵Ben Reeves-16/+43
in base impl.
2022-11-10Disallow specializing on const impls with non-const impls.Ben Reeves-4/+31
2022-11-10Allow specialized const trait impls.Ben Reeves-21/+44
Fixes #95186. Fixes #95187.
2022-11-09Rollup merge of #104156 - oli-obk:autoderef, r=estebankManish Goregaokar-2/+1
Cleanups in autoderef impl Just something I noticed. Turns out the `overloaded_span` is not actually used separately from the main span, so I merged them.
2022-11-09Emit error in `collecting_trait_impl_trait_tys` on mismatched signaturesNilstrieb-105/+142
Previously, a `delay_span_bug` was isssued, failing normalization. This create a `TyKind::Error` in the signature, which caused `compare_predicate_entailment` to swallow its signature mismatch error, causing ICEs because no error was emitted.
2022-11-09Auto merge of #103723 - CastilloDel:master, r=jackh726bors-11/+11
Remove allow(rustc::potential_query_instability) in rustc_trait_selection Related to https://github.com/rust-lang/rust/issues/84447 This PR needs to be benchmarked to check for regressions.
2022-11-09Auto merge of #104179 - Manishearth:rollup-yvsx5hh, r=Manishearthbors-5/+99
Rollup of 7 pull requests Successful merges: - #100508 (avoid making substs of type aliases late bound when used as fn args) - #101381 (Test that target feature mix up with homogeneous floats is sound) - #103353 (Fix Access Violation when using lld & ThinLTO on windows-msvc) - #103521 (Avoid possible infinite loop when next_point reaching the end of file) - #103559 (first move on a nested span_label) - #103778 (Update several crates for improved support of the new targets) - #103827 (Properly remap and check for substs compatibility in `confirm_impl_trait_in_trait_candidate`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-08Rollup merge of #100508 - BoxyUwU:make_less_things_late_bound, r=nikomatsakisManish Goregaokar-5/+99
avoid making substs of type aliases late bound when used as fn args fixes #47511 fixes #85533 (although I did not know theses issues existed when i was working on this :upside_down_face:) currently `Alias<...>` is treated the same as `Struct<...>` when deciding if generics should be late bound or early bound but this is not correct as `Alias` might normalize to a projection which does not constrain the generics. I think this needs more tests before merging more explanation of PR [here](https://hackmd.io/v44a-QVjTIqqhK9uretyQg?view) Hackmd inline for future readers: --- This assumes reader is familiar with the concept of early/late bound lifetimes. There's a section on rustc-dev-guide if not (although i think some details are a bit out of date) ## problem & background Not all lifetimes on a fn can be late bound: ```rust fn foo<'a>() -> &'a (); impl<'a> Fn<()> for FooFnDef { type Output = &'a (); // uh oh unconstrained lifetime } ``` so we make make them early bound ```rust fn foo<'a>() -> &'a (); impl<'a> Fn<()> for FooFnDef<'a> {// wow look at all that lifetimey type Output = &'a (); } ``` (Closures have the same constraint however it is not enforced leading to soundness bugs, [#84385](https://github.com/rust-lang/rust/pull/84385) implements this "downgrading late bound to early bound" for closures) lifetimes on fn items are only late bound when they are "constrained" by the fn args: ```rust fn foo<'a>(_: &'a ()) -> &'a (); // late bound, not present on `FooFnItem` // vv impl<'a> Trait<(&'a (),)> for FooFnItem { type Output = &'a (); } // projections do not constrain inputs fn bar<'a, T: Trait>(_: <T as Trait<'a>>::Assoc) -> &'a (); // early bound // vv impl<'a, T: Trait> Fn<(<T as Trait<'a>>::Assoc,)> for BarFnItem<'a, T> { type Output = &'a (); } ``` current logic for determining if inputs "constrain" a lifetime works off of HIR so does not normalize aliases. It also assumes that any path with no self type constrains all its substs (i.e. `Foo<'a, u32>` has no self type but `T::Assoc` does). This falls apart for top level type aliases (see linked issues): ```rust type Alias<'a, T> = <T as Trait<'a>>::Assoc; // wow look its a path with no self type uwu // i bet that constrains `'a` so it should be latebound // vvvvvvvvvvv fn foo<'a, T: Trait>(_: Alias<'a, T>) -> &'a (); // `Alias` normalized to make things clearer // vvvvvvvvvvvvvvvvvvvvvvv impl<'a, T: Trait> Fn<(<T as Trait<'a>>::Assoc,)> for FooFnDef<T> { type Output = &'a (); // oh no `'a` isnt constrained wah wah waaaah *trumbone noises* // i think, idk what musical instrument that is } ``` ## solution The PR solves this by having the hir visitor that checks for lifetimes in constraining uses check if the path is a `DefKind::Alias`. If it is we ""normalize"" it by calling `type_of` and walking the returned type. This is a bit hacky as it requires a mapping between the substs on the path in hir, and the generics of the `type Alias<...>` which is on the ty layer. Alternative solutions may involve calculating the "late boundness" of lifetimes after/during astconv rather than relying on hir at all. We already have code to determine whether a lifetime SHOULD be late bound or not as this is currently how the error for `fn foo<'a, T: Trait>(_: Alias<'a, T>) -> &'a ();` gets emitted. It is probably not possible to do this right now, late boundness is used by `generics_of` and `gather_explicit_predicates_of` as we currently do not put late bound lifetimes in `Generics`. Although this seems sus to me as the long term goal is to make all generics late bound which would result in `generics_of(function)` being empty? [#103448](https://github.com/rust-lang/rust/pull/103448) places all lifetimes in `Generics` regardless of late boundness so that may be a good step towards making this possible.
2022-11-09Auto merge of #103171 - jackh726:gen-interior-hrtb-error, r=cjgillotbors-8/+13
Better error for HRTB error from generator interior cc #100013 This is just a first pass at an error. It could be better, and shouldn't really be emitted in the first place. But this is better than what was being emitted before.
2022-11-08commentBoxy-11/+23
2022-11-08Reduce the scope of allow(rustc::potential_query_instability) in ↵CastilloDel-11/+11
rustc_trait_selection Make InferCtxtExt use a FxIndexMap This should be faster, because the map is only being used to iterate, which is supposed to be faster with the IndexMap Make the user_computed_preds use an IndexMap It is being used mostly for iteration, so the change shouldn't result in a perf hit Make the RegionDeps fields use an IndexMap This change could be a perf hit. Both `larger` and `smaller` are used for iteration, but they are also used for insertions. Make types_without_default_bounds use an IndexMap It uses extend, but it also iterates and removes items. Not sure if this will be a perf hit. Make InferTtxt.reported_trait_errors use an IndexMap This change brought a lot of other changes. The map seems to have been mostly used for iteration, so the performance shouldn't suffer. Add FIXME to change ProvisionalEvaluationCache.map to use an IndexMap Right now this results in a perf hit. IndexMap doesn't have the `drain_filter` API, so in `on_completion` we now need to iterate two times over the map.
2022-11-08Remove overloaded_span argument from `new`, where it is usually redundant ↵Oli Scherer-2/+1
with the main span
2022-11-08Rollup merge of #104094 - lcnr:on_unimplemented-move, r=wesleywiserDylan DPC-1/+2
fully move `on_unimplemented` to `error_reporting` the `traits` module has a few too many submodules in my opinion.
2022-11-08Rollup merge of #103865 - compiler-errors:fallback-has-occurred-tracking, ↵Dylan DPC-12/+12
r=eholk Move `fallback_has_occurred` state tracking to `FnCtxt` Removes a ton of callsites that defaulted to `false`
2022-11-08add 'ty_error_with_guaranteed' and 'const_error_with_guaranteed'yukang-17/+20
2022-11-07Add an optional Span to BrAnon and use it to print better error for HRTB ↵Jack Huey-8/+13
error from generator interior
2022-11-07fully move `on_unimplemented` to error reportinglcnr-1/+2
2022-11-06Auto merge of #99943 - compiler-errors:tuple-trait, r=jackh726bors-0/+28
Implement `std::marker::Tuple`, use it in `extern "rust-call"` and `Fn`-family traits Implements rust-lang/compiler-team#537 I made a few opinionated decisions in this implementation, specifically: 1. Enforcing `extern "rust-call"` on fn items during wfcheck, 2. Enforcing this for all functions (not just ones that have bodies), 3. Gating this `Tuple` marker trait behind its own feature, instead of grouping it into (e.g.) `unboxed_closures`. Still needing to be done: 1. Enforce that `extern "rust-call"` `fn`-ptrs are well-formed only if they have 1/2 args and the second one implements `Tuple`. (Doing this would fix ICE in #66696.) 2. Deny all explicit/user `impl`s of the `Tuple` trait, kinda like `Sized`. 3. Fixing `Tuple` trait built-in impl for chalk, so that chalkification tests are un-broken. Open questions: 1. Does this need t-lang or t-libs signoff? Fixes #99820
2022-11-06fixyfixfixBoxy-5/+87
2022-11-06interpret: support for per-byte provenanceRalf Jung-1/+1
2022-11-06Move fallback_has_occurred to FnCtxtMichael Goulet-12/+12
2022-11-05Adjust diagnostics, bless testsMichael Goulet-2/+8
2022-11-05Enforce rust-check ABI in signatures, callsMichael Goulet-0/+22
2022-11-05Rollup merge of #103972 - oli-obk:unoptional, r=fee1-deadMatthias Krüger-10/+10
Remove an option and choose a behaviour-preserving default instead. r? ``@fee1-dead``
2022-11-05Rollup merge of #103621 - fee1-dead-contrib:iat-fix-use, r=cjgillotDylan DPC-0/+14
Correctly resolve Inherent Associated Types I don't know if this is the best way to do this, but at least it is one way.
2022-11-04Refactor tcx mk_const parameters.Mateusz-7/+4
2022-11-04Remove an option and choose a behaviour-preserving default instead.Oli Scherer-10/+10
2022-11-04Rollup merge of #103780 - compiler-errors:bound-closure-lifetimes, r=jackh726Matthias Krüger-3/+4
Fix late-bound lifetime closure ICEs in HIR typeck and MIR borrowck During HIR typeck, we need to teach astconv to treat late-bound regions within a closure body as free, fixing escaping bound vars ICEs in both of the issues below. However, this then gets us to MIR borrowck, which itself needs to be taught how to instantiate free region vids for late-bound regions that come from items that _aren't_ the typeck root (for now, just closures). Fixes #103771 Fixes #103736
2022-11-04Rollup merge of #103915 - chenyukang:yukang/fix-103874, r=lcnrMatthias Krüger-4/+2
Improve use of ErrorGuaranteed and code cleanup Part of #103874
2022-11-03Correctly resolve Inherent Associated TypesDeadbeef-0/+14
2022-11-02Rollup merge of #103875 - oli-obk:ast_conv_simplification, r=spastorinoMatthias Krüger-13/+7
Simplify astconv item def id handling
2022-11-02Rollup merge of #103870 - TaKO8Ki:fix-103790, r=fee1-deadMatthias Krüger-0/+3
Fix `inferred_kind` ICE Fixes #103790
2022-11-02Rollup merge of #99801 - ↵Matthias Krüger-2/+29
Neo-Zhixing:fix/generic_const_exprs_parent_opaque_predicates, r=oli-obk fix(generic_const_exprs): Fix predicate inheritance for children of opaque types Fixes #99705 We currently have a special case to perform predicate inheritance when the const item is in the generics. I think we're also going to need this for opaque return types. When evaluating the predicates applied to the associated item, it'll inherit from its parent, the opaque type, which will never have predicates applied. This PR bypass the opaque typed parent and inherit predicates directly from the function itself.
2022-11-03change error_reported to use Result instead of an optionyukang-4/+2
2022-11-02Simplify astconv item def id handlingOli Scherer-13/+7
2022-11-02return const_error when ty has errorsTakayuki Maeda-0/+3
2022-11-01Rollup merge of #103575 - Xiretza:suggestions-style-attr, r=davidtwcoManish Goregaokar-2/+6
Change #[suggestion_*] attributes to use style="..." As discussed [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20tool_only_span_suggestion), this changes `#[(multipart_)suggestion_{short,verbose,hidden}(...)]` attributes to plain `#[(multipart_)suggestion(...)]` attributes with a `style = "{short,verbose,hidden}"` parameter. It also adds a new style, `tool-only`, that corresponds to `tool_only_span_suggestion`/`tool_only_multipart_suggestion` and causes the suggestion to not be shown in human-readable output at all. Best reviewed commit-by-commit, there's a bit of noise in there. cc #100717 `@compiler-errors` r? `@davidtwco`