Skip to content

Commit 755629f

Browse files
committed
Auto merge of #117706 - matthiaskrgr:rollup-lscx7dg, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #114316 (Add AIX platform support document) - #117531 (rustdoc: properly elide cross-crate host effect args) - #117650 (Add -Zcross-crate-inline-threshold=yes) - #117663 (bump some deps) - #117667 (Document clippy_config in nightly-rustc docs) - #117698 (Clarify `space_between`) - #117700 (coverage: Rename the `run-coverage` test mode to `coverage-run`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents fab1054 + 7e4ffa9 commit 755629f

File tree

36 files changed

+350
-151
lines changed

36 files changed

+350
-151
lines changed

Cargo.lock

+6-20
Original file line numberDiff line numberDiff line change
@@ -1281,25 +1281,14 @@ checksum = "88bffebc5d80432c9b140ee17875ff173a8ab62faad5b257da912bd2f6c1c0a1"
12811281

12821282
[[package]]
12831283
name = "errno"
1284-
version = "0.3.1"
1284+
version = "0.3.5"
12851285
source = "registry+https://github.com/rust-lang/crates.io-index"
1286-
checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a"
1286+
checksum = "ac3e13f66a2f95e32a39eaa81f6b95d42878ca0e1db0c7543723dfe12557e860"
12871287
dependencies = [
1288-
"errno-dragonfly",
12891288
"libc",
12901289
"windows-sys 0.48.0",
12911290
]
12921291

