Skip to content

Commit 6f97d99

Browse files
Auto merge of #145161 - Zalathar:rollup-uyqbw90, r=<try>
Rollup of 8 pull requests try-job: x86_64-msvc-ext1
2 parents ca77504 + ce531fb commit 6f97d99

File tree

104 files changed

+1145
-1162
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+1145
-1162
lines changed

compiler/rustc_ast/src/ast.rs

Lines changed: 165 additions & 166 deletions
Large diffs are not rendered by default.

compiler/rustc_ast/src/ast_traits.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use std::fmt;
66
use std::marker::PhantomData;
77

8-
use crate::ptr::P;
98
use crate::tokenstream::LazyAttrTokenStream;
109
use crate::{
1110
Arm, AssocItem, AttrItem, AttrKind, AttrVec, Attribute, Block, Crate, Expr, ExprField,
@@ -53,7 +52,7 @@ impl_has_node_id!(
5352
WherePredicate,
5453
);
5554

56-
impl<T: HasNodeId> HasNodeId for P<T> {
55+
impl<T: HasNodeId> HasNodeId for Box<T> {
5756
fn node_id(&self) -> NodeId {
5857
(**self).node_id()
5958
}
@@ -119,7 +118,7 @@ impl<T: HasTokens> HasTokens for Option<T> {
119118
}
120119
}
121120

122-
impl<T: HasTokens> HasTokens for P<T> {
121+
impl<T: HasTokens> HasTokens for Box<T> {
123122
fn tokens(&self) -> Option<&LazyAttrTokenStream> {
124123
(**self).tokens()
125124
}
@@ -245,7 +244,7 @@ impl_has_attrs!(
245244
);
246245
impl_has_attrs_none!(Attribute, AttrItem, Block, Pat, Path, Ty, Visibility);
247246

248-
impl<T: HasAttrs> HasAttrs for P<T> {
247+
impl<T: HasAttrs> HasAttrs for Box<T> {
249248
const SUPPORTS_CUSTOM_INNER_ATTRS: bool = T::SUPPORTS_CUSTOM_INNER_ATTRS;
250249
fn attrs(&self) -> &[Attribute] {
251250
(**self).attrs()
@@ -322,8 +321,8 @@ impl<Wrapped, Tag> AstNodeWrapper<Wrapped, Tag> {
322321
}
323322

324323
// FIXME: remove after `stmt_expr_attributes` is stabilized.
325-
impl<T, Tag> From<AstNodeWrapper<P<T>, Tag>> for AstNodeWrapper<T, Tag> {
326-
fn from(value: AstNodeWrapper<P<T>, Tag>) -> Self {
324+
impl<T, Tag> From<AstNodeWrapper<Box<T>, Tag>> for AstNodeWrapper<T, Tag> {
325+
fn from(value: AstNodeWrapper<Box<T>, Tag>) -> Self {
327326
AstNodeWrapper { wrapped: *value.wrapped, tag: value.tag }
328327
}
329328
}

compiler/rustc_ast/src/attr/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use crate::ast::{
1313
Expr, ExprKind, LitKind, MetaItem, MetaItemInner, MetaItemKind, MetaItemLit, NormalAttr, Path,
1414
PathSegment, Safety,
1515
};
16-
use crate::ptr::P;
1716
use crate::token::{self, CommentKind, Delimiter, InvisibleOrigin, MetaVarKind, Token};
1817
use crate::tokenstream::{
1918
DelimSpan, LazyAttrTokenStream, Spacing, TokenStream, TokenStreamIter, TokenTree,
@@ -660,7 +659,7 @@ pub fn mk_attr_from_item(
660659
span: Span,
661660
) -> Attribute {
662661
Attribute {
663-
kind: AttrKind::Normal(P(NormalAttr { item, tokens })),
662+
kind: AttrKind::Normal(Box::new(NormalAttr { item, tokens })),
664663
id: g.mk_attr_id(),
665664
style,
666665
span,
@@ -710,7 +709,7 @@ pub fn mk_attr_name_value_str(
710709
span: Span,
711710
) -> Attribute {
712711
let lit = token::Lit::new(token::Str, escape_string_symbol(val), None);
713-
let expr = P(Expr {
712+
let expr = Box::new(Expr {
714713
id: DUMMY_NODE_ID,
715714
kind: ExprKind::Lit(lit),
716715
span,

compiler/rustc_ast/src/expand/autodiff_attrs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ use std::fmt::{self, Display, Formatter};
77
use std::str::FromStr;
88

99
use crate::expand::{Decodable, Encodable, HashStable_Generic};
10-
use crate::ptr::P;
1110
use crate::{Ty, TyKind};
1211

1312
/// Forward and Reverse Mode are well known names for automatic differentiation implementations.
@@ -162,7 +161,7 @@ pub fn valid_ret_activity(mode: DiffMode, activity: DiffActivity) -> bool {
162161
/// since Duplicated expects a mutable ref/ptr and we would thus end up with a shadow value
163162
/// who is an indirect type, which doesn't match the primal scalar type. We can't prevent
164163
/// users here from marking scalars as Duplicated, due to type aliases.
165-
pub fn valid_ty_for_activity(ty: &P<Ty>, activity: DiffActivity) -> bool {
164+
pub fn valid_ty_for_activity(ty: &Box<Ty>, activity: DiffActivity) -> bool {
166165
use DiffActivity::*;
167166
// It's always allowed to mark something as Const, since we won't compute derivatives wrt. it.
168167
// Dual variants also support all types.

compiler/rustc_ast/src/format.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use rustc_macros::{Decodable, Encodable, Walkable};
33
use rustc_span::{Ident, Span, Symbol};
44

55
use crate::Expr;
6-
use crate::ptr::P;
76
use crate::token::LitKind;
87

98
// Definitions:
@@ -147,7 +146,7 @@ impl FormatArguments {
147146
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
148147
pub struct FormatArgument {
149148
pub kind: FormatArgumentKind,
150-
pub expr: P<Expr>,
149+
pub expr: Box<Expr>,
151150
}
152151

153152
#[derive(Clone, Encodable, Decodable, Debug, Walkable)]

compiler/rustc_ast/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ pub mod expand;
3737
pub mod format;
3838
pub mod mut_visit;
3939
pub mod node_id;
40-
pub mod ptr;
4140
pub mod token;
4241
pub mod tokenstream;
4342
pub mod visit;

compiler/rustc_ast/src/mut_visit.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use smallvec::{SmallVec, smallvec};
1717
use thin_vec::ThinVec;
1818

1919
use crate::ast::*;
20-
use crate::ptr::P;
2120
use crate::tokenstream::*;
2221
use crate::visit::{AssocCtxt, BoundKind, FnCtxt, LifetimeCtxt, VisitorResult, try_visit};
2322

@@ -41,7 +40,7 @@ pub(crate) trait MutVisitable<V: MutVisitor> {
4140
fn visit_mut(&mut self, visitor: &mut V, extra: Self::Extra);
4241
}
4342

44-
impl<V: MutVisitor, T: ?Sized> MutVisitable<V> for P<T>
43+
impl<V: MutVisitor, T: ?Sized> MutVisitable<V> for Box<T>
4544
where
4645
T: MutVisitable<V>,
4746
{
@@ -293,15 +292,15 @@ macro_rules! generate_flat_map_visitor_fns {
293292
}
294293

295294
generate_flat_map_visitor_fns! {
296-
visit_items, P<Item>, flat_map_item;
297-
visit_foreign_items, P<ForeignItem>, flat_map_foreign_item;
295+
visit_items, Box<Item>, flat_map_item;
296+
visit_foreign_items, Box<ForeignItem>, flat_map_foreign_item;
298297
visit_generic_params, GenericParam, flat_map_generic_param;
299298
visit_stmts, Stmt, flat_map_stmt;
300-
visit_exprs, P<Expr>, filter_map_expr;
299+
visit_exprs, Box<Expr>, filter_map_expr;
301300
visit_expr_fields, ExprField, flat_map_expr_field;
302301
visit_pat_fields, PatField, flat_map_pat_field;
303302
visit_variants, Variant, flat_map_variant;
304-
visit_assoc_items, P<AssocItem>, flat_map_assoc_item, ctxt: AssocCtxt;
303+
visit_assoc_items, Box<AssocItem>, flat_map_assoc_item, ctxt: AssocCtxt;
305304
visit_where_predicates, WherePredicate, flat_map_where_predicate;
306305
visit_params, Param, flat_map_param;
307306
visit_field_defs, FieldDef, flat_map_field_def;
@@ -333,12 +332,12 @@ generate_walk_flat_map_fns! {
333332
walk_flat_map_where_predicate(WherePredicate) => visit_where_predicate;
334333
walk_flat_map_field_def(FieldDef) => visit_field_def;
335334
walk_flat_map_expr_field(ExprField) => visit_expr_field;
336-
walk_flat_map_item(P<Item>) => visit_item;
337-
walk_flat_map_foreign_item(P<ForeignItem>) => visit_foreign_item;
338-
walk_flat_map_assoc_item(P<AssocItem>, ctxt: AssocCtxt) => visit_assoc_item;
335+
walk_flat_map_item(Box<Item>) => visit_item;
336+
walk_flat_map_foreign_item(Box<ForeignItem>) => visit_foreign_item;
337+
walk_flat_map_assoc_item(Box<AssocItem>, ctxt: AssocCtxt) => visit_assoc_item;
339338
}
340339

341-
pub fn walk_filter_map_expr<T: MutVisitor>(vis: &mut T, mut e: P<Expr>) -> Option<P<Expr>> {
340+
pub fn walk_filter_map_expr<T: MutVisitor>(vis: &mut T, mut e: Box<Expr>) -> Option<Box<Expr>> {
342341
vis.visit_expr(&mut e);
343342
Some(e)
344343
}

compiler/rustc_ast/src/ptr.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.

compiler/rustc_ast/src/visit.rs

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use rustc_span::{Ident, Span, Symbol};
2020
use thin_vec::ThinVec;
2121

2222
use crate::ast::*;
23-
use crate::ptr::P;
2423
use crate::tokenstream::DelimSpan;
2524

2625
#[derive(Copy, Clone, Debug, PartialEq)]
@@ -82,7 +81,7 @@ pub(crate) trait Visitable<'a, V: Visitor<'a>> {
8281
fn visit(&'a self, visitor: &mut V, extra: Self::Extra) -> V::Result;
8382
}
8483

85-
impl<'a, V: Visitor<'a>, T: ?Sized> Visitable<'a, V> for P<T>
84+
impl<'a, V: Visitor<'a>, T: ?Sized> Visitable<'a, V> for Box<T>
8685
where
8786
T: Visitable<'a, V>,
8887
{
@@ -322,7 +321,7 @@ macro_rules! common_visitor_and_walkers {
322321
Fn(FnCtxt, &'a $($mut)? Visibility, &'a $($mut)? Fn),
323322

324323
/// E.g., `|x, y| body`.
325-
Closure(&'a $($mut)? ClosureBinder, &'a $($mut)? Option<CoroutineKind>, &'a $($mut)? P<FnDecl>, &'a $($mut)? P<Expr>),
324+
Closure(&'a $($mut)? ClosureBinder, &'a $($mut)? Option<CoroutineKind>, &'a $($mut)? Box<FnDecl>, &'a $($mut)? Box<Expr>),
326325
}
327326

328327
impl<'a> FnKind<'a> {
@@ -390,9 +389,9 @@ macro_rules! common_visitor_and_walkers {
390389
ThinVec<(NodeId, Path)>,
391390
ThinVec<PathSegment>,
392391
ThinVec<PreciseCapturingArg>,
393-
ThinVec<P<Pat>>,
394-
ThinVec<P<Ty>>,
395-
ThinVec<P<TyPat>>,
392+
ThinVec<Box<Pat>>,
393+
ThinVec<Box<Ty>>,
394+
ThinVec<Box<TyPat>>,
396395
);
397396

398397
// This macro generates `impl Visitable` and `impl MutVisitable` that forward to `Walkable`
@@ -676,11 +675,11 @@ macro_rules! common_visitor_and_walkers {
676675
// Do nothing.
677676
}
678677

679-
fn flat_map_foreign_item(&mut self, ni: P<ForeignItem>) -> SmallVec<[P<ForeignItem>; 1]> {
678+
fn flat_map_foreign_item(&mut self, ni: Box<ForeignItem>) -> SmallVec<[Box<ForeignItem>; 1]> {
680679
walk_flat_map_foreign_item(self, ni)
681680
}
682681

683-
fn flat_map_item(&mut self, i: P<Item>) -> SmallVec<[P<Item>; 1]> {
682+
fn flat_map_item(&mut self, i: Box<Item>) -> SmallVec<[Box<Item>; 1]> {
684683
walk_flat_map_item(self, i)
685684
}
686685

@@ -690,9 +689,9 @@ macro_rules! common_visitor_and_walkers {
690689

691690
fn flat_map_assoc_item(
692691
&mut self,
693-
i: P<AssocItem>,
692+
i: Box<AssocItem>,
694693
ctxt: AssocCtxt,
695-
) -> SmallVec<[P<AssocItem>; 1]> {
694+
) -> SmallVec<[Box<AssocItem>; 1]> {
696695
walk_flat_map_assoc_item(self, i, ctxt)
697696
}
698697

@@ -704,7 +703,7 @@ macro_rules! common_visitor_and_walkers {
704703
walk_flat_map_arm(self, arm)
705704
}
706705

707-
fn filter_map_expr(&mut self, e: P<Expr>) -> Option<P<Expr>> {
706+
fn filter_map_expr(&mut self, e: Box<Expr>) -> Option<Box<Expr>> {
708707
walk_filter_map_expr(self, e)
709708
}
710709

@@ -1144,15 +1143,15 @@ macro_rules! generate_list_visit_fns {
11441143
}
11451144

11461145
generate_list_visit_fns! {
1147-
visit_items, P<Item>, visit_item;
1148-
visit_foreign_items, P<ForeignItem>, visit_foreign_item;
1146+
visit_items, Box<Item>, visit_item;
1147+
visit_foreign_items, Box<ForeignItem>, visit_foreign_item;
11491148
visit_generic_params, GenericParam, visit_generic_param;
11501149
visit_stmts, Stmt, visit_stmt;
1151-
visit_exprs, P<Expr>, visit_expr;
1150+
visit_exprs, Box<Expr>, visit_expr;
11521151
visit_expr_fields, ExprField, visit_expr_field;
11531152
visit_pat_fields, PatField, visit_pat_field;
11541153
visit_variants, Variant, visit_variant;
1155-
visit_assoc_items, P<AssocItem>, visit_assoc_item, ctxt: AssocCtxt;
1154+
visit_assoc_items, Box<AssocItem>, visit_assoc_item, ctxt: AssocCtxt;
11561155
visit_where_predicates, WherePredicate, visit_where_predicate;
11571156
visit_params, Param, visit_param;
11581157
visit_field_defs, FieldDef, visit_field_def;

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::ops::ControlFlow;
22
use std::sync::Arc;
33

4-
use rustc_ast::ptr::P as AstP;
54
use rustc_ast::*;
65
use rustc_ast_pretty::pprust::expr_to_string;
76
use rustc_data_structures::stack::ensure_sufficient_stack;
@@ -53,7 +52,7 @@ impl<'v> rustc_ast::visit::Visitor<'v> for WillCreateDefIdsVisitor {
5352
}
5453

5554
impl<'hir> LoweringContext<'_, 'hir> {
56-
fn lower_exprs(&mut self, exprs: &[AstP<Expr>]) -> &'hir [hir::Expr<'hir>] {
55+
fn lower_exprs(&mut self, exprs: &[Box<Expr>]) -> &'hir [hir::Expr<'hir>] {
5756
self.arena.alloc_from_iter(exprs.iter().map(|x| self.lower_expr_mut(x)))
5857
}
5958

@@ -455,7 +454,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
455454
fn lower_legacy_const_generics(
456455
&mut self,
457456
mut f: Expr,
458-
args: ThinVec<AstP<Expr>>,
457+
args: ThinVec<Box<Expr>>,
459458
legacy_args_idx: &[usize],
460459
) -> hir::ExprKind<'hir> {
461460
let ExprKind::Path(None, path) = &mut f.kind else {
@@ -495,7 +494,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
495494
self.create_def(node_id, None, DefKind::AnonConst, f.span);
496495
let mut visitor = WillCreateDefIdsVisitor {};
497496
let const_value = if let ControlFlow::Break(span) = visitor.visit_expr(&arg) {
498-
AstP(Expr {
497+
Box::new(Expr {
499498
id: self.next_node_id(),
500499
kind: ExprKind::Err(invalid_expr_error(self.tcx, span)),
501500
span: f.span,
@@ -516,7 +515,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
516515
// Add generic args to the last element of the path.
517516
let last_segment = path.segments.last_mut().unwrap();
518517
assert!(last_segment.args.is_none());
519-
last_segment.args = Some(AstP(GenericArgs::AngleBracketed(AngleBracketedArgs {
518+
last_segment.args = Some(Box::new(GenericArgs::AngleBracketed(AngleBracketedArgs {
520519
span: DUMMY_SP,
521520
args: generic_args,
522521
})));
@@ -812,7 +811,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
812811
self.lower_attrs(
813812
inner_hir_id,
814813
&[Attribute {
815-
kind: AttrKind::Normal(ptr::P(NormalAttr::from_ident(Ident::new(
814+
kind: AttrKind::Normal(Box::new(NormalAttr::from_ident(Ident::new(
816815
sym::track_caller,
817816
span,
818817
)))),
@@ -1285,7 +1284,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
12851284
fn extract_tuple_struct_path<'a>(
12861285
&mut self,
12871286
expr: &'a Expr,
1288-
) -> Option<(&'a Option<AstP<QSelf>>, &'a Path)> {
1287+
) -> Option<(&'a Option<Box<QSelf>>, &'a Path)> {
12891288
if let ExprKind::Path(qself, path) = &expr.kind {
12901289
// Does the path resolve to something disallowed in a tuple struct/variant pattern?
12911290
if let Some(partial_res) = self.resolver.get_partial_res(expr.id) {
@@ -1307,7 +1306,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13071306
fn extract_unit_struct_path<'a>(
13081307
&mut self,
13091308
expr: &'a Expr,
1310-
) -> Option<(&'a Option<AstP<QSelf>>, &'a Path)> {
1309+
) -> Option<(&'a Option<Box<QSelf>>, &'a Path)> {
13111310
if let ExprKind::Path(qself, path) = &expr.kind {
13121311
// Does the path resolve to something disallowed in a unit struct/variant pattern?
13131312
if let Some(partial_res) = self.resolver.get_partial_res(expr.id) {
@@ -1478,7 +1477,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
14781477
/// Each sub-assignment is recorded in `assignments`.
14791478
fn destructure_sequence(
14801479
&mut self,
1481-
elements: &[AstP<Expr>],
1480+
elements: &[Box<Expr>],
14821481
ctx: &str,
14831482
eq_sign_span: Span,
14841483
assignments: &mut Vec<hir::Stmt<'hir>>,

0 commit comments

Comments
 (0)