rust/compiler/rustc_ast/src
León Orell Valerian Liehr b79d3b1ec1
Rollup merge of #134661 - dtolnay:prefixattr, r=fmease
Reduce precedence of expressions that have an outer attr

Previously, `-Zunpretty=expanded` would expand this program as follows:

```rust
#![feature(stmt_expr_attributes)]

macro_rules! repro {
    ($e:expr) => {
        #[allow(deprecated)] $e
    };
}

#[derive(Default)]
struct Thing {
    #[deprecated]
    field: i32,
}

fn main() {
    let thing = Thing::default();
    let _ = repro!(thing).field;
}
```

```rs
#![feature(prelude_import)]
#![feature(stmt_expr_attributes)]
#[prelude_import]
use std::prelude::rust_2021::*;
#[macro_use]
extern crate std;

struct Thing {
    #[deprecated]
    field: i32,
}

#[automatically_derived]
impl ::core::default::Default for Thing {
    #[inline]
    fn default() -> Thing {
        Thing { field: ::core::default::Default::default() }
    }
}

fn main() {
    let thing = Thing::default();
    let _ = #[allow(deprecated)] thing.field;
}
```

This is not the correct expansion. The correct output would have `(#[allow(deprecated)] thing).field` with the attribute applying only to `thing`, not to `thing.field`.
2025-06-15 23:51:54 +02:00
..
attr Reduce P<T> to a typedef of Box<T>. 2025-05-27 13:29:24 +10:00
expand Rollup merge of #139351 - EnzymeAD:autodiff-batching2, r=oli-obk 2025-04-17 21:53:23 +02:00
util Replace rustc_lexer/unescape with rustc-literal-escaper crate 2025-04-04 14:44:45 +02:00
ast.rs Reduce precedence of expressions that have an outer attr 2025-06-13 18:09:13 -07:00
ast_traits.rs remove visit_clobber and move DummyAstNode to rustc_expand 2025-05-29 12:46:26 +08:00
entry.rs remove support for the #[start] attribute 2025-01-21 06:59:15 -07:00
format.rs Limit formatting width and precision to 16 bits. 2025-03-10 12:20:05 +01:00
lib.rs introduce common macro for MutVisitor and Visitor to dedup code 2025-05-19 21:21:03 +08:00
mut_visit.rs deduplicate the rest of AST walker functions 2025-06-09 21:59:20 +08:00
node_id.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
ptr.rs Reduce P<T> to a typedef of Box<T>. 2025-05-27 13:29:24 +10:00
token.rs Remove token::{Open,Close}Delim. 2025-04-21 07:35:56 +10:00
tokenstream.rs remove eq_unspanned from TokenStream 2025-05-26 17:02:51 +08:00
visit.rs early linting: avoid redundant calls to check_id 2025-06-12 19:01:19 +08:00