Skip to content

Commit b2f5393

Browse files
committed
Auto merge of #29887 - sanxiyn:match-ref-pats, r=sfackler
2 parents b31cc64 + 95f6ea9 commit b2f5393

File tree

7 files changed

+57
-57
lines changed

7 files changed

+57
-57
lines changed

src/libsyntax/ast.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1686,9 +1686,9 @@ pub enum Visibility {
16861686

16871687
impl Visibility {
16881688
pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility {
1689-
match self {
1690-
&Inherited => parent_visibility,
1691-
&Public => *self
1689+
match *self {
1690+
Inherited => parent_visibility,
1691+
Public => *self
16921692
}
16931693
}
16941694
}

src/libsyntax/ext/deriving/generic/ty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ impl<'a> LifetimeBounds<'a> {
242242
cx.lifetime_def(span, cx.ident_of(*lt).name, bounds)
243243
}).collect();
244244
let ty_params = self.bounds.iter().map(|t| {
245-
match t {
246-
&(ref name, ref bounds) => {
245+
match *t {
246+
(ref name, ref bounds) => {
247247
mk_ty_param(cx,
248248
span,
249249
*name,

src/libsyntax/ext/quote.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ pub mod rt {
6363

6464
impl<T: ToTokens> ToTokens for Option<T> {
6565
fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
66-
match self {
67-
&Some(ref t) => t.to_tokens(cx),
68-
&None => Vec::new(),
66+
match *self {
67+
Some(ref t) => t.to_tokens(cx),
68+
None => Vec::new(),
6969
}
7070
}
7171
}

src/libsyntax/ext/tt/macro_parser.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,16 @@ enum TokenTreeOrTokenTreeVec {
107107

108108
impl TokenTreeOrTokenTreeVec {
109109
fn len(&self) -> usize {
110-
match self {
111-
&TtSeq(ref v) => v.len(),
112-
&Tt(ref tt) => tt.len(),
110+
match *self {
111+
TtSeq(ref v) => v.len(),
112+
Tt(ref tt) => tt.len(),
113113
}
114114
}
115115

116116
fn get_tt(&self, index: usize) -> TokenTree {
117-
match self {
118-
&TtSeq(ref v) => v[index].clone(),
119-
&Tt(ref tt) => tt.get_tt(index),
117+
match *self {
118+
TtSeq(ref v) => v[index].clone(),
119+
Tt(ref tt) => tt.get_tt(index),
120120
}
121121
}
122122
}
@@ -144,17 +144,17 @@ pub struct MatcherPos {
144144

145145
pub fn count_names(ms: &[TokenTree]) -> usize {
146146
ms.iter().fold(0, |count, elt| {
147-
count + match elt {
148-
&TokenTree::Sequence(_, ref seq) => {
147+
count + match *elt {
148+
TokenTree::Sequence(_, ref seq) => {
149149
seq.num_captures
150150
}
151-
&TokenTree::Delimited(_, ref delim) => {
151+
TokenTree::Delimited(_, ref delim) => {
152152
count_names(&delim.tts)
153153
}
154-
&TokenTree::Token(_, MatchNt(..)) => {
154+
TokenTree::Token(_, MatchNt(..)) => {
155155
1
156156
}
157-
&TokenTree::Token(_, _) => 0,
157+
TokenTree::Token(_, _) => 0,
158158
}
159159
})
160160
}
@@ -203,18 +203,18 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>])
203203
-> HashMap<Name, Rc<NamedMatch>> {
204204
fn n_rec(p_s: &ParseSess, m: &TokenTree, res: &[Rc<NamedMatch>],
205205
ret_val: &mut HashMap<Name, Rc<NamedMatch>>, idx: &mut usize) {
206-
match m {
207-
&TokenTree::Sequence(_, ref seq) => {
206+
match *m {
207+
TokenTree::Sequence(_, ref seq) => {
208208
for next_m in &seq.tts {
209209
n_rec(p_s, next_m, res, ret_val, idx)
210210
}
211211
}
212-
&TokenTree::Delimited(_, ref delim) => {
212+
TokenTree::Delimited(_, ref delim) => {
213213
for next_m in &delim.tts {
214214
n_rec(p_s, next_m, res, ret_val, idx)
215215
}
216216
}
217-
&TokenTree::Token(sp, MatchNt(bind_name, _, _, _)) => {
217+
TokenTree::Token(sp, MatchNt(bind_name, _, _, _)) => {
218218
match ret_val.entry(bind_name.name) {
219219
Vacant(spot) => {
220220
spot.insert(res[*idx].clone());
@@ -228,8 +228,8 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>])
228228
}
229229
}
230230
}
231-
&TokenTree::Token(_, SubstNt(..)) => panic!("Cannot fill in a NT"),
232-
&TokenTree::Token(_, _) => (),
231+
TokenTree::Token(_, SubstNt(..)) => panic!("Cannot fill in a NT"),
232+
TokenTree::Token(_, _) => (),
233233
}
234234
}
235235
let mut ret_val = HashMap::new();

src/libsyntax/print/pprust.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -1263,13 +1263,13 @@ impl<'a> State<'a> {
12631263
_ => {}
12641264
}
12651265

1266-
match opt_trait {
1267-
&Some(ref t) => {
1266+
match *opt_trait {
1267+
Some(ref t) => {
12681268
try!(self.print_trait_ref(t));
12691269
try!(space(&mut self.s));
12701270
try!(self.word_space("for"));
12711271
}
1272-
&None => {}
1272+
None => {}
12731273
}
12741274

12751275
try!(self.print_type(&**ty));
@@ -1499,10 +1499,10 @@ impl<'a> State<'a> {
14991499
try!(self.print_tt(tt));
15001500
// There should be no space between the module name and the following `::` in paths,
15011501
// otherwise imported macros get re-parsed from crate metadata incorrectly (#20701)
1502-
suppress_space = match tt {
1503-
&TokenTree::Token(_, token::Ident(_, token::ModName)) |
1504-
&TokenTree::Token(_, token::MatchNt(_, _, _, token::ModName)) |
1505-
&TokenTree::Token(_, token::SubstNt(_, token::ModName)) => true,
1502+
suppress_space = match *tt {
1503+
TokenTree::Token(_, token::Ident(_, token::ModName)) |
1504+
TokenTree::Token(_, token::MatchNt(_, _, _, token::ModName)) |
1505+
TokenTree::Token(_, token::SubstNt(_, token::ModName)) => true,
15061506
_ => false
15071507
}
15081508
}
@@ -2618,8 +2618,8 @@ impl<'a> State<'a> {
26182618
try!(self.rbox(0, Inconsistent));
26192619
let mut first = true;
26202620
if let Some(explicit_self) = opt_explicit_self {
2621-
let m = match explicit_self {
2622-
&ast::SelfStatic => ast::MutImmutable,
2621+
let m = match *explicit_self {
2622+
ast::SelfStatic => ast::MutImmutable,
26232623
_ => match decl.inputs[0].pat.node {
26242624
ast::PatIdent(ast::BindByValue(m), _, _) => m,
26252625
_ => ast::MutImmutable
@@ -2804,18 +2804,18 @@ impl<'a> State<'a> {
28042804
try!(self.word_space(","));
28052805
}
28062806

2807-
match predicate {
2808-
&ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ref bound_lifetimes,
2809-
ref bounded_ty,
2810-
ref bounds,
2811-
..}) => {
2807+
match *predicate {
2808+
ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ref bound_lifetimes,
2809+
ref bounded_ty,
2810+
ref bounds,
2811+
..}) => {
28122812
try!(self.print_formal_lifetime_list(bound_lifetimes));
28132813
try!(self.print_type(&**bounded_ty));
28142814
try!(self.print_bounds(":", bounds));
28152815
}
2816-
&ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime,
2817-
ref bounds,
2818-
..}) => {
2816+
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime,
2817+
ref bounds,
2818+
..}) => {
28192819
try!(self.print_lifetime(lifetime));
28202820
try!(word(&mut self.s, ":"));
28212821

@@ -2827,7 +2827,7 @@ impl<'a> State<'a> {
28272827
}
28282828
}
28292829
}
2830-
&ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{ref path, ref ty, ..}) => {
2830+
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{ref path, ref ty, ..}) => {
28312831
try!(self.print_path(path, false, 0));
28322832
try!(space(&mut self.s));
28332833
try!(self.word_space("="));

src/libsyntax/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
353353
let has_test_attr = attr::contains_name(&i.attrs, "test");
354354

355355
fn has_test_signature(i: &ast::Item) -> HasTestSignature {
356-
match &i.node {
357-
&ast::ItemFn(ref decl, _, _, _, ref generics, _) => {
356+
match i.node {
357+
ast::ItemFn(ref decl, _, _, _, ref generics, _) => {
358358
let no_output = match decl.output {
359359
ast::DefaultReturn(..) => true,
360360
ast::Return(ref t) if t.node == ast::TyTup(vec![]) => true,

src/libsyntax/visit.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -496,25 +496,25 @@ pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics
496496
}
497497
walk_list!(visitor, visit_lifetime_def, &generics.lifetimes);
498498
for predicate in &generics.where_clause.predicates {
499-
match predicate {
500-
&WherePredicate::BoundPredicate(WhereBoundPredicate{ref bounded_ty,
501-
ref bounds,
502-
ref bound_lifetimes,
503-
..}) => {
499+
match *predicate {
500+
WherePredicate::BoundPredicate(WhereBoundPredicate{ref bounded_ty,
501+
ref bounds,
502+
ref bound_lifetimes,
503+
..}) => {
504504
visitor.visit_ty(bounded_ty);
505505
walk_list!(visitor, visit_ty_param_bound, bounds);
506506
walk_list!(visitor, visit_lifetime_def, bound_lifetimes);
507507
}
508-
&WherePredicate::RegionPredicate(WhereRegionPredicate{ref lifetime,
509-
ref bounds,
510-
..}) => {
508+
WherePredicate::RegionPredicate(WhereRegionPredicate{ref lifetime,
509+
ref bounds,
510+
..}) => {
511511
visitor.visit_lifetime(lifetime);
512512
walk_list!(visitor, visit_lifetime, bounds);
513513
}
514-
&WherePredicate::EqPredicate(WhereEqPredicate{id,
515-
ref path,
516-
ref ty,
517-
..}) => {
514+
WherePredicate::EqPredicate(WhereEqPredicate{id,
515+
ref path,
516+
ref ty,
517+
..}) => {
518518
visitor.visit_path(path, id);
519519
visitor.visit_ty(ty);
520520
}

0 commit comments

Comments
 (0)