summary refs log tree commit diff
path: root/compiler/rustc_hir_analysis/src/astconv
AgeCommit message (Collapse)AuthorLines
2023-01-21Encode whether foreign opaques are TAITs or notMichael Goulet-1/+1
2022-12-05normalize inherent associated types after substitutionLeón Orell Valerian Liehr-0/+1
2022-12-05Auto merge of #104920 - compiler-errors:avoid-infcx-build, r=jackh726bors-4/+1
Avoid some `InferCtxt::build` calls Either because we're inside of an `InferCtxt` already, or because we're not in a place where we'd ever see inference vars. r? types
2022-12-04Avoid InferCtxt::build in generic_arg_mismatch_errMichael Goulet-4/+1
2022-12-03Properly substitute inherent associated types.Camille GILLOT-4/+9
2022-11-28Simplify more FnCtxt normalizationMichael Goulet-1/+1
2022-11-28FnCtxt normalization stuffMichael Goulet-0/+3
2022-11-27Rollup merge of #104976 - WaffleLapkin:move_comments, r=cjgillotMatthias Krüger-2/+2
Prefer doc comments over `//`-comments in compiler Doc comments are generally nicer: they show up in the documentation, they are shown in IDEs when you hover other mentions of items, etc. Thus it makes sense to use them instead of `//`-comments.
2022-11-27Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errorsbors-5/+6
Separate lifetime ident from lifetime resolution in HIR Drive-by: change how suggested generic args are computed. Fixes https://github.com/rust-lang/rust/issues/103815 I recommend reviewing commit-by-commit.
2022-11-27Prefer doc comments over `//`-comments in compilerMaybe Waffle-2/+2
2022-11-25Introduce PredicateKind::ClauseSantiago Pastorino-2/+2
2022-11-23Separate lifetime ident from resolution in HIR.Camille GILLOT-5/+6
2022-11-21Auto merge of #104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgrbors-1/+1
Rollup of 9 pull requests Successful merges: - #104420 (Fix doc example for `wrapping_abs`) - #104499 (rustdoc JSON: Use `Function` everywhere and remove `Method`) - #104500 (`rustc_ast`: remove `ref` patterns) - #104511 (Mark functions created for `raw-dylib` on x86 with DllImport storage class) - #104595 (Add `PolyExistentialPredicate` type alias) - #104605 (deduplicate constant evaluation in cranelift backend) - #104628 (Revert "Update CI to use Android NDK r25b") - #104662 (Streamline deriving on packed structs.) - #104667 (Revert formatting changes of a test) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-11-21Rollup merge of #104595 - compiler-errors:poly-existential-predicate, r=lcnrMatthias Krüger-1/+1
Add `PolyExistentialPredicate` type alias Wrapping `ExistentialPredicate`s in a binder is very common, and this alias already exists for the `PolyExistential{TraitRef,Projection}` types.
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-28/+5
Support using `Self` or projections inside an RPIT/async fn I reuse the same idea as https://github.com/rust-lang/rust/pull/103449 to use variances to encode whether a lifetime parameter is captured by impl-trait. The current implementation of async and RPIT replace all lifetimes from the parent generics by `'static`. This PR changes the scheme ```rust impl<'a> Foo<'a> { fn foo<'b, T>() -> impl Into<Self> + 'b { ... } } opaque Foo::<'_a>::foo::<'_b, T>::opaque<'b>: Into<Foo<'_a>> + 'b; impl<'a> Foo<'a> { // OLD fn foo<'b, T>() -> Foo::<'static>::foo::<'static, T>::opaque::<'b> { ... } ^^^^^^^ the `Self` becomes `Foo<'static>` // NEW fn foo<'b, T>() -> Foo::<'a>::foo::<'b, T>::opaque::<'b> { ... } ^^ the `Self` stays `Foo<'a>` } ``` There is the same issue with projections. In the example, substitute `Self` by `<T as Trait<'b>>::Assoc` in the sugared version, and `Foo<'_a>` by `<T as Trait<'_b>>::Assoc` in the desugared one. This allows to support `Self` in impl-trait, since we do not replace lifetimes by `'static` any more. The same trick allows to use projections like `T::Assoc` where `Self` is allowed. The feature is gated behind a `impl_trait_projections` feature gate. The implementation relies on 2 tweaking rules for opaques in 2 places: - we only relate substs that correspond to captured lifetimes during TypeRelation; - we only list captured lifetimes in choice region computation. For simplicity, I encoded the "capturedness" of lifetimes as a variance, `Bivariant` vs `Invariant` for unused vs captured lifetimes. The `variances_of` query used to ICE for opaques. Impl-trait that do not reference `Self` or projections will have their variances as: - `o` (invariant) for each parent type or const; - `*` (bivariant) for each parent lifetime --> will not participate in borrowck; - `o` (invariant) for each own lifetime. Impl-trait that does reference `Self` and/or projections will have some parent lifetimes marked as `o` (as the example above), and participate in type relation and borrowck. In the example above, `variances_of(opaque) = ['_a: o, '_b: *, T: o, 'b: o]`. r? types cc `@compiler-errors` , as you asked about the issue with `Self` and projections.
2022-11-19drive-by: PolyExistentialPredicateMichael Goulet-1/+1
2022-11-18require an `ErrorGuaranteed` to taint infcx with errorsBoxy-3/+7
2022-11-17Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-deadbors-9/+6
Record `LocalDefId` in HIR nodes instead of a side table This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR. This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed. This first part adds the information to HIR nodes themselves instead of a table. The second part is https://github.com/rust-lang/rust/pull/103902 The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter. The fourth part will be to completely remove the side table.
2022-11-14respect visibility & stability of inherent associated typesLeón Orell Valerian Liehr-37/+46
2022-11-13Store a LocalDefId in hir::AnonConst.Camille GILLOT-6/+4
2022-11-13Store a LocalDefId in hir::GenericParam.Camille GILLOT-3/+2
2022-11-12Inherit generics for impl-trait.Camille GILLOT-28/+5
2022-11-09Auto merge of #103171 - jackh726:gen-interior-hrtb-error, r=cjgillotbors-2/+2
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-08add 'ty_error_with_guaranteed' and 'const_error_with_guaranteed'yukang-11/+15
2022-11-07Add an optional Span to BrAnon and use it to print better error for HRTB ↵Jack Huey-2/+2
error from generator interior
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-04Remove an option and choose a behaviour-preserving default instead.Oli Scherer-10/+10
2022-11-04Rollup merge of #103915 - chenyukang:yukang/fix-103874, r=lcnrMatthias Krüger-1/+1
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-11/+5
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-03change error_reported to use Result instead of an optionyukang-1/+1
2022-11-02Simplify astconv item def id handlingOli Scherer-11/+5
2022-11-02return const_error when ty has errorsTakayuki Maeda-0/+3
2022-10-29Use LanguageItems::require lessCameron Steffen-4/+3
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-1/+1
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
2022-10-25Split diagnostic details out into a separate function and fluent filesOli Scherer-4/+1
2022-10-25Move a wf-check into the site where the value is instantiatedOli Scherer-18/+53
2022-10-21Auto merge of #103344 - Dylan-DPC:rollup-d1rpfvx, r=Dylan-DPCbors-11/+14
Rollup of 6 pull requests Successful merges: - #102287 (Elaborate supertrait bounds when triggering `unused_must_use` on `impl Trait`) - #102922 (Filtering spans when emitting json) - #103051 (translation: doc comments with derives, subdiagnostic-less enum variants, more derive use) - #103111 (Account for hygiene in typo suggestions, and use them to point to shadowed names) - #103260 (Fixup a few tests needing asm support) - #103321 (rustdoc: improve appearance of source page navigation bar) Failed merges: - #103209 (Diagnostic derives: allow specifying multiple alternative suggestions) r? `@ghost` `@rustbot` modify labels: rollup
2022-10-20rustc_hir_typeck: fix paths and partially mv fileslcnr-1/+1
2022-10-20Implement assertions and fixes to not emit empty spans without suggestionsKevin Per-11/+14
2022-10-07Change InferCtxtBuilder from enter to buildCameron Steffen-3/+3
2022-10-01Auto merge of #101986 - WaffleLapkin:move_lint_note_to_the_bottom, r=estebankbors-28/+32
Move lint level source explanation to the bottom So, uhhhhh r? `@estebank` ## User-facing change "note: `#[warn(...)]` on by default" and such are moved to the bottom of the diagnostic: ```diff - = note: `#[warn(unsupported_calling_conventions)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #87678 <https://github.com/rust-lang/rust/issues/87678> + = note: `#[warn(unsupported_calling_conventions)]` on by default ``` Why warning is enabled is the least important thing, so it shouldn't be the first note the user reads, IMO. ## Developer-facing change `struct_span_lint` and similar methods have a different signature. Before: `..., impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>)` After: `..., impl Into<DiagnosticMessage>, impl for<'a, 'b> FnOnce(&'b mut DiagnosticBuilder<'a, ()>) -> &'b mut DiagnosticBuilder<'a, ()>` The reason for this is that `struct_span_lint` needs to edit the diagnostic _after_ `decorate` closure is called. This also makes lint code a little bit nicer in my opinion. Another option is to use `impl for<'a> FnOnce(LintDiagnosticBuilder<'a, ()>) -> DiagnosticBuilder<'a, ()>` altough I don't _really_ see reasons to do `let lint = lint.build(message)` everywhere. ## Subtle problem By moving the message outside of the closure (that may not be called if the lint is disabled) `format!(...)` is executed earlier, possibly formatting `Ty` which may call a query that trims paths that crashes the compiler if there were no warnings... I don't think it's that big of a deal, considering that we move from `format!(...)` to `fluent` (which is lazy by-default) anyway, however this required adding a workaround which is unfortunate. ## P.S. I'm sorry, I do not how to make this PR smaller/easier to review. Changes to the lint API affect SO MUCH 😢
2022-10-01Refactor rustc lint APIMaybe Waffle-28/+32
2022-09-30Rollup merge of #102492 - compiler-errors:simplify-deny-assoc-bindings, ↵Matthias Krüger-11/+7
r=cjgillot Don't lower assoc bindings just to deny them Some clean-up: https://github.com/rust-lang/rust/pull/102338#discussion_r981590931
2022-09-29Don't lower assoc bindings just to deny themMichael Goulet-11/+7
2022-09-29Shrink `hir::def::Res`.Nicholas Nethercote-5/+4
`Res::SelfTy` currently has two `Option`s. When the second one is `Some` the first one is never consulted. So we can split it into two variants, `Res::SelfTyParam` and `Res::SelfTyAlias`, reducing the size of `Res` from 24 bytes to 12. This then shrinks `hir::Path` and `hir::PathSegment`, which are the HIR types that take up the most space.
2022-09-27Deny associated type bindings within associated type bindingsMichael Goulet-3/+9
2022-09-27rustc_typeck to rustc_hir_analysislcnr-0/+4169