summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src/lib.rs
AgeCommit message (Collapse)AuthorLines
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
2024-05-28Cache whether a body has inline constsOli Scherer-1/+7
2024-05-17Rename Unsafe to SafetySantiago Pastorino-1/+1
2024-05-13Warn against redundant use<...>Michael Goulet-6/+9
2024-05-09Add `ErrorGuaranteed` to `Recovered::Yes` and use it more.Nicholas Nethercote-1/+2
The starting point for this was identical comments on two different fields, in `ast::VariantData::Struct` and `hir::VariantData::Struct`: ``` // FIXME: investigate making this a `Option<ErrorGuaranteed>` recovered: bool ``` I tried that, and then found that I needed to add an `ErrorGuaranteed` to `Recovered::Yes`. Then I ended up using `Recovered` instead of `Option<ErrorGuaranteed>` for these two places and elsewhere, which required moving `ErrorGuaranteed` from `rustc_parse` to `rustc_ast`. This makes things more consistent, because `Recovered` is used in more places, and there are fewer uses of `bool` and `Option<ErrorGuaranteed>`. And safer, because it's difficult/impossible to set `recovered` to `Recovered::Yes` without having emitted an error.
2024-05-04Auto merge of #124401 - oli-obk:some_hir_cleanups, r=cjgillotbors-12/+14
Some hir cleanups It seemed odd to not put `AnonConst` in the arena, compared with the other types that we did put into an arena. This way we can also give it a `Span` without growing a lot of other HIR data structures because of the extra field. r? compiler
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-4/+1
2024-04-26Move `ConstArg::span` to `AnonConst::span`Oli Scherer-4/+3
2024-04-26put `hir::AnonConst` on the hir arenaOli Scherer-9/+12
2024-04-25ast: Generalize item kind visitingVadim Petrochenkov-1/+1
And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).
2024-04-17Rename `BindingAnnotation` to `BindingMode`Jules Bertholet-5/+5
2024-04-17Rollup merge of #122813 - nnethercote:nicer-quals, r=compiler-errorsMatthias Krüger-22/+15
Qualifier tweaking Adding and removing qualifiers in some cases that make things nicer. Details in individual commits. r? `@compiler-errors`
2024-04-16Avoid lots of `hir::HirId{,Map,Set}` qualifiers.Nicholas Nethercote-22/+15
Because they're a bit redundant.
2024-04-15Use a path instead of an ident (and stop manually resolving)Michael Goulet-4/+7
2024-04-15Add hir::Node::PreciseCapturingNonLifetimeArgMichael Goulet-2/+6
2024-04-15Validation and other thingsMichael Goulet-5/+4
2024-04-15Lower and resolve precise captures in HIRMichael Goulet-7/+40
2024-04-15Use dedicated PreciseCapturingArg for representing what goes in use<>Michael Goulet-46/+43
2024-04-15Begin AST lowering for precise capturesMichael Goulet-29/+50
2024-04-15Parsing , pre-lowering support for precise capturesMichael Goulet-1/+2
2024-04-08Thread pattern types through the HIROli Scherer-1/+1
2024-04-08Add pattern types to astOli Scherer-1/+4
2024-04-03rustc_index: Add a `ZERO` constant to index typesVadim Petrochenkov-4/+4
It is commonly used.
2024-03-27Implement `mut ref`/`mut ref mut`Jules Bertholet-2/+2
2024-03-22Rename `hir::Local` into `hir::LetStmt`Guillaume Gomez-1/+1
2024-03-21Fix bad span for explicit lifetime suggestionShoyu Vanilla-27/+36
Move verbose logic to a function Minor renaming
2024-03-15Auto merge of #122517 - petrochenkov:bodihash, r=oli-obkbors-17/+2
Fill in HIR hash for associated opaque types Fixes https://github.com/rust-lang/rust/issues/122508
2024-03-14Fill in HIR hash for associated opaque typesVadim Petrochenkov-17/+2
2024-03-14Rename `hir::StmtKind::Local` into `hir::StmtKind::Let`Guillaume Gomez-1/+1
2024-03-08Simplify ImplTraitContextMichael Goulet-26/+17
2024-03-08Make TAITs capture all higher-ranked lifetimes in scopeMichael Goulet-13/+14
2024-03-07Rollup merge of #121089 - oli-obk:create_def_feed, r=petrochenkovGuillaume Gomez-1/+1
Remove `feed_local_def_id` best reviewed commit by commit Basically I returned `TyCtxtFeed` from `create_def` and then preserved that in the local caches based on https://github.com/rust-lang/rust/pull/121084 r? ````@petrochenkov````
2024-03-06Rewrite the `untranslatable_diagnostic` lint.Nicholas Nethercote-0/+1
Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This commit changes it to check calls to any function with an `impl Into<{D,Subd}iagMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. The commit also adds `#[allow(rustc::untranslatable_diagnostic)`] attributes to places that need it that are caught by the improved lint. These places that might be easy to convert to translatable diagnostics. Finally, it also: - Expands and corrects some comments. - Does some minor formatting improvements. - Adds missing `DecorateLint` cases to `tests/ui-fulldeps/internal-lints/diagnostics.rs`.
2024-03-05Avoid using feed_unit_query from within queriesOli Scherer-1/+1
2024-02-28Rename `DiagnosticArgFromDisplay` as `DiagArgFromDisplay`.Nicholas Nethercote-3/+3
2024-02-23Revert some `span_bug`s to `span_delayed_bug`.Nicholas Nethercote-1/+3
Fixes #121410. Fixes #121414. Fixes #121418. Fixes #121431.
2024-02-21Convert `delayed_bug`s to `bug`s.Nicholas Nethercote-3/+1
I have a suspicion that quite a few delayed bug paths are impossible to reach, so I did an experiment. I converted every `delayed_bug` to a `bug`, ran the full test suite, then converted back every `bug` that was hit. A surprising number were never hit. The next commit will convert some more back, based on human judgment.
2024-02-16Move trait into attr so it's greppableMichael Goulet-2/+2
2024-02-16Use extension trait deriveMichael Goulet-9/+2
2024-02-16Rollup merge of #121109 - nnethercote:TyKind-Err-guar-2, r=oli-obkGuillaume Gomez-1/+2
Add an ErrorGuaranteed to ast::TyKind::Err (attempt 2) This makes it more like `hir::TyKind::Err`, and avoids a `has_errors` assertion in `LoweringContext::lower_ty_direct`. r? ```@oli-obk```
2024-02-15Add `ErrorGuaranteed` to `ast::LitKind::Err`, `token::LitKind::Err`.Nicholas Nethercote-1/+2
This mostly works well, and eliminates a couple of delayed bugs. One annoying thing is that we should really also add an `ErrorGuaranteed` to `proc_macro::bridge::LitKind::Err`. But that's difficult because `proc_macro` doesn't have access to `ErrorGuaranteed`, so we have to fake it.
2024-02-15Add an `ErrorGuaranteed` to `ast::TyKind::Err`.Nicholas Nethercote-1/+2
This makes it more like `hir::TyKind::Err`, and avoids a `span_delayed_bug` call in `LoweringContext::lower_ty_direct`. It also requires adding `ast::TyKind::Dummy`, now that `ast::TyKind::Err` can't be used for that purpose in the absence of an error emission. There are a couple of cases that aren't as neat as I would have liked, marked with `FIXME` comments.
2024-02-14Use fewer delayed bugs.Nicholas Nethercote-3/+1
For some cases where it's clear that an error has already occurred, e.g.: - there's a comment stating exactly that, or - things like HIR lowering, where we are lowering an error kind The commit also tweaks some comments around delayed bug sites.
2024-02-12Lowering field access for anonymous adtsFrank King-16/+11
2024-02-12Lower anonymous structs or unions to HIRFrank King-11/+43