summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2024-11-19Introduce `min_generic_const_args` and directly represent pathsNoah Lev-48/+60
Co-authored-by: Boxy UwU <rust@boxyuwu.dev> Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2024-11-15Fix span edition for 2024 RPIT coming from an external macroEric Huss-1/+1
This fixes a problem where code generated by an external macro with an RPIT would end up using the call-site edition instead of the macro's edition for the RPIT. When used from a 2024 crate, this caused the code to change behavior to the 2024 capturing rules, which we don't want. This was caused by the impl-trait lowering code would replace the span with one marked with `DesugaringKind::OpaqueTy` desugaring. However, it was also overriding the edition of the span with the edition of the local crate. Instead it should be using the edition of the span itself. Fixes https://github.com/rust-lang/rust/issues/132917
2024-10-31Encode cross-crate opaque type originMichael Goulet-3/+3
2024-10-30Remap impl-trait lifetimes on HIR instead of AST lowering.Camille GILLOT-246/+9
2024-10-29Rollup merge of #131375 - klensy:clone_on_ref_ptr, r=cjgillotJubilee-1/+1
compiler: apply clippy::clone_on_ref_ptr for CI Apply lint https://rust-lang.github.io/rust-clippy/master/index.html#/clone_on_ref_ptr for compiler, also see https://github.com/rust-lang/rust/pull/131225#discussion_r1790109443. Some Arc's can be misplaced with Lrc's, sorry. https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/enable.20more.20clippy.20lints.20for.20compiler.20.28and.5Cor.20std.29
2024-10-28fix clippy::clone_on_ref_ptr for compilerklensy-1/+1
2024-10-28more consistent debug_assertionsAdwin White-3/+14
2024-10-28Add duplicate lowering checkAdwin White-12/+23
2024-10-28Lower AST node id only onceAdwin White-37/+28
2024-10-24Remove associated type based effects logicMichael Goulet-17/+3
2024-10-23nightly feature tracking: get rid of the per-feature bool fieldsRalf Jung-6/+6
2024-10-22Represent TraitBoundModifiers as distinct parts in HIRMichael Goulet-18/+4
2024-10-19Make sure that outer opaques capture inner opaques's lifetimes even with ↵Michael Goulet-58/+21
precise capturing syntax
2024-10-15Auto merge of #131723 - matthiaskrgr:rollup-krcslig, r=matthiaskrgrbors-28/+22
Rollup of 9 pull requests Successful merges: - #122670 (Fix bug where `option_env!` would return `None` when env var is present but not valid Unicode) - #131095 (Use environment variables instead of command line arguments for merged doctests) - #131339 (Expand set_ptr_value / with_metadata_of docs) - #131652 (Move polarity into `PolyTraitRef` rather than storing it on the side) - #131675 (Update lint message for ABI not supported) - #131681 (Fix up-to-date checking for run-make tests) - #131702 (Suppress import errors for traits that couldve applied for method lookup error) - #131703 (Resolved python deprecation warning in publish_toolstate.py) - #131710 (Remove `'apostrophes'` from `rustc_parse_format`) r? `@ghost` `@rustbot` modify labels: rollup
2024-10-15Rollup merge of #130635 - eholk:pin-reborrow-sugar, r=compiler-errorsMatthias Krüger-8/+43
Add `&pin (mut|const) T` type position sugar This adds parser support for `&pin mut T` and `&pin const T` references. These are desugared to `Pin<&mut T>` and `Pin<&T>` in the AST lowering phases. This PR currently includes #130526 since that one is in the commit queue. Only the most recent commits (bd450027eb4a94b814a7dd9c0fa29102e6361149 and following) are new. Tracking: - #130494 r? `@compiler-errors`
2024-10-14Move trait bound modifiers into ast::PolyTraitRefMichael Goulet-9/+6
2024-10-14Move trait bound modifiers into hir::PolyTraitRefMichael Goulet-23/+20
2024-10-13Remove const trait bound modifier hackMichael Goulet-8/+2
2024-10-11Auto merge of #131045 - compiler-errors:remove-unnamed_fields, r=wesleywiserbors-40/+0
Retire the `unnamed_fields` feature for now `#![feature(unnamed_fields)]` was implemented in part in #115131 and #115367, however work on that feature has (afaict) stalled and in the mean time there have been some concerns raised (e.g.[^1][^2]) about whether `unnamed_fields` is worthwhile to have in the language, especially in its current desugaring. Because it represents a compiler implementation burden including a new kind of anonymous ADT and additional complication to field selection, and is quite prone to bugs today, I'm choosing to remove the feature. However, since I'm not one to really write a bunch of words, I'm specifically *not* going to de-RFC this feature. This PR essentially *rolls back* the state of this feature to "RFC accepted but not yet implemented"; however if anyone wants to formally unapprove the RFC from the t-lang side, then please be my guest. I'm just not totally willing to summarize the various language-facing reasons for why this feature is or is not worthwhile, since I'm coming from the compiler side mostly. Fixes #117942 Fixes #121161 Fixes #121263 Fixes #121299 Fixes #121722 Fixes #121799 Fixes #126969 Fixes #131041 Tracking: * https://github.com/rust-lang/rust/issues/49804 [^1]: https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Unnamed.20struct.2Funion.20fields [^2]: https://github.com/rust-lang/rust/issues/49804#issuecomment-1972619108
2024-10-10Add gate for precise capturing in traitsMichael Goulet-5/+14
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`.