Skip to content

Commit 67342b8

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

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

-1
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

-15
This file was deleted.

compiler/rustc_feature/src/active.rs

+4
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

+3-2
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

+21-15
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

+1-2
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

+1-1
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

+1-1
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

+10-2
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

+4-2
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"),

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,7 @@ symbols! {
634634
index_mut,
635635
infer_outlives_requirements,
636636
infer_static_outlives_requirements,
637+
inherent_associated_types,
637638
inlateout,
638639
inline,
639640
inline_const,

compiler/rustc_trait_selection/src/traits/auto_trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
7777
ty: Ty<'tcx>,
7878
orig_env: ty::ParamEnv<'tcx>,
7979
trait_did: DefId,
80-
mut auto_trait_callback: impl FnMut(&InferCtxt<'_, 'tcx>, AutoTraitInfo<'tcx>) -> A,
80+
mut auto_trait_callback: impl FnMut(AutoTraitInfo<'tcx>) -> A,
8181
) -> AutoTraitResult<A> {
8282
let tcx = self.tcx;
8383

@@ -211,7 +211,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
211211

212212
let info = AutoTraitInfo { full_user_env, region_data, vid_to_region };
213213

214-
AutoTraitResult::PositiveImpl(auto_trait_callback(&infcx, info))
214+
AutoTraitResult::PositiveImpl(auto_trait_callback(info))
215215
})
216216
}
217217
}

compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_hir::lang_items::LangItem;
1111
use rustc_hir::{ExprKind, ItemKind, Node};
1212
use rustc_infer::infer;
1313
use rustc_middle::lint::in_external_macro;
14-
use rustc_middle::ty::{self, Ty};
14+
use rustc_middle::ty::{self, Binder, Ty};
1515
use rustc_span::symbol::kw;
1616

