about summary refs log tree commit diff
path: root/compiler/rustc_ast
AgeCommit message (Collapse)AuthorLines
2023-11-04Add the vis.visit_capture_by() in noop_visit_exprDinu Blanovschi-1/+2
2023-11-04add `fn visit_capture_by` to MutVisitor and fix pprust-expr-roundtrip.rsDinu Blanovschi-0/+13
2023-11-04fixes for rustfmt + ast visitorDinu Blanovschi-1/+5
2023-11-04feat(hir): Store the `Span` of the `move` keywordDinu Blanovschi-1/+4
2023-10-30Clean up `rustc_*/Cargo.toml`.Nicholas Nethercote-3/+3
- Sort dependencies and features sections. - Add `tidy` markers to the sorted sections so they stay sorted. - Remove empty `[lib`] sections. - Remove "See more keys..." comments. Excluded files: - rustc_codegen_{cranelift,gcc}, because they're external. - rustc_lexer, because it has external use. - stable_mir, because it has external use.
2023-10-29Auto merge of #116447 - oli-obk:gen_fn, r=compiler-errorsbors-11/+38
Implement `gen` blocks in the 2024 edition Coroutines tracking issue https://github.com/rust-lang/rust/issues/43122 `gen` block tracking issue https://github.com/rust-lang/rust/issues/117078 This PR implements `gen` blocks that implement `Iterator`. Most of the logic with `async` blocks is shared, and thus I renamed various types that were referring to `async` specifically. An example usage of `gen` blocks is ```rust fn foo() -> impl Iterator<Item = i32> { gen { yield 42; for i in 5..18 { if i.is_even() { continue } yield i * 2; } } } ``` The limitations (to be resolved) of the implementation are listed in the tracking issue
2023-10-27Add gen blocks to ast and do some broken ast loweringOli Scherer-11/+31
2023-10-26Rollup merge of #117114 - nnethercote:improve-stringify-test, r=petrochenkovMatthias Krüger-0/+7
Improve `stringify.rs` test Best reviewed one commit at a time. r? `@petrochenkov`
2023-10-26Reserve `gen` keyword for `gen {}` blocks and `gen fn` in 2024 editionOli Scherer-0/+7
2023-10-24Augment `stringify.rs` test.Nicholas Nethercote-0/+7
By adding tests (or placeholders, or comments) for missing AST variants.
2023-10-22use visibility to check unused imports and delete some stmtsbohan-1/+0
2023-10-19Uplift movability and mutability, the simple wayMichael Goulet-63/+6
2023-10-15Auto merge of #116688 - compiler-errors:rustfmt-up, r=WaffleLapkin,Nilstriebbors-11/+15
Format all the let-chains in compiler crates Since rust-lang/rustfmt#5910 has landed, soon we will have support for formatting let-chains (as soon as rustfmt syncs and beta gets bumped). This PR applies the changes [from master rustfmt to rust-lang/rust eagerly](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/out.20formatting.20of.20prs/near/374997516), so that the next beta bump does not have to deal with a 200+ file diff and can remain concerned with other things like `cfg(bootstrap)` -- #113637 was a pain to land, for example, because of let-else. I will also add this commit to the ignore list after it has landed. The commands that were run -- I'm not great at bash-foo, but this applies rustfmt to every compiler crate, and then reverts the two crates that should probably be formatted out-of-tree. ``` ~/rustfmt $ ls -1d ~/rust/compiler/* | xargs -I@ cargo run --bin rustfmt -- `@/src/lib.rs` --config-path ~/rust --edition=2021 # format all of the compiler crates ~/rust $ git checkout HEAD -- compiler/rustc_codegen_{gcc,cranelift} # revert changes to cg-gcc and cg-clif ``` cc `@rust-lang/rustfmt` r? `@WaffleLapkin` or `@Nilstrieb` who said they may be able to review this purely mechanical PR :> cc `@Mark-Simulacrum` and `@petrochenkov,` who had some thoughts on the order of operations with big formatting changes in https://github.com/rust-lang/rust/pull/95262#issue-1178993801. I think the situation has changed since then, given that let-chains support exists on master rustfmt now, and I'm fairly confident that this formatting PR should land even if *bootstrap* rustfmt doesn't yet format let-chains in order to lessen the burden of the next beta bump.
2023-10-14Rollup merge of #116696 - c410-f3r:in-doc, r=petrochenkovMatthias Krüger-0/+27
Misc improvements cc https://github.com/rust-lang/rust/pull/116323#discussion_r1355282195 r? `@petrochenkov`
2023-10-13Misc improvementsCaio-0/+27
2023-10-13Format all the let chains in compilerMichael Goulet-11/+15
2023-10-12Use `TokenStream::token_alone` in one place.Nicholas Nethercote-4/+4
2023-10-12Rename `Token::is_op` as `Token::is_punct`.Nicholas Nethercote-1/+1
For consistency with `proc_macro::Punct`.
2023-10-08rustdoc: remove rust logo from non-Rust cratesMichael Howell-0/+3
2023-10-05Rollup merge of #116223 - catandcoder:master, r=cjgillotJubilee-1/+1
Fix misuses of a vs an Fixes the misuse of "a" vs "an", according to English grammatical expectations and using https://www.a-or-an.com/
2023-10-04Fix misuses of a vs ancui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-10-01Factor out the two `entry_point_type` functions.Nicholas Nethercote-0/+27
They are very similar, and each one has a comment about the importance of being kept in sync with the other. This commit removes the duplication.
2023-09-17Auto merge of #114452 - weiznich:feature/diagnostic_on_unimplemented, ↵bors-0/+16
r=compiler-errors `#[diagnostic::on_unimplemented]` without filters This commit adds support for a `#[diagnostic::on_unimplemented]` attribute with the following options: * `message` to customize the primary error message * `note` to add a customized note message to an error message * `label` to customize the label part of the error message The relevant behavior is specified in [RFC-3366](https://rust-lang.github.io/rfcs/3366-diagnostic-attribute-namespace.html)
2023-09-12`#[diagnostic::on_unimplemented]` without filtersGeorg Semmler-0/+16
This commit adds support for a `#[diagnostic::on_unimplemented]` attribute with the following options: * `message` to customize the primary error message * `note` to add a customized note message to an error message * `label` to customize the label part of the error message Co-authored-by: León Orell Valerian Liehr <me@fmease.dev> Co-authored-by: Michael Goulet <michael@errs.io>
2023-09-11Move let expression checking to parsingMatthew Jasper-5/+5
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-09-04improve `AttrTokenStream`mojave2-11/+7
2023-08-24Auto merge of #115131 - frank-king:feature/unnamed-fields-lite, r=petrochenkovbors-0/+12
Parse unnamed fields and anonymous structs or unions (no-recovery) It is part of #114782 which implements #49804. Only parse anonymous structs or unions in struct field definition positions. r? `@petrochenkov`
2023-08-24Parse unnamed fields and anonymous structs or unionsFrank King-0/+12
Anonymous structs or unions are only allowed in struct field definitions. Co-authored-by: carbotaniuman <41451839+carbotaniuman@users.noreply.github.com>
2023-08-19Fix a stack overflow with long else if chainsJohn Kåre Alsaker-1/+2
2023-08-08Auto merge of #114545 - fee1-dead-contrib:lower-impl-effect, r=oli-obkbors-0/+10
correctly lower `impl const` to bind to host effect param r? `@oli-obk`
2023-08-06Generate better function argument names in global_allocator expansionDavid Tolnay-5/+17
2023-08-06lower impl const to bind to host effect paramDeadbeef-0/+10
2023-08-04Improve spans for indexing expressionsNilstrieb-6/+10
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-08-03Auto merge of #114353 - nnethercote:parser-ast-cleanups, r=petrochenkovbors-39/+9
Some parser and AST cleanups Things I found while looking closely at this code. r? `@petrochenkov`
2023-08-03Remove `MacDelimiter`.Nicholas Nethercote-37/+9
It's the same as `Delimiter`, minus the `Invisible` variant. I'm generally in favour of using types to make impossible states unrepresentable, but this one feels very low-value, and the conversions between the two types are annoying and confusing. Look at the change in `src/tools/rustfmt/src/expr.rs` for an example: the old code converted from `MacDelimiter` to `Delimiter` and back again, for no good reason. This suggests the author was confused about the types.
2023-08-02Rollup merge of #114321 - SparrowLii:parallel_test, r=oli-obkNilstrieb-6/+0
get auto traits for parallel rustc test for #106930 #[Edit] Since this doesn't block try build now, we can close https://github.com/rust-lang/rust/issues/106930 fixes #106930
2023-08-02get auto traits for parallel rustcSparrowLii-6/+0
Signed-off-by: SparrowLii <liyuan179@huawei.com>
2023-08-02Fix an erroneous comment.Nicholas Nethercote-2/+0
The `None` variant has already been renamed `Invisible`.
2023-07-31Remove `TokenTreeCursor::replace_prev_and_rewind`.Nicholas Nethercote-9/+0
It's no longer used.
2023-07-31Move doc comment desugaring out of `TokenCursor`.Nicholas Nethercote-3/+89
`TokenCursor` currently does doc comment desugaring on the fly, if the `desugar_doc_comment` field is set. This requires also modifying the token stream on the fly with `replace_prev_and_rewind`. This commit moves the doc comment desugaring out of `TokenCursor`, by introducing a new `TokenStream::desugar_doc_comment` method. This separation of desugaring and iterating makes the code nicer.
2023-07-28Parse generic const itemsLeón Orell Valerian Liehr-4/+12
2023-07-28Auto merge of #114119 - nnethercote:opt-TokenKind-clone, r=petrochenkovbors-1/+16
Optimize `TokenKind::clone`. `TokenKind` would impl `Copy` if it weren't for `TokenKind::Interpolated`. This commit makes `clone` reflect that. r? `@ghost`
2023-07-28Auto merge of #114115 - nnethercote:less-token-tree-cloning, r=petrochenkovbors-37/+33
Less `TokenTree` cloning `TokenTreeCursor` has this comment on it: ``` // FIXME: Many uses of this can be replaced with by-reference iterator to avoid clones. ``` This PR completes that FIXME. It doesn't have much perf effect, but at least we now know that. r? `@petrochenkov`
2023-07-27Optimize `TokenKind::clone`.Nicholas Nethercote-1/+16
`TokenKind` would impl `Copy` if it weren't for `TokenKind::Interpolated`. This commit makes `clone` reflect that.
2023-07-27Remove `Iterator` impl for `TokenTreeCursor`.Nicholas Nethercote-13/+8
This is surprising, but the new comment explains why. It's a logical conclusion in the drive to avoid `TokenTree` clones. `TokenTreeCursor` is now only used within `Parser`. It's still needed due to `replace_prev_and_rewind`.
2023-07-27Make `TokenTree::uninterpolate` take `&self` and return a `Cow`.Nicholas Nethercote-12/+14
Making it similar to `Token::uninterpolate`. This avoids some more token tree cloning.
2023-07-27Use `TokenStream::trees` instead of `into_trees` for attributes.Nicholas Nethercote-14/+13
This avoids cloning some token trees. A couple of `clone` calls were inserted, but only on some paths, and the next commit will remove them.
2023-07-23more clippy::style fixes:Matthias Krüger-1/+1
get_first single_char_add_str unnecessary_mut_passed manual_map manual_is_ascii_check
2023-07-22Rollup merge of #112508 - compiler-errors:trait-sig-lifetime-sugg-ice, ↵Matthias Krüger-1/+6
r=cjgillot Tweak spans for self arg, fix borrow suggestion for signature mismatch 1. Adjust a suggestion message that was annoying me 2. Fix #112503 by recording the right spans for the `self` part of the `&self` 0th argument 3. Remove the suggestion for adjusting a trait signature on type mismatch, bc that's gonna probably break all the other impls of the trait even if it fixes its one usage :sweat_smile:
2023-07-12Flip cfg's for bootstrap bumpMark Rousskov-1/+1