mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
some clippy::perf fixes
This commit is contained in:
parent
0157cc977f
commit
ff6601e0fc
@ -1096,7 +1096,7 @@ impl<'a> Parser<'a> {
|
|||||||
(Err(ref mut err), Some((mut snapshot, ExprKind::Path(None, path)))) => {
|
(Err(ref mut err), Some((mut snapshot, ExprKind::Path(None, path)))) => {
|
||||||
let name = pprust::path_to_string(&path);
|
let name = pprust::path_to_string(&path);
|
||||||
snapshot.bump(); // `(`
|
snapshot.bump(); // `(`
|
||||||
match snapshot.parse_struct_fields(path.clone(), false, token::Paren) {
|
match snapshot.parse_struct_fields(path, false, token::Paren) {
|
||||||
Ok((fields, ..)) if snapshot.eat(&token::CloseDelim(token::Paren)) => {
|
Ok((fields, ..)) if snapshot.eat(&token::CloseDelim(token::Paren)) => {
|
||||||
// We have are certain we have `Enum::Foo(a: 3, b: 4)`, suggest
|
// We have are certain we have `Enum::Foo(a: 3, b: 4)`, suggest
|
||||||
// `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
|
// `Enum::Foo { a: 3, b: 4 }` or `Enum::Foo(3, 4)`.
|
||||||
|
@ -431,7 +431,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
|
|||||||
.sess
|
.sess
|
||||||
.source_map()
|
.source_map()
|
||||||
.span_to_snippet(self.expr.span)
|
.span_to_snippet(self.expr.span)
|
||||||
.map_or(false, |snip| snip.starts_with("("));
|
.map_or(false, |snip| snip.starts_with('('));
|
||||||
|
|
||||||
// Very crude check to see whether the expression must be wrapped
|
// Very crude check to see whether the expression must be wrapped
|
||||||
// in parentheses for the suggestion to work (issue #89497).
|
// in parentheses for the suggestion to work (issue #89497).
|
||||||
|
@ -1887,7 +1887,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
};
|
};
|
||||||
let expr_snippet =
|
let expr_snippet =
|
||||||
self.tcx.sess.source_map().span_to_snippet(expr.span).unwrap_or(String::new());
|
self.tcx.sess.source_map().span_to_snippet(expr.span).unwrap_or(String::new());
|
||||||
let is_wrapped = expr_snippet.starts_with("(") && expr_snippet.ends_with(")");
|
let is_wrapped = expr_snippet.starts_with('(') && expr_snippet.ends_with(')');
|
||||||
let after_open = expr.span.lo() + rustc_span::BytePos(1);
|
let after_open = expr.span.lo() + rustc_span::BytePos(1);
|
||||||
let before_close = expr.span.hi() - rustc_span::BytePos(1);
|
let before_close = expr.span.hi() - rustc_span::BytePos(1);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user