Fix match_ref_pats flagged by Clippy
This commit is contained in:
parent
c61e8fd61a
commit
95f6ea920d
7 changed files with 57 additions and 57 deletions
|
@ -1687,9 +1687,9 @@ pub enum Visibility {
|
||||||
|
|
||||||
impl Visibility {
|
impl Visibility {
|
||||||
pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility {
|
pub fn inherit_from(&self, parent_visibility: Visibility) -> Visibility {
|
||||||
match self {
|
match *self {
|
||||||
&Inherited => parent_visibility,
|
Inherited => parent_visibility,
|
||||||
&Public => *self
|
Public => *self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -242,8 +242,8 @@ impl<'a> LifetimeBounds<'a> {
|
||||||
cx.lifetime_def(span, cx.ident_of(*lt).name, bounds)
|
cx.lifetime_def(span, cx.ident_of(*lt).name, bounds)
|
||||||
}).collect();
|
}).collect();
|
||||||
let ty_params = self.bounds.iter().map(|t| {
|
let ty_params = self.bounds.iter().map(|t| {
|
||||||
match t {
|
match *t {
|
||||||
&(ref name, ref bounds) => {
|
(ref name, ref bounds) => {
|
||||||
mk_ty_param(cx,
|
mk_ty_param(cx,
|
||||||
span,
|
span,
|
||||||
*name,
|
*name,
|
||||||
|
|
|
@ -63,9 +63,9 @@ pub mod rt {
|
||||||
|
|
||||||
impl<T: ToTokens> ToTokens for Option<T> {
|
impl<T: ToTokens> ToTokens for Option<T> {
|
||||||
fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
|
fn to_tokens(&self, cx: &ExtCtxt) -> Vec<TokenTree> {
|
||||||
match self {
|
match *self {
|
||||||
&Some(ref t) => t.to_tokens(cx),
|
Some(ref t) => t.to_tokens(cx),
|
||||||
&None => Vec::new(),
|
None => Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,16 +107,16 @@ enum TokenTreeOrTokenTreeVec {
|
||||||
|
|
||||||
impl TokenTreeOrTokenTreeVec {
|
impl TokenTreeOrTokenTreeVec {
|
||||||
fn len(&self) -> usize {
|
fn len(&self) -> usize {
|
||||||
match self {
|
match *self {
|
||||||
&TtSeq(ref v) => v.len(),
|
TtSeq(ref v) => v.len(),
|
||||||
&Tt(ref tt) => tt.len(),
|
Tt(ref tt) => tt.len(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_tt(&self, index: usize) -> TokenTree {
|
fn get_tt(&self, index: usize) -> TokenTree {
|
||||||
match self {
|
match *self {
|
||||||
&TtSeq(ref v) => v[index].clone(),
|
TtSeq(ref v) => v[index].clone(),
|
||||||
&Tt(ref tt) => tt.get_tt(index),
|
Tt(ref tt) => tt.get_tt(index),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,17 +144,17 @@ pub struct MatcherPos {
|
||||||
|
|
||||||
pub fn count_names(ms: &[TokenTree]) -> usize {
|
pub fn count_names(ms: &[TokenTree]) -> usize {
|
||||||
ms.iter().fold(0, |count, elt| {
|
ms.iter().fold(0, |count, elt| {
|
||||||
count + match elt {
|
count + match *elt {
|
||||||
&TokenTree::Sequence(_, ref seq) => {
|
TokenTree::Sequence(_, ref seq) => {
|
||||||
seq.num_captures
|
seq.num_captures
|
||||||
}
|
}
|
||||||
&TokenTree::Delimited(_, ref delim) => {
|
TokenTree::Delimited(_, ref delim) => {
|
||||||
count_names(&delim.tts)
|
count_names(&delim.tts)
|
||||||
}
|
}
|
||||||
&TokenTree::Token(_, MatchNt(..)) => {
|
TokenTree::Token(_, MatchNt(..)) => {
|
||||||
1
|
1
|
||||||
}
|
}
|
||||||
&TokenTree::Token(_, _) => 0,
|
TokenTree::Token(_, _) => 0,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -203,18 +203,18 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>])
|
||||||
-> HashMap<Name, Rc<NamedMatch>> {
|
-> HashMap<Name, Rc<NamedMatch>> {
|
||||||
fn n_rec(p_s: &ParseSess, m: &TokenTree, res: &[Rc<NamedMatch>],
|
fn n_rec(p_s: &ParseSess, m: &TokenTree, res: &[Rc<NamedMatch>],
|
||||||
ret_val: &mut HashMap<Name, Rc<NamedMatch>>, idx: &mut usize) {
|
ret_val: &mut HashMap<Name, Rc<NamedMatch>>, idx: &mut usize) {
|
||||||
match m {
|
match *m {
|
||||||
&TokenTree::Sequence(_, ref seq) => {
|
TokenTree::Sequence(_, ref seq) => {
|
||||||
for next_m in &seq.tts {
|
for next_m in &seq.tts {
|
||||||
n_rec(p_s, next_m, res, ret_val, idx)
|
n_rec(p_s, next_m, res, ret_val, idx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&TokenTree::Delimited(_, ref delim) => {
|
TokenTree::Delimited(_, ref delim) => {
|
||||||
for next_m in &delim.tts {
|
for next_m in &delim.tts {
|
||||||
n_rec(p_s, next_m, res, ret_val, idx)
|
n_rec(p_s, next_m, res, ret_val, idx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&TokenTree::Token(sp, MatchNt(bind_name, _, _, _)) => {
|
TokenTree::Token(sp, MatchNt(bind_name, _, _, _)) => {
|
||||||
match ret_val.entry(bind_name.name) {
|
match ret_val.entry(bind_name.name) {
|
||||||
Vacant(spot) => {
|
Vacant(spot) => {
|
||||||
spot.insert(res[*idx].clone());
|
spot.insert(res[*idx].clone());
|
||||||
|
@ -228,8 +228,8 @@ pub fn nameize(p_s: &ParseSess, ms: &[TokenTree], res: &[Rc<NamedMatch>])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&TokenTree::Token(_, SubstNt(..)) => panic!("Cannot fill in a NT"),
|
TokenTree::Token(_, SubstNt(..)) => panic!("Cannot fill in a NT"),
|
||||||
&TokenTree::Token(_, _) => (),
|
TokenTree::Token(_, _) => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut ret_val = HashMap::new();
|
let mut ret_val = HashMap::new();
|
||||||
|
|
|
@ -1263,13 +1263,13 @@ impl<'a> State<'a> {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
match opt_trait {
|
match *opt_trait {
|
||||||
&Some(ref t) => {
|
Some(ref t) => {
|
||||||
try!(self.print_trait_ref(t));
|
try!(self.print_trait_ref(t));
|
||||||
try!(space(&mut self.s));
|
try!(space(&mut self.s));
|
||||||
try!(self.word_space("for"));
|
try!(self.word_space("for"));
|
||||||
}
|
}
|
||||||
&None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
try!(self.print_type(&**ty));
|
try!(self.print_type(&**ty));
|
||||||
|
@ -1499,10 +1499,10 @@ impl<'a> State<'a> {
|
||||||
try!(self.print_tt(tt));
|
try!(self.print_tt(tt));
|
||||||
// There should be no space between the module name and the following `::` in paths,
|
// There should be no space between the module name and the following `::` in paths,
|
||||||
// otherwise imported macros get re-parsed from crate metadata incorrectly (#20701)
|
// otherwise imported macros get re-parsed from crate metadata incorrectly (#20701)
|
||||||
suppress_space = match tt {
|
suppress_space = match *tt {
|
||||||
&TokenTree::Token(_, token::Ident(_, token::ModName)) |
|
TokenTree::Token(_, token::Ident(_, token::ModName)) |
|
||||||
&TokenTree::Token(_, token::MatchNt(_, _, _, token::ModName)) |
|
TokenTree::Token(_, token::MatchNt(_, _, _, token::ModName)) |
|
||||||
&TokenTree::Token(_, token::SubstNt(_, token::ModName)) => true,
|
TokenTree::Token(_, token::SubstNt(_, token::ModName)) => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2618,8 +2618,8 @@ impl<'a> State<'a> {
|
||||||
try!(self.rbox(0, Inconsistent));
|
try!(self.rbox(0, Inconsistent));
|
||||||
let mut first = true;
|
let mut first = true;
|
||||||
if let Some(explicit_self) = opt_explicit_self {
|
if let Some(explicit_self) = opt_explicit_self {
|
||||||
let m = match explicit_self {
|
let m = match *explicit_self {
|
||||||
&ast::SelfStatic => ast::MutImmutable,
|
ast::SelfStatic => ast::MutImmutable,
|
||||||
_ => match decl.inputs[0].pat.node {
|
_ => match decl.inputs[0].pat.node {
|
||||||
ast::PatIdent(ast::BindByValue(m), _, _) => m,
|
ast::PatIdent(ast::BindByValue(m), _, _) => m,
|
||||||
_ => ast::MutImmutable
|
_ => ast::MutImmutable
|
||||||
|
@ -2804,18 +2804,18 @@ impl<'a> State<'a> {
|
||||||
try!(self.word_space(","));
|
try!(self.word_space(","));
|
||||||
}
|
}
|
||||||
|
|
||||||
match predicate {
|
match *predicate {
|
||||||
&ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ref bound_lifetimes,
|
ast::WherePredicate::BoundPredicate(ast::WhereBoundPredicate{ref bound_lifetimes,
|
||||||
ref bounded_ty,
|
ref bounded_ty,
|
||||||
ref bounds,
|
ref bounds,
|
||||||
..}) => {
|
..}) => {
|
||||||
try!(self.print_formal_lifetime_list(bound_lifetimes));
|
try!(self.print_formal_lifetime_list(bound_lifetimes));
|
||||||
try!(self.print_type(&**bounded_ty));
|
try!(self.print_type(&**bounded_ty));
|
||||||
try!(self.print_bounds(":", bounds));
|
try!(self.print_bounds(":", bounds));
|
||||||
}
|
}
|
||||||
&ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime,
|
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime,
|
||||||
ref bounds,
|
ref bounds,
|
||||||
..}) => {
|
..}) => {
|
||||||
try!(self.print_lifetime(lifetime));
|
try!(self.print_lifetime(lifetime));
|
||||||
try!(word(&mut self.s, ":"));
|
try!(word(&mut self.s, ":"));
|
||||||
|
|
||||||
|
@ -2827,7 +2827,7 @@ impl<'a> State<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
&ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{ref path, ref ty, ..}) => {
|
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{ref path, ref ty, ..}) => {
|
||||||
try!(self.print_path(path, false, 0));
|
try!(self.print_path(path, false, 0));
|
||||||
try!(space(&mut self.s));
|
try!(space(&mut self.s));
|
||||||
try!(self.word_space("="));
|
try!(self.word_space("="));
|
||||||
|
|
|
@ -353,8 +353,8 @@ fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
|
||||||
let has_test_attr = attr::contains_name(&i.attrs, "test");
|
let has_test_attr = attr::contains_name(&i.attrs, "test");
|
||||||
|
|
||||||
fn has_test_signature(i: &ast::Item) -> HasTestSignature {
|
fn has_test_signature(i: &ast::Item) -> HasTestSignature {
|
||||||
match &i.node {
|
match i.node {
|
||||||
&ast::ItemFn(ref decl, _, _, _, ref generics, _) => {
|
ast::ItemFn(ref decl, _, _, _, ref generics, _) => {
|
||||||
let no_output = match decl.output {
|
let no_output = match decl.output {
|
||||||
ast::DefaultReturn(..) => true,
|
ast::DefaultReturn(..) => true,
|
||||||
ast::Return(ref t) if t.node == ast::TyTup(vec![]) => true,
|
ast::Return(ref t) if t.node == ast::TyTup(vec![]) => true,
|
||||||
|
|
|
@ -496,25 +496,25 @@ pub fn walk_generics<'v, V: Visitor<'v>>(visitor: &mut V, generics: &'v Generics
|
||||||
}
|
}
|
||||||
walk_list!(visitor, visit_lifetime_def, &generics.lifetimes);
|
walk_list!(visitor, visit_lifetime_def, &generics.lifetimes);
|
||||||
for predicate in &generics.where_clause.predicates {
|
for predicate in &generics.where_clause.predicates {
|
||||||
match predicate {
|
match *predicate {
|
||||||
&WherePredicate::BoundPredicate(WhereBoundPredicate{ref bounded_ty,
|
WherePredicate::BoundPredicate(WhereBoundPredicate{ref bounded_ty,
|
||||||
ref bounds,
|
ref bounds,
|
||||||
ref bound_lifetimes,
|
ref bound_lifetimes,
|
||||||
..}) => {
|
..}) => {
|
||||||
visitor.visit_ty(bounded_ty);
|
visitor.visit_ty(bounded_ty);
|
||||||
walk_list!(visitor, visit_ty_param_bound, bounds);
|
walk_list!(visitor, visit_ty_param_bound, bounds);
|
||||||
walk_list!(visitor, visit_lifetime_def, bound_lifetimes);
|
walk_list!(visitor, visit_lifetime_def, bound_lifetimes);
|
||||||
}
|
}
|
||||||
&WherePredicate::RegionPredicate(WhereRegionPredicate{ref lifetime,
|
WherePredicate::RegionPredicate(WhereRegionPredicate{ref lifetime,
|
||||||
ref bounds,
|
ref bounds,
|
||||||
..}) => {
|
..}) => {
|
||||||
visitor.visit_lifetime(lifetime);
|
visitor.visit_lifetime(lifetime);
|
||||||
walk_list!(visitor, visit_lifetime, bounds);
|
walk_list!(visitor, visit_lifetime, bounds);
|
||||||
}
|
}
|
||||||
&WherePredicate::EqPredicate(WhereEqPredicate{id,
|
WherePredicate::EqPredicate(WhereEqPredicate{id,
|
||||||
ref path,
|
ref path,
|
||||||
ref ty,
|
ref ty,
|
||||||
..}) => {
|
..}) => {
|
||||||
visitor.visit_path(path, id);
|
visitor.visit_path(path, id);
|
||||||
visitor.visit_ty(ty);
|
visitor.visit_ty(ty);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue