about summary refs log tree commit diff
path: root/compiler/rustc_ast
AgeCommit message (Collapse)AuthorLines
2024-04-25ast: Visit item components in "natural" orderVadim Petrochenkov-4/+4
2024-04-25ast: Generalize item kind visitingVadim Petrochenkov-311/+341
And avoid duplicating logic for visiting `Item`s with different kinds (regular, associated, foreign).
2024-04-25Rollup merge of #124324 - nnethercote:minor-ast-cleanups, r=estebankMatthias Krüger-78/+71
Minor AST cleanups r? ``@estebank``
2024-04-25Add comments about attribute tokens.Nicholas Nethercote-0/+2
This clarifies something that has puzzled me for some time.
2024-04-24Remove unnecessary `pub`s in `mut_visit.rs`.Nicholas Nethercote-65/+60
This makes it clearer what is actually used outside of this crate.
2024-04-24Rename `NestedMetaItem::name_value_literal`.Nicholas Nethercote-2/+3
It's a highly misleading name, because it's completely different to `MetaItem::name_value_literal`. Specifically, it doesn't match `MetaItemKind::NameValue` (e.g. `#[foo = 3]`), it matches `MetaItemKind::List` (e.g. `#[foo(3)]`).
2024-04-24Remove `MetaItemKind::value_str`.Nicholas Nethercote-8/+4
`MetaItem::value_str` is good enough. And this makes `MetaItem::value_str` more like `MetaItem::meta_item_list` and `name_value_literal`.
2024-04-24Make `LazyAttrTokenStream::encode` panic.Nicholas Nethercote-3/+2
It's unreachable, because AST JSON printing support was removed some time ago.
2024-04-23delegation: Support renamingVadim Petrochenkov-4/+13
2024-04-18Auto merge of #124008 - nnethercote:simpler-static_assert_size, r=Nilstriebbors-3/+3
Simplify `static_assert_size`s. We want to run them on all 64-bit platforms. r? `@ghost`
2024-04-18Simplify `static_assert_size`s.Nicholas Nethercote-3/+3
We want to run them on all 64-bit platforms.
2024-04-17Improve `BindingMode` doc commentJules Bertholet-2/+4
2024-04-17Rename `BindingAnnotation` to `BindingMode`Jules Bertholet-10/+10
2024-04-17Store `ByRef` instead of `BindingAnnotation` in `PatInfo`Jules Bertholet-7/+9
2024-04-16Fix empty-set symbol in commentsDavid Tolnay-1/+1
2024-04-16Rollup merge of #123512 - Jules-Bertholet:ref-pat-eat-one-layer-2024, ↵Guillaume Gomez-0/+8
r=Nadrieril Match ergonomics 2024: Implement eat-one-layer r? `@Nadrieril` cc #123076 `@rustbot` label A-edition-2024 A-patterns
2024-04-16Auto merge of #123468 - compiler-errors:precise-capturing, r=oli-obkbors-4/+55
Implement syntax for `impl Trait` to specify its captures explicitly (`feature(precise_capturing)`) Implements `impl use<'a, 'b, T, U> Sized` syntax that allows users to explicitly list the captured parameters for an opaque, rather than inferring it from the opaque's bounds (or capturing *all* lifetimes under 2024-edition capture rules). This allows us to exclude some implicit captures, so this syntax may be used as a migration strategy for changes due to #117587. We represent this list of captured params as `PreciseCapturingArg` in AST and HIR, resolving them between `rustc_resolve` and `resolve_bound_vars`. Later on, we validate that the opaques only capture the parameters in this list. We artificially limit the feature to *require* mentioning all type and const parameters, since we don't currently have support for non-lifetime bivariant generics. This can be relaxed in the future. We also may need to limit this to require naming *all* lifetime parameters for RPITIT, since GATs have no variance. I have to investigate this. This can also be relaxed in the future. r? `@oli-obk` Tracking issue: - https://github.com/rust-lang/rust/issues/123432
2024-04-15Address review commentsJules Bertholet-2/+2
2024-04-15Ensure inherited reference is never set to `&mut` behind an `&`Jules Bertholet-0/+8
2024-04-16Rollup merge of #123462 - fmease:rn-mod-sep-to-path-sep, r=nnethercoteLeón Orell Valerian Liehr-12/+14
Cleanup: Rename `ModSep` to `PathSep` `::` is usually referred to as the *path separator* (citation needed). The existing name `ModSep` for *module separator* is a bit misleading since it in fact separates the segments of arbitrary path segments, not only ones resolving to modules. Let me just give a shout-out to associated items (`T::Assoc`, `<Ty as Trait>::function`) and enum variants (`Option::None`). Motivation: Reduce friction for new contributors, prevent potential confusion. cc `@petrochenkov` r? nnethercote or compiler
2024-04-15Use a path instead of an ident (and stop manually resolving)Michael Goulet-6/+6
2024-04-15Validation and other thingsMichael Goulet-4/+4
2024-04-15Lower and resolve precise captures in HIRMichael Goulet-29/+9
2024-04-15Use dedicated PreciseCapturingArg for representing what goes in use<>Michael Goulet-3/+70
2024-04-15Parsing , pre-lowering support for precise capturesMichael Goulet-3/+7
2024-04-11Deduplicate `is_comparison` impl between `BinOpKind` and `AssocOp`Oli Scherer-8/+2
2024-04-08Actually create ranged int types in the type system.Oli Scherer-1/+1
2024-04-08Add pattern types to astOli Scherer-0/+11
2024-04-04Rename ModSep to PathSepLeón Orell Valerian Liehr-12/+14
2024-04-04Rollup merge of #123397 - krtab:foreign_fn_qualif_diag, r=petrochenkovMatthias Krüger-0/+8
Fix diagnostic for qualifier in extern block Closes: https://github.com/rust-lang/rust/issues/123306
2024-04-04Fix diagnostic for qualifier in extern blockArthur Carcano-0/+8
Closes: https://github.com/rust-lang/rust/issues/123306
2024-04-03Rollup merge of #123401 - Zalathar:assert-size-aarch64, r=fmeaseJacob Pratt-3/+3
Check `x86_64` size assertions on `aarch64`, too (Context: https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Checking.20size.20assertions.20on.20aarch64.3F) Currently the compiler has around 30 sets of `static_assert_size!` for various size-critical data structures (e.g. various IR nodes), guarded by `#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]`. (Presumably this cfg avoids having to maintain separate size values for 32-bit targets and unusual 64-bit targets. Apparently it may have been necessary before the i128/u128 alignment changes, too.) This is slightly incovenient for people on aarch64 workstations (e.g. Macs), because the assertions normally aren't checked until we push to a PR. So this PR adds `aarch64` to the `#[cfg(..)]` guarding all of those assertions in the compiler. --- Implemented with a simple find/replace. Verified by manually inspecting each `static_assert_size!` in `compiler/`, and checking that either the replacement succeeded, or adding aarch64 wouldn't have been appropriate.
2024-04-03Rollup merge of #123395 - compiler-errors:postfix-matches-fixes-2, ↵Matthias Krüger-3/+7
r=petrochenkov More postfix match fixes These affect diagnostics only, as far as I can tell. I'm too lazy to come up with UI tests, but I could be convinced otherwise. Specifically, I think changing the precedence computation actually doesn't change anything, but tweaking `contains_exterior_struct_lit` does mean that some diagnostics will begin parenthesizing `S {}.match {}`.
2024-04-03rustc_ast: Update `P<T>` docs to reflect mutable status.Alona Enraght-Moony-9/+7
`P<T>` has implemented `DerefMut` since #54277. While this was lamented at the time [1], rustc now relies on it extensively via the many implementors of MutVisitor [2]. Updates the docs to reflect that `P<T>` is fundamentally mutable, and a few other cleanups to make them nicer to browse. [1]: https://github.com/rust-lang/rust/pull/54277#discussion_r257181754 [2]: https://doc.rust-lang.org/1.77.1/nightly-rustc/rustc_ast/mut_visit/trait.MutVisitor.html#implementors
2024-04-03Check `x86_64` size assertions on `aarch64`, tooZalathar-3/+3
This makes it easier for contributors on aarch64 workstations (e.g. Macs) to notice when these assertions have been violated.
2024-04-02Fix contains_exterior_struct_litMichael Goulet-1/+2
2024-04-02Fix precedence of postfix matchMichael Goulet-2/+5
2024-03-27Implement `mut ref`/`mut ref mut`Jules Bertholet-12/+7
2024-03-22Auto merge of #122869 - matthiaskrgr:rollup-0navj4l, r=matthiaskrgrbors-3/+12
Rollup of 9 pull requests Successful merges: - #121619 (Experimental feature postfix match) - #122370 (Gracefully handle `AnonConst` in `diagnostic_hir_wf_check()`) - #122537 (interpret/allocation: fix aliasing issue in interpreter and refactor getters a bit) - #122542 (coverage: Clean up marker statements that aren't needed later) - #122800 (Add `NonNull::<[T]>::is_empty`.) - #122820 (Stop using `<DefId as Ord>` in various diagnostic situations) - #122847 (Suggest `RUST_MIN_STACK` workaround on overflow) - #122855 (Fix Itanium mangling usizes) - #122863 (add more ice tests ) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-22Rollup merge of #121619 - RossSmyth:pfix_match, r=petrochenkovMatthias Krüger-3/+12
Experimental feature postfix match This has a basic experimental implementation for the RFC postfix match (rust-lang/rfcs#3295, #121618). [Liaison is](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Postfix.20Match.20Liaison/near/423301844) ```@scottmcm``` with the lang team's [experimental feature gate process](https://github.com/rust-lang/lang-team/blob/master/src/how_to/experiment.md). This feature has had an RFC for a while, and there has been discussion on it for a while. It would probably be valuable to see it out in the field rather than continue discussing it. This feature also allows to see how popular postfix expressions like this are for the postfix macros RFC, as those will take more time to implement. It is entirely implemented in the parser, so it should be relatively easy to remove if needed. This PR is split in to 5 commits to ease review. 1. The implementation of the feature & gating. 2. Add a MatchKind field, fix uses, fix pretty. 3. Basic rustfmt impl, as rustfmt crashes upon seeing this syntax without a fix. 4. Add new MatchSource to HIR for Clippy & other HIR consumers
2024-03-22Update (doc) commentsLeón Orell Valerian Liehr-5/+1
Several (doc) comments were super outdated or didn't provide enough context. Some doc comments shoved everything in a single paragraph without respecting the fact that the first paragraph should be a single sentence because rustdoc treats these as item descriptions / synopses on module pages.
2024-03-21Rollup merge of #122793 - compiler-errors:deref-pat-syntax, r=NadrierilMatthias Krüger-2/+11
Implement macro-based deref!() syntax for deref patterns Stop using `box PAT` syntax for deref patterns, and instead use a perma-unstable macro. Blocked on #122222 r? `@Nadrieril`
2024-03-21Implement macro-based deref!() syntax for deref patternsMichael Goulet-2/+11
Stop using `box PAT` syntax for deref patterns, as it's misleading and also causes their semantics being tangled up.
2024-03-21Shrink the comment on `TokenTree`.Nicholas Nethercote-12/+1
It uses very old language that is more confusing today than helpful, including references to `SubstNt` that no longer exists. The comment above `TokenStream` is better, and suffices for a basic understanding of these types.
2024-03-21Fix out-of-date comment.Nicholas Nethercote-1/+1
2024-03-21Rename `Token::is_path`.Nicholas Nethercote-2/+2
This makes it consistent with `is_whole_expr` and `is_whole_block`.
2024-03-20Auto merge of #122754 - Mark-Simulacrum:bootstrap-bump, r=albertlarsan68bors-1/+0
Bump to 1.78 bootstrap compiler https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-03-20step cfgsMark Rousskov-1/+0
2024-03-20Rollup merge of #121543 - onur-ozkan:clippy-args, r=oli-obkMatthias Krüger-0/+1
various clippy fixes We need to keep the order of the given clippy lint rules before passing them. Since clap doesn't offer any useful interface for this purpose out of the box, we have to handle it manually. Additionally, this PR makes `-D` rules work as expected. Previously, lint rules were limited to `-W`. By enabling `-D`, clippy began to complain numerous lines in the tree, all of which have been resolved in this PR as well. Fixes #121481 cc `@matthiaskrgr`
2024-03-20resolve clippy errorsonur-ozkan-0/+1
Signed-off-by: onur-ozkan <work@onurozkan.dev>