Skip to content

Commit 67342b8

Browse files
committed
Auto merge of #82698 - JohnTitor:rollup-htd533c, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #80189 (Convert primitives in the standard library to intra-doc links) - #80874 (Update intra-doc link documentation to match the implementation) - #82376 (Add option to enable MIR inlining independently of mir-opt-level) - #82516 (Add incomplete feature gate for inherent associate types.) - #82579 (Fix turbofish recovery with multiple generic args) - #82593 (Teach rustdoc how to display WASI.) - #82597 (Get TyCtxt from self instead of passing as argument in AutoTraitFinder) - #82627 (Erase late bound regions to avoid ICE) - #82661 (:arrow_up: rust-analyzer) - #82691 (Update books) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents edeee91 + 97f9b18 commit 67342b8

File tree

85 files changed

+599
-317
lines changed

Some content is hidden

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

85 files changed

+599
-317
lines changed

compiler/rustc_error_codes/src/error_codes.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ E0198: include_str!("./error_codes/E0198.md"),
103103
E0199: include_str!("./error_codes/E0199.md"),
104104
E0200: include_str!("./error_codes/E0200.md"),
105105
E0201: include_str!("./error_codes/E0201.md"),
106-
E0202: include_str!("./error_codes/E0202.md"),
107106
E0203: include_str!("./error_codes/E0203.md"),
108107
E0204: include_str!("./error_codes/E0204.md"),
109108
E0205: include_str!("./error_codes/E0205.md"),

compiler/rustc_error_codes/src/error_codes/E0202.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

