about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-01-23Evaluate `output_filenames` before one of its dependencies gets stolenOli Scherer-0/+1
2023-01-17Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726Matthias Krüger-4/+4
Remove double spaces after dots in comments Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17Remove double spaces after dots in commentsMaybe Waffle-4/+4
2023-01-12Remove `untracked_crate` field and instead pass it along with the resolver.Oli Scherer-2/+1
2023-01-12Expand format_args!() in rust_ast_lowering.Mara Bos-0/+1
2023-01-05Fix `uninlined_format_args` for some compiler cratesnils-4/+4
Convert all the crates that have had their diagnostic migration completed (except save_analysis because that will be deleted soon and apfloat because of the licensing problem).
2023-01-02Auto merge of #84762 - cjgillot:resolve-span-opt, r=petrochenkovbors-1/+1
Encode spans relative to the enclosing item -- enable on nightly Follow-up to #84373 with the flag `-Zincremental-relative-spans` set by default. This PR seeks to remove one of the main shortcomings of incremental: the handling of spans. Changing the contents of a function may require redoing part of the compilation process for another function in another file because of span information is changed. Within one file: all the spans in HIR change, so typechecking had to be re-done. Between files: spans of associated types/consts/functions change, so type-based resolution needs to be re-done (hygiene information is stored in the span). The flag `-Zincremental-relative-spans` encodes local spans relative to the span of an item, stored inside the `source_span` query. Trap: stashed diagnostics are referenced by the "raw" span, so stealing them requires to remove the span's parent. In order to avoid too much traffic in the span interner, span encoding uses the `ctxt_or_tag` field to encode: - the parent when the `SyntaxContext` is 0; - the `SyntaxContext` when the parent is `None`. Even with this, the PR creates a lot of traffic to the Span interner, when a Span has both a LocalDefId parent and a non-root SyntaxContext. They appear in lowering, when we add a parent to all spans, including those which come from macros, and during inlining when we mark inlined spans. The last commit changes how queries of `LocalDefId` manage their cache. I can put this in a separate PR if required. Possible future directions: - validate that all spans are marked in HIR validation; - mark macro-expanded spans relative to the def-site and not the use-site.
2022-12-29Rollup merge of #106221 - Nilstrieb:rptr-more-like-ref-actually, ↵Matthias Krüger-3/+3
r=compiler-errors Rename `Rptr` to `Ref` in AST and HIR The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-28Rename `Rptr` to `Ref` in AST and HIRNilstrieb-3/+3
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-27Rollup merge of #106064 - lukas-code:outlives-macro, r=cjgillotMichael Goulet-2/+5
Partially fix `explicit_outlives_requirements` lint in macros Show the suggestion if and only if the bounds are from the same source context. fixes https://github.com/rust-lang/rust/issues/106044 fixes https://github.com/rust-lang/rust/issues/106063
2022-12-26address review comments + better testsLukas Markeffsky-2/+5
2022-12-25Rollup merge of #106137 - matthiaskrgr:clippy_style, r=jyn514Matthias Krüger-2/+2
fix more clippy::style findings match_result_ok obfuscated_if_else single_char_add writeln_empty_string collapsible_match iter_cloned_collect unnecessary_mut_passed r? `@compiler-errors`
2022-12-25Rollup merge of #105375 - WaffleLapkin:docfix, r=cjgillotMatthias Krüger-4/+2
Fix an outdated comment mentioning parameter that doesn't exist anymore I'm not too familiar with the code in question, but from what I see I think the new comment makes sense. r? `@cjgillot` (you touched these arguments lately https://github.com/rust-lang/rust/pull/91557/files#diff-ad0c15bbde97a607d4758ec7eaf88248be5d6b8ae084dfc84127f81e3f7a9bb4L1702, https://github.com/rust-lang/rust/pull/104048/files#diff-ad0c15bbde97a607d4758ec7eaf88248be5d6b8ae084dfc84127f81e3f7a9bb4L1682)
2022-12-25Only enable relative span hashing on nightly.Camille GILLOT-1/+1
2022-12-25Enable relative span hashing.Camille GILLOT-1/+1
2022-12-25fix more clippy::style findingsMatthias Krüger-2/+2
match_result_ok obfuscated_if_else single_char_add writeln_empty_string collapsible_match iter_cloned_collect unnecessary_mut_passed
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-1/+1
2022-12-19Rollup merge of #105864 - matthiaskrgr:compl, r=NilstriebDylan DPC-1/+1
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-19clippy::complexity fixesMatthias Krüger-1/+1
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-18Revert "Introduce lowering_arena to avoid creating AST nodes on the fly"Nilstrieb-35/+20
This reverts commit d9a1faaa9cff6eab069ea8e5cd7862d0ae48e231. This was originally part of a larger PR that has now been closed as a different approach is taken now.
2022-12-12Auto merge of #105160 - nnethercote:rm-Lit-token_lit, r=petrochenkovbors-1/+2
Remove `token::Lit` from `ast::MetaItemLit`. Currently `ast::MetaItemLit` represents the literal kind twice. This PR removes that redundancy. Best reviewed one commit at a time. r? `@petrochenkov`
2022-12-10compiler: remove unnecessary imports and qualified pathsKaDiWa-2/+2
2022-12-08Rollup merge of #105408 - cuviper:help-rpitirpit, r=compiler-errorsMatthias Krüger-11/+21
Add help for `#![feature(impl_trait_in_fn_trait_return)]` This adds a new variant `ImplTraitContext::FeatureGated`, so we can generalize the help for `return_position_impl_trait_in_trait` to also work for `impl_trait_in_fn_trait_return`. cc #99697
2022-12-06Add help for `#![feature(impl_trait_in_fn_trait_return)]`Josh Stone-11/+21
This adds a new variant `ImplTraitContext::FeatureGated`, so we can generalize the help for `return_position_impl_trait_in_trait` to also work for `impl_trait_in_fn_trait_return`.
2022-12-06Fix an outdated comment mentioning parameter that doesn't exist anymoreMaybe Waffle-4/+2
2022-12-06Simplify attribute handling in rustc_ast_loweringGary Guo-1/+1
Given that attributes is stored in a separate BTreeMap, it's not necessary to pass it in when constructing `hir::Expr`. We can just construct `hir::Expr` and then call `self.lower_attrs` later if it needs attributes. As most desugaring code don't use attributes, this allows some code cleanup.
2022-12-02Remove `token::Lit` from `ast::MetaItemLit`.Nicholas Nethercote-1/+2
`token::Lit` contains a `kind` field that indicates what kind of literal it is. `ast::MetaItemLit` currently wraps a `token::Lit` but also has its own `kind` field. This means that `ast::MetaItemLit` encodes the literal kind in two different ways. This commit changes `ast::MetaItemLit` so it no longer wraps `token::Lit`. It now contains the `symbol` and `suffix` fields from `token::Lit`, but not the `kind` field, eliminating the redundancy.
2022-12-01Fill in `def_span` when creating def ids.Oli Scherer-4/+12
This makes sure that ICEing because of def ids created outside of ast lowering will be able to produce a query backtrace and not cause a double panic because of trying to call the `def_span` query
2022-11-29Make TyCtxtFeed::def_id private.Camille GILLOT-1/+1
2022-11-29Only allow feeding a value to newly created definitions.Camille GILLOT-1/+1
2022-11-28Rename `ast::Lit` as `ast::MetaItemLit`.Nicholas Nethercote-3/+3
2022-11-28Factor out a repeated expression in `lower_attr_args`.Nicholas Nethercote-9/+4
2022-11-27Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errorsbors-66/+51
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-24nested-match mutability (proposed by the reviewer)Maybe Waffle-6/+4
2022-11-24Use kw::Empty for elided lifetimes in path.Camille GILLOT-1/+0
2022-11-24Record in HIR whether lifetime elision was succesful.Camille GILLOT-29/+34
2022-11-23Add `Mutability::{is_mut,is_not}`Maybe Waffle-3/+1
2022-11-23Separate lifetime ident from resolution in HIR.Camille GILLOT-36/+17
2022-11-23Rollup merge of #104721 - WaffleLapkin:deref-harder, r=oli-obkDylan DPC-60/+58
Remove more `ref` patterns from the compiler r? `@oli-obk` Previous PR: https://github.com/rust-lang/rust/pull/104500
2022-11-22`rustc_ast_lowering`: remove `ref` patternsMaybe Waffle-60/+58
2022-11-22Rollup merge of #104615 - spastorino:create-async-def-id-in-lowering, ↵Dylan DPC-1/+3
r=compiler-errors Create def_id for async fns during lowering r? `@compiler-errors`
2022-11-22Split `MacArgs` in two.Nicholas Nethercote-25/+11
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
2022-11-21Auto merge of #103491 - cjgillot:self-rpit, r=oli-obkbors-12/+6
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-19Create def_id for async fns during loweringSantiago Pastorino-1/+3
2022-11-18Auto merge of #101562 - nnethercote:shrink-ast-Expr-harder, r=petrochenkovbors-1/+1
Shrink `ast::Expr` harder r? `@ghost`
2022-11-18Auto merge of #104330 - CastilloDel:ast_lowering, r=cjgillotbors-6/+4
Remove allow(rustc::potential_query_instability) from rustc_ast_lowering Related to https://github.com/rust-lang/rust/issues/84447. `@cjgillot` Thanks for helping me!
2022-11-17Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-deadbors-1/+9
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-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-1/+1
patterns.
2022-11-16Use `token::Lit` in `ast::ExprKind::Lit`.Nicholas Nethercote-2/+9
Instead of `ast::Lit`. Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing. This commit changes the language very slightly. Some programs that used to not compile now will compile. This is because some invalid literals that are removed by `cfg` or attribute macros will no longer trigger errors. See this comment for more details: https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773
2022-11-15Change LoweringContext.children to VecCastilloDel-5/+4