summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2024-01-28hir: Use `InferArg` in `ArrayLen::Infer`Vadim Petrochenkov-1/+4
2024-01-25Remove unused featuresclubby789-2/+0
2024-01-16Simplify BodyId hashing.Camille GILLOT-3/+3
2024-01-13Add check for ui_testing via promoting parameters from `ParseSess` to `Session`George-lewis-2/+2
2024-01-12Delegation implementation: step 1Bryanskiy-0/+1
2024-01-07Split note, fix const/static impl trait errorMichael Goulet-2/+2
2024-01-07Inline some helpers no longer needed due to RPITIT being stableMichael Goulet-47/+29
2024-01-07Make ImplTraitPosition display more descriptiveMichael Goulet-9/+9
2024-01-04Rollup merge of #119540 - fmease:no-effect-args-inside-dyn-trait, ↵Matthias Krüger-13/+15
r=compiler-errors Don't synthesize host effect args inside trait object types While we were indeed emitting an error for `~const` & `const` trait bounds in trait object types, we were still synthesizing host effect args for them. Since we don't record the original trait bound modifiers for dyn-Trait in `hir::TyKind::TraitObject` (unlike we do for let's say impl-Trait, `hir::TyKind::OpaqueTy`), AstConv just assumes `ty::BoundConstness::NotConst` in `conv_object_ty_poly_trait_ref` which given `<host> dyn ~const NonConstTrait` resulted in us not realizing that `~const` was used on a non-const trait which lead to a failed assertion in the end. Instead of updating `hir::TyKind::TraitObject` to track this kind of information, just strip the user-provided constness (similar to #119505). Fixes #119524.
2024-01-03Don't synthesize host effect args inside trait object typesLeón Orell Valerian Liehr-13/+15
2024-01-01Deny defaults for higher-ranked generic parametersLeón Orell Valerian Liehr-30/+40
2023-12-27Auto merge of #119099 - fmease:always-const-trait-bounds, r=fee1-deadbors-37/+49
Introduce `const Trait` (always-const trait bounds) Feature `const_trait_impl` currently lacks a way to express “always const” trait bounds. This makes it impossible to define generic items like fns or structs which contain types that depend on const method calls (\*). While the final design and esp. the syntax of effects / keyword generics isn't set in stone, some version of “always const” trait bounds will very likely form a part of it. Further, their implementation is trivial thanks to the `effects` backbone. Not sure if this needs t-lang sign-off though. (\*): ```rs #![feature(const_trait_impl, effects, generic_const_exprs)] fn compute<T: const Trait>() -> Type<{ T::generate() }> { /*…*/ } struct Store<T: const Trait> where Type<{ T::generate() }>:, { field: Type<{ T::generate() }>, } ``` Lastly, “always const” trait bounds are a perfect fit for `generic_const_items`. ```rs #![feature(const_trait_impl, effects, generic_const_items)] const DEFAULT<T: const Default>: T = T::default(); ``` Previously, we (oli, fee1-dead and I) wanted to reinterpret `~const Trait` as `const Trait` in generic const items which would've been quite surprising and not very generalizable. Supersedes #117530. --- cc `@oli-obk` As discussed r? fee1-dead (or compiler)
2023-12-27Introduce `const Trait` (always-const trait bounds)León Orell Valerian Liehr-37/+49
2023-12-26Auto merge of #119324 - compiler-errors:rollup-c6eqcg9, r=compiler-errorsbors-1/+5
Rollup of 5 pull requests Successful merges: - #119235 (Add missing feature gate for sanitizer CFI cfgs) - #119240 (Make some non-diagnostic-affecting `QPath::LangItem` into regular `QPath`s) - #119297 (Pass DeadItem and lint as consistent group in dead-code.) - #119307 (Clean up some lifetimes in `rustc_pattern_analysis`) - #119323 (add test for coercing never to infinite type) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-26Rollup merge of #119240 - compiler-errors:lang-item-more, r=petrochenkovMichael Goulet-1/+5
Make some non-diagnostic-affecting `QPath::LangItem` into regular `QPath`s The rest of 'em affect diagnostics, so leave them alone... for now. cc #115178
2023-12-26fallback `default` to `None` during ast-loweing for lifetime binderbohan-2/+23
2023-12-26Make some non-diagnostic-affecting QPath::LangItem into regular qpathsMichael Goulet-1/+5
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-17/+20
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-22Auto merge of #118847 - eholk:for-await, r=compiler-errorsbors-0/+2
Add support for `for await` loops This adds support for `for await` loops. This includes parsing, desugaring in AST->HIR lowering, and adding some support functions to the library. Given a loop like: ```rust for await i in iter { ... } ``` this is desugared to something like: ```rust let mut iter = iter.into_async_iter(); while let Some(i) = loop { match core::pin::Pin::new(&mut iter).poll_next(cx) { Poll::Ready(i) => break i, Poll::Pending => yield, } } { ... } ``` This PR also adds a basic `IntoAsyncIterator` trait. This is partly for symmetry with the way `Iterator` and `IntoIterator` work. The other reason is that for async iterators it's helpful to have a place apart from the data structure being iterated over to store state. `IntoAsyncIterator` gives us a good place to do this. I've gated this feature behind `async_for_loop` and opened #118898 as the feature tracking issue. r? `@compiler-errors`
2023-12-22Auto merge of #119163 - fmease:refactor-ast-trait-bound-modifiers, ↵bors-26/+27
r=compiler-errors Refactor AST trait bound modifiers Instead of having two types to represent trait bound modifiers in the parser / the AST (`parser::ty::BoundModifiers` & `ast::TraitBoundModifier`), only to map one to the other later, just use `parser::ty::BoundModifiers` (moved & renamed to `ast::TraitBoundModifiers`). The struct type is more extensible and easier to deal with (see [here](https://github.com/rust-lang/rust/pull/119099/files#r1430749981) and [here](https://github.com/rust-lang/rust/pull/119099/files#r1430752116) for context) since it more closely models what it represents: A compound of two kinds of modifiers, constness and polarity. Modeling this as an enum (the now removed `ast::TraitBoundModifier`) meant one had to add a new variant per *combination* of modifier kind, which simply isn't scalable and which lead to a lot of explicit non-DRY matches. NB: `hir::TraitBoundModifier` being an enum is fine since HIR doesn't need to worry representing invalid modifier kind combinations as those get rejected during AST validation thereby immensely cutting down the number of possibilities.
2023-12-20Refactor AST trait bound modifiersLeón Orell Valerian Liehr-26/+27
2023-12-20resolve: Eagerly feed closure visibilitiesVadim Petrochenkov-5/+1
Also factor out all tcx-dependent operations performed for every created definition into `TyCtxt::create_def`
2023-12-19Desugar for await loopsEric Holk-0/+2
2023-12-18Replace some instances of FxHashMap/FxHashSet with stable alternatives ↵Michael Woerister-10/+10
(mostly in rustc_hir and rustc_ast_lowering) Part of https://github.com/rust-lang/compiler-team/issues/533
2023-12-18resolve: Replace visibility table in resolver outputs with query feedingVadim Petrochenkov-4/+6
Also feed missing visibilities for import stems and trait impl items, which were previously evaluated lazily.
2023-12-15banish hir::GenericBound::LangItemTraitMichael Goulet-6/+37
2023-12-15Collect lang items from ASTMichael Goulet-0/+1
2023-12-10Auto merge of #116952 - compiler-errors:lifetime_capture_rules_2024, r=TaKO8Kibors-2/+5
Implement 2024-edition lifetime capture rules RFC Implements rust-lang/rfcs#3498.
2023-12-10remove redundant importssurechen-1/+0
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-09Rollup merge of #118766 - compiler-errors:lower-spans, r=spastorinoGuillaume Gomez-3/+3
Lower some forgotten spans I wrote a HIR visitor that visited all of the spans in the HIR, and made it ICE when we have a unlowered span. That led me to discover these unlowered spans.
2023-12-09Lower spans for opaque duplicated lifetimes, const infer varsMichael Goulet-3/+3
2023-12-08More nitsMichael Goulet-1/+2
2023-12-08Add testsMichael Goulet-9/+16
2023-12-08Support async gen fnMichael Goulet-3/+5
2023-12-06Auto merge of #118605 - fee1-dead-contrib:rm-rustc_host, r=compiler-errorsbors-10/+2
Remove `#[rustc_host]`, use internal desugaring Also removed a way for users to explicitly specify the host param since that isn't particularly useful. This should eliminate any pain with encoding attributes across crates and etc. r? `@compiler-errors`
2023-12-05Enable new capture rules by default on edition 2024Michael Goulet-0/+1
2023-12-05Add lifetime_capture_rules_2024Michael Goulet-2/+4
2023-12-05Remove `#[rustc_host]`, use internal desugaringDeadbeef-10/+2
2023-12-04Address code review feedbackEric Holk-7/+7
2023-12-04Fix some broken testsEric Holk-1/+1
2023-12-04Option<CoroutineKind>Eric Holk-14/+4
2023-12-04Merge Async and Gen into CoroutineKindEric Holk-32/+25
2023-12-04Lower return types for gen fn to impl IteratorEric Holk-22/+53
2023-12-03rustc: Harmonize `DefKind` and `DefPathData`Vadim Petrochenkov-11/+10
`DefPathData::(ClosureExpr,ImplTrait)` are renamed to match `DefKind::(Closure,OpaqueTy)`. `DefPathData::ImplTraitAssocTy` is replaced with `DefPathData::TypeNS(kw::Empty)` because both correspond to `DefKind::AssocTy`. It's possible that introducing `(DefKind,DefPathData)::AssocOpaqueTy` could be a better solution, but that would be a much more invasive change. Const generic parameters introduced for effects are moved from `DefPathData::TypeNS` to `DefPathData::ValueNS`, because constants are values. `DefPathData` is no longer passed to `create_def` functions to avoid redundancy.
2023-12-02Inline and remove `LoweringContext::handler()`.Nicholas Nethercote-5/+1
It has a single call site.
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-6/+7
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-29Auto merge of #118433 - matthiaskrgr:rollup-fi9lrwg, r=matthiaskrgrbors-3/+8
Rollup of 7 pull requests Successful merges: - #116839 (Implement thread parking for xous) - #118265 (remove the memcpy-on-equal-ptrs assumption) - #118269 (Unify `TraitRefs` and `PolyTraitRefs` in `ValuePairs`) - #118394 (Remove HIR opkinds) - #118398 (Add proper cfgs in std) - #118419 (Eagerly return `ExprKind::Err` on `yield`/`await` in wrong coroutine context) - #118422 (Fix coroutine validation for mixed panic strategy) r? `@ghost` `@rustbot` modify labels: rollup
2023-11-29Rollup merge of #118401 - nnethercote:rustc_ast_lowering, r=compiler-errorsMatthias Krüger-3/+42
`rustc_ast_lowering` cleanups Just some cleanups I found while looking through this code. r? `@spastorino`
2023-11-28Fix spans for bad await in inline constMichael Goulet-3/+8
2023-11-28resolve: Feed the `def_kind` query immediately on `DefId` creationVadim Petrochenkov-9/+14