Auto merge of #90380 - Mark-Simulacrum:revert-89558-query-stable-lint, r=lcnr

Revert "Add rustc lint, warning when iterating over hashmaps"

Fixes perf regressions introduced in https://github.com/rust-lang/rust/pull/90235 by temporarily reverting the relevant PR.
This commit is contained in:
bors 2021-10-29 04:55:51 +00:00
commit 88a5a984fe
43 changed files with 68 additions and 299 deletions

View file

@ -35,7 +35,6 @@
#![feature(iter_zip)]
#![feature(never_type)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
use rustc_ast::token::{self, Token};
use rustc_ast::tokenstream::{CanSynthesizeMissingTokens, TokenStream, TokenTree};

View file

@ -7,7 +7,6 @@
#![feature(iter_is_partitioned)]
#![feature(box_patterns)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
pub mod ast_validation;
pub mod feature_gate;

View file

@ -12,7 +12,6 @@
#![feature(trusted_step)]
#![feature(try_blocks)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_middle;

View file

@ -11,7 +11,6 @@
#![feature(proc_macro_internals)]
#![feature(proc_macro_quote)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
extern crate proc_macro;

View file

@ -13,7 +13,6 @@
#![feature(iter_zip)]
#![feature(nll)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
use back::write::{create_informational_target_machine, create_target_machine};

View file

@ -8,7 +8,6 @@
#![feature(nll)]
#![feature(associated_type_bounds)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
//! The backend-agnostic functions of this crate use functions defined in various traits that

View file

@ -24,7 +24,6 @@
#![feature(trusted_step)]
#![feature(try_blocks)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate tracing;

View file

@ -27,7 +27,6 @@
#![feature(thread_id_value)]
#![allow(rustc::default_hash_types)]
#![deny(unaligned_references)]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate tracing;

View file

