From 420b9864b74bee3f7b8f3915aff10047742fe873 Mon Sep 17 00:00:00 2001 From: Samuel Moelius Date: Fri, 4 Apr 2025 15:22:09 -0400 Subject: [PATCH] Fix duplicate warning; merge test into `tests/ui-fulldeps/internal-lints` --- compiler/rustc_lint/src/internal.rs | 3 +++ .../ui-fulldeps/internal-lints/query_stability.rs | 3 +++ .../internal-lints/query_stability.stderr | 10 +++++++++- .../internal-lints/query_stability_into_iter.rs | 11 ----------- .../query_stability_into_iter.stderr | 15 --------------- 5 files changed, 15 insertions(+), 27 deletions(-) delete mode 100644 tests/ui/internal-lints/query_stability_into_iter.rs delete mode 100644 tests/ui/internal-lints/query_stability_into_iter.stderr diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index f9d96ce01bb..f51a6050e96 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -133,6 +133,9 @@ fn check_into_iter_stability<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx let Some(into_iterator_def_id) = cx.tcx.get_diagnostic_item(sym::IntoIterator) else { return; }; + if expr.span.from_expansion() { + return; + }; // Is `expr` a function or method call? let Some((callee_def_id, generic_args, recv, args)) = get_callee_generic_args_and_args(cx, expr) diff --git a/tests/ui-fulldeps/internal-lints/query_stability.rs b/tests/ui-fulldeps/internal-lints/query_stability.rs index 7b897fabd2d..f136dde7349 100644 --- a/tests/ui-fulldeps/internal-lints/query_stability.rs +++ b/tests/ui-fulldeps/internal-lints/query_stability.rs @@ -34,4 +34,7 @@ fn main() { //~^ ERROR using `values_mut` can result in unstable query results *val = *val + 10; } + + FxHashMap::::default().extend(x); + //~^ ERROR using `into_iter` can result in unstable query results } diff --git a/tests/ui-fulldeps/internal-lints/query_stability.stderr b/tests/ui-fulldeps/internal-lints/query_stability.stderr index 43b156dc20a..deedd7b1b91 100644 --- a/tests/ui-fulldeps/internal-lints/query_stability.stderr +++ b/tests/ui-fulldeps/internal-lints/query_stability.stderr @@ -59,5 +59,13 @@ LL | for val in x.values_mut() { | = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale -error: aborting due to 7 previous errors +error: using `into_iter` can result in unstable query results + --> $DIR/query_stability.rs:38:45 + | +LL | FxHashMap::::default().extend(x); + | ^ + | + = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale + +error: aborting due to 8 previous errors diff --git a/tests/ui/internal-lints/query_stability_into_iter.rs b/tests/ui/internal-lints/query_stability_into_iter.rs deleted file mode 100644 index c674786f09c..00000000000 --- a/tests/ui/internal-lints/query_stability_into_iter.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ compile-flags: -Z unstable-options - -#![deny(rustc::potential_query_instability)] - -use std::collections::HashSet; - -fn main() { - let set = HashSet::::default(); - HashSet::::default().extend(set); - //~^ ERROR using `into_iter` can result in unstable query results -} diff --git a/tests/ui/internal-lints/query_stability_into_iter.stderr b/tests/ui/internal-lints/query_stability_into_iter.stderr deleted file mode 100644 index 08caf796241..00000000000 --- a/tests/ui/internal-lints/query_stability_into_iter.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: using `into_iter` can result in unstable query results - --> $DIR/query_stability_into_iter.rs:9:38 - | -LL | HashSet::::default().extend(set); - | ^^^ - | - = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale -note: the lint level is defined here - --> $DIR/query_stability_into_iter.rs:3:9 - | -LL | #![deny(rustc::potential_query_instability)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error -