Skip to content

Commit 88a5a98

Browse files
committed
Auto merge of rust-lang#90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnr
Revert "Add rustc lint, warning when iterating over hashmaps" Fixes perf regressions introduced in rust-lang#90235 by temporarily reverting the relevant PR.
2 parents a9f664f + 3215eeb commit 88a5a98

File tree

43 files changed

+68
-299
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+68
-299
lines changed

compiler/rustc_ast_lowering/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#![feature(iter_zip)]
3636
#![feature(never_type)]
3737
#![recursion_limit = "256"]
38-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
3938

4039
use rustc_ast::token::{self, Token};
4140
use rustc_ast::tokenstream::{CanSynthesizeMissingTokens, TokenStream, TokenTree};

compiler/rustc_ast_passes/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#![feature(iter_is_partitioned)]
88
#![feature(box_patterns)]
99
#![recursion_limit = "256"]
10-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
1110

1211
pub mod ast_validation;
1312
pub mod feature_gate;

compiler/rustc_borrowck/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#![feature(trusted_step)]
1313
#![feature(try_blocks)]
1414
#![recursion_limit = "256"]
15-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
1615

1716
#[macro_use]
1817
extern crate rustc_middle;

compiler/rustc_builtin_macros/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#![feature(proc_macro_internals)]
1212
#![feature(proc_macro_quote)]
1313
#![recursion_limit = "256"]
14-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
1514

1615
extern crate proc_macro;
1716

compiler/rustc_codegen_llvm/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#![feature(iter_zip)]
1414
#![feature(nll)]
1515
#![recursion_limit = "256"]
16-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
1716

1817
use back::write::{create_informational_target_machine, create_target_machine};
1918

compiler/rustc_codegen_ssa/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![feature(nll)]
99
#![feature(associated_type_bounds)]
1010
#![recursion_limit = "256"]
11-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
1211

1312
//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
1413
//! The backend-agnostic functions of this crate use functions defined in various traits that

compiler/rustc_const_eval/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Rust MIR: a lowered representation of Rust.
2424
#![feature(trusted_step)]
2525
#![feature(try_blocks)]
2626
#![recursion_limit = "256"]
27-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
2827

2928
#[macro_use]
3029
extern crate tracing;

compiler/rustc_data_structures/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#![feature(thread_id_value)]
2828
#![allow(rustc::default_hash_types)]
2929
#![deny(unaligned_references)]
30-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
3130

3231
#[macro_use]
3332
extern crate tracing;

compiler/rustc_driver/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#![feature(nll)]
99
#![feature(once_cell)]
1010
#![recursion_limit = "256"]
11-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
1211

1312
#[macro_use]
1413
extern crate tracing;
@@ -847,7 +846,7 @@ Available lint options:
847846
let builtin = sort_lints(sess, builtin);
848847

849848
let (plugin_groups, builtin_groups): (Vec<_>, _) =
850-
lint_store.get_lint_groups().partition(|&(.., p)| p);
849+
lint_store.get_lint_groups().iter().cloned().partition(|&(.., p)| p);
851850
let plugin_groups = sort_lint_groups(plugin_groups);
852851
let builtin_groups = sort_lint_groups(builtin_groups);
853852

compiler/rustc_errors/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#![feature(iter_zip)]
1111
#![feature(let_else)]
1212
#![feature(nll)]
13-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
1413

1514
#[macro_use]
1615
extern crate rustc_macros;

compiler/rustc_expand/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#![feature(proc_macro_span)]
1111
#![feature(try_blocks)]
1212
#![recursion_limit = "256"]
13-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
1413

1514
#[macro_use]
1615
extern crate rustc_macros;

compiler/rustc_feature/src/builtin_attrs.rs

