Skip to content

Commit 68dbc84

Browse files
committed
Auto merge of rust-lang#12780 - future-highway:str-to-string-expansions, r=Manishearth
Ignore `_to_string` lints in code `from_expansion` Includes the `string_to_string` and `str_to_string` lints. changelog: [`str_to_string`]: Ignore code from expansion changelog: [`string_to_string`]: Ignore code from expansion
2 parents baf2a23 + cd00f5b commit 68dbc84

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Diff for: clippy_lints/src/strings.rs

+8
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ declare_lint_pass!(StrToString => [STR_TO_STRING]);
389389

390390
impl<'tcx> LateLintPass<'tcx> for StrToString {
391391
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
392+
if expr.span.from_expansion() {
393+
return;
394+
}
395+
392396
if let ExprKind::MethodCall(path, self_arg, ..) = &expr.kind
393397
&& path.ident.name == sym::to_string
394398
&& let ty = cx.typeck_results().expr_ty(self_arg)
@@ -437,6 +441,10 @@ declare_lint_pass!(StringToString => [STRING_TO_STRING]);
437441

438442
impl<'tcx> LateLintPass<'tcx> for StringToString {
439443
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
444+
if expr.span.from_expansion() {
445+
return;
446+
}
447+
440448
if let ExprKind::MethodCall(path, self_arg, ..) = &expr.kind
441449
&& path.ident.name == sym::to_string
442450
&& let ty = cx.typeck_results().expr_ty(self_arg)

0 commit comments

Comments
 (0)