compiler/rustc_feature/src/active.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,9 @@ declare_features! (
641641
/// Allows `pub` on `macro_rules` items.
642642
(active, pub_macro_rules, "1.52.0", Some(78855), None),
643643

644+
/// Allows associated types in inherent impls.
645+
(active, inherent_associated_types, "1.52.0", Some(8995), None),
646+
644647
// -------------------------------------------------------------------------
645648
// feature-group-end: actual feature gates
646649
// -------------------------------------------------------------------------
@@ -666,6 +669,7 @@ pub const INCOMPLETE_FEATURES: &[Symbol] = &[
666669
sym::unsized_locals,
667670
sym::capture_disjoint_fields,
668671
sym::const_generics_defaults,
672+
sym::inherent_associated_types,
669673
];
670674

671675
/// Some features are not allowed to be used together at the same time, if

compiler/rustc_interface/src/tests.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,9 @@ fn test_debugging_options_tracking_hash() {
557557
tracked!(function_sections, Some(false));
558558
tracked!(human_readable_cgu_names, true);
559559
tracked!(inline_in_all_cgus, Some(true));
560-
tracked!(inline_mir_threshold, 123);
561-
tracked!(inline_mir_hint_threshold, 123);
560+
tracked!(inline_mir, Some(true));
561+
tracked!(inline_mir_threshold, Some(123));
562+
tracked!(inline_mir_hint_threshold, Some(123));
562563
tracked!(insert_sideeffect, true);
563564
tracked!(instrument_coverage, true);
564565
tracked!(instrument_mcount, true);

compiler/rustc_mir/src/transform/inline.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,27 @@ struct CallSite<'tcx> {
3737
source_info: SourceInfo,
3838
}
3939

40+
/// Returns true if MIR inlining is enabled in the current compilation session.
41+
crate fn is_enabled(tcx: TyCtxt<'_>) -> bool {
42+
if tcx.sess.opts.debugging_opts.instrument_coverage {
43+
// Since `Inline` happens after `InstrumentCoverage`, the function-specific coverage
44+
// counters can be invalidated, such as by merging coverage counter statements from
45+
// a pre-inlined function into a different function. This kind of change is invalid,
46+
// so inlining must be skipped. Note: This check is performed here so inlining can
47+
// be disabled without preventing other optimizations (regardless of `mir_opt_level`).
48+
return false;
49+
}
50+
51+
if let Some(enabled) = tcx.sess.opts.debugging_opts.inline_mir {
52+
return enabled;
53+
}
54+
55+
tcx.sess.opts.debugging_opts.mir_opt_level >= 2
56+
}
57+
4058
impl<'tcx> MirPass<'tcx> for Inline {
4159
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
42-
// If you change this optimization level, also change the level in
43-
// `mir_drops_elaborated_and_const_checked` for the call to `mir_inliner_callees`.
44-
// Otherwise you will get an ICE about stolen MIR.
45-
if tcx.sess.opts.debugging_opts.mir_opt_level < 2 {
46-
return;
47-
}
48-
49-
if tcx.sess.opts.debugging_opts.instrument_coverage {
50-
// Since `Inline` happens after `InstrumentCoverage`, the function-specific coverage
51-
// counters can be invalidated, such as by merging coverage counter statements from
52-
// a pre-inlined function into a different function. This kind of change is invalid,
53-
// so inlining must be skipped. Note: This check is performed here so inlining can
54-
// be disabled without preventing other optimizations (regardless of `mir_opt_level`).
60+
if !is_enabled(tcx) {
5561
return;
5662
}
5763

@@ -343,9 +349,9 @@ impl Inliner<'tcx> {
343349
let tcx = self.tcx;
344350

345351
let mut threshold = if callee_attrs.requests_inline() {
346-
self.tcx.sess.opts.debugging_opts.inline_mir_hint_threshold
352+
self.tcx.sess.opts.debugging_opts.inline_mir_hint_threshold.unwrap_or(100)
347353
} else {
348-
self.tcx.sess.opts.debugging_opts.inline_mir_threshold
354+
self.tcx.sess.opts.debugging_opts.inline_mir_threshold.unwrap_or(50)
349355
};
350356

351357
// Give a bonus functions with a small number of blocks,

compiler/rustc_mir/src/transform/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,7 @@ fn mir_drops_elaborated_and_const_checked<'tcx>(
430430
let def = ty::WithOptConstParam::unknown(did);
431431

432432
// Do not compute the mir call graph without said call graph actually being used.
433-
// Keep this in sync with the mir inliner's optimization level.
434-
if tcx.sess.opts.debugging_opts.mir_opt_level >= 2 {
433+
if inline::is_enabled(tcx) {
435434
let _ = tcx.mir_inliner_callees(ty::InstanceDef::Item(def));
436435
}
437436
}

compiler/rustc_parse/src/parser/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ impl<'a> Parser<'a> {
662662
let x = self.parse_seq_to_before_end(
663663
&token::Gt,
664664
SeqSep::trailing_allowed(token::Comma),
665-
|p| p.parse_ty(),
665+
|p| p.parse_generic_arg(),
666666
);
667667
match x {
668668
Ok((_, _, false)) => {

compiler/rustc_parse/src/parser/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ impl<'a> Parser<'a> {
545545

546546
/// Parse a generic argument in a path segment.
547547
/// This does not include constraints, e.g., `Item = u8`, which is handled in `parse_angle_arg`.
548-
fn parse_generic_arg(&mut self) -> PResult<'a, Option<GenericArg>> {
548+
pub(super) fn parse_generic_arg(&mut self) -> PResult<'a, Option<GenericArg>> {
549549
let start = self.token.span;
550550
let arg = if self.check_lifetime() && self.look_ahead(1, |t| !t.is_like_plus()) {
551551
// Parse lifetime argument.

compiler/rustc_parse/src/parser/ty.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,20 @@ impl<'a> Parser<'a> {
360360
}
361361
Err(err) => return Err(err),
362362
};
363+
363364
let ty = if self.eat(&token::Semi) {
364-
TyKind::Array(elt_ty, self.parse_anon_const_expr()?)
365+
let mut length = self.parse_anon_const_expr()?;
366+
if let Err(e) = self.expect(&token::CloseDelim(token::Bracket)) {
367+
// Try to recover from `X<Y, ...>` when `X::<Y, ...>` works
368+
self.check_mistyped_turbofish_with_multiple_type_params(e, &mut length.value)?;
369+
self.expect(&token::CloseDelim(token::Bracket))?;
370+
}
371+
TyKind::Array(elt_ty, length)
365372
} else {
373+
self.expect(&token::CloseDelim(token::Bracket))?;
366374
TyKind::Slice(elt_ty)
367375
};
368-
self.expect(&token::CloseDelim(token::Bracket))?;
376+
369377
Ok(ty)
370378
}
371379

compiler/rustc_session/src/options.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -957,9 +957,11 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
957957
(default: no)"),
958958
incremental_verify_ich: bool = (false, parse_bool, [UNTRACKED],
959959
"verify incr. comp. hashes of green query instances (default: no)"),
960-
inline_mir_threshold: usize = (50, parse_uint, [TRACKED],
960+
inline_mir: Option<bool> = (None, parse_opt_bool, [TRACKED],
961+
"enable MIR inlining (default: no)"),
962+
inline_mir_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
961963
"a default MIR inlining threshold (default: 50)"),
962-
inline_mir_hint_threshold: usize = (100, parse_uint, [TRACKED],
964+
inline_mir_hint_threshold: Option<usize> = (None, parse_opt_uint, [TRACKED],
963965
"inlining threshold for functions with inline hint (default: 100)"),
964966
inline_in_all_cgus: Option<bool> = (None, parse_opt_bool, [TRACKED],
965967
"control whether `#[inline]` functions are in all CGUs"),

0 commit comments

Comments
 (0)