-3
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,6 @@ pub const BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
460460
// Prevents field reads in the marked trait or method to be considered
461461
// during dead code analysis.
462462
rustc_attr!(rustc_trivial_field_reads, Normal, template!(Word), INTERNAL_UNSTABLE),
463-
// Used by the `rustc::potential_query_instability` lint to warn methods which
464-
// might not be stable during incremental compilation.
465-
rustc_attr!(rustc_lint_query_instability, Normal, template!(Word), INTERNAL_UNSTABLE),
466463

467464
// ==========================================================================
468465
// Internal attributes, Const related:

compiler/rustc_incremental/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(let_else)]
66
#![feature(nll)]
77
#![recursion_limit = "256"]
8-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
98

109
#[macro_use]
1110
extern crate rustc_middle;

compiler/rustc_infer/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#![feature(min_specialization)]
2525
#![feature(label_break_value)]
2626
#![recursion_limit = "512"] // For rustdoc
27-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
2827

2928
#[macro_use]
3029
extern crate rustc_macros;

compiler/rustc_interface/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(nll)]
66
#![feature(once_cell)]
77
#![recursion_limit = "256"]
8-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
98

109
mod callbacks;
1110
pub mod interface;

compiler/rustc_lint/src/context.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,7 @@ impl LintStore {
144144
&self.lints
145145
}
146146