@ -8,7 +8,6 @@
#![feature(nll)]
#![feature(once_cell)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate tracing;
@ -847,7 +846,7 @@ fn sort_lint_groups(
let builtin = sort_lints(sess, builtin);
let (plugin_groups, builtin_groups): (Vec<_>, _) =
lint_store.get_lint_groups().partition(|&(.., p)| p);
lint_store.get_lint_groups().iter().cloned().partition(|&(.., p)| p);
let plugin_groups = sort_lint_groups(plugin_groups);
let builtin_groups = sort_lint_groups(builtin_groups);

View file

@ -10,7 +10,6 @@
#![feature(iter_zip)]
#![feature(let_else)]
#![feature(nll)]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_macros;

View file

@ -10,7 +10,6 @@
#![feature(proc_macro_span)]
#![feature(try_blocks)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_macros;

View file

@ -460,9 +460,6 @@ macro_rules! experimental {
// Prevents field reads in the marked trait or method to be considered
// during dead code analysis.
rustc_attr!(rustc_trivial_field_reads, Normal, template!(Word), INTERNAL_UNSTABLE),
// Used by the `rustc::potential_query_instability` lint to warn methods which
// might not be stable during incremental compilation.
rustc_attr!(rustc_lint_query_instability, Normal, template!(Word), INTERNAL_UNSTABLE),
// ==========================================================================
// Internal attributes, Const related:

View file

@ -5,7 +5,6 @@
#![feature(let_else)]
#![feature(nll)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_middle;

View file

@ -24,7 +24,6 @@
#![feature(min_specialization)]
#![feature(label_break_value)]
#![recursion_limit = "512"] // For rustdoc
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_macros;

View file

@ -5,7 +5,6 @@
#![feature(nll)]
#![feature(once_cell)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
mod callbacks;
pub mod interface;

View file

@ -144,11 +144,7 @@ pub fn get_lints<'t>(&'t self) -> &'t [&'static Lint] {
&self.lints
}
pub fn get_lint_groups<'t>(
&'t self,
) -> impl Iterator<Item = (&'static str, Vec<LintId>, bool)> + 't {
// This function is not used in a way which observes the order of lints.
#[cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
pub fn get_lint_groups<'t>(&'t self) -> Vec<(&'static str, Vec<LintId>, bool)> {
self.lint_groups
.iter()
.filter(|(_, LintGroup { depr, .. })| {
@ -158,6 +154,7 @@ pub fn get_lint_groups<'t>(
.map(|(k, LintGroup { lint_ids, from_plugin, .. })| {
(*k, lint_ids.clone(), *from_plugin)
})
.collect()
}
pub fn register_early_pass(

View file

@ -5,7 +5,10 @@
use rustc_ast as ast;
use rustc_errors::Applicability;
use rustc_hir::def::Res;
use rustc_hir::*;
use rustc_hir::{
GenericArg, HirId, Item, ItemKind, MutTy, Mutability, Node, Path, PathSegment, QPath, Ty,
TyKind,
};
use rustc_middle::ty;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::hygiene::{ExpnKind, MacroKind};
@ -48,60 +51,6 @@ fn check_path(&mut self, cx: &LateContext<'_>, path: &Path<'_>, hir_id: HirId) {
}
}
declare_tool_lint! {
pub rustc::POTENTIAL_QUERY_INSTABILITY,
Allow,
"require explicit opt-in when using potentially unstable methods or functions",
report_in_external_macro: true
}
declare_lint_pass!(QueryStability => [POTENTIAL_QUERY_INSTABILITY]);
impl LateLintPass<'_> for QueryStability {
fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
// FIXME(rustdoc): This lint uses typecheck results, causing rustdoc to
// error if there are resolution failures.
//
// As internal lints are currently always run if there are `unstable_options`,
// they are added to the lint store of rustdoc. Internal lints are also
// not used via the `lint_mod` query. Crate lints run outside of a query
// so rustdoc currently doesn't disable them.
//
// Instead of relying on this, either change crate lints to a query disabled by
// rustdoc, only run internal lints if the user is explicitly opting in
// or figure out a different way to avoid running lints for rustdoc.
if cx.tcx.sess.opts.actually_rustdoc {
return;
}
let (def_id, span) = match expr.kind {
ExprKind::Path(ref path) if let Some(def_id) = cx.qpath_res(path, expr.hir_id).opt_def_id() => {
(def_id, expr.span)
}
ExprKind::MethodCall(_, span, _, _) if let Some(def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id) => {
(def_id, span)
},
_ => return,
};
let substs = cx.typeck_results().node_substs(expr.hir_id);
if let Ok(Some(instance)) = ty::Instance::resolve(cx.tcx, cx.param_env, def_id, substs) {
let def_id = instance.def_id();
if cx.tcx.has_attr(def_id, sym::rustc_lint_query_instability) {
cx.struct_span_lint(POTENTIAL_QUERY_INSTABILITY, span, |lint| {
let msg = format!(
"using `{}` can result in unstable query results",
cx.tcx.item_name(def_id)
);
lint.build(&msg)
.note("if you believe this case to be fine, allow this lint and add a comment explaining your rationale")
.emit();
})
}
}
}
}
declare_tool_lint! {
pub rustc::USAGE_OF_TY_TYKIND,
Allow,

View file

@ -31,14 +31,12 @@
#![feature(box_patterns)]
#![feature(crate_visibility_modifier)]
#![feature(format_args_capture)]
#![feature(if_let_guard)]
#![feature(iter_order_by)]
#![feature(iter_zip)]
#![feature(never_type)]
#![feature(nll)]
#![feature(control_flow_enum)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_middle;
@ -486,8 +484,6 @@ fn register_internals(store: &mut LintStore) {
store.register_early_pass(|| Box::new(LintPassImpl));
store.register_lints(&DefaultHashTypes::get_lints());
store.register_late_pass(|| Box::new(DefaultHashTypes));
store.register_lints(&QueryStability::get_lints());
store.register_late_pass(|| Box::new(QueryStability));
store.register_lints(&ExistingDocKeyword::get_lints());
store.register_late_pass(|| Box::new(ExistingDocKeyword));
store.register_lints(&TyTyKind::get_lints());
@ -498,7 +494,6 @@ fn register_internals(store: &mut LintStore) {
None,
vec![
LintId::of(DEFAULT_HASH_TYPES),
LintId::of(POTENTIAL_QUERY_INSTABILITY),
LintId::of(USAGE_OF_TY_TYKIND),
LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),
LintId::of(TY_PASS_BY_REFERENCE),

View file

@ -10,7 +10,6 @@
#![feature(try_blocks)]
#![feature(never_type)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
extern crate proc_macro;

View file

@ -56,7 +56,6 @@
#![feature(try_reserve_kind)]
#![feature(nonzero_ops)]
#![recursion_limit = "512"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate bitflags;

View file

@ -10,7 +10,6 @@
#![feature(once_cell)]
#![feature(min_specialization)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate tracing;

View file

@ -12,7 +12,6 @@
#![feature(trusted_step)]
#![feature(try_blocks)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate tracing;

View file

@ -5,7 +5,6 @@
#![feature(let_else)]
#![feature(in_band_lifetimes)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate tracing;

View file

@ -62,7 +62,7 @@ impl CheckAttrVisitor<'tcx> {
fn check_attributes(
&self,
hir_id: HirId,
span: Span,
span: &Span,
target: Target,
item: Option<ItemLike<'_>>,
) {
@ -78,7 +78,7 @@ fn check_attributes(
sym::marker => self.check_marker(hir_id, attr, span, target),
sym::target_feature => self.check_target_feature(hir_id, attr, span, target),
sym::track_caller => {
self.check_track_caller(hir_id, attr.span, attrs, span, target)
self.check_track_caller(hir_id, &attr.span, attrs, span, target)
}
sym::doc => self.check_doc_attrs(
attr,
@ -103,9 +103,6 @@ fn check_attributes(
sym::rustc_legacy_const_generics => {
self.check_rustc_legacy_const_generics(&attr, span, target, item)
}
sym::rustc_lint_query_instability => {
self.check_rustc_lint_query_instability(&attr, span, target)
}
sym::rustc_clean
| sym::rustc_dirty
| sym::rustc_if_this_changed
@ -233,7 +230,7 @@ fn inline_attr_str_error_without_macro_def(&self, hir_id: HirId, attr: &Attribut
}
/// Checks if an `#[inline]` is applied to a function or a closure. Returns `true` if valid.
fn check_inline(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) -> bool {
fn check_inline(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) -> bool {
match target {
Target::Fn
| Target::Closure
@ -276,7 +273,7 @@ fn check_inline(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Targ
E0518,
"attribute should be applied to function or closure",
)
.span_label(span, "not a function or closure")
.span_label(*span, "not a function or closure")
.emit();
false
}
@ -315,7 +312,7 @@ fn check_generic_attr(
}
/// Checks if `#[naked]` is applied to a function definition.
fn check_naked(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) -> bool {
fn check_naked(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) -> bool {
match target {
Target::Fn
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => true,
@ -334,7 +331,7 @@ fn check_naked(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Targe
attr.span,
"attribute should be applied to a function definition",
)
.span_label(span, "not a function definition")
.span_label(*span, "not a function definition")
.emit();
false
}
@ -342,7 +339,7 @@ fn check_naked(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Targe
}
/// Checks if `#[cmse_nonsecure_entry]` is applied to a function definition.
fn check_cmse_nonsecure_entry(&self, attr: &Attribute, span: Span, target: Target) -> bool {
fn check_cmse_nonsecure_entry(&self, attr: &Attribute, span: &Span, target: Target) -> bool {
match target {
Target::Fn
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => true,
@ -353,7 +350,7 @@ fn check_cmse_nonsecure_entry(&self, attr: &Attribute, span: Span, target: Targe
attr.span,
"attribute should be applied to a function definition",
)
.span_label(span, "not a function definition")
.span_label(*span, "not a function definition")
.emit();
false
}
@ -364,16 +361,16 @@ fn check_cmse_nonsecure_entry(&self, attr: &Attribute, span: Span, target: Targe
fn check_track_caller(
&self,
hir_id: HirId,
attr_span: Span,
attr_span: &Span,
attrs: &'hir [Attribute],
span: Span,
span: &Span,
target: Target,
) -> bool {
match target {
_ if attrs.iter().any(|attr| attr.has_name(sym::naked)) => {
struct_span_err!(
self.tcx.sess,
attr_span,
*attr_span,
E0736,
"cannot use `#[track_caller]` with `#[naked]`",
)
@ -394,11 +391,11 @@ fn check_track_caller(
_ => {
struct_span_err!(
self.tcx.sess,
attr_span,
*attr_span,
E0739,
"attribute should be applied to function"
)
.span_label(span, "not a function")
.span_label(*span, "not a function")
.emit();
false
}
@ -410,7 +407,7 @@ fn check_non_exhaustive(
&self,
hir_id: HirId,
attr: &Attribute,
span: Span,
span: &Span,
target: Target,
) -> bool {
match target {
@ -430,7 +427,7 @@ fn check_non_exhaustive(
E0701,
"attribute can only be applied to a struct or enum"
)
.span_label(span, "not a struct or enum")
.span_label(*span, "not a struct or enum")
.emit();
false
}
@ -438,7 +435,7 @@ fn check_non_exhaustive(
}
/// Checks if the `#[marker]` attribute on an `item` is valid. Returns `true` if valid.
fn check_marker(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) -> bool {
fn check_marker(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) -> bool {
match target {
Target::Trait => true,
// FIXME(#80564): We permit struct fields, match arms and macro defs to have an
@ -453,7 +450,7 @@ fn check_marker(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Targ
self.tcx
.sess
.struct_span_err(attr.span, "attribute can only be applied to a trait")
.span_label(span, "not a trait")
.span_label(*span, "not a trait")
.emit();
false
}
@ -465,7 +462,7 @@ fn check_target_feature(
&self,
hir_id: HirId,
attr: &Attribute,
span: Span,
span: &Span,
target: Target,
) -> bool {
match target {
@ -481,7 +478,7 @@ fn check_target_feature(
being phased out; it will become a hard error in \
a future release!",
)
.span_label(span, "not a function")
.span_label(*span, "not a function")
.emit();
});
true
@ -498,7 +495,7 @@ fn check_target_feature(
self.tcx
.sess
.struct_span_err(attr.span, "attribute should be applied to a function")
.span_label(span, "not a function")
.span_label(*span, "not a function")
.emit();
false
}
@ -1050,14 +1047,14 @@ fn check_doc_attrs(
}
/// Checks if `#[must_not_suspend]` is applied to a function. Returns `true` if valid.
fn check_must_not_suspend(&self, attr: &Attribute, span: Span, target: Target) -> bool {
fn check_must_not_suspend(&self, attr: &Attribute, span: &Span, target: Target) -> bool {
match target {
Target::Struct | Target::Enum | Target::Union | Target::Trait => true,
_ => {
self.tcx
.sess
.struct_span_err(attr.span, "`must_not_suspend` attribute should be applied to a struct, enum, or trait")
.span_label(span, "is not a struct, enum, or trait")
.span_label(*span, "is not a struct, enum, or trait")
.emit();
false
}
@ -1065,7 +1062,7 @@ fn check_must_not_suspend(&self, attr: &Attribute, span: Span, target: Target) -
}
/// Checks if `#[cold]` is applied to a non-function. Returns `true` if valid.
fn check_cold(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) {
fn check_cold(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) {
match target {
Target::Fn | Target::Method(..) | Target::ForeignFn | Target::Closure => {}
// FIXME(#80564): We permit struct fields, match arms and macro defs to have an
@ -1085,7 +1082,7 @@ fn check_cold(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target
being phased out; it will become a hard error in \
a future release!",
)
.span_label(span, "not a function")
.span_label(*span, "not a function")
.emit();
});
}
@ -1093,7 +1090,7 @@ fn check_cold(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target
}
/// Checks if `#[link_name]` is applied to an item other than a foreign function or static.
fn check_link_name(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) {
fn check_link_name(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) {
match target {
Target::ForeignFn | Target::ForeignStatic => {}
// FIXME(#80564): We permit struct fields, match arms and macro defs to have an
@ -1127,7 +1124,7 @@ fn check_link_name(&self, hir_id: HirId, attr: &Attribute, span: Span, target: T
}
}
diag.span_label(span, "not a foreign function or static");
diag.span_label(*span, "not a foreign function or static");
diag.emit();
});
}
@ -1135,7 +1132,7 @@ fn check_link_name(&self, hir_id: HirId, attr: &Attribute, span: Span, target: T
}
/// Checks if `#[no_link]` is applied to an `extern crate`. Returns `true` if valid.
fn check_no_link(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) -> bool {
fn check_no_link(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) -> bool {
match target {
Target::ExternCrate => true,
// FIXME(#80564): We permit struct fields, match arms and macro defs to have an
@ -1153,7 +1150,7 @@ fn check_no_link(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Tar
attr.span,
"attribute should be applied to an `extern crate` item",
)
.span_label(span, "not an `extern crate` item")
.span_label(*span, "not an `extern crate` item")
.emit();
false
}
@ -1169,7 +1166,7 @@ fn check_export_name(
&self,
hir_id: HirId,
attr: &Attribute,
span: Span,
span: &Span,
target: Target,
) -> bool {
match target {
@ -1190,7 +1187,7 @@ fn check_export_name(
attr.span,
"attribute should be applied to a free function, impl method or static",
)
.span_label(span, "not a free function, impl method or static")
.span_label(*span, "not a free function, impl method or static")
.emit();
false
}
@ -1200,14 +1197,14 @@ fn check_export_name(
fn check_rustc_layout_scalar_valid_range(
&self,
attr: &Attribute,
span: Span,
span: &Span,
target: Target,
) -> bool {
if target != Target::Struct {
self.tcx
.sess
.struct_span_err(attr.span, "attribute should be applied to a struct")
.span_label(span, "not a struct")
.span_label(*span, "not a struct")
.emit();
return false;
}
@ -1232,7 +1229,7 @@ fn check_rustc_layout_scalar_valid_range(
fn check_rustc_legacy_const_generics(
&self,
attr: &Attribute,
span: Span,
span: &Span,
target: Target,
item: Option<ItemLike<'_>>,
) -> bool {
@ -1241,7 +1238,7 @@ fn check_rustc_legacy_const_generics(
self.tcx
.sess
.struct_span_err(attr.span, "attribute should be applied to a function")
.span_label(span, "not a function")
.span_label(*span, "not a function")
.emit();
return false;
}
@ -1327,25 +1324,6 @@ fn check_rustc_legacy_const_generics(
}
}
fn check_rustc_lint_query_instability(
&self,
attr: &Attribute,
span: Span,
target: Target,
) -> bool {
let is_function = matches!(target, Target::Fn | Target::Method(..));
if !is_function {
self.tcx
.sess
.struct_span_err(attr.span, "attribute should be applied to a function")
.span_label(span, "not a function")
.emit();
false
} else {
true
}
}
/// Checks that the dep-graph debugging attributes are only present when the query-dep-graph
/// option is passed to the compiler.
fn check_rustc_dirty_clean(&self, attr: &Attribute) -> bool {
@ -1361,7 +1339,7 @@ fn check_rustc_dirty_clean(&self, attr: &Attribute) -> bool {
}
/// Checks if `#[link_section]` is applied to a function or static.
fn check_link_section(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) {
fn check_link_section(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) {
match target {
Target::Static | Target::Fn | Target::Method(..) => {}
// FIXME(#80564): We permit struct fields, match arms and macro defs to have an
@ -1381,7 +1359,7 @@ fn check_link_section(&self, hir_id: HirId, attr: &Attribute, span: Span, target
being phased out; it will become a hard error in \
a future release!",
)
.span_label(span, "not a function or static")
.span_label(*span, "not a function or static")
.emit();
});
}
@ -1389,7 +1367,7 @@ fn check_link_section(&self, hir_id: HirId, attr: &Attribute, span: Span, target
}
/// Checks if `#[no_mangle]` is applied to a function or static.
fn check_no_mangle(&self, hir_id: HirId, attr: &Attribute, span: Span, target: Target) {
fn check_no_mangle(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) {
match target {
Target::Static | Target::Fn => {}
Target::Method(..) if self.is_impl_item(hir_id) => {}
@ -1419,7 +1397,7 @@ fn check_no_mangle(&self, hir_id: HirId, attr: &Attribute, span: Span, target: T
being phased out; it will become a hard error in \
a future release!",
)
.span_label(span, format!("foreign {}", foreign_item_kind))
.span_label(*span, format!("foreign {}", foreign_item_kind))
.note("symbol names in extern blocks are not mangled")
.span_suggestion(
attr.span,
@ -1442,7 +1420,7 @@ fn check_no_mangle(&self, hir_id: HirId, attr: &Attribute, span: Span, target: T
being phased out; it will become a hard error in \
a future release!",
)
.span_label(span, "not a free function, impl method or static")
.span_label(*span, "not a free function, impl method or static")
.emit();
});
}
@ -1453,7 +1431,7 @@ fn check_no_mangle(&self, hir_id: HirId, attr: &Attribute, span: Span, target: T
fn check_repr(
&self,
attrs: &'hir [Attribute],
span: Span,
span: &Span,
target: Target,
item: Option<ItemLike<'_>>,
hir_id: HirId,
@ -1587,7 +1565,7 @@ fn check_repr(
"{}",
&format!("attribute should be applied to {} {}", article, allowed_targets)
)
.span_label(span, &format!("not {} {}", article, allowed_targets))
.span_label(*span, &format!("not {} {}", article, allowed_targets))
.emit();
}
@ -1650,7 +1628,7 @@ fn check_allow_internal_unstable(
&self,
hir_id: HirId,
attr: &Attribute,
span: Span,
span: &Span,
target: Target,
attrs: &[Attribute],
) -> bool {
@ -1683,7 +1661,7 @@ fn check_allow_internal_unstable(
self.tcx
.sess
.struct_span_err(attr.span, "attribute should be applied to a macro")
.span_label(span, "not a macro")
.span_label(*span, "not a macro")
.emit();
false
}
@ -1696,7 +1674,7 @@ fn check_rustc_allow_const_fn_unstable(
&self,
hir_id: HirId,
attr: &Attribute,
span: Span,
span: &Span,
target: Target,
) -> bool {
match target {
@ -1717,7 +1695,7 @@ fn check_rustc_allow_const_fn_unstable(
self.tcx
.sess
.struct_span_err(attr.span, "attribute should be applied to `const fn`")
.span_label(span, "not a `const fn`")
.span_label(*span, "not a `const fn`")
.emit();
false
}
@ -1728,7 +1706,7 @@ fn check_rustc_allow_const_fn_unstable(
fn check_default_method_body_is_const(
&self,
attr: &Attribute,
span: Span,
span: &Span,
target: Target,
) -> bool {
match target {
@ -1740,14 +1718,14 @@ fn check_default_method_body_is_const(
attr.span,
"attribute should be applied to a trait method with body",
)
.span_label(span, "not a trait method or missing a body")
.span_label(*span, "not a trait method or missing a body")
.emit();
false
}
}
}
fn check_stability_promotable(&self, attr: &Attribute, _span: Span, target: Target) -> bool {
fn check_stability_promotable(&self, attr: &Attribute, _span: &Span, target: Target) -> bool {
match target {
Target::Expression => {
self.tcx
@ -1760,7 +1738,7 @@ fn check_stability_promotable(&self, attr: &Attribute, _span: Span, target: Targ
}
}
fn check_deprecated(&self, hir_id: HirId, attr: &Attribute, _span: Span, target: Target) {
fn check_deprecated(&self, hir_id: HirId, attr: &Attribute, _span: &Span, target: Target) {
match target {
Target::Closure | Target::Expression | Target::Statement | Target::Arm => {
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
@ -1832,29 +1810,29 @@ fn visit_item(&mut self, item: &'tcx Item<'tcx>) {
}
let target = Target::from_item(item);
self.check_attributes(item.hir_id(), item.span, target, Some(ItemLike::Item(item)));
self.check_attributes(item.hir_id(), &item.span, target, Some(ItemLike::Item(item)));
intravisit::walk_item(self, item)
}
fn visit_generic_param(&mut self, generic_param: &'tcx hir::GenericParam<'tcx>) {
let target = Target::from_generic_param(generic_param);
self.check_attributes(generic_param.hir_id, generic_param.span, target, None);
self.check_attributes(generic_param.hir_id, &generic_param.span, target, None);
intravisit::walk_generic_param(self, generic_param)
}
fn visit_trait_item(&mut self, trait_item: &'tcx TraitItem<'tcx>) {
let target = Target::from_trait_item(trait_item);
self.check_attributes(trait_item.hir_id(), trait_item.span, target, None);
self.check_attributes(trait_item.hir_id(), &trait_item.span, target, None);
intravisit::walk_trait_item(self, trait_item)
}
fn visit_field_def(&mut self, struct_field: &'tcx hir::FieldDef<'tcx>) {
self.check_attributes(struct_field.hir_id, struct_field.span, Target::Field, None);
self.check_attributes(struct_field.hir_id, &struct_field.span, Target::Field, None);
intravisit::walk_field_def(self, struct_field);
}
fn visit_arm(&mut self, arm: &'tcx hir::Arm<'tcx>) {
self.check_attributes(arm.hir_id, arm.span, Target::Arm, None);
self.check_attributes(arm.hir_id, &arm.span, Target::Arm, None);
intravisit::walk_arm(self, arm);
}
@ -1862,7 +1840,7 @@ fn visit_foreign_item(&mut self, f_item: &'tcx ForeignItem<'tcx>) {
let target = Target::from_foreign_item(f_item);
self.check_attributes(
f_item.hir_id(),
f_item.span,
&f_item.span,
target,
Some(ItemLike::ForeignItem(f_item)),
);
@ -1871,14 +1849,14 @@ fn visit_foreign_item(&mut self, f_item: &'tcx ForeignItem<'tcx>) {
fn visit_impl_item(&mut self, impl_item: &'tcx hir::ImplItem<'tcx>) {
let target = target_from_impl_item(self.tcx, impl_item);
self.check_attributes(impl_item.hir_id(), impl_item.span, target, None);
self.check_attributes(impl_item.hir_id(), &impl_item.span, target, None);
intravisit::walk_impl_item(self, impl_item)
}
fn visit_stmt(&mut self, stmt: &'tcx hir::Stmt<'tcx>) {
// When checking statements ignore expressions, they will be checked later.
if let hir::StmtKind::Local(ref l) = stmt.kind {
self.check_attributes(l.hir_id, stmt.span, Target::Statement, None);
self.check_attributes(l.hir_id, &stmt.span, Target::Statement, None);
}
intravisit::walk_stmt(self, stmt)
}
@ -1889,7 +1867,7 @@ fn visit_expr(&mut self, expr: &'tcx hir::Expr<'tcx>) {
_ => Target::Expression,
};
self.check_attributes(expr.hir_id, expr.span, target, None);
self.check_attributes(expr.hir_id, &expr.span, target, None);
intravisit::walk_expr(self, expr)
}
@ -1899,12 +1877,12 @@ fn visit_variant(
generics: &'tcx hir::Generics<'tcx>,
item_id: HirId,
) {
self.check_attributes(variant.id, variant.span, Target::Variant, None);
self.check_attributes(variant.id, &variant.span, Target::Variant, None);
intravisit::walk_variant(self, variant, generics, item_id)
}
fn visit_param(&mut self, param: &'tcx hir::Param<'tcx>) {
self.check_attributes(param.hir_id, param.span, Target::Param, None);
self.check_attributes(param.hir_id, &param.span, Target::Param, None);
intravisit::walk_param(self, param);
}
@ -1972,7 +1950,7 @@ fn check_mod_attrs(tcx: TyCtxt<'_>, module_def_id: LocalDefId) {
let check_attr_visitor = &mut CheckAttrVisitor { tcx };
tcx.hir().visit_item_likes_in_module(module_def_id, &mut check_attr_visitor.as_deep_visitor());
if module_def_id.is_top_level_module() {
check_attr_visitor.check_attributes(CRATE_HIR_ID, DUMMY_SP, Target::Mod, None);
check_attr_visitor.check_attributes(CRATE_HIR_ID, &DUMMY_SP, Target::Mod, None);
check_invalid_crate_level_attr(tcx, tcx.hir().krate_attrs());
}
}

View file

@ -14,7 +14,6 @@
#![feature(nll)]
#![feature(try_blocks)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_middle;

View file

@ -5,7 +5,6 @@
#![feature(try_blocks)]
#![feature(associated_type_defaults)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
use rustc_ast::MacroDef;
use rustc_attr as attr;

View file

@ -8,7 +8,6 @@
#![feature(once_cell)]
#![feature(rustc_attrs)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_macros;

View file

@ -6,7 +6,6 @@
#![feature(let_else)]
#![feature(min_specialization)]
#![feature(thread_local_const_init)]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate tracing;

View file

@ -20,7 +20,6 @@
#![feature(nll)]
#![recursion_limit = "256"]
#![allow(rustdoc::private_intra_doc_links)]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate tracing;

View file

@ -2,7 +2,6 @@
#![feature(if_let_guard)]
#![feature(nll)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
mod dump_visitor;
mod dumper;

View file

@ -2,7 +2,6 @@
#![feature(min_specialization)]
#![feature(once_cell)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_macros;

View file

@ -21,7 +21,6 @@
#![feature(nll)]
#![feature(min_specialization)]
#![feature(thread_local_const_init)]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_macros;

View file

@ -1115,7 +1115,6 @@
rustc_layout_scalar_valid_range_end,
rustc_layout_scalar_valid_range_start,
rustc_legacy_const_generics,
rustc_lint_query_instability,
rustc_macro_transparency,
rustc_main,
rustc_mir,

View file

@ -93,7 +93,6 @@
#![feature(in_band_lifetimes)]
#![feature(iter_zip)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_middle;

View file

@ -22,7 +22,6 @@
#![feature(crate_visibility_modifier)]
#![feature(control_flow_enum)]
#![recursion_limit = "512"] // For rustdoc
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate rustc_macros;

View file

@ -829,7 +829,6 @@ pub(in super::super) fn resolve_lang_item_path(
self.tcx.type_of(def_id)
};
let substs = self.infcx.fresh_substs_for_item(span, def_id);
self.write_substs(hir_id, substs);
let ty = item_ty.subst(self.tcx, substs);
self.write_resolution(hir_id, Ok((def_kind, def_id)));

View file

@ -71,7 +71,6 @@
#![feature(slice_partition_dedup)]
#![feature(control_flow_enum)]
#![recursion_limit = "256"]
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
#[macro_use]
extern crate tracing;

View file

@ -414,7 +414,6 @@ pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> {
/// println!("key: {} val: {}", key, val);
/// }
/// ```
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn iter(&self) -> Iter<'_, K, V> {
Iter { base: self.base.iter() }
@ -443,7 +442,6 @@ pub fn iter(&self) -> Iter<'_, K, V> {
/// println!("key: {} val: {}", key, val);
/// }
/// ```
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> {
IterMut { base: self.base.iter_mut() }
@ -504,7 +502,6 @@ pub fn is_empty(&self) -> bool {
/// assert!(a.is_empty());
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "drain", since = "1.6.0")]
pub fn drain(&mut self) -> Drain<'_, K, V> {
Drain { base: self.base.drain() }
@ -546,7 +543,6 @@ pub fn drain(&mut self) -> Drain<'_, K, V> {
/// assert_eq!(odds, vec![1, 3, 5, 7]);
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[unstable(feature = "hash_drain_filter", issue = "59618")]
pub fn drain_filter<F>(&mut self, pred: F) -> DrainFilter<'_, K, V, F>
where
@ -953,7 +949,6 @@ pub fn remove_entry<Q: ?Sized>(&mut self, k: &Q) -> Option<(K, V)>
/// assert_eq!(map.len(), 4);
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "retain_hash_collection", since = "1.18.0")]
pub fn retain<F>(&mut self, f: F)
where
@ -983,7 +978,6 @@ pub fn retain<F>(&mut self, f: F)
/// assert_eq!(vec, ["a", "b", "c"]);
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "map_into_keys_values", since = "1.54.0")]
pub fn into_keys(self) -> IntoKeys<K, V> {
IntoKeys { inner: self.into_iter() }
@ -1010,7 +1004,6 @@ pub fn into_keys(self) -> IntoKeys<K, V> {
/// assert_eq!(vec, [1, 2, 3]);
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "map_into_keys_values", since = "1.54.0")]
pub fn into_values(self) -> IntoValues<K, V> {
IntoValues { inner: self.into_iter() }
@ -1976,7 +1969,6 @@ impl<'a, K, V, S> IntoIterator for &'a HashMap<K, V, S> {
type IntoIter = Iter<'a, K, V>;
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
fn into_iter(self) -> Iter<'a, K, V> {
self.iter()
}
@ -1988,7 +1980,6 @@ impl<'a, K, V, S> IntoIterator for &'a mut HashMap<K, V, S> {
type IntoIter = IterMut<'a, K, V>;
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
fn into_iter(self) -> IterMut<'a, K, V> {
self.iter_mut()
}
@ -2017,7 +2008,6 @@ impl<K, V, S> IntoIterator for HashMap<K, V, S> {
/// let vec: Vec<(&str, i32)> = map.into_iter().collect();
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
fn into_iter(self) -> IntoIter<K, V> {
IntoIter { base: self.base.into_iter() }
}

View file

@ -185,7 +185,6 @@ pub fn capacity(&self) -> usize {
/// }
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn iter(&self) -> Iter<'_, T> {
Iter { base: self.base.iter() }
@ -245,7 +244,6 @@ pub fn is_empty(&self) -> bool {
/// assert!(set.is_empty());
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "drain", since = "1.6.0")]
pub fn drain(&mut self) -> Drain<'_, T> {
Drain { base: self.base.drain() }
@ -284,7 +282,6 @@ pub fn drain(&mut self) -> Drain<'_, T> {
/// assert_eq!(odds, vec![1, 3, 5, 7]);
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[unstable(feature = "hash_drain_filter", issue = "59618")]
pub fn drain_filter<F>(&mut self, pred: F) -> DrainFilter<'_, T, F>
where
@ -509,7 +506,6 @@ pub fn shrink_to(&mut self, min_capacity: usize) {
/// assert_eq!(diff, [4].iter().collect());
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn difference<'a>(&'a self, other: &'a HashSet<T, S>) -> Difference<'a, T, S> {
Difference { iter: self.iter(), other }
@ -537,7 +533,6 @@ pub fn difference<'a>(&'a self, other: &'a HashSet<T, S>) -> Difference<'a, T, S
/// assert_eq!(diff1, [1, 4].iter().collect());
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn symmetric_difference<'a>(
&'a self,
@ -565,7 +560,6 @@ pub fn symmetric_difference<'a>(
/// assert_eq!(intersection, [2, 3].iter().collect());
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn intersection<'a>(&'a self, other: &'a HashSet<T, S>) -> Intersection<'a, T, S> {
if self.len() <= other.len() {
@ -594,7 +588,6 @@ pub fn intersection<'a>(&'a self, other: &'a HashSet<T, S>) -> Intersection<'a,
/// assert_eq!(union, [1, 2, 3, 4].iter().collect());
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn union<'a>(&'a self, other: &'a HashSet<T, S>) -> Union<'a, T, S> {
if self.len() >= other.len() {
@ -929,7 +922,6 @@ pub fn take<Q: ?Sized>(&mut self, value: &Q) -> Option<T>
/// set.retain(|&k| k % 2 == 0);
/// assert_eq!(set.len(), 3);
/// ```
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
#[stable(feature = "retain_hash_collection", since = "1.18.0")]
pub fn retain<F>(&mut self, f: F)
where
@ -1411,7 +1403,6 @@ impl<'a, T, S> IntoIterator for &'a HashSet<T, S> {
type IntoIter = Iter<'a, T>;
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
fn into_iter(self) -> Iter<'a, T> {
self.iter()
}
@ -1443,7 +1434,6 @@ impl<T, S> IntoIterator for HashSet<T, S> {
/// }
/// ```
#[inline]
#[cfg_attr(not(bootstrap), rustc_lint_query_instability)]
fn into_iter(self) -> IntoIter<T> {
IntoIter { base: self.base.into_iter() }
}

View file

@ -1,24 +0,0 @@
// compile-flags: -Z unstable-options
#![feature(rustc_private)]
#![deny(rustc::potential_query_instability)]
extern crate rustc_data_structures;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
fn main() {
let mut x = FxHashMap::<u32, i32>::default();
for _ in x.drain() {}
//~^ ERROR using `drain` can result in unstable
for _ in x.iter() {}
//~^ ERROR using `iter`
for _ in Some(&mut x).unwrap().iter_mut() {}
//~^ ERROR using `iter_mut`
for _ in x {}
//~^ ERROR using `into_iter`
}

View file

@ -1,39 +0,0 @@
error: using `drain` can result in unstable query results
--> $DIR/query_stability.rs:13:16
|
LL | for _ in x.drain() {}
| ^^^^^
|
note: the lint level is defined here
--> $DIR/query_stability.rs:4:9
|
LL | #![deny(rustc::potential_query_instability)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale
error: using `iter` can result in unstable query results
--> $DIR/query_stability.rs:16:16
|
LL | for _ in x.iter() {}
| ^^^^
|
= note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale
error: using `iter_mut` can result in unstable query results
--> $DIR/query_stability.rs:19:36
|
LL | for _ in Some(&mut x).unwrap().iter_mut() {}
| ^^^^^^^^
|
= note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale
error: using `into_iter` can result in unstable query results
--> $DIR/query_stability.rs:22:14
|
LL | for _ in x {}
| ^
|
= note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale
error: aborting due to 4 previous errors

View file

@ -1,15 +0,0 @@
// compile-flags: -Z unstable-options
#![feature(rustc_attrs)]
#[rustc_lint_query_instability]
//~^ ERROR attribute should be applied to a function
struct Foo;
impl Foo {
#[rustc_lint_query_instability(a)]
//~^ ERROR malformed `rustc_lint_query_instability`
fn bar() {}
}
fn main() {}

View file

@ -1,17 +0,0 @@
error: malformed `rustc_lint_query_instability` attribute input
--> $DIR/query_stability_incorrect.rs:10:5
|
LL | #[rustc_lint_query_instability(a)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_lint_query_instability]`
error: attribute should be applied to a function
--> $DIR/query_stability_incorrect.rs:5:1
|
LL | #[rustc_lint_query_instability]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL |
LL | struct Foo;
| ----------- not a function
error: aborting due to 2 previous errors