about summary refs log tree commit diff
path: root/compiler/rustc_ast/src
AgeCommit message (Collapse)AuthorLines
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
2023-07-07Auto merge of #113270 - the8472:opt-macro-tts, r=nnethercotebors-3/+12
perform TokenStream replacement in-place when possible in expand_macro
2023-07-04Add effects during lowering for `~const` boundsDeadbeef-0/+9
2023-07-03Use Lrc::make_mut instead of Lrc::get_mutThe 8472-10/+4
2023-07-03perform TokenStream replacement in-place when possible in expand_macroThe 8472-3/+18
2023-06-28Adjust inner span of implicit self ref argumentMichael Goulet-1/+6
2023-06-19Syntatically accept `become` expressionsMaybe Waffle-1/+11
2023-06-01Remember names of `cfg`-ed out items to mention them in diagnosticsNilstrieb-0/+17
`#[cfg]`s are frequently used to gate crate content behind cargo features. This can lead to very confusing errors when features are missing. For example, `serde` doesn't have the `derive` feature by default. Therefore, `serde::Serialize` fails to resolve with a generic error, even though the macro is present in the docs. This commit adds a list of all stripped item names to metadata. This is filled during macro expansion and then, through a fed query, persisted in metadata. The downstream resolver can then access the metadata to look at possible candidates for mentioning in the errors. This slightly increases metadata (800k->809k for the feature-heavy windows crate), but not enough to really matter.
2023-05-27Add warn-by-default lint for local binding shadowing exported glob re-export ↵许杰友 Jieyou Xu (Joe)-0/+1
item
2023-05-25Auto merge of #86844 - bjorn3:global_alloc_improvements, r=pnkfelixbors-7/+15
Support #[global_allocator] without the allocator shim This makes it possible to use liballoc/libstd in combination with `--emit obj` if you use `#[global_allocator]`. This is what rust-for-linux uses right now and systemd may use in the future. Currently they have to depend on the exact implementation of the allocator shim to create one themself as `--emit obj` doesn't create an allocator shim. Note that currently the allocator shim also defines the oom error handler, which is normally required too. Once `#![feature(default_alloc_error_handler)]` becomes the only option, this can be avoided. In addition when using only fallible allocator methods and either `--cfg no_global_oom_handling` for liballoc (like rust-for-linux) or `--gc-sections` no references to the oom error handler will exist. To avoid this feature being insta-stable, you will have to define `__rust_no_alloc_shim_is_unstable` to avoid linker errors. (Labeling this with both T-compiler and T-lang as it originally involved both an implementation detail and had an insta-stable user facing change. As noted above, the `__rust_no_alloc_shim_is_unstable` symbol requirement should prevent unintended dependence on this unstable feature.)
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-8/+7
2023-05-13refactor: add chunks method to TokenStream to obviate rustdoc clonesCaleb Cartwright-0/+4
2023-05-13Auto merge of #107586 - SparrowLii:parallel-query, r=cjgillotbors-6/+7
Introduce `DynSend` and `DynSync` auto trait for parallel compiler part of parallel-rustc #101566 This PR introduces `DynSend / DynSync` trait and `FromDyn / IntoDyn` structure in rustc_data_structure::marker. `FromDyn` can dynamically check data structures for thread safety when switching to parallel environments (such as calling `par_for_each_in`). This happens only when `-Z threads > 1` so it doesn't affect single-threaded mode's compile efficiency. r? `@cjgillot`
2023-05-11Prevent insta-stable no alloc shim supportbjorn3-0/+2
You will need to add the following as replacement for the old __rust_* definitions when not using the alloc shim. #[no_mangle] static __rust_no_alloc_shim_is_unstable: u8 = 0;