remove a couple of redundant clones
This commit is contained in:
parent
dfdbe30004
commit
87b6f415f2
@ -311,7 +311,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
error: &mut bool,
|
error: &mut bool,
|
||||||
) {
|
) {
|
||||||
if let Some((if_span, msg)) = ret_reason {
|
if let Some((if_span, msg)) = ret_reason {
|
||||||
err.span_label(if_span, msg.clone());
|
err.span_label(if_span, msg);
|
||||||
} else if let ExprKind::Block(block, _) = then_expr.kind
|
} else if let ExprKind::Block(block, _) = then_expr.kind
|
||||||
&& let Some(expr) = block.expr
|
&& let Some(expr) = block.expr
|
||||||
{
|
{
|
||||||
|
@ -452,7 +452,6 @@ impl<'a> Parser<'a> {
|
|||||||
let mut expected = self
|
let mut expected = self
|
||||||
.expected_tokens
|
.expected_tokens
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
|
||||||
.filter(|token| {
|
.filter(|token| {
|
||||||
// Filter out suggestions that suggest the same token which was found and deemed incorrect.
|
// Filter out suggestions that suggest the same token which was found and deemed incorrect.
|
||||||
fn is_ident_eq_keyword(found: &TokenKind, expected: &TokenType) -> bool {
|
fn is_ident_eq_keyword(found: &TokenKind, expected: &TokenType) -> bool {
|
||||||
@ -464,7 +463,7 @@ impl<'a> Parser<'a> {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
if *token != parser::TokenType::Token(self.token.kind.clone()) {
|
if **token != parser::TokenType::Token(self.token.kind.clone()) {
|
||||||
let eq = is_ident_eq_keyword(&self.token.kind, &token);
|
let eq = is_ident_eq_keyword(&self.token.kind, &token);
|
||||||
// If the suggestion is a keyword and the found token is an ident,
|
// If the suggestion is a keyword and the found token is an ident,
|
||||||
// the content of which are equal to the suggestion's content,
|
// the content of which are equal to the suggestion's content,
|
||||||
@ -483,6 +482,7 @@ impl<'a> Parser<'a> {
|
|||||||
}
|
}
|
||||||
false
|
false
|
||||||
})
|
})
|
||||||
|
.cloned()
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
expected.sort_by_cached_key(|x| x.to_string());
|
expected.sort_by_cached_key(|x| x.to_string());
|
||||||
expected.dedup();
|
expected.dedup();
|
||||||
|
@ -893,7 +893,7 @@ impl<'a> Parser<'a> {
|
|||||||
ParseError {
|
ParseError {
|
||||||
description: "expected format parameter to occur after `:`".to_owned(),
|
description: "expected format parameter to occur after `:`".to_owned(),
|
||||||
note: None,
|
note: None,
|
||||||
label: format!("expected `{}` to occur after `:`", alignment).to_owned(),
|
label: format!("expected `{}` to occur after `:`", alignment),
|
||||||
span: pos.to(pos),
|
span: pos.to(pos),
|
||||||
secondary_label: None,
|
secondary_label: None,
|
||||||
suggestion: Suggestion::None,
|
suggestion: Suggestion::None,
|
||||||
|
@ -84,9 +84,9 @@ pub fn span_lint_and_help<T: LintContext>(
|
|||||||
cx.span_lint(lint, span, msg.to_string(), |diag| {
|
cx.span_lint(lint, span, msg.to_string(), |diag| {
|
||||||
let help = help.to_string();
|
let help = help.to_string();
|
||||||
if let Some(help_span) = help_span {
|
if let Some(help_span) = help_span {
|
||||||
diag.span_help(help_span, help.to_string());
|
diag.span_help(help_span, help);
|
||||||
} else {
|
} else {
|
||||||
diag.help(help.to_string());
|
diag.help(help);
|
||||||
}
|
}
|
||||||
docs_link(diag, lint);
|
docs_link(diag, lint);
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user