Skip to content

Commit c877d61

Browse files
Use more autoderef in libsyntax
1 parent db6e5d5 commit c877d61

File tree

10 files changed

+171
-171
lines changed

10 files changed

+171
-171
lines changed

src/libsyntax/attr.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub trait AttributeMethods {
143143
impl AttributeMethods for Attribute {
144144
/// Extract the MetaItem from inside this Attribute.
145145
fn meta(&self) -> &MetaItem {
146-
&*self.node.value
146+
&self.node.value
147147
}
148148

149149
/// Convert self to a normal #[doc="foo"] comment, if it is a
@@ -370,17 +370,17 @@ pub fn cfg_matches<T: CfgDiag>(cfgs: &[P<MetaItem>],
370370
diag: &mut T) -> bool {
371371
match cfg.node {
372372
ast::MetaItemKind::List(ref pred, ref mis) if &pred[..] == "any" =>
373-
mis.iter().any(|mi| cfg_matches(cfgs, &**mi, diag)),
373+
mis.iter().any(|mi| cfg_matches(cfgs, &mi, diag)),
374374
ast::MetaItemKind::List(ref pred, ref mis) if &pred[..] == "all" =>
375-
mis.iter().all(|mi| cfg_matches(cfgs, &**mi, diag)),
375+
mis.iter().all(|mi| cfg_matches(cfgs, &mi, diag)),
376376
ast::MetaItemKind::List(ref pred, ref mis) if &pred[..] == "not" => {
377377
if mis.len() != 1 {
378378
diag.emit_error(|diagnostic| {
379379
diagnostic.span_err(cfg.span, "expected 1 cfg-pattern");
380380
});
381381
return false;
382382
}
383-
!cfg_matches(cfgs, &*mis[0], diag)
383+
!cfg_matches(cfgs, &mis[0], diag)
384384
}
385385
ast::MetaItemKind::List(ref pred, _) => {
386386
diag.emit_error(|diagnostic| {

src/libsyntax/ext/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ fn expand_item_multi_modifier(mut it: Annotatable,
10401040
allow_internal_unstable: true,
10411041
}
10421042
});
1043-
it = mac.expand(fld.cx, attr.span, &*attr.node.value, it);
1043+
it = mac.expand(fld.cx, attr.span, &attr.node.value, it);
10441044
fld.cx.bt_pop();
10451045
}
10461046
_ => unreachable!()

src/libsyntax/feature_gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ impl<'a> Context<'a> {
676676
}
677677
}
678678
for &(ref n, ref ty) in self.plugin_attributes {
679-
if &*n == name {
679+
if n == name {
680680
// Plugins can't gate attributes, so we don't check for it
681681
// unlike the code above; we only use this loop to
682682
// short-circuit to avoid the checks below

src/libsyntax/fold.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ pub fn noop_fold_item_simple<T: Folder>(Item {id, ident, attrs, node, vis, span}
10711071
let ident = match node {
10721072
// The node may have changed, recompute the "pretty" impl name.
10731073
ItemKind::Impl(_, _, _, ref maybe_trait, ref ty, _) => {
1074-
ast_util::impl_pretty_name(maybe_trait, Some(&**ty))
1074+
ast_util::impl_pretty_name(maybe_trait, Some(&ty))
10751075
}
10761076
_ => ident
10771077
};

src/libsyntax/parse/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -606,8 +606,8 @@ pub fn integer_lit(s: &str,
606606
2 => sd.span_err(sp, "binary float literal is not supported"),
607607
_ => ()
608608
}
609-
let ident = token::intern_and_get_ident(&*s);
610-
return filtered_float_lit(ident, Some(&**suf), sd, sp)
609+
let ident = token::intern_and_get_ident(&s);
610+
return filtered_float_lit(ident, Some(&suf), sd, sp)
611611
}
612612
}
613613

@@ -990,24 +990,24 @@ mod tests {
990990
#[test] fn parse_use() {
991991
let use_s = "use foo::bar::baz;";
992992
let vitem = string_to_item(use_s.to_string()).unwrap();
993-
let vitem_s = item_to_string(&*vitem);
993+
let vitem_s = item_to_string(&vitem);
994994
assert_eq!(&vitem_s[..], use_s);
995995

996996
let use_s = "use foo::bar as baz;";
997997
let vitem = string_to_item(use_s.to_string()).unwrap();
998-
let vitem_s = item_to_string(&*vitem);
998+
let vitem_s = item_to_string(&vitem);
999999
assert_eq!(&vitem_s[..], use_s);
10001000
}
10011001

10021002
#[test] fn parse_extern_crate() {
10031003
let ex_s = "extern crate foo;";
10041004
let vitem = string_to_item(ex_s.to_string()).unwrap();
1005-
let vitem_s = item_to_string(&*vitem);
1005+
let vitem_s = item_to_string(&vitem);
10061006
assert_eq!(&vitem_s[..], ex_s);
10071007

10081008
let ex_s = "extern crate foo as bar;";
10091009
let vitem = string_to_item(ex_s.to_string()).unwrap();
1010-
let vitem_s = item_to_string(&*vitem);
1010+
let vitem_s = item_to_string(&vitem);
10111011
assert_eq!(&vitem_s[..], ex_s);
10121012
}
10131013

@@ -1030,7 +1030,7 @@ mod tests {
10301030
}
10311031
}
10321032
let mut v = PatIdentVisitor { spans: Vec::new() };
1033-
::visit::walk_item(&mut v, &*item);
1033+
::visit::walk_item(&mut v, &item);
10341034
return v.spans;
10351035
}
10361036

src/libsyntax/parse/parser.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl<'a> Parser<'a> {
444444
} else {
445445
b.push_str(", ");
446446
}
447-
b.push_str(&*a.to_string());
447+
b.push_str(&a.to_string());
448448
b
449449
})
450450
}
@@ -696,7 +696,7 @@ impl<'a> Parser<'a> {
696696
if text.is_empty() {
697697
self.span_bug(sp, "found empty literal suffix in Some")
698698
}
699-
self.span_err(sp, &*format!("{} with a suffix is invalid", kind));
699+
self.span_err(sp, &format!("{} with a suffix is invalid", kind));
700700
}
701701
}
702702
}
@@ -1574,7 +1574,7 @@ impl<'a> Parser<'a> {
15741574

15751575
if suffix_illegal {
15761576
let sp = self.last_span;
1577-
self.expect_no_suffix(sp, &*format!("{} literal", lit.short_name()), suf)
1577+
self.expect_no_suffix(sp, &format!("{} literal", lit.short_name()), suf)
15781578
}
15791579

15801580
Ok(out)
@@ -2083,7 +2083,7 @@ impl<'a> Parser<'a> {
20832083
let mut trailing_comma = false;
20842084
while self.token != token::CloseDelim(token::Paren) {
20852085
es.push(try!(self.parse_expr()));
2086-
try!(self.commit_expr(&**es.last().unwrap(), &[],
2086+
try!(self.commit_expr(&es.last().unwrap(), &[],
20872087
&[token::Comma, token::CloseDelim(token::Paren)]));
20882088
if self.check(&token::Comma) {
20892089
trailing_comma = true;
@@ -2295,7 +2295,7 @@ impl<'a> Parser<'a> {
22952295
}
22962296

22972297
fields.push(try!(self.parse_field()));
2298-
try!(self.commit_expr(&*fields.last().unwrap().expr,
2298+
try!(self.commit_expr(&fields.last().unwrap().expr,
22992299
&[token::Comma],
23002300
&[token::CloseDelim(token::Brace)]));
23012301
}
@@ -2508,7 +2508,7 @@ impl<'a> Parser<'a> {
25082508
}
25092509
continue;
25102510
}
2511-
if self.expr_is_complete(&*e) { break; }
2511+
if self.expr_is_complete(&e) { break; }
25122512
match self.token {
25132513
// expr(...)
25142514
token::OpenDelim(token::Paren) => {
@@ -2530,7 +2530,7 @@ impl<'a> Parser<'a> {
25302530
self.bump();
25312531
let ix = try!(self.parse_expr());
25322532
hi = self.span.hi;
2533-
try!(self.commit_expr_expecting(&*ix, token::CloseDelim(token::Bracket)));
2533+
try!(self.commit_expr_expecting(&ix, token::CloseDelim(token::Bracket)));
25342534
let index = self.mk_index(e, ix);
25352535
e = self.mk_expr(lo, hi, index, None)
25362536
}
@@ -2820,7 +2820,7 @@ impl<'a> Parser<'a> {
28202820
};
28212821

28222822

2823-
if self.expr_is_complete(&*lhs) {
2823+
if self.expr_is_complete(&lhs) {
28242824
// Semi-statement forms are odd. See https://github.com/rust-lang/rust/issues/29071
28252825
return Ok(lhs);
28262826
}
@@ -2844,7 +2844,7 @@ impl<'a> Parser<'a> {
28442844
}
28452845
self.bump();
28462846
if op.is_comparison() {
2847-
self.check_no_chained_comparison(&*lhs, &op);
2847+
self.check_no_chained_comparison(&lhs, &op);
28482848
}
28492849
// Special cases:
28502850
if op == AssocOp::As {
@@ -3152,7 +3152,7 @@ impl<'a> Parser<'a> {
31523152
let lo = self.last_span.lo;
31533153
let discriminant = try!(self.parse_expr_res(
31543154
Restrictions::RESTRICTION_NO_STRUCT_LITERAL, None));
3155-
if let Err(mut e) = self.commit_expr_expecting(&*discriminant,
3155+
if let Err(mut e) = self.commit_expr_expecting(&discriminant,
31563156
token::OpenDelim(token::Brace)) {
31573157
if self.token == token::Token::Semi {
31583158
e.span_note(match_span, "did you mean to remove this `match` keyword?");
@@ -3183,11 +3183,11 @@ impl<'a> Parser<'a> {
31833183
let expr = try!(self.parse_expr_res(Restrictions::RESTRICTION_STMT_EXPR, None));
31843184

31853185
let require_comma =
3186-
!classify::expr_is_simple_block(&*expr)
3186+
!classify::expr_is_simple_block(&expr)
31873187
&& self.token != token::CloseDelim(token::Brace);
31883188

31893189
if require_comma {
3190-
try!(self.commit_expr(&*expr, &[token::Comma], &[token::CloseDelim(token::Brace)]));
3190+
try!(self.commit_expr(&expr, &[token::Comma], &[token::CloseDelim(token::Brace)]));
31913191
} else {
31923192
self.eat(&token::Comma);
31933193
}
@@ -3936,7 +3936,7 @@ impl<'a> Parser<'a> {
39363936
stmts: &mut Vec<Stmt>,
39373937
last_block_expr: &mut Option<P<Expr>>) -> PResult<'a, ()> {
39383938
// expression without semicolon
3939-
if classify::expr_requires_semi_to_be_stmt(&*e) {
3939+
if classify::expr_requires_semi_to_be_stmt(&e) {
39403940
// Just check for errors and recover; do not eat semicolon yet.
39413941
try!(self.commit_stmt(&[],
39423942
&[token::Semi, token::CloseDelim(token::Brace)]));
@@ -4861,7 +4861,7 @@ impl<'a> Parser<'a> {
48614861
impl_items.push(try!(self.parse_impl_item()));
48624862
}
48634863

4864-
Ok((ast_util::impl_pretty_name(&opt_trait, Some(&*ty)),
4864+
Ok((ast_util::impl_pretty_name(&opt_trait, Some(&ty)),
48654865
ItemKind::Impl(unsafety, polarity, generics, opt_trait, ty, impl_items),
48664866
Some(attrs)))
48674867
}
@@ -5075,7 +5075,7 @@ impl<'a> Parser<'a> {
50755075
let ty = try!(self.parse_ty_sum());
50765076
try!(self.expect(&token::Eq));
50775077
let e = try!(self.parse_expr());
5078-
try!(self.commit_expr_expecting(&*e, token::Semi));
5078+
try!(self.commit_expr_expecting(&e, token::Semi));
50795079
let item = match m {
50805080
Some(m) => ItemKind::Static(ty, m, e),
50815081
None => ItemKind::Const(ty, e),

src/libsyntax/parse/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ impl InternedString {
666666
impl Deref for InternedString {
667667
type Target = str;
668668

669-
fn deref(&self) -> &str { &*self.string }
669+
fn deref(&self) -> &str { &self.string }
670670
}
671671

672672
impl fmt::Debug for InternedString {

0 commit comments

Comments
 (0)