about summary refs log tree commit diff
path: root/compiler/rustc_ast_lowering/src
AgeCommit message (Collapse)AuthorLines
2024-05-31Rollup merge of #125790 - WaffleLapkin:no-tail-recomputation-in-lower-stmts, ↵Matthias Krüger-1/+1
r=lcnr Don't recompute `tail` in `lower_stmts` Does not really matter, but this is slightly nicer. `@bors` rollup
2024-05-31Rollup merge of #125635 - fmease:mv-type-binding-assoc-item-constraint, ↵Matthias Krüger-48/+42
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-31Don't recompute `tail` in `lower_stmts`Waffle Maybe-1/+1
2024-05-30Rename HIR `TypeBinding` to `AssocItemConstraint` and related cleanupLeón Orell Valerian Liehr-48/+42
2024-05-28Cache whether a body has inline constsOli Scherer-2/+11
2024-05-28Create const block DefIds in typeck instead of ast loweringOli Scherer-16/+1
2024-05-17Rename Unsafe to SafetySantiago Pastorino-15/+15
2024-05-15delegation: Implement list delegationVadim Petrochenkov-6/+14
```rust reuse prefix::{a, b, c} ```
2024-05-13Warn against redundant use<...>Michael Goulet-6/+9
2024-05-09Add `ErrorGuaranteed` to `Recovered::Yes` and use it more.Nicholas Nethercote-3/+4
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-08Rollup merge of #123344 - pietroalbini:pa-unused-imports, r=NilstriebMatthias Krüger-3/+3
Remove braces when fixing a nested use tree into a single item [Back in 2019](https://github.com/rust-lang/rust/pull/56645) I added rustfix support for the `unused_imports` lint, to automatically remove them when running `cargo fix`. For the most part this worked great, but when removing all but one childs of a nested use tree it turned `use foo::{Unused, Used}` into `use foo::{Used}`. This is slightly annoying, because it then requires you to run `rustfmt` to get `use foo::Used`. This PR automatically removes braces and the surrouding whitespace when all but one child of a nested use tree are unused. To get it done I had to add the span of the nested use tree to the AST, and refactor a bit the code I wrote back then. A thing I noticed is, there doesn't seem to be any `//@ run-rustfix` test for fixing the `unused_imports` lint. I created a test in `tests/suggestions` (is that the right directory?) that for now tests just what I added in the PR. I can followup in a separate PR to add more tests for fixing `unused_lints`. This PR is best reviewed commit-by-commit.
2024-05-04Lower never patterns to Unreachable in mirNadrieril-2/+2
2024-05-04Auto merge of #124401 - oli-obk:some_hir_cleanups, r=cjgillotbors-16/+19
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-30Rollup merge of #124511 - nnethercote:rm-extern-crates, r=fee1-deadMatthias Krüger-4/+4
Remove many `#[macro_use] extern crate foo` items This requires the addition of more `use` items, which often make the code more verbose. But they also make the code easier to read, because `#[macro_use]` obscures where macros are defined. r? `@fee1-dead`
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-4/+4
2024-04-30Rollup merge of #124524 - spastorino:make-foreign-static-use-struct, r=oli-obkMatthias Krüger-4/+4
Add StaticForeignItem and use it on ForeignItemKind This is in preparation for unsafe extern blocks that adds a safe variant for functions inside extern blocks. r? `@oli-obk` cc `@compiler-errors`
2024-04-29Rollup merge of #124488 - est31:arbitrary_expressions_error, r=pnkfelixMatthias Krüger-1/+7
Add a note to the ArbitraryExpressionInPattern error The current "arbitrary expressions aren't allowed in patterns" error is confusing, as it fires for code where it *looks* like a pattern but the compiler still treats it as an expression. That this is due to the `:expr` fragment specifier forcing the expression-ness property on the code. In the test suite, the "arbitrary expressions aren't allowed in patterns" error can only be found in combination with macro_rules macros that force expression-ness of their content, namely via `:expr` metavariables. I also can't come up with cases where there would be an expression instead of a pattern, so I think it's always coming from an `:expr`. In order to make the error less confusing, this adds a note explaining the weird `:expr` fragment behaviour. Fixes #99380
2024-04-29Add StaticForeignItem and use it on ForeignItemKindSantiago Pastorino-4/+4
2024-04-28Add a note to the ArbitraryExpressionInPattern errorest31-1/+7
2024-04-26`Span`s are already 64 bit, just like references, so stop putting them ↵Oli Scherer-1/+1
behind indirections
2024-04-26Move `ConstArg::span` to `AnonConst::span`Oli Scherer-4/+4
2024-04-26put `hir::AnonConst` on the hir arenaOli Scherer-12/+15
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-24Auto merge of #122500 - petrochenkov:deleg, r=fmeasebors-42/+77
delegation: Support renaming, and async, const, extern "ABI" and C-variadic functions Also allow delegating to functions with opaque types (`impl Trait`). The delegation item will refer to the original opaque type from the callee, fresh opaque type won't be created, which seems like a reasonable behavior. (Such delegation items will cause query cycles when used in trait impls, but it can be fixed later.) Part of https://github.com/rust-lang/rust/issues/118212.
2024-04-24Error on using `yield` without also using `#[coroutine]` on the closureOli Scherer-1/+15
And suggest adding the `#[coroutine]` to the closure
2024-04-24Add explicit syntax for coroutines instead of relying on closures having ↵Oli Scherer-1/+11
`yield` expressions
2024-04-23delegation: Support async, const, extern "ABI" and C-variadic functionsVadim Petrochenkov-42/+77
Also allow `impl Trait` in delegated functions. The delegation item will refer to the original opaque type from the callee, fresh opaque type won't be created.
2024-04-21Pass translation closure to add_to_diag_with() as referenceXiretza-1/+1
2024-04-18Rollup merge of #123935 - tstsrt:fix-115423, r=oli-obkJubilee-77/+117
Don't inline integer literals when they overflow - new attempt Basically #116633 but I implemented the suggested changes. Fixes #115423. Fixes #116631. This is my first contribution to this repo so please let me know if I'm supposed to change something :)
2024-04-17Rename `BindingAnnotation` to `BindingMode`Jules Bertholet-18/+13
2024-04-17Rollup merge of #122813 - nnethercote:nicer-quals, r=compiler-errorsMatthias Krüger-27/+21
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-27/+21
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/+23
2024-04-15Validation and other thingsMichael Goulet-5/+11
2024-04-15Lower and resolve precise captures in HIRMichael Goulet-16/+46
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-15Improve semantics of int_ty_max functionsninad-34/+26
2024-04-14store the span of the nested part of the use tree in the astPietro Albini-3/+3
2024-04-14Fix formattingninad-1/+3
2024-04-14Don't inline integer literals when out of rangeninad-77/+123
2024-04-08Actually create ranged int types in the type system.Oli Scherer-0/+4
2024-04-08Thread pattern types through the HIROli Scherer-1/+1
2024-04-08Add pattern types to astOli Scherer-1/+4
2024-04-04hir: Use `ItemLocalId` in a couple more placesVadim Petrochenkov-6/+5
2024-04-03Auto merge of #123429 - matthiaskrgr:rollup-4emw4e9, r=matthiaskrgrbors-8/+8
Rollup of 8 pull requests Successful merges: - #121595 (Better reporting on generic argument mismatchs) - #122619 (Fix some unsoundness with PassMode::Cast ABI) - #122964 (Rename `expose_addr` to `expose_provenance`) - #123291 (Move some tests) - #123301 (pattern analysis: fix union handling) - #123395 (More postfix match fixes) - #123419 (rustc_index: Add a `ZERO` constant to index types) - #123421 (Fix target name in NetBSD platform-support doc) r? `@ghost` `@rustbot` modify labels: rollup
2024-04-03rustc_index: Add a `ZERO` constant to index typesVadim Petrochenkov-8/+8
It is commonly used.
2024-04-03hir: Drop owner's own item-local id (zero) from parenting tablesVadim Petrochenkov-1/+3