Skip to content

Commit 1cbc459

Browse files
committed
Auto merge of rust-lang#104673 - matthiaskrgr:rollup-85f65ov, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#104420 (Fix doc example for `wrapping_abs`) - rust-lang#104499 (rustdoc JSON: Use `Function` everywhere and remove `Method`) - rust-lang#104500 (`rustc_ast`: remove `ref` patterns) - rust-lang#104511 (Mark functions created for `raw-dylib` on x86 with DllImport storage class) - rust-lang#104595 (Add `PolyExistentialPredicate` type alias) - rust-lang#104605 (deduplicate constant evaluation in cranelift backend) - rust-lang#104628 (Revert "Update CI to use Android NDK r25b") - rust-lang#104662 (Streamline deriving on packed structs.) - rust-lang#104667 (Revert formatting changes of a test) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7fe6f36 + 9326261 commit 1cbc459

File tree

49 files changed

+415
-499
lines changed

Some content is hidden

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

49 files changed

+415
-499
lines changed

compiler/rustc_ast/src/ast.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ impl GenericArgs {
175175
}
176176

177177
pub fn span(&self) -> Span {
178-
match *self {
179-
AngleBracketed(ref data) => data.span,
180-
Parenthesized(ref data) => data.span,
178+
match self {
179+
AngleBracketed(data) => data.span,
180+
Parenthesized(data) => data.span,
181181
}
182182
}
183183
}
@@ -312,8 +312,8 @@ pub enum GenericBound {
312312
impl GenericBound {
313313
pub fn span(&self) -> Span {
314314
match self {
315-
GenericBound::Trait(ref t, ..) => t.span,
316-
GenericBound::Outlives(ref l) => l.ident.span,
315+
GenericBound::Trait(t, ..) => t.span,
316+
GenericBound::Outlives(l) => l.ident.span,
317317
}
318318
}
319319
}
@@ -1115,23 +1115,23 @@ impl Expr {
11151115
/// If this is not the case, name resolution does not resolve `N` when using
11161116
/// `min_const_generics` as more complex expressions are not supported.
11171117
pub fn is_potential_trivial_const_param(&self) -> bool {
1118-
let this = if let ExprKind::Block(ref block, None) = self.kind {
1119-
if block.stmts.len() == 1 {
1120-
if let StmtKind::Expr(ref expr) = block.stmts[0].kind { expr } else { self }
1121-
} else {
1122-
self
1123-
}
1118+
let this = if let ExprKind::Block(block, None) = &self.kind
1119+
&& block.stmts.len() == 1
1120+
&& let StmtKind::Expr(expr) = &block.stmts[0].kind
1121+
{
1122+
expr
11241123
} else {
11251124
self
11261125
};
11271126

1128-
if let ExprKind::Path(None, ref path) = this.kind {
1129-
if path.segments.len() == 1 && path.segments[0].args.is_none() {
1130-
return true;
1131-
}
1127+
if let ExprKind::Path(None, path) = &this.kind
1128+
&& path.segments.len() == 1
1129+
&& path.segments[0].args.is_none()
1130+
{
1131+
true
1132+
} else {
1133+
false
11321134
}
1133-
1134-
false
11351135
}
11361136

11371137
pub fn to_bound(&self) -> Option<GenericBound> {
@@ -2393,9 +2393,9 @@ pub enum FnRetTy {
23932393

23942394
impl FnRetTy {
23952395
pub fn span(&self) -> Span {
2396-
match *self {
2397-
FnRetTy::Default(span) => span,
2398-
FnRetTy::Ty(ref ty) => ty.span,
2396+
match self {
2397+
&FnRetTy::Default(span) => span,
2398+
FnRetTy::Ty(ty) => ty.span,
23992399
}
24002400
}
24012401
}
@@ -2657,8 +2657,8 @@ pub enum VariantData {
26572657
impl VariantData {
26582658
/// Return the fields of this variant.
26592659
pub fn fields(&self) -> &[FieldDef] {
2660-
match *self {
2661-
VariantData::Struct(ref fields, ..) | VariantData::Tuple(ref fields, _) => fields,
2660+
match self {
2661+
VariantData::Struct(fields, ..) | VariantData::Tuple(fields, _) => fields,
26622662
_ => &[],
26632663
}
26642664
}

compiler/rustc_ast/src/attr/mod.rs

+44-46
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,16 @@ impl MarkedAttrs {
4444
impl NestedMetaItem {
4545
/// Returns the `MetaItem` if `self` is a `NestedMetaItem::MetaItem`.
4646
pub fn meta_item(&self) -> Option<&MetaItem> {
47-
match *self {
48-
NestedMetaItem::MetaItem(ref item) => Some(item),
47+
match self {
48+
NestedMetaItem::MetaItem(item) => Some(item),
4949
_ => None,
5050
}
5151
}
5252

5353
/// Returns the `Lit` if `self` is a `NestedMetaItem::Literal`s.
5454
pub fn literal(&self) -> Option<&Lit> {
55-
match *self {
56-
NestedMetaItem::Literal(ref lit) => Some(lit),
55+
match self {
56+
NestedMetaItem::Literal(lit) => Some(lit),
5757
_ => None,
5858
}
5959
}
@@ -116,18 +116,18 @@ impl NestedMetaItem {
116116
impl Attribute {
117117
#[inline]
118118
pub fn has_name(&self, name: Symbol) -> bool {
119-
match self.kind {
120-
AttrKind::Normal(ref normal) => normal.item.path == name,
119+
match &self.kind {
120+
AttrKind::Normal(normal) => normal.item.path == name,
121121
AttrKind::DocComment(..) => false,
122122
}
123123
}
124124

125125
/// For a single-segment attribute, returns its name; otherwise, returns `None`.
126126
pub fn ident(&self) -> Option<Ident> {
127-
match self.kind {
128-
AttrKind::Normal(ref normal) => {
129-
if normal.item.path.segments.len() == 1 {
130-
Some(normal.item.path.segments[0].ident)
127+
match &self.kind {
128+
AttrKind::Normal(normal) => {
129+
if let [ident] = &*normal.item.path.segments {
130+
Some(ident.ident)
131131
} else {
132132
None
133133
}
@@ -140,17 +140,15 @@ impl Attribute {
140140
}
141141

142142
pub fn value_str(&self) -> Option<Symbol> {
143-
match self.kind {
144-
AttrKind::Normal(ref normal) => {
145-
normal.item.meta_kind().and_then(|kind| kind.value_str())
146-
}
143+
match &self.kind {
144+
AttrKind::Normal(normal) => normal.item.meta_kind().and_then(|kind| kind.value_str()),
147145
AttrKind::DocComment(..) => None,
148146
}
149147
}
150148

151149
pub fn meta_item_list(&self) -> Option<Vec<NestedMetaItem>> {
152-
match self.kind {
153-
AttrKind::Normal(ref normal) => match normal.item.meta_kind() {
150+
match &self.kind {
151+
AttrKind::Normal(normal) => match normal.item.meta_kind() {
154152
Some(MetaItemKind::List(list)) => Some(list),
155153
_ => None,
156154
},
@@ -191,8 +189,8 @@ impl MetaItem {
191189
}
192190

193191
pub fn meta_item_list(&self) -> Option<&[NestedMetaItem]> {
194-
match self.kind {
195-
MetaItemKind::List(ref l) => Some(&l[..]),
192+
match &self.kind {
193+
MetaItemKind::List(l) => Some(&**l),
196194
_ => None,
197195
}
198196
}
@@ -268,9 +266,9 @@ impl Attribute {
268266
/// * `#[doc = "doc"]` returns `Some("doc")`.
269267
/// * `#[doc(...)]` returns `None`.
270268
pub fn doc_str(&self) -> Option<Symbol> {
271-
match self.kind {
272-
AttrKind::DocComment(.., data) => Some(data),
273-
AttrKind::Normal(ref normal) if normal.item.path == sym::doc => {
269+
match &self.kind {
270+
AttrKind::DocComment(.., data) => Some(*data),
271+
AttrKind::Normal(normal) if normal.item.path == sym::doc => {
274272
normal.item.meta_kind().and_then(|kind| kind.value_str())
275273
}
276274
_ => None,
@@ -282,8 +280,8 @@ impl Attribute {
282280
}
283281

284282
pub fn get_normal_item(&self) -> &AttrItem {
285-
match self.kind {
286-
AttrKind::Normal(ref normal) => &normal.item,
283+
match &self.kind {
284+
AttrKind::Normal(normal) => &normal.item,
287285
AttrKind::DocComment(..) => panic!("unexpected doc comment"),
288286
}
289287
}
@@ -297,28 +295,28 @@ impl Attribute {
297295

298296
/// Extracts the MetaItem from inside this Attribute.
299297
pub fn meta(&self) -> Option<MetaItem> {
300-
match self.kind {
301-
AttrKind::Normal(ref normal) => normal.item.meta(self.span),
298+
match &self.kind {
299+
AttrKind::Normal(normal) => normal.item.meta(self.span),
302300
AttrKind::DocComment(..) => None,
303301
}
304302
}
305303

306304
pub fn meta_kind(&self) -> Option<MetaItemKind> {
307-
match self.kind {
308-
AttrKind::Normal(ref normal) => normal.item.meta_kind(),
305+
match &self.kind {
306+
AttrKind::Normal(normal) => normal.item.meta_kind(),
309307
AttrKind::DocComment(..) => None,
310308
}
311309
}
312310

313311
pub fn tokens(&self) -> TokenStream {
314-
match self.kind {
315-
AttrKind::Normal(ref normal) => normal
312+
match &self.kind {
313+
AttrKind::Normal(normal) => normal
316314
.tokens
317315
.as_ref()
318316
.unwrap_or_else(|| panic!("attribute is missing tokens: {:?}", self))
319317
.to_attr_token_stream()
320318
.to_tokenstream(),
321-
AttrKind::DocComment(comment_kind, data) => TokenStream::new(vec![TokenTree::Token(
319+
&AttrKind::DocComment(comment_kind, data) => TokenStream::new(vec![TokenTree::Token(
322320
Token::new(token::DocComment(comment_kind, self.style, data), self.span),
323321
Spacing::Alone,
324322
)]),
@@ -496,17 +494,17 @@ impl MetaItem {
496494
let span = span.with_hi(segments.last().unwrap().ident.span.hi());
497495
Path { span, segments, tokens: None }
498496
}
499-
Some(TokenTree::Token(Token { kind: token::Interpolated(nt), .. }, _)) => match *nt {
500-
token::Nonterminal::NtMeta(ref item) => return item.meta(item.path.span),
501-
token::Nonterminal::NtPath(ref path) => (**path).clone(),
497+
Some(TokenTree::Token(Token { kind: token::Interpolated(nt), .. }, _)) => match &*nt {
498+
token::Nonterminal::NtMeta(item) => return item.meta(item.path.span),
499+
token::Nonterminal::NtPath(path) => (**path).clone(),
502500
_ => return None,
503501
},
504502
_ => return None,
505503
};
506504
let list_closing_paren_pos = tokens.peek().map(|tt| tt.span().hi());
507505
let kind = MetaItemKind::from_tokens(tokens)?;
508-
let hi = match kind {
509-
MetaItemKind::NameValue(ref lit) => lit.span.hi(),
506+
let hi = match &kind {
507+
MetaItemKind::NameValue(lit) => lit.span.hi(),
510508
MetaItemKind::List(..) => list_closing_paren_pos.unwrap_or(path.span.hi()),
511509
_ => path.span.hi(),
512510
};
@@ -518,8 +516,8 @@ impl MetaItem {
518516
impl MetaItemKind {
519517
pub fn value_str(&self) -> Option<Symbol> {
520518
match self {
521-
MetaItemKind::NameValue(ref v) => match v.kind {
522-
LitKind::Str(ref s, _) => Some(*s),
519+
MetaItemKind::NameValue(v) => match v.kind {
520+
LitKind::Str(s, _) => Some(s),
523521
_ => None,
524522
},
525523
_ => None,
@@ -557,15 +555,15 @@ impl MetaItemKind {
557555
}
558556

559557
fn token_trees(&self, span: Span) -> Vec<TokenTree> {
560-
match *self {
558+
match self {
561559
MetaItemKind::Word => vec![],
562-
MetaItemKind::NameValue(ref lit) => {
560+
MetaItemKind::NameValue(lit) => {
563561
vec![
564562
TokenTree::token_alone(token::Eq, span),
565563
TokenTree::Token(lit.to_token(), Spacing::Alone),
566564
]
567565
}
568-
MetaItemKind::List(ref list) => {
566+
MetaItemKind::List(list) => {
569567
let mut tokens = Vec::new();
570568
for (i, item) in list.iter().enumerate() {
571569
if i > 0 {
@@ -648,16 +646,16 @@ impl MetaItemKind {
648646

649647
impl NestedMetaItem {
650648
pub fn span(&self) -> Span {
651-
match *self {
652-
NestedMetaItem::MetaItem(ref item) => item.span,
653-
NestedMetaItem::Literal(ref lit) => lit.span,
649+
match self {
650+
NestedMetaItem::MetaItem(item) => item.span,
651+
NestedMetaItem::Literal(lit) => lit.span,
654652
}
655653
}
656654

657655
fn token_trees(&self) -> Vec<TokenTree> {
658-
match *self {
659-
NestedMetaItem::MetaItem(ref item) => item.token_trees(),
660-
NestedMetaItem::Literal(ref lit) => {
656+
match self {
657+
NestedMetaItem::MetaItem(item) => item.token_trees(),
658+
NestedMetaItem::Literal(lit) => {
661659
vec![TokenTree::Token(lit.to_token(), Spacing::Alone)]
662660
}
663661
}

compiler/rustc_ast/src/mut_visit.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -439,15 +439,15 @@ pub fn noop_visit_constraint<T: MutVisitor>(
439439
) {
440440
vis.visit_id(id);
441441
vis.visit_ident(ident);
442-
if let Some(ref mut gen_args) = gen_args {
442+
if let Some(gen_args) = gen_args {
443443
vis.visit_generic_args(gen_args);
444444
}
445445
match kind {
446-
AssocConstraintKind::Equality { ref mut term } => match term {
446+
AssocConstraintKind::Equality { term } => match term {
447447
Term::Ty(ty) => vis.visit_ty(ty),
448448
Term::Const(c) => vis.visit_anon_const(c),
449449
},
450-
AssocConstraintKind::Bound { ref mut bounds } => visit_bounds(bounds, vis),
450+
AssocConstraintKind::Bound { bounds } => visit_bounds(bounds, vis),
451451
}
452452
vis.visit_span(span);
453453
}
@@ -880,7 +880,7 @@ pub fn noop_flat_map_generic_param<T: MutVisitor>(
880880
let GenericParam { id, ident, attrs, bounds, kind, colon_span, is_placeholder: _ } = &mut param;
881881
vis.visit_id(id);
882882
vis.visit_ident(ident);
883-
if let Some(ref mut colon_span) = colon_span {
883+
if let Some(colon_span) = colon_span {
884884
vis.visit_span(colon_span);
885885
}
886886
visit_attrs(attrs, vis);

compiler/rustc_ast/src/token.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -601,17 +601,18 @@ impl Token {
601601

602602
/// Returns `true` if the token is an interpolated path.
603603
fn is_path(&self) -> bool {
604-
if let Interpolated(ref nt) = self.kind && let NtPath(..) = **nt {
604+
if let Interpolated(nt) = &self.kind && let NtPath(..) = **nt {
605605
return true;
606606
}
607+
607608
false
608609
}
609610

610611
/// Would `maybe_whole_expr` in `parser.rs` return `Ok(..)`?
611612
/// That is, is this a pre-parsed expression dropped into the token stream
612613
/// (which happens while parsing the result of macro expansion)?
613614
pub fn is_whole_expr(&self) -> bool {
614-
if let Interpolated(ref nt) = self.kind
615+
if let Interpolated(nt) = &self.kind
615616
&& let NtExpr(_) | NtLiteral(_) | NtPath(_) | NtBlock(_) = **nt
616617
{
617618
return true;
@@ -622,9 +623,10 @@ impl Token {
622623

623624
// Is the token an interpolated block (`$b:block`)?
624625
pub fn is_whole_block(&self) -> bool {
625-
if let Interpolated(ref nt) = self.kind && let NtBlock(..) = **nt {
626+
if let Interpolated(nt) = &self.kind && let NtBlock(..) = **nt {
626627
return true;
627628
}
629+
628630
false
629631
}
630632

compiler/rustc_ast/src/util/parser.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -377,26 +377,26 @@ pub fn needs_par_as_let_scrutinee(order: i8) -> bool {
377377
/// parens or other delimiters, e.g., `X { y: 1 }`, `X { y: 1 }.method()`, `foo == X { y: 1 }` and
378378
/// `X { y: 1 } == foo` all do, but `(X { y: 1 }) == foo` does not.
379379
pub fn contains_exterior_struct_lit(value: &ast::Expr) -> bool {
380-
match value.kind {
380+
match &value.kind {
381381
ast::ExprKind::Struct(..) => true,
382382

383-
ast::ExprKind::Assign(ref lhs, ref rhs, _)
384-
| ast::ExprKind::AssignOp(_, ref lhs, ref rhs)
385-
| ast::ExprKind::Binary(_, ref lhs, ref rhs) => {
383+
ast::ExprKind::Assign(lhs, rhs, _)
384+
| ast::ExprKind::AssignOp(_, lhs, rhs)
385+
| ast::ExprKind::Binary(_, lhs, rhs) => {
386386
// X { y: 1 } + X { y: 2 }
387387
contains_exterior_struct_lit(&lhs) || contains_exterior_struct_lit(&rhs)
388388
}
389-
ast::ExprKind::Await(ref x)
390-
| ast::ExprKind::Unary(_, ref x)
391-
| ast::ExprKind::Cast(ref x, _)
392-
| ast::ExprKind::Type(ref x, _)
393-
| ast::ExprKind::Field(ref x, _)
394-
| ast::ExprKind::Index(ref x, _) => {
389+
ast::ExprKind::Await(x)
390+
| ast::ExprKind::Unary(_, x)
391+
| ast::ExprKind::Cast(x, _)
392+
| ast::ExprKind::Type(x, _)
393+
| ast::ExprKind::Field(x, _)
394+
| ast::ExprKind::Index(x, _) => {
395395
// &X { y: 1 }, X { y: 1 }.y
396396
contains_exterior_struct_lit(&x)
397397
}
398398

399-
ast::ExprKind::MethodCall(box ast::MethodCall { ref receiver, .. }) => {
399+
ast::ExprKind::MethodCall(box ast::MethodCall { receiver, .. }) => {
400400
// X { y: 1 }.bar(...)
401401
contains_exterior_struct_lit(&receiver)
402402
}

0 commit comments

Comments
 (0)