Skip to content

Commit 00d5e42

Browse files
committed
Auto merge of #90235 - matthiaskrgr:rollup-7pqtevk, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #89558 (Add rustc lint, warning when iterating over hashmaps) - #90100 (Skip documentation for tier 2 targets on dist-x86_64-apple-darwin) - #90155 (Fix alignment of method headings for scannability) - #90162 (Mark `{array, slice}::{from_ref, from_mut}` as const fn) - #90221 (Fix ICE when forgetting to `Box` a parameter to a `Self::func` call) - #90234 (Temporarily turn overflow checks off for rustc-rayon-core) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents ed08a67 + eee29fd commit 00d5e42

File tree

58 files changed

+409
-98
lines changed

Some content is hidden

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

58 files changed

+409
-98
lines changed

.github/workflows/ci.yml

+11-4
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ jobs:
287287
os: ubuntu-latest-xl
288288
- name: dist-x86_64-apple
289289
env:
290-
SCRIPT: "./x.py dist"
290+
SCRIPT: "./x.py dist --exclude src/doc --exclude extended && ./x.py dist --target=x86_64-apple-darwin src/doc && ./x.py dist extended"
291291
RUST_CONFIGURE_ARGS: "--host=x86_64-apple-darwin --target=x86_64-apple-darwin,aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
292292
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
293293
MACOSX_DEPLOYMENT_TARGET: 10.7
@@ -532,9 +532,16 @@ jobs:
532532
strategy:
533533
matrix:
534534
include:
535-
- name: dist-x86_64-linux
536-
os: ubuntu-latest-xl
537-
env: {}
535+
- name: dist-x86_64-apple
536+
env:
537+
SCRIPT: "./x.py dist --exclude src/doc --exclude extended && ./x.py dist --target=x86_64-apple-darwin src/doc && ./x.py dist extended"
538+
RUST_CONFIGURE_ARGS: "--host=x86_64-apple-darwin --target=x86_64-apple-darwin,aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false"
539+
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
540+
MACOSX_DEPLOYMENT_TARGET: 10.7
541+
NO_LLVM_ASSERTIONS: 1
542+
NO_DEBUG_ASSERTIONS: 1
543+
DIST_REQUIRE_ALL_TOOLS: 1
544+
os: macos-latest
538545
timeout-minutes: 600
539546
runs-on: "${{ matrix.os }}"
540547
steps:

Cargo.toml

+7
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ overflow-checks = false
7777
# per-crate configuration isn't specifiable in the environment.
7878
codegen-units = 10000
7979

80+
[profile.release.package.rustc-rayon-core]
81+
# The rustc fork of Rayon has deadlock detection code which intermittently
82+
# causes overflows in the CI (see https://github.com/rust-lang/rust/issues/90227)
83+
# so we turn overflow checks off for now.
84+
# FIXME: This workaround should be removed once #90227 is fixed.
85+
overflow-checks = false
86+
8087
# These dependencies of the standard library implement symbolication for
8188
# backtraces on most platforms. Their debuginfo causes both linking to be slower
8289
# (more data to chew through) and binaries to be larger without really all that

compiler/rustc_ast_lowering/src/lib.rs

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

3940
use rustc_ast::token::{self, Token};
4041
use rustc_ast::tokenstream::{CanSynthesizeMissingTokens, TokenStream, TokenTree};

compiler/rustc_ast_passes/src/lib.rs

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

1112
pub mod ast_validation;
1213
pub mod feature_gate;

compiler/rustc_borrowck/src/lib.rs

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

1718
#[macro_use]
1819
extern crate rustc_middle;

compiler/rustc_builtin_macros/src/lib.rs

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

1516
extern crate proc_macro;
1617

compiler/rustc_codegen_llvm/src/lib.rs

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

1718
use back::write::{create_informational_target_machine, create_target_machine};
1819

compiler/rustc_codegen_ssa/src/lib.rs

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

1213
//! This crate contains codegen code that is used by all codegen backends (LLVM and others).
1314
//! 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,6 +24,7 @@ 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))]
2728

2829
#[macro_use]
2930
extern crate tracing;

compiler/rustc_data_structures/src/lib.rs

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

3233
#[macro_use]
3334
extern crate tracing;

compiler/rustc_driver/src/lib.rs

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

1213
#[macro_use]
1314
extern crate tracing;
@@ -846,7 +847,7 @@ Available lint options:
846847
let builtin = sort_lints(sess, builtin);
847848