1717
use std::iter;
@@ -487,6 +487,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
487487
let found = self.resolve_vars_with_obligations(found);
488488
if let hir::FnRetTy::Return(ty) = fn_decl.output {
489489
let ty = AstConv::ast_ty_to_ty(self, ty);
490+
let ty = self.tcx.erase_late_bound_regions(Binder::bind(ty));
490491
let ty = self.normalize_associated_types_in(expr.span, ty);
491492
if self.can_coerce(found, ty) {
492493
err.multipart_suggestion(

compiler/rustc_typeck/src/collect/type_of.rs

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::errors::AssocTypeOnInherentImpl;
21
use rustc_data_structures::fx::FxHashSet;
32
use rustc_errors::{Applicability, ErrorReported, StashKey};
43
use rustc_hir as hir;
@@ -294,7 +293,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
294293
}
295294
ImplItemKind::TyAlias(ref ty) => {
296295
if tcx.impl_trait_ref(tcx.hir().get_parent_did(hir_id).to_def_id()).is_none() {
297-
report_assoc_ty_on_inherent_impl(tcx, item.span);
296+
check_feature_inherent_assoc_ty(tcx, item.span);
298297
}
299298

300299
icx.to_ty(ty)
@@ -746,6 +745,16 @@ fn infer_placeholder_type(
746745
})
747746
}
748747

749-
fn report_assoc_ty_on_inherent_impl(tcx: TyCtxt<'_>, span: Span) {
750-
tcx.sess.emit_err(AssocTypeOnInherentImpl { span });
748+
fn check_feature_inherent_assoc_ty(tcx: TyCtxt<'_>, span: Span) {
749+
if !tcx.features().inherent_associated_types {
750+
use rustc_session::parse::feature_err;
751+
use rustc_span::symbol::sym;
752+
feature_err(
753+
&tcx.sess.parse_sess,
754+
sym::inherent_associated_types,
755+
span,
756+
"inherent associated types are unstable",
757+
)
758+
.emit();
759+
}
751760
}

compiler/rustc_typeck/src/errors.rs

-7
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,6 @@ pub struct CopyImplOnTypeWithDtor {
8282
pub span: Span,
8383
}
8484

85-
#[derive(SessionDiagnostic)]
86-
#[error = "E0202"]
87-
pub struct AssocTypeOnInherentImpl {
88-
#[message = "associated types are not yet supported in inherent impls (see #8995)"]
89-
pub span: Span,
90-
}
91-
9285
#[derive(SessionDiagnostic)]
9386
#[error = "E0203"]
9487
pub struct MultipleRelaxedDefaultBounds {

library/alloc/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@
104104
#![feature(fundamental)]
105105
#![feature(inplace_iteration)]
106106
#![feature(int_bits_const)]
107+
// Technically, this is a bug in rustdoc: rustdoc sees the documentation on `#[lang = slice_alloc]`
108+
// blocks is for `&[T]`, which also has documentation using this feature in `core`, and gets mad
109+
// that the feature-gate isn't enabled. Ideally, it wouldn't check for the feature gate for docs
110+
// from other crates, but since this can only appear for lang items, it doesn't seem worth fixing.
111+
#![feature(intra_doc_pointers)]
107112
#![feature(lang_items)]
108113
#![feature(layout_for_ptr)]
109114
#![feature(maybe_uninit_ref)]

library/alloc/src/slice.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! A dynamically-sized view into a contiguous sequence, `[T]`.
22
//!
3-
//! *[See also the slice primitive type](../../std/primitive.slice.html).*
3+
//! *[See also the slice primitive type](slice).*
44
//!
55
//! Slices are a view into a block of memory represented as a pointer and a
66
//! length.
@@ -71,12 +71,12 @@
7171
//! [`.chunks`], [`.windows`] and more.
7272
//!
7373
//! [`Hash`]: core::hash::Hash
74-
//! [`.iter`]: ../../std/primitive.slice.html#method.iter
75-
//! [`.iter_mut`]: ../../std/primitive.slice.html#method.iter_mut
76-
//! [`.split`]: ../../std/primitive.slice.html#method.split
77-
//! [`.splitn`]: ../../std/primitive.slice.html#method.splitn
78-
//! [`.chunks`]: ../../std/primitive.slice.html#method.chunks
79-
//! [`.windows`]: ../../std/primitive.slice.html#method.windows
74+
//! [`.iter`]: slice::iter
75+
//! [`.iter_mut`]: slice::iter_mut
76+
//! [`.split`]: slice::split
77+
//! [`.splitn`]: slice::splitn
78+
//! [`.chunks`]: slice::chunks
79+
//! [`.windows`]: slice::windows
8080
#![stable(feature = "rust1", since = "1.0.0")]
8181
// Many of the usings in this module are only used in the test configuration.
8282
// It's cleaner to just turn off the unused_imports warning than to fix them.
@@ -673,7 +673,7 @@ impl [u8] {
673673
// Extension traits for slices over specific kinds of data
674674
////////////////////////////////////////////////////////////////////////////////
675675

676-
/// Helper trait for [`[T]::concat`](../../std/primitive.slice.html#method.concat).
676+
/// Helper trait for [`[T]::concat`](slice::concat).
677677
///
678678
/// Note: the `Item` type parameter is not used in this trait,
679679
/// but it allows impls to be more generic.
@@ -708,19 +708,19 @@ pub trait Concat<Item: ?Sized> {
708708
/// The resulting type after concatenation
709709
type Output;
710710

711-
/// Implementation of [`[T]::concat`](../../std/primitive.slice.html#method.concat)
711+
/// Implementation of [`[T]::concat`](slice::concat)
712712
#[unstable(feature = "slice_concat_trait", issue = "27747")]
713713
fn concat(slice: &Self) -> Self::Output;
714714
}
715715

716-
/// Helper trait for [`[T]::join`](../../std/primitive.slice.html#method.join)
716+
/// Helper trait for [`[T]::join`](slice::join)
717717
#[unstable(feature = "slice_concat_trait", issue = "27747")]
718718
pub trait Join<Separator> {
719719
#[unstable(feature = "slice_concat_trait", issue = "27747")]
720720
/// The resulting type after concatenation
721721
type Output;
722722

723-
/// Implementation of [`[T]::join`](../../std/primitive.slice.html#method.join)
723+
/// Implementation of [`[T]::join`](slice::join)
724724
#[unstable(feature = "slice_concat_trait", issue = "27747")]
725725
fn join(slice: &Self, sep: Separator) -> Self::Output;
726726
}

library/alloc/src/str.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Unicode string slices.
22
//!
3-
//! *[See also the `str` primitive type](../../std/primitive.str.html).*
3+
//! *[See also the `str` primitive type](str).*
44
//!
55
//! The `&str` type is one of the two main string types, the other being `String`.
66
//! Unlike its `String` counterpart, its contents are borrowed.

library/alloc/src/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ impl String {
495495
/// `from_utf8_lossy()` will replace any invalid UTF-8 sequences with
496496
/// [`U+FFFD REPLACEMENT CHARACTER`][U+FFFD], which looks like this: �
497497
///
498-
/// [byteslice]: ../../std/primitive.slice.html
498+
/// [byteslice]: prim@slice
499499
/// [U+FFFD]: core::char::REPLACEMENT_CHARACTER
500500
///
501501
/// If you are sure that the byte slice is valid UTF-8, and you don't want

library/alloc/src/vec/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ mod spec_extend;
216216
/// # Slicing
217217
///
218218
/// A `Vec` can be mutable. Slices, on the other hand, are read-only objects.
219-
/// To get a [slice], use [`&`]. Example:
219+
/// To get a [slice][prim@slice], use [`&`]. Example:
220220
///
221221
/// ```
222222
/// fn read_slice(slice: &[usize]) {
@@ -369,8 +369,6 @@ mod spec_extend;
369369
/// [`reserve`]: Vec::reserve
370370
/// [`MaybeUninit`]: core::mem::MaybeUninit
371371
/// [owned slice]: Box
372-
/// [slice]: ../../std/primitive.slice.html
373-
/// [`&`]: ../../std/primitive.reference.html
374372
#[stable(feature = "rust1", since = "1.0.0")]
375373
#[cfg_attr(not(test), rustc_diagnostic_item = "vec_type")]
376374
pub struct Vec<T, #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global> {
@@ -2517,7 +2515,7 @@ impl<T, A: Allocator> Vec<T, A> {
25172515
/// This implementation is specialized for slice iterators, where it uses [`copy_from_slice`] to
25182516
/// append the entire slice at once.
25192517
///
2520-
/// [`copy_from_slice`]: ../../std/primitive.slice.html#method.copy_from_slice
2518+
/// [`copy_from_slice`]: slice::copy_from_slice
25212519
#[stable(feature = "extend_ref", since = "1.2.0")]
25222520
impl<'a, T: Copy + 'a, A: Allocator + 'a> Extend<&'a T> for Vec<T, A> {
25232521
fn extend<I: IntoIterator<Item = &'a T>>(&mut self, iter: I) {

library/core/src/alloc/layout.rs

-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ impl Layout {
164164
/// [`Layout::for_value`] on a reference to an extern type tail.
165165
/// - otherwise, it is conservatively not allowed to call this function.
166166
///
167-
/// [slice]: ../../std/primitive.slice.html
168167
/// [trait object]: ../../book/ch17-02-trait-objects.html
169168
/// [extern type]: ../../unstable-book/language-features/extern-types.html
170169
#[unstable(feature = "layout_for_ptr", issue = "69835")]

library/core/src/array/iter.rs

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ use crate::{
99
};
1010

1111
/// A by-value [array] iterator.
12-
///
13-
/// [array]: ../../std/primitive.array.html
1412
#[stable(feature = "array_value_iter", since = "1.51.0")]
1513
pub struct IntoIter<T, const N: usize> {
1614
/// This is the array we are iterating over.

0 commit comments

Comments
 (0)