1293-
[[package]]
1294-
name = "errno-dragonfly"
1295-
version = "0.1.2"
1296-
source = "registry+https://github.com/rust-lang/crates.io-index"
1297-
checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf"
1298-
dependencies = [
1299-
"cc",
1300-
"libc",
1301-
]
1302-
13031292
[[package]]
13041293
name = "error_index_generator"
13051294
version = "0.0.0"
@@ -2055,7 +2044,6 @@ dependencies = [
20552044
"anyhow",
20562045
"clap",
20572046
"flate2",
2058-
"num_cpus",
20592047
"rayon",
20602048
"tar",
20612049
"walkdir",
@@ -3181,24 +3169,22 @@ dependencies = [
31813169

31823170
[[package]]
31833171
name = "rayon"
3184-
version = "1.7.0"
3172+
version = "1.8.0"
31853173
source = "registry+https://github.com/rust-lang/crates.io-index"
3186-
checksum = "1d2df5196e37bcc87abebc0053e20787d73847bb33134a69841207dd0a47f03b"
3174+
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
31873175
dependencies = [
31883176
"either",
31893177
"rayon-core",
31903178
]
31913179

31923180
[[package]]
31933181
name = "rayon-core"
3194-
version = "1.11.0"
3182+
version = "1.12.0"
31953183
source = "registry+https://github.com/rust-lang/crates.io-index"
3196-
checksum = "4b8f95bd6966f5c87776639160a66bd8ab9895d9d4ab01ddba9fc60661aebe8d"
3184+
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
31973185
dependencies = [
3198-
"crossbeam-channel",
31993186
"crossbeam-deque",
32003187
"crossbeam-utils",
3201-
"num_cpus",
32023188
]
32033189

32043190
[[package]]

compiler/rustc_ast_pretty/src/pprust/state.rs

+42-30
Original file line numberDiff line numberDiff line change
@@ -146,37 +146,49 @@ pub fn print_crate<'a>(
146146
s.s.eof()
147147
}
148148

149-
/// This makes printed token streams look slightly nicer,
150-
/// and also addresses some specific regressions described in #63896 and #73345.
151-
fn space_between(prev: &TokenTree, curr: &TokenTree) -> bool {
152-
if let TokenTree::Token(token, _) = prev {
153-
// No space after these tokens, e.g. `x.y`, `$e`
154-
// (The carets point to `prev`.) ^ ^
155-
if matches!(token.kind, token::Dot | token::Dollar) {
156-
return false;
157-
}
158-
if let token::DocComment(comment_kind, ..) = token.kind {
159-
return comment_kind != CommentKind::Line;
160-
}
161-
}
162-
match curr {
163-
// No space before these tokens, e.g. `foo,`, `println!`, `x.y`
164-
// (The carets point to `curr`.) ^ ^ ^
149+
/// Should two consecutive tokens be printed with a space between them?
150+
///
151+
/// Note: some old proc macros parse pretty-printed output, so changes here can
152+
/// break old code. For example:
153+
/// - #63896: `#[allow(unused,` must be printed rather than `#[allow(unused ,`
154+
/// - #73345: `#[allow(unused)] must be printed rather than `# [allow(unused)]
155+
///
156+
fn space_between(tt1: &TokenTree, tt2: &TokenTree) -> bool {
157+
use token::*;
158+
use Delimiter::*;
159+
use TokenTree::Delimited as Del;
160+
use TokenTree::Token as Tok;
161+
162+
// Each match arm has one or more examples in comments. The default is to
163+
// insert space between adjacent tokens, except for the cases listed in
164+
// this match.
165+
match (tt1, tt2) {
166+
// No space after line doc comments.
167+
(Tok(Token { kind: DocComment(CommentKind::Line, ..), .. }, _), _) => false,
168+
169+
// `.` + ANYTHING: `x.y`, `tup.0`
170+
// `$` + ANYTHING: `$e`
171+
(Tok(Token { kind: Dot | Dollar, .. }, _), _) => false,
172+
173+
// ANYTHING + `,`: `foo,`
174+
// ANYTHING + `.`: `x.y`, `tup.0`
175+
// ANYTHING + `!`: `foo! { ... }`
165176
//
166-
// FIXME: having `Not` here works well for macro invocations like
167-
// `println!()`, but is bad when `!` means "logical not" or "the never
168-
// type", where the lack of space causes ugliness like this:
169-
// `Fn() ->!`, `x =! y`, `if! x { f(); }`.
170-
TokenTree::Token(token, _) => !matches!(token.kind, token::Comma | token::Not | token::Dot),
171-
// No space before parentheses if preceded by these tokens, e.g. `foo(...)`
172-
TokenTree::Delimited(_, Delimiter::Parenthesis, _) => {
173-
!matches!(prev, TokenTree::Token(Token { kind: token::Ident(..), .. }, _))
174-
}
175-
// No space before brackets if preceded by these tokens, e.g. `#[...]`
176-
TokenTree::Delimited(_, Delimiter::Bracket, _) => {
177-
!matches!(prev, TokenTree::Token(Token { kind: token::Pound, .. }, _))
178-
}
179-
TokenTree::Delimited(..) => true,
177+
// FIXME: Incorrect cases:
178+
// - Logical not: `x =! y`, `if! x { f(); }`
179+
// - Never type: `Fn() ->!`
180+
(_, Tok(Token { kind: Comma | Dot | Not, .. }, _)) => false,
181+
182+
// IDENT + `(`: `f(3)`
183+
//
184+
// FIXME: Incorrect cases:
185+
// - Let: `let(a, b) = (1, 2)`
186+
(Tok(Token { kind: Ident(..), .. }, _), Del(_, Parenthesis, _)) => false,
187+
188+
// `#` + `[`: `#[attr]`
189+
(Tok(Token { kind: Pound, .. }, _), Del(_, Bracket, _)) => false,
190+
191+
_ => true,
180192
}
181193
}
182194

compiler/rustc_interface/src/tests.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ use rustc_data_structures::profiling::TimePassesFormat;
44
use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
55
use rustc_session::config::{
66
build_configuration, build_session_options, rustc_optgroups, BranchProtection, CFGuard, Cfg,
7-
DebugInfo, DumpMonoStatsFormat, ErrorOutputType, ExternEntry, ExternLocation, Externs, Input,
8-
InstrumentCoverage, InstrumentXRay, LinkSelfContained, LinkerPluginLto, LocationDetail, LtoCli,
9-
MirSpanview, OomStrategy, Options, OutFileName, OutputType, OutputTypes, PAuthKey, PacRet,
10-
Passes, Polonius, ProcMacroExecutionStrategy, Strip, SwitchWithOptPath, SymbolManglingVersion,
11-
TraitSolver, WasiExecModel,
7+
DebugInfo, DumpMonoStatsFormat, ErrorOutputType, ExternEntry, ExternLocation, Externs,
8+
InliningThreshold, Input, InstrumentCoverage, InstrumentXRay, LinkSelfContained,
9+
LinkerPluginLto, LocationDetail, LtoCli, MirSpanview, OomStrategy, Options, OutFileName,
10+
OutputType, OutputTypes, PAuthKey, PacRet, Passes, Polonius, ProcMacroExecutionStrategy, Strip,
11+
SwitchWithOptPath, SymbolManglingVersion, TraitSolver, WasiExecModel,
1212
};
1313
use rustc_session::lint::Level;
1414
use rustc_session::search_paths::SearchPath;
@@ -748,7 +748,7 @@ fn test_unstable_options_tracking_hash() {
748748
);
749749
tracked!(codegen_backend, Some("abc".to_string()));
750750
tracked!(crate_attr, vec!["abc".to_string()]);
751-
tracked!(cross_crate_inline_threshold, Some(200));
751+
tracked!(cross_crate_inline_threshold, InliningThreshold::Always);
752752
tracked!(debug_info_for_profiling, true);
753753
tracked!(debug_macros, true);
754754
tracked!(dep_info_omit_d_target, true);

compiler/rustc_mir_transform/src/cross_crate_inline.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_middle::mir::visit::Visitor;
77
use rustc_middle::mir::*;
88
use rustc_middle::query::Providers;
99
use rustc_middle::ty::TyCtxt;
10+
use rustc_session::config::InliningThreshold;
1011
use rustc_session::config::OptLevel;
1112

1213
pub fn provide(providers: &mut Providers) {
@@ -54,15 +55,20 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
5455
return false;
5556
}
5657

58+
let threshold = match tcx.sess.opts.unstable_opts.cross_crate_inline_threshold {
59+
InliningThreshold::Always => return true,
60+
InliningThreshold::Sometimes(threshold) => threshold,
61+
InliningThreshold::Never => return false,
62+
};
63+
5764
let mir = tcx.optimized_mir(def_id);
5865
let mut checker =
5966
CostChecker { tcx, callee_body: mir, calls: 0, statements: 0, landing_pads: 0, resumes: 0 };
6067
checker.visit_body(mir);
6168
checker.calls == 0
6269
&& checker.resumes == 0
6370
&& checker.landing_pads == 0
64-
&& checker.statements
65-
<= tcx.sess.opts.unstable_opts.cross_crate_inline_threshold.unwrap_or(100)
71+
&& checker.statements <= threshold
6672
}
6773

6874
struct CostChecker<'b, 'tcx> {

compiler/rustc_session/src/config.rs

+18-4
Original file line numberDiff line numberDiff line change
@@ -3161,10 +3161,10 @@ impl PpMode {
31613161
pub(crate) mod dep_tracking {
31623162
use super::{
31633163
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, DebugInfoCompression,
3164-
ErrorOutputType, InstrumentCoverage, InstrumentXRay, LinkerPluginLto, LocationDetail,
3165-
LtoCli, OomStrategy, OptLevel, OutFileName, OutputType, OutputTypes, Polonius,
3166-
RemapPathScopeComponents, ResolveDocLinks, SourceFileHashAlgorithm, SplitDwarfKind,
3167-
SwitchWithOptPath, SymbolManglingVersion, TraitSolver, TrimmedDefPaths,
3164+
ErrorOutputType, InliningThreshold, InstrumentCoverage, InstrumentXRay, LinkerPluginLto,
3165+
LocationDetail, LtoCli, OomStrategy, OptLevel, OutFileName, OutputType, OutputTypes,
3166+
Polonius, RemapPathScopeComponents, ResolveDocLinks, SourceFileHashAlgorithm,
3167+
SplitDwarfKind, SwitchWithOptPath, SymbolManglingVersion, TraitSolver, TrimmedDefPaths,
31683168
};
31693169
use crate::lint;
31703170
use crate::options::WasiExecModel;
@@ -3270,6 +3270,7 @@ pub(crate) mod dep_tracking {
32703270
LanguageIdentifier,
32713271
TraitSolver,
32723272
Polonius,
3273+
InliningThreshold,
32733274
);
32743275

32753276
impl<T1, T2> DepTrackingHash for (T1, T2)
@@ -3435,3 +3436,16 @@ impl Polonius {
34353436
matches!(self, Polonius::Next)
34363437
}
34373438
}
3439+
3440+
#[derive(Clone, Copy, PartialEq, Hash, Debug)]
3441+
pub enum InliningThreshold {
3442+
Always,
3443+
Sometimes(usize),
3444+
Never,
3445+
}
3446+
3447+
impl Default for InliningThreshold {
3448+
fn default() -> Self {
3449+
Self::Sometimes(100)
3450+
}
3451+
}

compiler/rustc_session/src/options.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ mod desc {
428428
"one of supported execution strategies (`same-thread`, or `cross-thread`)";
429429
pub const parse_dump_solver_proof_tree: &str = "one of: `always`, `on-request`, `on-error`";
430430
pub const parse_remap_path_scope: &str = "comma separated list of scopes: `macro`, `diagnostics`, `unsplit-debuginfo`, `split-debuginfo`, `split-debuginfo-path`, `object`, `all`";
431+
pub const parse_inlining_threshold: &str =
432+
"either a boolean (`yes`, `no`, `on`, `off`, etc), or a non-negative number";
431433
}
432434

433435
mod parse {
@@ -1310,6 +1312,26 @@ mod parse {
13101312
};
13111313
true
13121314
}
1315+
1316+
pub(crate) fn parse_inlining_threshold(slot: &mut InliningThreshold, v: Option<&str>) -> bool {
1317+
match v {
1318+
Some("always" | "yes") => {
1319+
*slot = InliningThreshold::Always;
1320+
}
1321+
Some("never") => {
1322+
*slot = InliningThreshold::Never;
1323+
}
1324+
Some(v) => {
1325+
if let Ok(threshold) = v.parse() {
1326+
*slot = InliningThreshold::Sometimes(threshold);
1327+
} else {
1328+
return false;
1329+
}
1330+
}
1331+
None => return false,
1332+
}
1333+
true
1334+
}
13131335
}
13141336

13151337
options! {
@@ -1479,7 +1501,7 @@ options! {
14791501
"combine CGUs into a single one"),
14801502
crate_attr: Vec<String> = (Vec::new(), parse_string_push, [TRACKED],
14811503
"inject the given attribute in the crate"),
1482-
cross_crate_inline_threshold: Option<usize> = (None, parse_opt_number, [TRACKED],
1504+
cross_crate_inline_threshold: InliningThreshold = (InliningThreshold::Sometimes(100), parse_inlining_threshold, [TRACKED],
14831505
"threshold to allow cross crate inlining of functions"),
14841506
debug_info_for_profiling: bool = (false, parse_bool, [TRACKED],
14851507
"emit discriminators and other data necessary for AutoFDO"),

src/bootstrap/Cargo.lock

+4-36
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,6 @@ dependencies = [
180180
"libc",
181181
]
182182

183-
[[package]]
184-
name = "crossbeam-channel"
185-
version = "0.5.6"
186-
source = "registry+https://github.com/rust-lang/crates.io-index"
187-
checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"
188-
dependencies = [
189-
"cfg-if",
190-
"crossbeam-utils",
191-
]
192-
193183
[[package]]
194184
name = "crossbeam-deque"
195185
version = "0.8.2"
@@ -323,15 +313,6 @@ version = "0.4.1"
323313
source = "registry+https://github.com/rust-lang/crates.io-index"
324314
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
325315

326-
[[package]]
327-
name = "hermit-abi"
328-
version = "0.1.19"
329-
source = "registry+https://github.com/rust-lang/crates.io-index"
330-
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
331-
dependencies = [
332-
"libc",
333-
]
334-
335316
[[package]]
336317
name = "hex"
337318
version = "0.4.3"
@@ -443,16 +424,6 @@ dependencies = [
443424
"winapi",
444425
]
445426

446-
[[package]]
447-
name = "num_cpus"
448-
version = "1.13.1"
449-
source = "registry+https://github.com/rust-lang/crates.io-index"
450-
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
451-
dependencies = [
452-
"hermit-abi",
453-
"libc",
454-
]
455-
456427
[[package]]
457428
name = "object"
458429
version = "0.32.0"
@@ -514,25 +485,22 @@ dependencies = [
514485

515486
[[package]]
516487
name = "rayon"
517-
version = "1.6.0"
488+
version = "1.8.0"
518489
source = "registry+https://github.com/rust-lang/crates.io-index"
519-
checksum = "1e060280438193c554f654141c9ea9417886713b7acd75974c85b18a69a88e0b"
490+
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
520491
dependencies = [
521-
"crossbeam-deque",
522492
"either",
523493
"rayon-core",
524494
]
525495

526496
[[package]]
527497
name = "rayon-core"
528-
version = "1.10.1"
498+
version = "1.12.0"
529499
source = "registry+https://github.com/rust-lang/crates.io-index"
530-
checksum = "cac410af5d00ab6884528b4ab69d1e8e146e8d471201800fa1b4524126de6ad3"
500+
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
531501
dependencies = [
532-
"crossbeam-channel",
533502
"crossbeam-deque",
534503
"crossbeam-utils",
535-
"num_cpus",
536504
]
537505

538506
[[package]]

src/bootstrap/src/core/build_steps/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ tool_doc!(
887887
"src/tools/rustfmt",
888888
crates = ["rustfmt-nightly", "rustfmt-config_proc_macro"]
889889
);
890-
tool_doc!(Clippy, "clippy", "src/tools/clippy", crates = ["clippy_utils"]);
890+
tool_doc!(Clippy, "clippy", "src/tools/clippy", crates = ["clippy_config", "clippy_utils"]);
891891
tool_doc!(Miri, "miri", "src/tools/miri", crates = ["miri"]);
892892
tool_doc!(
893893
Cargo,

0 commit comments

Comments
 (0)