about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2024-10-07Add sugar for &pin (const|mut) typesEric Holk-8/+43
2024-10-04rm `ItemKind::OpaqueTy`Noah Lev-18/+9
This introduce an additional collection of opaques on HIR, as they can no longer be listed using the free item list.
2024-10-02Move in_trait into OpaqueTyOriginMichael Goulet-43/+37
2024-10-02Use named fields for OpaqueTyOriginMichael Goulet-5/+7
2024-10-02Remove redundant in_trait from hir::TyKind::OpaqueDefMichael Goulet-1/+0
2024-10-01Remove anon struct and union typesMichael Goulet-40/+0
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-4/+4
2024-09-22Auto merge of #130337 - BoxyUwU:anon_const_macro_call, r=camelidbors-1/+1
Fix anon const def-creation when macros are involved take 2 Fixes #130321 There were two cases that #129137 did not handle correctly: - Given a const argument `Foo<{ bar!() }>` in which `bar!()` expands to `N`, we would visit the anon const and then visit the `{ bar() }` expression instead of visiting the macro call. This meant that we would build a def for the anon const as `{ bar!() }` is not a trivial const argument as `bar!()` is not a path. - Given a const argument `Foo<{ bar!() }>` is which `bar!()` expands to `{ qux!() }` in which `qux!()` expands to `N`, it should not be considered a trivial const argument as `{{ N }}` has two pairs of braces. If we only looked at `qux`'s expansion it would *look* like a trivial const argument even though it is not. We have to track whether we have "unwrapped" a brace already when recursing into the expansions of `bar`/`qux`/any macro r? `@camelid`
2024-09-21Handle macro calls in anon const def creation take 2Boxy-1/+1
2024-09-20Add missing diagnostics and flesh out testsMichael Goulet-0/+5
2024-09-20Implement RTN in resolve_bound_vars and HIR ty loweringMichael Goulet-2/+2
2024-09-20Conditionally allow lowering RTN (..) in pathsMichael Goulet-1/+21
2024-09-12Re-enable `ConstArgKind::Path` lowering by defaultNoah Lev-4/+3
...and remove the `const_arg_path` feature gate as a result. It was only a stopgap measure to fix the regression that the new lowering introduced (which should now be fixed by this PR).
2024-09-01Rollup merge of #129493 - cjgillot:early-opaque-def, r=petrochenkovMatthias Krüger-26/+4
Create opaque definitions in resolver. Implementing https://github.com/rust-lang/rust/issues/129023#issuecomment-2306079532 That was easier than I expected. r? `@petrochenkov`
2024-08-31Create opaque definitions in resolver.Camille GILLOT-26/+4
2024-08-31Implement `elided_named_lifetimes` lintPavel Grigorenko-3/+3
2024-08-27Rollup merge of #129626 - compiler-errors:explicit-named, r=fmeaseMatthias Krüger-2/+0
Remove `ParamMode::ExplicitNamed` This was introduced as a hack to improve a diagnostics suggestion in #61679. It was subsequently broken, but also it was an incomplete hack that I don't believe we need to support, so let's just remove it.
2024-08-27Rollup merge of #129625 - compiler-errors:generic-args-mode, r=fmeaseMatthias Krüger-1/+1
Rename `ParenthesizedGenericArgs` to `GenericArgsMode` A bit easier to digest name. Broken out of a PR implementing return type notation.
2024-08-27Rollup merge of #126013 - nnethercote:unreachable_pub, r=UrgauMatthias Krüger-0/+1
Add `#[warn(unreachable_pub)]` to a bunch of compiler crates By default `unreachable_pub` identifies things that need not be `pub` and tells you to make them `pub(crate)`. But sometimes those things don't need any kind of visibility. So they way I did these was to remove the visibility entirely for each thing the lint identifies, and then add `pub(crate)` back in everywhere the compiler said it was necessary. (Or occasionally `pub(super)` when context suggested that was appropriate.) Tedious, but results in more `pub` removal. There are plenty more crates to do but this seems like enough for a first PR. r? `@compiler-errors`
2024-08-26Rename ParenthesizedGenericArgs to GenericArgsModeMichael Goulet-1/+1
2024-08-26Remove ParamMode::ExplicitNamedMichael Goulet-2/+0
2024-08-19Retroactively feature gate `ConstArgKind::Path`Boxy-3/+4
2024-08-16Add `warn(unreachable_pub)` to `rustc_ast_lowering`.Nicholas Nethercote-0/+1
2024-08-10rustc_ast_lowering: make "using `_` for array lengths is unstable" translatablePavel Grigorenko-2/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+6
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-26Rollup merge of #128226 - oli-obk:option_vs_empty_slice, r=petrochenkovTrevor Gross-3/+3
Remove redundant option that was just encoding that a slice was empty There is already a sanity check ensuring we don't put empty attribute lists into the HIR: https://github.com/rust-lang/rust/blob/6ef11b81c2c02c3c4b7556d1991a98572fe9af87/compiler/rustc_ast_lowering/src/lib.rs#L661-L667
2024-07-26Remove redundant option that was just encoding that a slice was emptyOli Scherer-3/+3
2024-07-25Support ?Trait bounds in supertraits and dyn Trait under a feature gateBryanskiy-15/+13
2024-07-16Add `ConstArgKind::Path` and make `ConstArg` its own HIR nodeNoah Lev-33/+117
This is a very large commit since a lot needs to be changed in order to make the tests pass. The salient changes are: - `ConstArgKind` gets a new `Path` variant, and all const params are now represented using it. Non-param paths still use `ConstArgKind::Anon` to prevent this change from getting too large, but they will soon use the `Path` variant too. - `ConstArg` gets a distinct `hir_id` field and its own variant in `hir::Node`. This affected many parts of the compiler that expected the parent of an `AnonConst` to be the containing context (e.g., an array repeat expression). They have been changed to check the "grandparent" where necessary. - Some `ast::AnonConst`s now have their `DefId`s created in rustc_ast_lowering rather than `DefCollector`. This is because in some cases they will end up becoming a `ConstArgKind::Path` instead, which has no `DefId`. We have to solve this in a hacky way where we guess whether the `AnonConst` could end up as a path const since we can't know for sure until after name resolution (`N` could refer to a free const or a nullary struct). If it has no chance as being a const param, then we create a `DefId` in `DefCollector` -- otherwise we decide during ast_lowering. This will have to be updated once all path consts use `ConstArgKind::Path`. - We explicitly use `ConstArgHasType` for array lengths, rather than implicitly relying on anon const type feeding -- this is due to the addition of `ConstArgKind::Path`. - Some tests have their outputs changed, but the changes are for the most part minor (including removing duplicate or almost-duplicate errors). One test now ICEs, but it is for an incomplete, unstable feature and is now tracked at #127009.
2024-07-16Use `ConstArg` for const param defaultsNoah Lev-1/+1
Now everything that actually affects the type system (i.e., excluding const blocks, enum variant discriminants, etc.) *should* be using `ConstArg`.
2024-07-16Use `ConstArg` for array lengthsNoah Lev-2/+2
2024-07-16Use `ConstArg` for assoc item constraintsNoah Lev-1/+1
2024-07-16Setup ast_lowering functions for `ConstArg`Noah Lev-50/+64
2024-07-16hir: Create `hir::ConstArgKind` enumNoah Lev-3/+3
This will allow lowering const params to a dedicated enum variant, rather than to an `AnonConst` that is later examined during `ty` lowering.
2024-07-16Add `current_def_id_parent` to `LoweringContext`Noah Lev-6/+26
This is needed to track anon const parents properly once we implement `ConstArgKind::Path` (which requires moving anon const def-creation outside of `DefCollector`): Why do we need this in addition to [`Self::current_hir_id_owner`]? Currently (as of June 2024), anonymous constants are not HIR owners; however, they do get their own DefIds. Some of these DefIds have to be created during AST lowering, rather than def collection, because we can't tell until after name resolution whether an anonymous constant will end up instead being a [`rustc_hir::ConstArgKind::Path`]. However, to compute which generics are available to an anonymous constant nested inside another, we need to make sure that the parent is recorded as the parent anon const, not the enclosing item. So we need to track parent defs differently from HIR owners, since they will be finer-grained in the case of anon consts.
2024-07-03Rollup merge of #127092 - compiler-errors:rtn-dots-redux, r=estebankMatthias Krüger-15/+10
Change return-type-notation to use `(..)` Aligns the syntax with the current wording of [RFC 3654](https://github.com/rust-lang/rfcs/pull/3654). Also implements rustfmt support (along with making a match exhaustive). Tracking: * https://github.com/rust-lang/rust/issues/109417
2024-06-28Change RTN to use .. againMichael Goulet-15/+10
2024-06-28implement new effects desugaringDeadbeef-76/+15
2024-06-24Deny use<> for RPITITsMichael Goulet-0/+20
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-2/+2
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-17Delay a bug and mark precise_capturing as not incompleteMichael Goulet-1/+5
2024-06-17Detect duplicatesMichael Goulet-4/+7
2024-06-17Rework precise capturing syntaxMichael Goulet-68/+64
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-1/+3
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-06-07Rollup merge of #124214 - carbotaniuman:parse_unsafe_attrs, r=michaelwoeristerMatthias Krüger-0/+1
Parse unsafe attributes Initial parse implementation for #123757 This is the initial work to parse unsafe attributes, which is represented as an extra `unsafety` field in `MetaItem` and `AttrItem`. There's two areas in the code where it appears that parsing is done manually and not using the parser stuff, and I'm not sure how I'm supposed to thread the change there.
2024-06-07Revert "Cache whether a body has inline consts"Oli Scherer-7/+1
This reverts commit eae5031ecbda434e92966099e0dc93917de03eff.
2024-06-06Parse unsafe attributescarbotaniuman-0/+1
2024-06-04Handle safety keyword for extern block inner itemsSantiago Pastorino-1/+1
2024-05-31Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, ↵Matthias Krüger-30/+21
r=compiler-errors Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanup Rename `hir::TypeBinding` and `ast::AssocConstraint` to `AssocItemConstraint` and update all items and locals using the old terminology. Motivation: The terminology *type binding* is extremely outdated. "Type bindings" not only include constraints on associated *types* but also on associated *constants* (feature `associated_const_equality`) and on RPITITs of associated *functions* (feature `return_type_notation`). Hence the word *item* in the new name. Furthermore, the word *binding* commonly refers to a mapping from a binder/identifier to a "value" for some definition of "value". Its use in "type binding" made sense when equality constraints (e.g., `AssocTy = Ty`) were the only kind of associated item constraint. Nowadays however, we also have *associated type bounds* (e.g., `AssocTy: Bound`) for which the term *binding* doesn't make sense. --- Old terminology (HIR, rustdoc): ``` `TypeBinding`: (associated) type binding ├── `Constraint`: associated type bound └── `Equality`: (associated) equality constraint (?) ├── `Ty`: (associated) type binding └── `Const`: associated const equality (constraint) ``` Old terminology (AST, abbrev.): ``` `AssocConstraint` ├── `Bound` └── `Equality` ├── `Ty` └── `Const` ``` New terminology (AST, HIR, rustdoc): ``` `AssocItemConstraint`: associated item constraint ├── `Bound`: associated type bound └── `Equality`: associated item equality constraint OR associated item binding (for short) ├── `Ty`: associated type equality constraint OR associated type binding (for short) └── `Const`: associated const equality constraint OR associated const binding (for short) ``` r? compiler-errors
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-30/+21