about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/item.rs
AgeCommit message (Collapse)AuthorLines
2023-12-22Auto merge of #119163 - fmease:refactor-ast-trait-bound-modifiers, ↵bors-1/+7
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-1/+7
2023-12-20Give `VariantData::Struct` named fields, to clairfy `recovered`.Alona Enraght-Moony-4/+5
2023-12-15Annotate some more bugsMichael Goulet-2/+7
2023-12-09Rollup merge of #118766 - compiler-errors:lower-spans, r=spastorinoGuillaume Gomez-0/+1
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 constness span in host paramMichael Goulet-0/+1
2023-12-08Introduce closure_id method on CoroutineKindMichael Goulet-4/+1
2023-12-08Make some matches exhaustive to avoid bugs, fix toolsMichael Goulet-0/+1
2023-12-08Support async gen fnMichael Goulet-5/+11
2023-12-08coro_kind -> coroutine_kindMichael Goulet-15/+22
2023-12-06Auto merge of #118605 - fee1-dead-contrib:rm-rustc_host, r=compiler-errorsbors-39/+16
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-05Remove `#[rustc_host]`, use internal desugaringDeadbeef-39/+16
2023-12-04Option<CoroutineKind>Eric Holk-12/+11
2023-12-04Merge Async and Gen into CoroutineKindEric Holk-61/+28
2023-12-04Lower return types for gen fn to impl IteratorEric Holk-46/+100
2023-12-03rustc: Harmonize `DefKind` and `DefPathData`Vadim Petrochenkov-9/+3
`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-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-4/+4
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-4/+1
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-68/+38
`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-4/+1
2023-11-28resolve: Feed the `def_kind` query immediately on `DefId` creationVadim Petrochenkov-3/+11
2023-11-28Add `LoweringContext::new`.Nicholas Nethercote-37/+1
2023-11-28Create `LoweringContext::lower_assoc_item`.Nicholas Nethercote-31/+37
By moving most of `ItemLowerer::lower_assoc_item` into it. This is similar to `LoweringContext::lower_foreign_item`.
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-11/+6
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-04Fix remaining uses of `CaptureBy::Value`Dinu Blanovschi-1/+1
2023-11-02Minimize `pub` usage in `source_map.rs`.Nicholas Nethercote-2/+1
Most notably, this commit changes the `pub use crate::*;` in that file to `use crate::*;`. This requires a lot of `use` items in other crates to be adjusted, because everything defined within `rustc_span::*` was also available via `rustc_span::source_map::*`, which is bizarre. The commit also removes `SourceMap::span_to_relative_line_string`, which is unused.
2023-10-30Some more coroutine renamingsMichael Goulet-2/+2
2023-10-25Rename `AsyncCoroutineKind` to `CoroutineSource`Oli Scherer-1/+1
similar to how we have `MatchSource`, it explains where the desugaring came from.
2023-10-20s/generator/coroutine/Oli Scherer-4/+4
2023-10-20s/Generator/Coroutine/Oli Scherer-1/+1
2023-10-13Format all the let chains in compilerMichael Goulet-5/+12
2023-10-11small cleanupDeadbeef-6/+4
2023-09-21Record asyncness span in HIRMichael Goulet-1/+1
2023-08-08feat: `riscv-interrupt-{m,s}` calling conventionsSeth Pellegrino-4/+8
Similar to prior support added for the mips430, avr, and x86 targets this change implements the rough equivalent of clang's [`__attribute__((interrupt))`][clang-attr] for riscv targets, enabling e.g. ```rust static mut CNT: usize = 0; pub extern "riscv-interrupt-m" fn isr_m() { unsafe { CNT += 1; } } ``` to produce highly effective assembly like: ```asm pub extern "riscv-interrupt-m" fn isr_m() { 420003a0: 1141 addi sp,sp,-16 unsafe { CNT += 1; 420003a2: c62a sw a0,12(sp) 420003a4: c42e sw a1,8(sp) 420003a6: 3fc80537 lui a0,0x3fc80 420003aa: 63c52583 lw a1,1596(a0) # 3fc8063c <_ZN12esp_riscv_rt3CNT17hcec3e3a214887d53E.0> 420003ae: 0585 addi a1,a1,1 420003b0: 62b52e23 sw a1,1596(a0) } } 420003b4: 4532 lw a0,12(sp) 420003b6: 45a2 lw a1,8(sp) 420003b8: 0141 addi sp,sp,16 420003ba: 30200073 mret ``` (disassembly via `riscv64-unknown-elf-objdump -C -S --disassemble ./esp32c3-hal/target/riscv32imc-unknown-none-elf/release/examples/gpio_interrupt`) This outcome is superior to hand-coded interrupt routines which, lacking visibility into any non-assembly body of the interrupt handler, have to be very conservative and save the [entire CPU state to the stack frame][full-frame-save]. By instead asking LLVM to only save the registers that it uses, we defer the decision to the tool with the best context: it can more accurately account for the cost of spills if it knows that every additional register used is already at the cost of an implicit spill. At the LLVM level, this is apparently [implemented by] marking every register as "[callee-save]," matching the semantics of an interrupt handler nicely (it has to leave the CPU state just as it found it after its `{m|s}ret`). This approach is not suitable for every interrupt handler, as it makes no attempt to e.g. save the state in a user-accessible stack frame. For a full discussion of those challenges and tradeoffs, please refer to [the interrupt calling conventions RFC][rfc]. Inside rustc, this implementation differs from prior art because LLVM does not expose the "all-saved" function flavor as a calling convention directly, instead preferring to use an attribute that allows for differentiating between "machine-mode" and "superivsor-mode" interrupts. Finally, some effort has been made to guide those who may not yet be aware of the differences between machine-mode and supervisor-mode interrupts as to why no `riscv-interrupt` calling convention is exposed through rustc, and similarly for why `riscv-interrupt-u` makes no appearance (as it would complicate future LLVM upgrades). [clang-attr]: https://clang.llvm.org/docs/AttributeReference.html#interrupt-risc-v [full-frame-save]: https://github.com/esp-rs/esp-riscv-rt/blob/9281af2ecffe13e40992917316f36920c26acaf3/src/lib.rs#L440-L469 [implemented by]: https://github.com/llvm/llvm-project/blob/b7fb2a3fec7c187d58a6d338ab512d9173bca987/llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp#L61-L67 [callee-save]: https://github.com/llvm/llvm-project/blob/973f1fe7a8591c7af148e573491ab68cc15b6ecf/llvm/lib/Target/RISCV/RISCVCallingConv.td#L30-L37 [rfc]: https://github.com/rust-lang/rfcs/pull/3246
2023-08-08Auto merge of #114545 - fee1-dead-contrib:lower-impl-effect, r=oli-obkbors-25/+59
correctly lower `impl const` to bind to host effect param r? `@oli-obk`
2023-08-06lower impl const to bind to host effect paramDeadbeef-25/+59
2023-08-02Add separate feature gate for async fn track callerBryan Garza-1/+6
This patch adds a feature gate `async_fn_track_caller` that is separate from `closure_track_caller`. This is to allow enabling `async_fn_track_caller` separately. Fixes #110009
2023-07-28Lower generic const items to HIRLeón Orell Valerian Liehr-16/+39
2023-07-19add comment for lower_use_treeSparrowLii-0/+3
Signed-off-by: SparrowLii <liyuan179@huawei.com>
2023-07-19avoid clone path prefix when lowering to hirSparrowLii-11/+0
Signed-off-by: SparrowLii <liyuan179@huawei.com>
2023-07-04include `host_effect_index` in `Generics`Deadbeef-8/+5
2023-07-04Add effects during lowering for `~const` boundsDeadbeef-9/+111
2023-05-12Require `impl Trait` in associated types to appear in method signaturesOli Scherer-2/+8
2023-04-26IntoFuture::into_future is no longer unstableMichael Goulet-1/+0
2023-04-24Split `{Idx, IndexVec, IndexSlice}` into their own modulesMaybe Waffle-1/+1
2023-04-22Also arena-allocate `ast::MacroDef` to make `Item: Copy`Nilstrieb-1/+2
2023-04-19Rollup merge of #110451 - WaffleLapkin:ensure_return_elem, r=scottmcmMatthias Krüger-5/+5
Minor changes to `IndexVec::ensure_contains_elem` & related methods r? `@scottmcm`
2023-04-17Use `Item::expect_*` and `ImplItem::expect_*` moreMaybe Waffle-6/+4
2023-04-17Make `IndexVec::ensure_contains_elem` return a reference to the elementMaybe Waffle-5/+5
2023-04-04Rename `ast::Static` to `ast::StaticItem` to match `ast::ConstItem`Oli Scherer-1/+1