mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-01 00:49:30 +00:00
Ignore _to_string
lints in code from_expansion
Includes the `string_to_string` and `str_to_string` lints.
This commit is contained in:
parent
30b3b73aa6
commit
cd00f5b9e4
1 changed files with 8 additions and 0 deletions
|
@ -389,6 +389,10 @@ declare_lint_pass!(StrToString => [STR_TO_STRING]);
|
||||||
|
|
||||||
impl<'tcx> LateLintPass<'tcx> for StrToString {
|
impl<'tcx> LateLintPass<'tcx> for StrToString {
|
||||||
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
|
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
|
||||||
|
if expr.span.from_expansion() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if let ExprKind::MethodCall(path, self_arg, ..) = &expr.kind
|
if let ExprKind::MethodCall(path, self_arg, ..) = &expr.kind
|
||||||
&& path.ident.name == sym::to_string
|
&& path.ident.name == sym::to_string
|
||||||
&& let ty = cx.typeck_results().expr_ty(self_arg)
|
&& let ty = cx.typeck_results().expr_ty(self_arg)
|
||||||
|
@ -437,6 +441,10 @@ declare_lint_pass!(StringToString => [STRING_TO_STRING]);
|
||||||
|
|
||||||
impl<'tcx> LateLintPass<'tcx> for StringToString {
|
impl<'tcx> LateLintPass<'tcx> for StringToString {
|
||||||
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
|
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) {
|
||||||
|
if expr.span.from_expansion() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if let ExprKind::MethodCall(path, self_arg, ..) = &expr.kind
|
if let ExprKind::MethodCall(path, self_arg, ..) = &expr.kind
|
||||||
&& path.ident.name == sym::to_string
|
&& path.ident.name == sym::to_string
|
||||||
&& let ty = cx.typeck_results().expr_ty(self_arg)
|
&& let ty = cx.typeck_results().expr_ty(self_arg)
|
||||||
|
|
Loading…
Reference in a new issue