848849
let (plugin_groups, builtin_groups): (Vec<_>, _) =
849-
lint_store.get_lint_groups().iter().cloned().partition(|&(.., p)| p);
850+
lint_store.get_lint_groups().partition(|&(.., p)| p);
850851
let plugin_groups = sort_lint_groups(plugin_groups);
851852
let builtin_groups = sort_lint_groups(builtin_groups);
852853

compiler/rustc_errors/src/lib.rs

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

1415
#[macro_use]
1516
extern crate rustc_macros;

compiler/rustc_expand/src/lib.rs

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

1415
#[macro_use]
1516
extern crate rustc_macros;

compiler/rustc_feature/src/builtin_attrs.rs

+3
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,9 @@ 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),
463466

464467
// ==========================================================================
465468
// Internal attributes, Const related:

compiler/rustc_incremental/src/lib.rs

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

910
#[macro_use]
1011
extern crate rustc_middle;

compiler/rustc_infer/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
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))]
2728

2829
#[macro_use]
2930
extern crate rustc_macros;

compiler/rustc_interface/src/lib.rs

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

910
mod callbacks;
1011
pub mod interface;

compiler/rustc_lint/src/context.rs

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

147-
pub fn get_lint_groups<'t>(&'t self) -> Vec<(&'static str, Vec<LintId>, bool)> {
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))]
148152
self.lint_groups
149153
.iter()
150154
.filter(|(_, LintGroup { depr, .. })| {
@@ -154,7 +158,6 @@ impl LintStore {
154158
.map(|(k, LintGroup { lint_ids, from_plugin, .. })| {
155159
(*k, lint_ids.clone(), *from_plugin)
156160
})
157-
.collect()
158161
}
159162

160163
pub fn register_early_pass(

compiler/rustc_lint/src/internal.rs

+55-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ 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::{
9-
GenericArg, HirId, Item, ItemKind, MutTy, Mutability, Node, Path, PathSegment, QPath, Ty,
10-
TyKind,
11-
};
8+
use rustc_hir::*;
129
use rustc_middle::ty;
1310
use rustc_session::{declare_lint_pass, declare_tool_lint};
1411
use rustc_span::hygiene::{ExpnKind, MacroKind};
@@ -51,6 +48,60 @@ impl LateLintPass<'_> for DefaultHashTypes {
5148
}
5249
}
5350

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+
54105
declare_tool_lint! {
55106
pub rustc::USAGE_OF_TY_TYKIND,
56107
Allow,

compiler/rustc_lint/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@
3131
#![feature(box_patterns)]
3232
#![feature(crate_visibility_modifier)]
3333
#![feature(format_args_capture)]
34+
#![feature(if_let_guard)]
3435
#![feature(iter_order_by)]
3536
#![feature(iter_zip)]
3637
#![feature(never_type)]
3738
#![feature(nll)]
3839
#![feature(control_flow_enum)]
3940
#![recursion_limit = "256"]
41+
#![cfg_attr(not(bootstrap), allow(rustc::potential_query_instability))]
4042

4143
#[macro_use]
4244
extern crate rustc_middle;
@@ -484,6 +486,8 @@ fn register_internals(store: &mut LintStore) {
484486
store.register_early_pass(|| Box::new(LintPassImpl));
485487
store.register_lints(&DefaultHashTypes::get_lints());
486488
store.register_late_pass(|| Box::new(DefaultHashTypes));
489+
store.register_lints(&QueryStability::get_lints());
490+
store.register_late_pass(|| Box::new(QueryStability));
487491
store.register_lints(&ExistingDocKeyword::get_lints());
488492
store.register_late_pass(|| Box::new(ExistingDocKeyword));
489493
store.register_lints(&TyTyKind::get_lints());
@@ -494,6 +498,7 @@ fn register_internals(store: &mut LintStore) {
494498
None,
495499
vec![
496500
LintId::of(DEFAULT_HASH_TYPES),
501+
LintId::of(POTENTIAL_QUERY_INSTABILITY),
497502
LintId::of(USAGE_OF_TY_TYKIND),
498503
LintId::of(LINT_PASS_IMPL_WITHOUT_MACRO),
499504
LintId::of(TY_PASS_BY_REFERENCE),

compiler/rustc_metadata/src/lib.rs

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

1415
extern crate proc_macro;
1516

compiler/rustc_middle/src/lib.rs

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

6061
#[macro_use]
6162
extern crate bitflags;

compiler/rustc_mir_build/src/lib.rs

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

1415
#[macro_use]
1516
extern crate tracing;

compiler/rustc_mir_transform/src/lib.rs

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

1718
#[macro_use]
1819
extern crate tracing;

compiler/rustc_monomorphize/src/lib.rs

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

910
#[macro_use]
1011
extern crate tracing;

0 commit comments

Comments
 (0)