147-
pub fn get_lint_groups<'t>(
148-
&'t self,
149-
) -> impl Iterator<Item = (&'static str, Vec<LintId>, bool)> + 't {
150-
// This function is not used in a way which observes the order of lints.
151-
#[cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
147+
pub fn get_lint_groups<'t>(&'t self) -> Vec<(&'static str, Vec<LintId>, bool)> {
152148
self.lint_groups
153149
.iter()
154150
.filter(|(_, LintGroup { depr, .. })| {
@@ -158,6 +154,7 @@ impl LintStore {
158154
.map(|(k, LintGroup { lint_ids, from_plugin, .. })| {
159155
(*k, lint_ids.clone(), *from_plugin)
160156
})
157+
.collect()
161158
}
162159

163160
pub fn register_early_pass(

compiler/rustc_lint/src/internal.rs

+4-55
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}
55
use rustc_ast as ast;
66
use rustc_errors::Applicability;
77
use rustc_hir::def::Res;
8-
use rustc_hir::*;
8+
use rustc_hir::{
9+
GenericArg, HirId, Item, ItemKind, MutTy, Mutability, Node, Path, PathSegment, QPath, Ty,
10+
TyKind,
11+
};
912
use rustc_middle::ty;
1013
use rustc_session::{declare_lint_pass, declare_tool_lint};
1114
use rustc_span::hygiene::{ExpnKind, MacroKind};
@@ -48,60 +51,6 @@ impl LateLintPass<'_> for DefaultHashTypes {
4851
}
4952
}
5053

51-
declare_tool_lint! {
52-
pub rustc::POTENTIAL_QUERY_INSTABILITY,
53-
Allow,
54-
"require explicit opt-in when using potentially unstable methods or functions",
55-
report_in_external_macro: true
56-
}
57-
58-
declare_lint_pass!(QueryStability => [POTENTIAL_QUERY_INSTABILITY]);
59-
60-
impl LateLintPass<'_> for QueryStability {
61-
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
62-
// FIXME(rustdoc): This lint uses typecheck results, causing rustdoc to
63-
// error if there are resolution failures.
64-
//
65-
// As internal lints are currently always run if there are `unstable_options`,
66-
// they are added to the lint store of rustdoc. Internal lints are also
67-
// not used via the `lint_mod` query. Crate lints run outside of a query
68-
// so rustdoc currently doesn't disable them.
69-
//
70-
// Instead of relying on this, either change crate lints to a query disabled by
71-
// rustdoc, only run internal lints if the user is explicitly opting in
72-
// or figure out a different way to avoid running lints for rustdoc.
73-
if cx.tcx.sess.opts.actually_rustdoc {
74-
return;
75-
}
76-
77-
let (def_id, span) = match expr.kind {
78-
ExprKind::Path(ref path) if let Some(def_id) = cx.qpath_res(path, expr.hir_id).opt_def_id() => {
79-
(def_id, expr.span)
80-
}
81-
ExprKind::MethodCall(_, span, _, _) if let Some(def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) => {
82-
(def_id, span)
83-
},
84-
_ => return,
85-
};
86-
87-
let substs = cx.typeck_results().node_substs(expr.hir_id);
88-
if let Ok(Some(instance)) = ty::Instance::resolve(cx.tcx, cx.param_env, def_id, substs) {
89-
let def_id = instance.def_id();
90-
if cx.tcx.has_attr(def_id, sym::rustc_lint_query_instability) {
91-
cx.struct_span_lint(POTENTIAL_QUERY_INSTABILITY, span, |lint| {
92-
let msg = format!(
93-
"using `{}` can result in unstable query results",
94-
cx.tcx.item_name(def_id)
95-
);
96-
lint.build(&msg)
97-
.note("if you believe this case to be fine, allow this lint and add a comment explaining your rationale")
98-
.emit();
99-
})
100-
}
101-
}
102-
}
103-
}
104-
10554
declare_tool_lint! {
10655
pub rustc::USAGE_OF_TY_TYKIND,
10756
Allow,

compiler/rustc_lint/src/lib.rs

-5
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@
3131
#![feature(box_patterns)]
3232
#![feature(crate_visibility_modifier)]
3333
#![feature(format_args_capture)]
34-
#![feature(if_let_guard)]
3534
#![feature(iter_order_by)]
3635
#![feature(iter_zip)]
3736
#![feature(never_type)]
3837
#![feature(nll)]
3938
#![feature(control_flow_enum)]
4039
#![recursion_limit = "256"]
41-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
4240

4341
#[macro_use]
4442
extern crate rustc_middle;
@@ -486,8 +484,6 @@ fn register_internals(store: &mut LintStore) {
486484
store.register_early_pass(|| Box::new(LintPassImpl));
487485
store.register_lints(&DefaultHashTypes::get_lints());
488486
store.register_late_pass(|| Box::new(DefaultHashTypes));
489-
store.register_lints(&QueryStability::get_lints());
490-
store.register_late_pass(|| Box::new(QueryStability));
491487
store.register_lints(&ExistingDocKeyword::get_lints());
492488
store.register_late_pass(|| Box::new(ExistingDocKeyword));
493489
store.register_lints(&TyTyKind::get_lints());
@@ -498,7 +494,6 @@ fn register_internals(store: &mut LintStore) {
498494
None,
499495
vec![
500496
LintId::of(DEFAULT_HASH_TYPES),
501-
LintId::of(POTENTIAL_QUERY_INSTABILITY),
502497
LintId::of(USAGE_OF_TY_TYKIND),
503498
LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),
504499
LintId::of(TY_PASS_BY_REFERENCE),

compiler/rustc_metadata/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#![feature(try_blocks)]
1111
#![feature(never_type)]
1212
#![recursion_limit = "256"]
13-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
1413

1514
extern crate proc_macro;
1615

compiler/rustc_middle/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
#![feature(try_reserve_kind)]
5757
#![feature(nonzero_ops)]
5858
#![recursion_limit = "512"]
59-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
6059

6160
#[macro_use]
6261
extern crate bitflags;

compiler/rustc_mir_build/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#![feature(once_cell)]
1111
#![feature(min_specialization)]
1212
#![recursion_limit = "256"]
13-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
1413

1514
#[macro_use]
1615
extern crate tracing;

compiler/rustc_mir_transform/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#![feature(trusted_step)]
1313
#![feature(try_blocks)]
1414
#![recursion_limit = "256"]
15-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
1615

1716
#[macro_use]
1817
extern crate tracing;

compiler/rustc_monomorphize/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#![feature(let_else)]
66
#![feature(in_band_lifetimes)]
77
#![recursion_limit = "256"]
8-
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
98

109
#[macro_use]
1110
extern crate tracing;

0 commit comments

Comments
 (0)