about summary refs log tree commit diff
path: root/compiler/rustc_ast/src/visit.rs
AgeCommit message (Collapse)AuthorLines
2023-12-19Plumb awaitness of for loopsEric Holk-5/+5
2023-12-10remove redundant importssurechen-1/+1
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-08Auto merge of #118420 - compiler-errors:async-gen, r=eholkbors-1/+1
Introduce support for `async gen` blocks I'm delighted to demonstrate that `async gen` block are not very difficult to support. They're simply coroutines that yield `Poll<Option<T>>` and return `()`. **This PR is WIP and in draft mode for now** -- I'm mostly putting it up to show folks that it's possible. This PR needs a lang-team experiment associated with it or possible an RFC, since I don't think it falls under the jurisdiction of the `gen` RFC that was recently authored by oli (https://github.com/rust-lang/rfcs/pull/3513, https://github.com/rust-lang/rust/issues/117078). ### Technical note on the pre-generator-transform yield type: The reason that the underlying coroutines yield `Poll<Option<T>>` and not `Poll<T>` (which would make more sense, IMO, for the pre-transformed coroutine), is because the `TransformVisitor` that is used to turn coroutines into built-in state machine functions would have to destructure and reconstruct the latter into the former, which requires at least inserting a new basic block (for a `switchInt` terminator, to match on the `Poll` discriminant). This does mean that the desugaring (at the `rustc_ast_lowering` level) of `async gen` blocks is a bit more involved. However, since we already need to intercept both `.await` and `yield` operators, I don't consider it much of a technical burden. r? `@ghost`
2023-12-08coro_kind -> coroutine_kindMichael Goulet-1/+1
2023-12-08Auto merge of #118527 - Nadrieril:never_patterns_parse, r=compiler-errorsbors-1/+1
never_patterns: Parse match arms with no body Never patterns are meant to signal unreachable cases, and thus don't take bodies: ```rust let ptr: *const Option<!> = ...; match *ptr { None => { foo(); } Some(!), } ``` This PR makes rustc accept the above, and enforces that an arm has a body xor is a never pattern. This affects parsing of match arms even with the feature off, so this is delicate. (Plus this is my first non-trivial change to the parser). ~~The last commit is optional; it introduces a bit of churn to allow the new suggestions to be machine-applicable. There may be a better solution? I'm not sure.~~ EDIT: I removed that commit r? `@compiler-errors`
2023-12-04Merge Async and Gen into CoroutineKindEric Holk-1/+1
2023-12-03Parse a pattern with no armNadrieril-1/+1
2023-11-29Add `never_patterns` feature gateNadrieril-1/+1
2023-11-04fixes for rustfmt + ast visitorDinu Blanovschi-1/+5
2023-10-27Add gen blocks to ast and do some broken ast loweringOli Scherer-1/+1
2023-09-11Move let expression checking to parsingMatthew Jasper-1/+1
There was an incomplete version of the check in parsing and a second version in AST validation. This meant that some, but not all, invalid uses were allowed inside macros/disabled cfgs. It also means that later passes have a hard time knowing when the let expression is in a valid location, sometimes causing ICEs. - Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location. - Suppress later errors and MIR construction for invalid let expressions.
2023-08-24Parse unnamed fields and anonymous structs or unionsFrank King-0/+3
Anonymous structs or unions are only allowed in struct field definitions. Co-authored-by: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com>
2023-08-04Improve spans for indexing expressionsNilstrieb-1/+1
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
2023-07-28Parse generic const itemsLeón Orell Valerian Liehr-3/+8
2023-06-19Syntatically accept `become` expressionsMaybe Waffle-0/+1
2023-05-05misc nameres changes for anon constsBoxy-1/+4
2023-04-27Tweak await spanMichael Goulet-1/+1
2023-04-21offset_ofDrMeepster-0/+6
2023-04-10Remove `..` from return type notationMichael Goulet-1/+0
2023-04-04Rename `ast::Static` to `ast::StaticItem` to match `ast::ConstItem`Oli Scherer-2/+2
2023-04-04box a bunch of large typesOli Scherer-3/+3
2023-04-04Split out ast::ItemKind::Const into its own structOli Scherer-4/+4
2023-04-04rust-analyzer guided tuple field to named fieldOli Scherer-1/+2
2023-04-04rust-analyzer guided enum variant structificationOli Scherer-2/+2
2023-03-28Add `(..)` syntax for RTNMichael Goulet-0/+1
2023-03-19Remove the `NodeId` of `ast::ExprKind::Async`Arpad Borsos-1/+1
2023-03-12Remove `box_syntax` from AST and use in toolsclubby789-1/+0
2023-02-02Revert "Teach parser to understand fake anonymous enum syntax" and related ↵Michael Goulet-2/+2
commits Revert "review comment: Remove AST AnonTy" This reverts commit 020cca8d36cb678e3ddc2ead41364be314d19e93. Revert "Ensure macros are not affected" This reverts commit 12d18e403139eeeeb339e8611b2bed4910864edb. Revert "Emit fewer errors on patterns with possible type ascription" This reverts commit c847a01a3b1f620c4fdb98c75805033e768975d1. Revert "Teach parser to understand fake anonymous enum syntax" This reverts commit 2d824206655bfb26cb5eed43490ee396542b153e.
2023-01-26Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obkbors-0/+13
Move format_args!() into AST (and expand it during AST lowering) Implements https://github.com/rust-lang/compiler-team/issues/541 This moves FormatArgs from rustc_builtin_macros to rustc_ast_lowering. For now, the end result is the same. But this allows for future changes to do smarter things with format_args!(). It also allows Clippy to directly access the ast::FormatArgs, making things a lot easier. This change turns the format args types into lang items. The builtin macro used to refer to them by their path. After this change, the path is no longer relevant, making it easier to make changes in `core`. This updates clippy to use the new language items, but this doesn't yet make clippy use the ast::FormatArgs structure that's now available. That should be done after this is merged.
2023-01-23review comment: Remove AST AnonTyEsteban Küber-1/+1
2023-01-17Teach parser to understand fake anonymous enum syntaxEsteban Küber-2/+2
Parse `-> Ty | OtherTy`. Parse type ascription in top level patterns.
2023-01-12parse const closuresDeadbeef-0/+1
2023-01-12Expand format_args!() in rust_ast_lowering.Mara Bos-0/+13
2022-12-28Rename `Rptr` to `Ref` in AST and HIRNilstrieb-3/+3
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-03Rollup merge of #104199 - SarthakSingh31:issue-97417-1, r=cjgillotMatthias Krüger-0/+1
Keep track of the start of the argument block of a closure This removes a call to `tcx.sess.source_map()` from [compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs](https://github.com/rust-lang/rust/compare/master...SarthakSingh31:issue-97417-1?expand=1#diff-8406bbc0d0b43d84c91b1933305df896ecdba0d1f9269e6744f13d87a2ab268a) as required by #97417. VsCode automatically applied `rustfmt` to the files I edited under `src/tools`. I can undo that if its a problem. r? `@cjgillot`
2022-12-01rustc_ast_lowering: Stop lowering imports into multiple itemsVadim Petrochenkov-1/+1
Lower them into a single item with multiple resolutions instead. This also allows to remove additional `NodId`s and `DefId`s related to those additional items.
2022-11-28Keep track of the start of the argument block of a closureSarthak Singh-0/+1
2022-11-23Suggest `.clone()` or `ref binding` on E0382Esteban Küber-1/+1
2022-11-22Split `MacArgs` in two.Nicholas Nethercote-6/+6
`MacArgs` is an enum with three variants: `Empty`, `Delimited`, and `Eq`. It's used in two ways: - For representing attribute macro arguments (e.g. in `AttrItem`), where all three variants are used. - For representing function-like macros (e.g. in `MacCall` and `MacroDef`), where only the `Delimited` variant is used. In other words, `MacArgs` is used in two quite different places due to them having partial overlap. I find this makes the code hard to read. It also leads to various unreachable code paths, and allows invalid values (such as accidentally using `MacArgs::Empty` in a `MacCall`). This commit splits `MacArgs` in two: - `DelimArgs` is a new struct just for the "delimited arguments" case. It is now used in `MacCall` and `MacroDef`. - `AttrArgs` is a renaming of the old `MacArgs` enum for the attribute macro case. Its `Delimited` variant now contains a `DelimArgs`. Various other related things are renamed as well. These changes make the code clearer, avoids several unreachable paths, and disallows the invalid values.
2022-11-21Remove `ref` patterns from `rustc_ast`Maybe Waffle-138/+128
Also use if let chains in one case.
2022-11-17Box `ExprKind::{Closure,MethodCall}`, and `QSelf` in expressions, types, and ↵Nicholas Nethercote-5/+13
patterns.
2022-11-14Auto merge of #103858 - Mark-Simulacrum:bump-bootstrap, r=pietroalbinibors-1/+1
Bump bootstrap compiler to 1.66 This PR: - Bumps version placeholders to release - Bumps to latest beta - cfg-steps code r? `@pietroalbini`
2022-11-11Introduce `ExprKind::IncludedBytes`clubby789-1/+1
2022-11-06cfg-step codeMark Rousskov-1/+1
2022-10-23Workaround unstable stmt_expr_attributes for method receiver expressions.Camille GILLOT-0/+5
2022-10-10Rollup merge of #102868 - compiler-errors:rename-assoc-tyalias-to-ty, r=TaKO8KiDylan DPC-1/+1
Rename `AssocItemKind::TyAlias` to `AssocItemKind::Type` Thanks `@camsteffen` for catching this in ast too, cc https://github.com/rust-lang/rust/pull/102829#issuecomment-1272649247
2022-10-10Rename AssocItemKind::TyAlias to AssocItemKind::TypeMichael Goulet-1/+1
2022-10-09fixup lint nameMaybe Waffle-1/+1
2022-10-09allow or avoid for loops over option in compiler and testsMaybe Waffle-8/+6
2022-09-12Remove unused span argument from `walk_fn`.Nicholas Nethercote-3/+3