Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 18890f0

Browse files
committedJan 27, 2023
Auto merge of #107343 - JohnTitor:rollup-s6l94aj, r=JohnTitor
Rollup of 8 pull requests Successful merges: - #105784 (update stdarch) - #106856 (core: Support variety of atomic widths in width-agnostic functions) - #107171 (rustc_metadata: Fix `encode_attrs`) - #107242 (rustdoc: make item links consistently use `title="{shortty} {path}"`) - #107279 (Use new solver during selection) - #107284 (rustdoc: use smarter encoding for playground URL) - #107325 (rustdoc: Stop using `HirId`s) - #107336 (rustdoc: remove mostly-unused CSS classes `import-item` and `module-item`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents db137ba + 17a2e1f commit 18890f0

38 files changed

+302
-253
lines changed
 

‎compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 48 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::rmeta::def_path_hash_map::DefPathHashMapRef;
33
use crate::rmeta::table::TableBuilder;
44
use crate::rmeta::*;
55

6+
use rustc_ast::util::comments;
67
use rustc_ast::Attribute;
78
use rustc_data_structures::fingerprint::Fingerprint;
89
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
@@ -759,36 +760,54 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
759760
}
760761
}
761762

763+
struct AnalyzeAttrState {
764+
is_exported: bool,
765+
may_have_doc_links: bool,
766+
is_doc_hidden: bool,
767+
}
768+
762769
/// Returns whether an attribute needs to be recorded in metadata, that is, if it's usable and
763770
/// useful in downstream crates. Local-only attributes are an obvious example, but some
764771
/// rustdoc-specific attributes can equally be of use while documenting the current crate only.
765772
///
766773
/// Removing these superfluous attributes speeds up compilation by making the metadata smaller.
767774
///
768-
/// Note: the `is_def_id_public` parameter is used to cache whether the given `DefId` has a public
775+
/// Note: the `is_exported` parameter is used to cache whether the given `DefId` has a public
769776
/// visibility: this is a piece of data that can be computed once per defid, and not once per
770777
/// attribute. Some attributes would only be usable downstream if they are public.
771778
#[inline]
772-
fn should_encode_attr(
773-
tcx: TyCtxt<'_>,
774-
attr: &Attribute,
775-
def_id: LocalDefId,
776-
is_def_id_public: &mut Option<bool>,
777-
) -> bool {
779+
fn analyze_attr(attr: &Attribute, state: &mut AnalyzeAttrState) -> bool {
780+
let mut should_encode = false;
778781
if rustc_feature::is_builtin_only_local(attr.name_or_empty()) {
779782
// Attributes marked local-only don't need to be encoded for downstream crates.
780-
false
781-
} else if attr.doc_str().is_some() {
782-
// We keep all public doc comments because they might be "imported" into downstream crates
783-
// if they use `#[doc(inline)]` to copy an item's documentation into their own.
784-
*is_def_id_public.get_or_insert_with(|| tcx.effective_visibilities(()).is_exported(def_id))
783+
} else if let Some(s) = attr.doc_str() {
784+
// We keep all doc comments reachable to rustdoc because they might be "imported" into
785+
// downstream crates if they use `#[doc(inline)]` to copy an item's documentation into
786+
// their own.
787+
if state.is_exported {
788+
should_encode = true;
789+
if comments::may_have_doc_links(s.as_str()) {
790+
state.may_have_doc_links = true;
791+
}
792+
}
785793
} else if attr.has_name(sym::doc) {
786-
// If this is a `doc` attribute, and it's marked `inline` (as in `#[doc(inline)]`), we can
787-
// remove it. It won't be inlinable in downstream crates.
788-
attr.meta_item_list().map(|l| l.iter().any(|l| !l.has_name(sym::inline))).unwrap_or(false)
794+
// If this is a `doc` attribute that doesn't have anything except maybe `inline` (as in
795+
// `#[doc(inline)]`), then we can remove it. It won't be inlinable in downstream crates.
796+
if let Some(item_list) = attr.meta_item_list() {
797+
for item in item_list {
798+
if !item.has_name(sym::inline) {
799+
should_encode = true;
800+
if item.has_name(sym::hidden) {
801+
state.is_doc_hidden = true;
802+
break;
803+
}
804+
}
805+
}
806+
}
789807
} else {
790-
true
808+
should_encode = true;
791809
}
810+
should_encode
792811
}
793812

794813
fn should_encode_visibility(def_kind: DefKind) -> bool {
@@ -1108,24 +1127,24 @@ fn should_encode_trait_impl_trait_tys(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
11081127
impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
11091128
fn encode_attrs(&mut self, def_id: LocalDefId) {
11101129
let tcx = self.tcx;
1111-
let mut is_public: Option<bool> = None;
1112-
1113-
let hir_attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(def_id));
1114-
let mut attrs = hir_attrs
1130+
let mut state = AnalyzeAttrState {
1131+
is_exported: tcx.effective_visibilities(()).is_exported(def_id),
1132+
may_have_doc_links: false,
1133+
is_doc_hidden: false,
1134+
};
1135+
let attr_iter = tcx
1136+
.hir()
1137+
.attrs(tcx.hir().local_def_id_to_hir_id(def_id))
11151138
.iter()
1116-
.filter(move |attr| should_encode_attr(tcx, attr, def_id, &mut is_public));
1139+
.filter(|attr| analyze_attr(attr, &mut state));
1140+
1141+
record_array!(self.tables.attributes[def_id.to_def_id()] <- attr_iter);
11171142

1118-
record_array!(self.tables.attributes[def_id.to_def_id()] <- attrs.clone());
11191143
let mut attr_flags = AttrFlags::empty();
1120-
if attrs.any(|attr| attr.may_have_doc_links()) {
1144+
if state.may_have_doc_links {
11211145
attr_flags |= AttrFlags::MAY_HAVE_DOC_LINKS;
11221146
}
1123-
if hir_attrs
1124-
.iter()
1125-
.filter(|attr| attr.has_name(sym::doc))
1126-
.filter_map(|attr| attr.meta_item_list())
1127-
.any(|items| items.iter().any(|item| item.has_name(sym::hidden)))
1128-
{
1147+
if state.is_doc_hidden {
11291148
attr_flags |= AttrFlags::IS_DOC_HIDDEN;
11301149
}
11311150
if !attr_flags.is_empty() {

‎compiler/rustc_session/src/config.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
945945
if sess.target.has_thread_local {
946946
ret.insert((sym::target_thread_local, None));
947947
}
948+
let mut has_atomic = false;
948949
for (i, align) in [
949950
(8, layout.i8_align.abi),
950951
(16, layout.i16_align.abi),
@@ -953,6 +954,7 @@ fn default_configuration(sess: &Session) -> CrateConfig {
953954
(128, layout.i128_align.abi),
954955
] {
955956
if i >= min_atomic_width && i <= max_atomic_width {
957+
has_atomic = true;
956958
let mut insert_atomic = |s, align: Align| {
957959
ret.insert((sym::target_has_atomic_load_store, Some(Symbol::intern(s))));
958960
if atomic_cas {
@@ -969,6 +971,12 @@ fn default_configuration(sess: &Session) -> CrateConfig {
969971
}
970972
}
971973
}
974+
if sess.is_nightly_build() && has_atomic {
975+
ret.insert((sym::target_has_atomic_load_store, None));
976+
if atomic_cas {
977+
ret.insert((sym::target_has_atomic, None));
978+
}
979+
}
972980

973981
let panic_strategy = sess.panic_strategy();
974982
ret.insert((sym::panic, Some(panic_strategy.desc_symbol())));

‎compiler/rustc_trait_selection/src/traits/select/mod.rs

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ use rustc_errors::Diagnostic;
3838
use rustc_hir as hir;
3939
use rustc_hir::def_id::DefId;
4040
use rustc_infer::infer::LateBoundRegionConversionTime;
41+
use rustc_infer::traits::TraitEngine;
42+
use rustc_infer::traits::TraitEngineExt;
4143
use rustc_middle::dep_graph::{DepKind, DepNodeIndex};
4244
use rustc_middle::mir::interpret::ErrorHandled;
4345
use rustc_middle::ty::abstract_const::NotConstEvaluatable;
@@ -47,6 +49,7 @@ use rustc_middle::ty::relate::TypeRelation;
4749
use rustc_middle::ty::SubstsRef;
4850
use rustc_middle::ty::{self, EarlyBinder, PolyProjectionPredicate, ToPolyTraitRef, ToPredicate};
4951
use rustc_middle::ty::{Ty, TyCtxt, TypeFoldable, TypeVisitable};
52+
use rustc_session::config::TraitSolver;
5053
use rustc_span::symbol::sym;
5154

5255
use std::cell::{Cell, RefCell};
@@ -544,10 +547,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
544547
obligation: &PredicateObligation<'tcx>,
545548
) -> Result<EvaluationResult, OverflowError> {
546549
self.evaluation_probe(|this| {
547-
this.evaluate_predicate_recursively(
548-
TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
549-
obligation.clone(),
550-
)
550+
if this.tcx().sess.opts.unstable_opts.trait_solver != TraitSolver::Next {
551+
this.evaluate_predicate_recursively(
552+
TraitObligationStackList::empty(&ProvisionalEvaluationCache::default()),
553+
obligation.clone(),
554+
)
555+
} else {
556+
this.evaluate_predicates_recursively_in_new_solver([obligation.clone()])
557+
}
551558
})
552559
}
553560

@@ -586,18 +593,40 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
586593
where
587594
I: IntoIterator<Item = PredicateObligation<'tcx>> + std::fmt::Debug,
588595
{
589-
let mut result = EvaluatedToOk;
590-
for obligation in predicates {
591-
let eval = self.evaluate_predicate_recursively(stack, obligation.clone())?;
592-
if let EvaluatedToErr = eval {
593-
// fast-path - EvaluatedToErr is the top of the lattice,
594-
// so we don't need to look on the other predicates.
595-
return Ok(EvaluatedToErr);
596-
} else {
597-
result = cmp::max(result, eval);
596+
if self.tcx().sess.opts.unstable_opts.trait_solver != TraitSolver::Next {
597+
let mut result = EvaluatedToOk;
598+
for obligation in predicates {
599+
let eval = self.evaluate_predicate_recursively(stack, obligation.clone())?;
600+
if let EvaluatedToErr = eval {
601+
// fast-path - EvaluatedToErr is the top of the lattice,
602+
// so we don't need to look on the other predicates.
603+
return Ok(EvaluatedToErr);
604+
} else {
605+
result = cmp::max(result, eval);
606+
}
598607
}
608+
Ok(result)
609+
} else {
610+
self.evaluate_predicates_recursively_in_new_solver(predicates)
599611
}
600-
Ok(result)
612+
}
613+
614+
/// Evaluates the predicates using the new solver when `-Ztrait-solver=next` is enabled
615+
fn evaluate_predicates_recursively_in_new_solver(
616+
&mut self,
617+
predicates: impl IntoIterator<Item = PredicateObligation<'tcx>>,
618+
) -> Result<EvaluationResult, OverflowError> {
619+
let mut fulfill_cx = crate::solve::FulfillmentCtxt::new();
620+
fulfill_cx.register_predicate_obligations(self.infcx, predicates);
621+
// True errors
622+
if !fulfill_cx.select_where_possible(self.infcx).is_empty() {
623+
return Ok(EvaluatedToErr);
624+
}
625+
if !fulfill_cx.select_all_or_error(self.infcx).is_empty() {
626+
return Ok(EvaluatedToAmbig);
627+
}
628+
// Regions and opaques are handled in the `evaluation_probe` by looking at the snapshot
629+
Ok(EvaluatedToOk)
601630
}
602631

603632
#[instrument(

‎library/core/src/sync/atomic.rs

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1861,7 +1861,8 @@ macro_rules! if_not_8_bit {
18611861
($_:ident, $($tt:tt)*) => { $($tt)* };
18621862
}
18631863

1864-
#[cfg(target_has_atomic_load_store = "8")]
1864+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic_load_store))]
1865+
#[cfg_attr(bootstrap, cfg(target_has_atomic_load_store = "8"))]
18651866
macro_rules! atomic_int {
18661867
($cfg_cas:meta,
18671868
$cfg_align:meta,
@@ -2988,7 +2989,8 @@ atomic_int_ptr_sized! {
29882989
}
29892990

29902991
#[inline]
2991-
#[cfg(target_has_atomic = "8")]
2992+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
2993+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
29922994
fn strongest_failure_ordering(order: Ordering) -> Ordering {
29932995
match order {
29942996
Release => Relaxed,
@@ -3030,7 +3032,8 @@ unsafe fn atomic_load<T: Copy>(dst: *const T, order: Ordering) -> T {
30303032
}
30313033

30323034
#[inline]
3033-
#[cfg(target_has_atomic = "8")]
3035+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3036+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
30343037
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
30353038
unsafe fn atomic_swap<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
30363039
// SAFETY: the caller must uphold the safety contract for `atomic_swap`.
@@ -3047,7 +3050,8 @@ unsafe fn atomic_swap<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
30473050

30483051
/// Returns the previous value (like __sync_fetch_and_add).
30493052
#[inline]
3050-
#[cfg(target_has_atomic = "8")]
3053+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3054+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
30513055
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
30523056
unsafe fn atomic_add<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
30533057
// SAFETY: the caller must uphold the safety contract for `atomic_add`.
@@ -3064,7 +3068,8 @@ unsafe fn atomic_add<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
30643068

30653069
/// Returns the previous value (like __sync_fetch_and_sub).
30663070
#[inline]
3067-
#[cfg(target_has_atomic = "8")]
3071+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3072+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
30683073
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
30693074
unsafe fn atomic_sub<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
30703075
// SAFETY: the caller must uphold the safety contract for `atomic_sub`.
@@ -3080,7 +3085,8 @@ unsafe fn atomic_sub<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
30803085
}
30813086

30823087
#[inline]
3083-
#[cfg(target_has_atomic = "8")]
3088+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3089+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
30843090
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
30853091
unsafe fn atomic_compare_exchange<T: Copy>(
30863092
dst: *mut T,
@@ -3115,7 +3121,8 @@ unsafe fn atomic_compare_exchange<T: Copy>(
31153121
}
31163122

31173123
#[inline]
3118-
#[cfg(target_has_atomic = "8")]
3124+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3125+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
31193126
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
31203127
unsafe fn atomic_compare_exchange_weak<T: Copy>(
31213128
dst: *mut T,
@@ -3150,7 +3157,8 @@ unsafe fn atomic_compare_exchange_weak<T: Copy>(
31503157
}
31513158

31523159
#[inline]
3153-
#[cfg(target_has_atomic = "8")]
3160+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3161+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
31543162
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
31553163
unsafe fn atomic_and<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
31563164
// SAFETY: the caller must uphold the safety contract for `atomic_and`
@@ -3166,7 +3174,8 @@ unsafe fn atomic_and<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
31663174
}
31673175

31683176
#[inline]
3169-
#[cfg(target_has_atomic = "8")]
3177+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3178+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
31703179
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
31713180
unsafe fn atomic_nand<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
31723181
// SAFETY: the caller must uphold the safety contract for `atomic_nand`
@@ -3182,7 +3191,8 @@ unsafe fn atomic_nand<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
31823191
}
31833192

31843193
#[inline]
3185-
#[cfg(target_has_atomic = "8")]
3194+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3195+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
31863196
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
31873197
unsafe fn atomic_or<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
31883198
// SAFETY: the caller must uphold the safety contract for `atomic_or`
@@ -3198,7 +3208,8 @@ unsafe fn atomic_or<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
31983208
}
31993209

32003210
#[inline]
3201-
#[cfg(target_has_atomic = "8")]
3211+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3212+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
32023213
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
32033214
unsafe fn atomic_xor<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
32043215
// SAFETY: the caller must uphold the safety contract for `atomic_xor`
@@ -3215,7 +3226,8 @@ unsafe fn atomic_xor<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
32153226

32163227
/// returns the max value (signed comparison)
32173228
#[inline]
3218-
#[cfg(target_has_atomic = "8")]
3229+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3230+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
32193231
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
32203232
unsafe fn atomic_max<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
32213233
// SAFETY: the caller must uphold the safety contract for `atomic_max`
@@ -3232,7 +3244,8 @@ unsafe fn atomic_max<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
32323244

32333245
/// returns the min value (signed comparison)
32343246
#[inline]
3235-
#[cfg(target_has_atomic = "8")]
3247+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3248+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
32363249
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
32373250
unsafe fn atomic_min<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
32383251
// SAFETY: the caller must uphold the safety contract for `atomic_min`
@@ -3249,7 +3262,8 @@ unsafe fn atomic_min<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
32493262

32503263
/// returns the max value (unsigned comparison)
32513264
#[inline]
3252-
#[cfg(target_has_atomic = "8")]
3265+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3266+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
32533267
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
32543268
unsafe fn atomic_umax<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
32553269
// SAFETY: the caller must uphold the safety contract for `atomic_umax`
@@ -3266,7 +3280,8 @@ unsafe fn atomic_umax<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
32663280

32673281
/// returns the min value (unsigned comparison)
32683282
#[inline]
3269-
#[cfg(target_has_atomic = "8")]
3283+
#[cfg_attr(not(bootstrap), cfg(target_has_atomic))]
3284+
#[cfg_attr(bootstrap, cfg(target_has_atomic = "8"))]
32703285
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
32713286
unsafe fn atomic_umin<T: Copy>(dst: *mut T, val: T, order: Ordering) -> T {
32723287
// SAFETY: the caller must uphold the safety contract for `atomic_umin`

‎library/std/tests/run-time-detect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,13 @@ fn x86_all() {
120120
println!("avx512dq: {:?}", is_x86_feature_detected!("avx512dq"));
121121
println!("avx512er: {:?}", is_x86_feature_detected!("avx512er"));
122122
println!("avx512f: {:?}", is_x86_feature_detected!("avx512f"));
123-
println!("avx512gfni: {:?}", is_x86_feature_detected!("avx512gfni"));
124123
println!("avx512ifma: {:?}", is_x86_feature_detected!("avx512ifma"));
125124
println!("avx512pf: {:?}", is_x86_feature_detected!("avx512pf"));
126-
println!("avx512vaes: {:?}", is_x86_feature_detected!("avx512vaes"));
127125
println!("avx512vbmi2: {:?}", is_x86_feature_detected!("avx512vbmi2"));
128126
println!("avx512vbmi: {:?}", is_x86_feature_detected!("avx512vbmi"));
129127
println!("avx512vl: {:?}", is_x86_feature_detected!("avx512vl"));
130128
println!("avx512vnni: {:?}", is_x86_feature_detected!("avx512vnni"));
131129
println!("avx512vp2intersect: {:?}", is_x86_feature_detected!("avx512vp2intersect"));
132-
println!("avx512vpclmulqdq: {:?}", is_x86_feature_detected!("avx512vpclmulqdq"));
133130
println!("avx512vpopcntdq: {:?}", is_x86_feature_detected!("avx512vpopcntdq"));
134131
println!("avx: {:?}", is_x86_feature_detected!("avx"));
135132
println!("bmi1: {:?}", is_x86_feature_detected!("bmi1"));
@@ -138,6 +135,7 @@ fn x86_all() {
138135
println!("f16c: {:?}", is_x86_feature_detected!("f16c"));
139136
println!("fma: {:?}", is_x86_feature_detected!("fma"));
140137
println!("fxsr: {:?}", is_x86_feature_detected!("fxsr"));
138+
println!("gfni: {:?}", is_x86_feature_detected!("gfni"));
141139
println!("lzcnt: {:?}", is_x86_feature_detected!("lzcnt"));
142140
//println!("movbe: {:?}", is_x86_feature_detected!("movbe")); // movbe is unsupported as a target feature
143141
println!("pclmulqdq: {:?}", is_x86_feature_detected!("pclmulqdq"));
@@ -154,6 +152,8 @@ fn x86_all() {
154152
println!("sse: {:?}", is_x86_feature_detected!("sse"));
155153
println!("ssse3: {:?}", is_x86_feature_detected!("ssse3"));
156154
println!("tbm: {:?}", is_x86_feature_detected!("tbm"));
155+
println!("vaes: {:?}", is_x86_feature_detected!("vaes"));
156+
println!("vpclmulqdq: {:?}", is_x86_feature_detected!("vpclmulqdq"));
157157
println!("xsave: {:?}", is_x86_feature_detected!("xsave"));
158158
println!("xsavec: {:?}", is_x86_feature_detected!("xsavec"));
159159
println!("xsaveopt: {:?}", is_x86_feature_detected!("xsaveopt"));

‎library/stdarch

Submodule stdarch updated 65 files

‎src/librustdoc/clean/mod.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_attr as attr;
1515
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexMap, FxIndexSet, IndexEntry};
1616
use rustc_hir as hir;
1717
use rustc_hir::def::{CtorKind, DefKind, Res};
18-
use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LOCAL_CRATE};
18+
use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId, LOCAL_CRATE};
1919
use rustc_hir::PredicateOrigin;
2020
use rustc_hir_analysis::hir_ty_to_ty;
2121
use rustc_infer::infer::region_constraints::{Constraint, RegionConstraintData};
@@ -116,7 +116,8 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext<
116116
}
117117
});
118118

119-
Item::from_hir_id_and_parts(doc.id, Some(doc.name), ModuleItem(Module { items, span }), cx)
119+
let kind = ModuleItem(Module { items, span });
120+
Item::from_def_id_and_parts(doc.def_id.to_def_id(), Some(doc.name), kind, cx)
120121
}
121122

122123
fn clean_generic_bound<'tcx>(
@@ -2067,12 +2068,12 @@ struct OneLevelVisitor<'hir> {
20672068
map: rustc_middle::hir::map::Map<'hir>,
20682069
item: Option<&'hir hir::Item<'hir>>,
20692070
looking_for: Ident,
2070-
target_hir_id: hir::HirId,
2071+
target_def_id: LocalDefId,
20712072
}
20722073

20732074
impl<'hir> OneLevelVisitor<'hir> {
2074-
fn new(map: rustc_middle::hir::map::Map<'hir>, target_hir_id: hir::HirId) -> Self {
2075-
Self { map, item: None, looking_for: Ident::empty(), target_hir_id }
2075+
fn new(map: rustc_middle::hir::map::Map<'hir>, target_def_id: LocalDefId) -> Self {
2076+
Self { map, item: None, looking_for: Ident::empty(), target_def_id }
20762077
}
20772078

20782079
fn reset(&mut self, looking_for: Ident) {
@@ -2092,7 +2093,7 @@ impl<'hir> hir::intravisit::Visitor<'hir> for OneLevelVisitor<'hir> {
20922093
if self.item.is_none()
20932094
&& item.ident == self.looking_for
20942095
&& matches!(item.kind, hir::ItemKind::Use(_, _))
2095-
|| item.hir_id() == self.target_hir_id
2096+
|| item.owner_id.def_id == self.target_def_id
20962097
{
20972098
self.item = Some(item);
20982099
}
@@ -2106,11 +2107,11 @@ impl<'hir> hir::intravisit::Visitor<'hir> for OneLevelVisitor<'hir> {
21062107
fn get_all_import_attributes<'hir>(
21072108
mut item: &hir::Item<'hir>,
21082109
tcx: TyCtxt<'hir>,
2109-
target_hir_id: hir::HirId,
2110+
target_def_id: LocalDefId,
21102111
attributes: &mut Vec<ast::Attribute>,
21112112
) {
21122113
let hir_map = tcx.hir();
2113-
let mut visitor = OneLevelVisitor::new(hir_map, target_hir_id);
2114+
let mut visitor = OneLevelVisitor::new(hir_map, target_def_id);
21142115
// If the item is an import and has at least a path with two parts, we go into it.
21152116
while let hir::ItemKind::Use(path, _) = item.kind &&
21162117
path.segments.len() > 1 &&
@@ -2138,7 +2139,7 @@ fn clean_maybe_renamed_item<'tcx>(
21382139
cx: &mut DocContext<'tcx>,
21392140
item: &hir::Item<'tcx>,
21402141
renamed: Option<Symbol>,
2141-
import_id: Option<hir::HirId>,
2142+
import_id: Option<LocalDefId>,
21422143
) -> Vec<Item> {
21432144
use hir::ItemKind;
21442145

@@ -2183,7 +2184,7 @@ fn clean_maybe_renamed_item<'tcx>(
21832184
generics: clean_generics(generics, cx),
21842185
fields: variant_data.fields().iter().map(|x| clean_field(x, cx)).collect(),
21852186
}),
2186-
ItemKind::Impl(impl_) => return clean_impl(impl_, item.hir_id(), cx),
2187+
ItemKind::Impl(impl_) => return clean_impl(impl_, item.owner_id.def_id, cx),
21872188
// proc macros can have a name set by attributes
21882189
ItemKind::Fn(ref sig, generics, body_id) => {
21892190
clean_fn_or_proc_macro(item, sig, generics, body_id, &mut name, cx)
@@ -2218,10 +2219,10 @@ fn clean_maybe_renamed_item<'tcx>(
22182219

22192220
let mut extra_attrs = Vec::new();
22202221
if let Some(hir::Node::Item(use_node)) =
2221-
import_id.and_then(|hir_id| cx.tcx.hir().find(hir_id))
2222+
import_id.and_then(|def_id| cx.tcx.hir().find_by_def_id(def_id))
22222223
{
22232224
// We get all the various imports' attributes.
2224-
get_all_import_attributes(use_node, cx.tcx, item.hir_id(), &mut extra_attrs);
2225+
get_all_import_attributes(use_node, cx.tcx, item.owner_id.def_id, &mut extra_attrs);
22252226
}
22262227

22272228
if !extra_attrs.is_empty() {
@@ -2244,12 +2245,12 @@ fn clean_maybe_renamed_item<'tcx>(
22442245

22452246
fn clean_variant<'tcx>(variant: &hir::Variant<'tcx>, cx: &mut DocContext<'tcx>) -> Item {
22462247
let kind = VariantItem(clean_variant_data(&variant.data, &variant.disr_expr, cx));
2247-
Item::from_hir_id_and_parts(variant.hir_id, Some(variant.ident.name), kind, cx)
2248+
Item::from_def_id_and_parts(variant.def_id.to_def_id(), Some(variant.ident.name), kind, cx)
22482249
}
22492250

22502251
fn clean_impl<'tcx>(
22512252
impl_: &hir::Impl<'tcx>,
2252-
hir_id: hir::HirId,
2253+
def_id: LocalDefId,
22532254
cx: &mut DocContext<'tcx>,
22542255
) -> Vec<Item> {
22552256
let tcx = cx.tcx;
@@ -2260,7 +2261,6 @@ fn clean_impl<'tcx>(
22602261
.iter()
22612262
.map(|ii| clean_impl_item(tcx.hir().impl_item(ii.id), cx))
22622263
.collect::<Vec<_>>();
2263-
let def_id = tcx.hir().local_def_id(hir_id);
22642264

22652265
// If this impl block is an implementation of the Deref trait, then we
22662266
// need to try inlining the target's inherent impl blocks as well.
@@ -2289,7 +2289,7 @@ fn clean_impl<'tcx>(
22892289
ImplKind::Normal
22902290
},
22912291
}));
2292-
Item::from_hir_id_and_parts(hir_id, None, kind, cx)
2292+
Item::from_def_id_and_parts(def_id.to_def_id(), None, kind, cx)
22932293
};
22942294
if let Some(type_alias) = type_alias {
22952295
ret.push(make_item(trait_.clone(), type_alias, items.clone()));
@@ -2510,8 +2510,8 @@ fn clean_maybe_renamed_foreign_item<'tcx>(
25102510
hir::ForeignItemKind::Type => ForeignTypeItem,
25112511
};
25122512

2513-
Item::from_hir_id_and_parts(
2514-
item.hir_id(),
2513+
Item::from_def_id_and_parts(
2514+
item.owner_id.def_id.to_def_id(),
25152515
Some(renamed.unwrap_or(item.ident.name)),
25162516
kind,
25172517
cx,

‎src/librustdoc/clean/types.rs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -439,17 +439,6 @@ impl Item {
439439
self.attrs.doc_value()
440440
}
441441

442-
/// Convenience wrapper around [`Self::from_def_id_and_parts`] which converts
443-
/// `hir_id` to a [`DefId`]
444-
pub(crate) fn from_hir_id_and_parts(
445-
hir_id: hir::HirId,
446-
name: Option<Symbol>,
447-
kind: ItemKind,
448-
cx: &mut DocContext<'_>,
449-
) -> Item {
450-
Item::from_def_id_and_parts(cx.tcx.hir().local_def_id(hir_id).to_def_id(), name, kind, cx)
451-
}
452-
453442
pub(crate) fn from_def_id_and_parts(
454443
def_id: DefId,
455444
name: Option<Symbol>,
@@ -2416,10 +2405,7 @@ impl ConstantKind {
24162405

24172406
pub(crate) fn is_literal(&self, tcx: TyCtxt<'_>) -> bool {
24182407
match *self {
2419-
ConstantKind::TyConst { .. } => false,
2420-
ConstantKind::Extern { def_id } => def_id.as_local().map_or(false, |def_id| {
2421-
is_literal_expr(tcx, tcx.hir().local_def_id_to_hir_id(def_id))
2422-
}),
2408+
ConstantKind::TyConst { .. } | ConstantKind::Extern { .. } => false,
24232409
ConstantKind::Local { body, .. } | ConstantKind::Anonymous { body } => {
24242410
is_literal_expr(tcx, body.hir_id)
24252411
}

‎src/librustdoc/doctest.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ use rustc_ast as ast;
22
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
33
use rustc_data_structures::sync::Lrc;
44
use rustc_errors::{ColorConfig, ErrorGuaranteed, FatalError};
5-
use rustc_hir as hir;
6-
use rustc_hir::def_id::LOCAL_CRATE;
7-
use rustc_hir::intravisit;
8-
use rustc_hir::{HirId, CRATE_HIR_ID};
5+
use rustc_hir::def_id::{LocalDefId, CRATE_DEF_ID, LOCAL_CRATE};
6+
use rustc_hir::{self as hir, intravisit, CRATE_HIR_ID};
97
use rustc_interface::interface;
108
use rustc_middle::hir::map::Map;
119
use rustc_middle::hir::nested_filter;
@@ -140,7 +138,7 @@ pub(crate) fn run(options: RustdocOptions) -> Result<(), ErrorGuaranteed> {
140138
};
141139
hir_collector.visit_testable(
142140
"".to_string(),
143-
CRATE_HIR_ID,
141+
CRATE_DEF_ID,
144142
tcx.hir().span(CRATE_HIR_ID),
145143
|this| tcx.hir().walk_toplevel_module(this),
146144
);
@@ -1214,11 +1212,11 @@ impl<'a, 'hir, 'tcx> HirCollector<'a, 'hir, 'tcx> {
12141212
fn visit_testable<F: FnOnce(&mut Self)>(
12151213
&mut self,
12161214
name: String,
1217-
hir_id: HirId,
1215+
def_id: LocalDefId,
12181216
sp: Span,
12191217
nested: F,
12201218
) {
1221-
let ast_attrs = self.tcx.hir().attrs(hir_id);
1219+
let ast_attrs = self.tcx.hir().attrs(self.tcx.hir().local_def_id_to_hir_id(def_id));
12221220
if let Some(ref cfg) = ast_attrs.cfg(self.tcx, &FxHashSet::default()) {
12231221
if !cfg.matches(&self.sess.parse_sess, Some(self.tcx.features())) {
12241222
return;
@@ -1247,7 +1245,7 @@ impl<'a, 'hir, 'tcx> HirCollector<'a, 'hir, 'tcx> {
12471245
self.collector.enable_per_target_ignores,
12481246
Some(&crate::html::markdown::ExtraInfo::new(
12491247
self.tcx,
1250-
hir_id,
1248+
def_id.to_def_id(),
12511249
span_of_attrs(&attrs).unwrap_or(sp),
12521250
)),
12531251
);
@@ -1276,37 +1274,37 @@ impl<'a, 'hir, 'tcx> intravisit::Visitor<'hir> for HirCollector<'a, 'hir, 'tcx>
12761274
_ => item.ident.to_string(),
12771275
};
12781276

1279-
self.visit_testable(name, item.hir_id(), item.span, |this| {
1277+
self.visit_testable(name, item.owner_id.def_id, item.span, |this| {
12801278
intravisit::walk_item(this, item);
12811279
});
12821280
}
12831281

12841282
fn visit_trait_item(&mut self, item: &'hir hir::TraitItem<'_>) {
1285-
self.visit_testable(item.ident.to_string(), item.hir_id(), item.span, |this| {
1283+
self.visit_testable(item.ident.to_string(), item.owner_id.def_id, item.span, |this| {
12861284
intravisit::walk_trait_item(this, item);
12871285
});
12881286
}
12891287

12901288
fn visit_impl_item(&mut self, item: &'hir hir::ImplItem<'_>) {
1291-
self.visit_testable(item.ident.to_string(), item.hir_id(), item.span, |this| {
1289+
self.visit_testable(item.ident.to_string(), item.owner_id.def_id, item.span, |this| {
12921290
intravisit::walk_impl_item(this, item);
12931291
});
12941292
}
12951293

12961294
fn visit_foreign_item(&mut self, item: &'hir hir::ForeignItem<'_>) {
1297-
self.visit_testable(item.ident.to_string(), item.hir_id(), item.span, |this| {
1295+
self.visit_testable(item.ident.to_string(), item.owner_id.def_id, item.span, |this| {
12981296
intravisit::walk_foreign_item(this, item);
12991297
});
13001298
}
13011299

13021300
fn visit_variant(&mut self, v: &'hir hir::Variant<'_>) {
1303-
self.visit_testable(v.ident.to_string(), v.hir_id, v.span, |this| {
1301+
self.visit_testable(v.ident.to_string(), v.def_id, v.span, |this| {
13041302
intravisit::walk_variant(this, v);
13051303
});
13061304
}
13071305

13081306
fn visit_field_def(&mut self, f: &'hir hir::FieldDef<'_>) {
1309-
self.visit_testable(f.ident.to_string(), f.hir_id, f.span, |this| {
1307+
self.visit_testable(f.ident.to_string(), f.def_id, f.span, |this| {
13101308
intravisit::walk_field_def(this, f);
13111309
});
13121310
}

‎src/librustdoc/html/markdown.rs

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
2828
use rustc_data_structures::fx::FxHashMap;
2929
use rustc_hir::def_id::DefId;
30-
use rustc_hir::HirId;
3130
use rustc_middle::ty::TyCtxt;
3231
use rustc_span::edition::Edition;
3332
use rustc_span::{Span, Symbol};
@@ -296,25 +295,42 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
296295
let channel = if test.contains("#![feature(") { "&amp;version=nightly" } else { "" };
297296

298297
// These characters don't need to be escaped in a URI.
299-
// FIXME: use a library function for percent encoding.
298+
// See https://url.spec.whatwg.org/#query-percent-encode-set
299+
// and https://url.spec.whatwg.org/#urlencoded-parsing
300+
// and https://url.spec.whatwg.org/#url-code-points
300301
fn dont_escape(c: u8) -> bool {
301302
(b'a' <= c && c <= b'z')
302303
|| (b'A' <= c && c <= b'Z')
303304
|| (b'0' <= c && c <= b'9')
304305
|| c == b'-'
305306
|| c == b'_'
306307
|| c == b'.'
308+
|| c == b','
307309
|| c == b'~'
308310
|| c == b'!'
309311
|| c == b'\''
310312
|| c == b'('
311313
|| c == b')'
312314
|| c == b'*'
315+
|| c == b'/'
316+
|| c == b';'
317+
|| c == b':'
318+
|| c == b'?'
319+
// As described in urlencoded-parsing, the
320+
// first `=` is the one that separates key from
321+
// value. Following `=`s are part of the value.
322+
|| c == b'='
313323
}
314324
let mut test_escaped = String::new();
315325
for b in test.bytes() {
316326
if dont_escape(b) {
317327
test_escaped.push(char::from(b));
328+
} else if b == b' ' {
329+
// URL queries are decoded with + replaced with SP
330+
test_escaped.push('+');
331+
} else if b == b'%' {
332+
test_escaped.push('%');
333+
test_escaped.push('%');
318334
} else {
319335
write!(test_escaped, "%{:02X}", b).unwrap();
320336
}
@@ -784,45 +800,26 @@ pub(crate) fn find_testable_code<T: doctest::Tester>(
784800
}
785801

786802
pub(crate) struct ExtraInfo<'tcx> {
787-
id: ExtraInfoId,
803+
def_id: DefId,
788804
sp: Span,
789805
tcx: TyCtxt<'tcx>,
790806
}
791807

792-
enum ExtraInfoId {
793-
Hir(HirId),
794-
Def(DefId),
795-
}
796-
797808
impl<'tcx> ExtraInfo<'tcx> {
798-
pub(crate) fn new(tcx: TyCtxt<'tcx>, hir_id: HirId, sp: Span) -> ExtraInfo<'tcx> {
799-
ExtraInfo { id: ExtraInfoId::Hir(hir_id), sp, tcx }
800-
}
801-
802-
pub(crate) fn new_did(tcx: TyCtxt<'tcx>, did: DefId, sp: Span) -> ExtraInfo<'tcx> {
803-
ExtraInfo { id: ExtraInfoId::Def(did), sp, tcx }
809+
pub(crate) fn new(tcx: TyCtxt<'tcx>, def_id: DefId, sp: Span) -> ExtraInfo<'tcx> {
810+
ExtraInfo { def_id, sp, tcx }
804811
}
805812

806813
fn error_invalid_codeblock_attr(&self, msg: &str, help: &str) {
807-
let hir_id = match self.id {
808-
ExtraInfoId::Hir(hir_id) => hir_id,
809-
ExtraInfoId::Def(item_did) => {
810-
match item_did.as_local() {
811-
Some(item_did) => self.tcx.hir().local_def_id_to_hir_id(item_did),
812-
None => {
813-
// If non-local, no need to check anything.
814-
return;
815-
}
816-
}
817-
}
818-
};
819-
self.tcx.struct_span_lint_hir(
820-
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
821-
hir_id,
822-
self.sp,
823-
msg,
824-
|lint| lint.help(help),
825-
);
814+
if let Some(def_id) = self.def_id.as_local() {
815+
self.tcx.struct_span_lint_hir(
816+
crate::lint::INVALID_CODEBLOCK_ATTRIBUTES,
817+
self.tcx.hir().local_def_id_to_hir_id(def_id),
818+
self.sp,
819+
msg,
820+
|lint| lint.help(help),
821+
);
822+
}
826823
}
827824
}
828825

‎src/librustdoc/html/render/print_item.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
391391
};
392392
write!(
393393
w,
394-
"<div class=\"item-left {stab}{add}import-item\"{id}>\
394+
"<div class=\"item-left{add}{stab}\"{id}>\
395395
<code>{vis}{imp}</code>\
396396
</div>\
397397
{stab_tags_before}{stab_tags}{stab_tags_after}",
@@ -437,7 +437,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
437437
};
438438
write!(
439439
w,
440-
"<div class=\"item-left {stab}{add}module-item\">\
440+
"<div class=\"item-left{add}{stab}\">\
441441
<a class=\"{class}\" href=\"{href}\" title=\"{title}\">{name}</a>\
442442
{visibility_emoji}\
443443
{unsafety_flag}\
@@ -452,7 +452,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
452452
stab = stab.unwrap_or_default(),
453453
unsafety_flag = unsafety_flag,
454454
href = item_path(myitem.type_(), myitem.name.unwrap().as_str()),
455-
title = [full_path(cx, myitem), myitem.type_().to_string()]
455+
title = [myitem.type_().to_string(), full_path(cx, myitem)]
456456
.iter()
457457
.filter_map(|s| if !s.is_empty() { Some(s.as_str()) } else { None })
458458
.collect::<Vec<_>>()

‎src/librustdoc/html/static/css/rustdoc.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,7 @@ so that we can apply CSS-filters to change the arrow color in themes */
977977
0 -1px 0 black;
978978
}
979979

980-
.module-item.unstable,
981-
.import-item.unstable {
980+
.item-left.unstable {
982981
opacity: 0.65;
983982
}
984983

‎src/librustdoc/passes/calculate_doc_coverage.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,7 @@ impl<'a, 'b> DocVisitor for CoverageCalculator<'a, 'b> {
216216
);
217217

218218
let has_doc_example = tests.found_tests != 0;
219-
// The `expect_def_id()` should be okay because `local_def_id_to_hir_id`
220-
// would presumably panic if a fake `DefIndex` were passed.
221-
let hir_id = self
222-
.ctx
223-
.tcx
224-
.hir()
225-
.local_def_id_to_hir_id(i.item_id.expect_def_id().expect_local());
219+
let hir_id = DocContext::as_local_hir_id(self.ctx.tcx, i.item_id).unwrap();
226220
let (level, source) = self.ctx.tcx.lint_level_at_node(MISSING_DOCS, hir_id);
227221

228222
// In case we have:

‎src/librustdoc/passes/check_doc_test_visibility.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use crate::visit::DocVisitor;
1414
use crate::visit_ast::inherits_doc_hidden;
1515
use rustc_hir as hir;
1616
use rustc_middle::lint::LintLevelSource;
17+
use rustc_middle::ty::DefIdTree;
1718
use rustc_session::lint;
18-
use rustc_span::symbol::sym;
1919

2020
pub(crate) const CHECK_DOC_TEST_VISIBILITY: Pass = Pass {
2121
name: "check_doc_test_visibility",
@@ -79,11 +79,11 @@ pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -
7979

8080
// The `expect_def_id()` should be okay because `local_def_id_to_hir_id`
8181
// would presumably panic if a fake `DefIndex` were passed.
82-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(item.item_id.expect_def_id().expect_local());
82+
let def_id = item.item_id.expect_def_id().expect_local();
8383

8484
// check if parent is trait impl
85-
if let Some(parent_hir_id) = cx.tcx.hir().opt_parent_id(hir_id) {
86-
if let Some(parent_node) = cx.tcx.hir().find(parent_hir_id) {
85+
if let Some(parent_def_id) = cx.tcx.opt_local_parent(def_id) {
86+
if let Some(parent_node) = cx.tcx.hir().find_by_def_id(parent_def_id) {
8787
if matches!(
8888
parent_node,
8989
hir::Node::Item(hir::Item {
@@ -96,13 +96,16 @@ pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -
9696
}
9797
}
9898

99-
if cx.tcx.hir().attrs(hir_id).lists(sym::doc).has_word(sym::hidden)
100-
|| inherits_doc_hidden(cx.tcx, hir_id)
101-
|| cx.tcx.hir().span(hir_id).in_derive_expansion()
99+
if cx.tcx.is_doc_hidden(def_id.to_def_id())
100+
|| inherits_doc_hidden(cx.tcx, def_id)
101+
|| cx.tcx.def_span(def_id.to_def_id()).in_derive_expansion()
102102
{
103103
return false;
104104
}
105-
let (level, source) = cx.tcx.lint_level_at_node(crate::lint::MISSING_DOC_CODE_EXAMPLES, hir_id);
105+
let (level, source) = cx.tcx.lint_level_at_node(
106+
crate::lint::MISSING_DOC_CODE_EXAMPLES,
107+
cx.tcx.hir().local_def_id_to_hir_id(def_id),
108+
);
106109
level != lint::Level::Allow || matches!(source, LintLevelSource::Default)
107110
}
108111

‎src/librustdoc/passes/collect_intra_doc_links.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,14 +1194,9 @@ impl LinkCollector<'_, '_> {
11941194
}
11951195

11961196
// item can be non-local e.g. when using #[doc(primitive = "pointer")]
1197-
if let Some((src_id, dst_id)) = id
1198-
.as_local()
1199-
// The `expect_def_id()` should be okay because `local_def_id_to_hir_id`
1200-
// would presumably panic if a fake `DefIndex` were passed.
1201-
.and_then(|dst_id| {
1202-
item.item_id.expect_def_id().as_local().map(|src_id| (src_id, dst_id))
1203-
})
1204-
{
1197+
if let Some((src_id, dst_id)) = id.as_local().and_then(|dst_id| {
1198+
item.item_id.expect_def_id().as_local().map(|src_id| (src_id, dst_id))
1199+
}) {
12051200
if self.cx.tcx.effective_visibilities(()).is_exported(src_id)
12061201
&& !self.cx.tcx.effective_visibilities(()).is_exported(dst_id)
12071202
{

‎src/librustdoc/passes/lint/check_code_block_syntax.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ use crate::passes::source_span_for_markdown_range;
1919
pub(crate) fn visit_item(cx: &DocContext<'_>, item: &clean::Item) {
2020
if let Some(dox) = &item.attrs.collapsed_doc_value() {
2121
let sp = item.attr_span(cx.tcx);
22-
let extra =
23-
crate::html::markdown::ExtraInfo::new_did(cx.tcx, item.item_id.expect_def_id(), sp);
22+
let extra = crate::html::markdown::ExtraInfo::new(cx.tcx, item.item_id.expect_def_id(), sp);
2423
for code_block in markdown::rust_code_blocks(dox, &extra) {
2524
check_rust_syntax(cx, item, dox, code_block);
2625
}
@@ -73,7 +72,6 @@ fn check_rust_syntax(
7372
return;
7473
};
7574

76-
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_id);
7775
let empty_block = code_block.lang_string == Default::default() && code_block.is_fenced;
7876
let is_ignore = code_block.lang_string.ignore != markdown::Ignore::None;
7977

@@ -93,6 +91,7 @@ fn check_rust_syntax(
9391
// Finally build and emit the completed diagnostic.
9492
// All points of divergence have been handled earlier so this can be
9593
// done the same way whether the span is precise or not.
94+
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_id);
9695
cx.tcx.struct_span_lint_hir(crate::lint::INVALID_RUST_CODEBLOCKS, hir_id, sp, msg, |lint| {
9796
let explanation = if is_ignore {
9897
"`ignore` code blocks require valid Rust code for syntax highlighting; \

‎src/librustdoc/passes/propagate_doc_cfg.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use crate::fold::DocFolder;
99
use crate::passes::Pass;
1010

1111
use rustc_hir::def_id::LocalDefId;
12+
use rustc_middle::ty::DefIdTree;
1213

1314
pub(crate) const PROPAGATE_DOC_CFG: Pass = Pass {
1415
name: "propagate-doc-cfg",
@@ -41,24 +42,22 @@ impl<'a, 'tcx> CfgPropagator<'a, 'tcx> {
4142
let Some(def_id) = item.item_id.as_def_id().and_then(|def_id| def_id.as_local())
4243
else { return };
4344

44-
let hir = self.cx.tcx.hir();
45-
let hir_id = hir.local_def_id_to_hir_id(def_id);
46-
4745
if check_parent {
48-
let expected_parent = hir.get_parent_item(hir_id);
46+
let expected_parent = self.cx.tcx.opt_local_parent(def_id);
4947
// If parents are different, it means that `item` is a reexport and we need
5048
// to compute the actual `cfg` by iterating through its "real" parents.
51-
if self.parent == Some(expected_parent.def_id) {
49+
if self.parent.is_some() && self.parent == expected_parent {
5250
return;
5351
}
5452
}
5553

5654
let mut attrs = Vec::new();
57-
for (parent_hir_id, _) in hir.parent_iter(hir_id) {
58-
if let Some(def_id) = hir.opt_local_def_id(parent_hir_id) {
59-
attrs.extend_from_slice(load_attrs(self.cx, def_id.to_def_id()));
60-
}
55+
let mut next_def_id = def_id;
56+
while let Some(parent_def_id) = self.cx.tcx.opt_local_parent(next_def_id) {
57+
attrs.extend_from_slice(load_attrs(self.cx, parent_def_id.to_def_id()));
58+
next_def_id = parent_def_id;
6159
}
60+
6261
let (_, cfg) = merge_attrs(self.cx, None, item.attrs.other_attrs.as_slice(), Some(&attrs));
6362
item.cfg = cfg;
6463
}

‎src/librustdoc/visit_ast.rs

Lines changed: 45 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
use rustc_data_structures::fx::FxHashSet;
55
use rustc_hir as hir;
66
use rustc_hir::def::{DefKind, Res};
7-
use rustc_hir::def_id::{DefId, DefIdMap};
8-
use rustc_hir::{HirIdSet, Node, CRATE_HIR_ID};
9-
use rustc_middle::ty::TyCtxt;
7+
use rustc_hir::def_id::{DefId, DefIdMap, LocalDefId, LocalDefIdSet};
8+
use rustc_hir::{Node, CRATE_HIR_ID};
9+
use rustc_middle::ty::{DefIdTree, TyCtxt};
1010
use rustc_span::def_id::{CRATE_DEF_ID, LOCAL_CRATE};
1111
use rustc_span::symbol::{kw, sym, Symbol};
1212
use rustc_span::Span;
@@ -23,19 +23,26 @@ pub(crate) struct Module<'hir> {
2323
pub(crate) name: Symbol,
2424
pub(crate) where_inner: Span,
2525
pub(crate) mods: Vec<Module<'hir>>,
26-
pub(crate) id: hir::HirId,
26+
pub(crate) def_id: LocalDefId,
2727
// (item, renamed, import_id)
28-
pub(crate) items: Vec<(&'hir hir::Item<'hir>, Option<Symbol>, Option<hir::HirId>)>,
28+
pub(crate) items: Vec<(&'hir hir::Item<'hir>, Option<Symbol>, Option<LocalDefId>)>,
2929
pub(crate) foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option<Symbol>)>,
3030
}
3131

3232
impl Module<'_> {
33-
pub(crate) fn new(name: Symbol, id: hir::HirId, where_inner: Span) -> Self {
34-
Module { name, id, where_inner, mods: Vec::new(), items: Vec::new(), foreigns: Vec::new() }
33+
pub(crate) fn new(name: Symbol, def_id: LocalDefId, where_inner: Span) -> Self {
34+
Module {
35+
name,
36+
def_id,
37+
where_inner,
38+
mods: Vec::new(),
39+
items: Vec::new(),
40+
foreigns: Vec::new(),
41+
}
3542
}
3643

3744
pub(crate) fn where_outer(&self, tcx: TyCtxt<'_>) -> Span {
38-
tcx.hir().span(self.id)
45+
tcx.def_span(self.def_id)
3946
}
4047
}
4148

@@ -46,10 +53,10 @@ fn def_id_to_path(tcx: TyCtxt<'_>, did: DefId) -> Vec<Symbol> {
4653
std::iter::once(crate_name).chain(relative).collect()
4754
}
4855

49-
pub(crate) fn inherits_doc_hidden(tcx: TyCtxt<'_>, mut node: hir::HirId) -> bool {
50-
while let Some(id) = tcx.hir().get_enclosing_scope(node) {
56+
pub(crate) fn inherits_doc_hidden(tcx: TyCtxt<'_>, mut node: LocalDefId) -> bool {
57+
while let Some(id) = tcx.opt_local_parent(node) {
5158
node = id;
52-
if tcx.hir().attrs(node).lists(sym::doc).has_word(sym::hidden) {
59+
if tcx.is_doc_hidden(node.to_def_id()) {
5360
return true;
5461
}
5562
}
@@ -61,7 +68,7 @@ pub(crate) fn inherits_doc_hidden(tcx: TyCtxt<'_>, mut node: hir::HirId) -> bool
6168

6269
pub(crate) struct RustdocVisitor<'a, 'tcx> {
6370
cx: &'a mut core::DocContext<'tcx>,
64-
view_item_stack: HirIdSet,
71+
view_item_stack: LocalDefIdSet,
6572
inlining: bool,
6673
/// Are the current module and all of its parents public?
6774
inside_public_path: bool,
@@ -71,8 +78,8 @@ pub(crate) struct RustdocVisitor<'a, 'tcx> {
7178
impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
7279
pub(crate) fn new(cx: &'a mut core::DocContext<'tcx>) -> RustdocVisitor<'a, 'tcx> {
7380
// If the root is re-exported, terminate all recursion.
74-
let mut stack = HirIdSet::default();
75-
stack.insert(hir::CRATE_HIR_ID);
81+
let mut stack = LocalDefIdSet::default();
82+
stack.insert(CRATE_DEF_ID);
7683
RustdocVisitor {
7784
cx,
7885
view_item_stack: stack,
@@ -89,7 +96,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
8996

9097
pub(crate) fn visit(mut self) -> Module<'tcx> {
9198
let mut top_level_module = self.visit_mod_contents(
92-
hir::CRATE_HIR_ID,
99+
CRATE_DEF_ID,
93100
self.cx.tcx.hir().root_module(),
94101
self.cx.tcx.crate_name(LOCAL_CRATE),
95102
None,
@@ -152,16 +159,15 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
152159

153160
fn visit_mod_contents(
154161
&mut self,
155-
id: hir::HirId,
162+
def_id: LocalDefId,
156163
m: &'tcx hir::Mod<'tcx>,
157164
name: Symbol,
158-
parent_id: Option<hir::HirId>,
165+
parent_id: Option<LocalDefId>,
159166
) -> Module<'tcx> {
160-
let mut om = Module::new(name, id, m.spans.inner_span);
161-
let def_id = self.cx.tcx.hir().local_def_id(id).to_def_id();
167+
let mut om = Module::new(name, def_id, m.spans.inner_span);
162168
// Keep track of if there were any private modules in the path.
163169
let orig_inside_public_path = self.inside_public_path;
164-
self.inside_public_path &= self.cx.tcx.visibility(def_id).is_public();
170+
self.inside_public_path &= self.cx.tcx.local_visibility(def_id).is_public();
165171
for &i in m.item_ids {
166172
let item = self.cx.tcx.hir().item(i);
167173
if matches!(item.kind, hir::ItemKind::Use(_, hir::UseKind::Glob)) {
@@ -193,7 +199,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
193199
/// Returns `true` if the target has been inlined.
194200
fn maybe_inline_local(
195201
&mut self,
196-
id: hir::HirId,
202+
def_id: LocalDefId,
197203
res: Res,
198204
renamed: Option<Symbol>,
199205
glob: bool,
@@ -211,10 +217,10 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
211217
return false;
212218
};
213219

214-
let use_attrs = tcx.hir().attrs(id);
220+
let use_attrs = tcx.hir().attrs(tcx.hir().local_def_id_to_hir_id(def_id));
215221
// Don't inline `doc(hidden)` imports so they can be stripped at a later stage.
216222
let is_no_inline = use_attrs.lists(sym::doc).has_word(sym::no_inline)
217-
|| use_attrs.lists(sym::doc).has_word(sym::hidden);
223+
|| tcx.is_doc_hidden(def_id.to_def_id());
218224

219225
// For cross-crate impl inlining we need to know whether items are
220226
// reachable in documentation -- a previously unreachable item can be
@@ -225,37 +231,39 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
225231
return false;
226232
}
227233

228-
let res_hir_id = match res_did.as_local() {
229-
Some(n) => tcx.hir().local_def_id_to_hir_id(n),
230-
None => return false,
234+
let Some(res_did) = res_did.as_local() else {
235+
return false;
231236
};
232237

233-
let is_private =
234-
!self.cx.cache.effective_visibilities.is_directly_public(self.cx.tcx, res_did);
235-
let is_hidden = inherits_doc_hidden(self.cx.tcx, res_hir_id);
238+
let is_private = !self
239+
.cx
240+
.cache
241+
.effective_visibilities
242+
.is_directly_public(self.cx.tcx, res_did.to_def_id());
243+
let is_hidden = inherits_doc_hidden(self.cx.tcx, res_did);
236244

237245
// Only inline if requested or if the item would otherwise be stripped.
238246
if (!please_inline && !is_private && !is_hidden) || is_no_inline {
239247
return false;
240248
}
241249

242-
if !self.view_item_stack.insert(res_hir_id) {
250+
if !self.view_item_stack.insert(res_did) {
243251
return false;
244252
}
245253

246-
let ret = match tcx.hir().get(res_hir_id) {
254+
let ret = match tcx.hir().get_by_def_id(res_did) {
247255
Node::Item(&hir::Item { kind: hir::ItemKind::Mod(ref m), .. }) if glob => {
248256
let prev = mem::replace(&mut self.inlining, true);
249257
for &i in m.item_ids {
250258
let i = self.cx.tcx.hir().item(i);
251-
self.visit_item(i, None, om, Some(id));
259+
self.visit_item(i, None, om, Some(def_id));
252260
}
253261
self.inlining = prev;
254262
true
255263
}
256264
Node::Item(it) if !glob => {
257265
let prev = mem::replace(&mut self.inlining, true);
258-
self.visit_item(it, renamed, om, Some(id));
266+
self.visit_item(it, renamed, om, Some(def_id));
259267
self.inlining = prev;
260268
true
261269
}
@@ -267,7 +275,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
267275
}
268276
_ => false,
269277
};
270-
self.view_item_stack.remove(&res_hir_id);
278+
self.view_item_stack.remove(&res_did);
271279
ret
272280
}
273281

@@ -276,7 +284,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
276284
item: &'tcx hir::Item<'_>,
277285
renamed: Option<Symbol>,
278286
om: &mut Module<'tcx>,
279-
parent_id: Option<hir::HirId>,
287+
parent_id: Option<LocalDefId>,
280288
) {
281289
debug!("visiting item {:?}", item);
282290
let name = renamed.unwrap_or(item.ident.name);
@@ -321,7 +329,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
321329
let is_glob = kind == hir::UseKind::Glob;
322330
let ident = if is_glob { None } else { Some(name) };
323331
if self.maybe_inline_local(
324-
item.hir_id(),
332+
item.owner_id.def_id,
325333
res,
326334
ident,
327335
is_glob,
@@ -356,7 +364,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
356364
}
357365
}
358366
hir::ItemKind::Mod(ref m) => {
359-
om.mods.push(self.visit_mod_contents(item.hir_id(), m, name, parent_id));
367+
om.mods.push(self.visit_mod_contents(item.owner_id.def_id, m, name, parent_id));
360368
}
361369
hir::ItemKind::Fn(..)
362370
| hir::ItemKind::ExternCrate(..)

‎tests/rustdoc-gui/label-next-to-symbol.goml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ assert-css: (
2020
// table like view
2121
assert-css: (".item-right.docblock-short", { "padding-left": "0px" })
2222
compare-elements-position-near: (
23-
"//*[@class='item-left module-item']//a[text()='replaced_function']",
23+
"//*[@class='item-left']//a[text()='replaced_function']",
2424
".item-left .stab.deprecated",
2525
{"y": 2},
2626
)
@@ -32,7 +32,7 @@ compare-elements-position: (
3232

3333
// Ensure no wrap
3434
compare-elements-position: (
35-
"//*[@class='item-left module-item']//a[text()='replaced_function']/..",
35+
"//*[@class='item-left']//a[text()='replaced_function']/..",
3636
"//*[@class='item-right docblock-short'][text()='a thing with a label']",
3737
("y"),
3838
)
@@ -43,7 +43,7 @@ size: (600, 600)
4343
// staggered layout with 2em spacing
4444
assert-css: (".item-right.docblock-short", { "padding-left": "32px" })
4545
compare-elements-position-near: (
46-
"//*[@class='item-left module-item']//a[text()='replaced_function']",
46+
"//*[@class='item-left']//a[text()='replaced_function']",
4747
".item-left .stab.deprecated",
4848
{"y": 2},
4949
)
@@ -55,7 +55,7 @@ compare-elements-position: (
5555

5656
// Ensure wrap
5757
compare-elements-position-false: (
58-
"//*[@class='item-left module-item']//a[text()='replaced_function']/..",
58+
"//*[@class='item-left']//a[text()='replaced_function']/..",
5959
"//*[@class='item-right docblock-short'][text()='a thing with a label']",
6060
("y"),
6161
)

‎tests/rustdoc-gui/module-items-font.goml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This test checks that the correct font is used on module items (in index.html pages).
22
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
33
assert-css: (
4-
".item-table .module-item a",
4+
".item-table .item-left > a",
55
{"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'},
66
ALL,
77
)

‎tests/rustdoc-gui/unsafe-fn.goml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
44
show-text: true
55

66
compare-elements-property: (
7-
"//a[@title='test_docs::safe_fn fn']/..",
8-
"//a[@title='test_docs::unsafe_fn fn']/..",
7+
"//a[@title='fn test_docs::safe_fn']/..",
8+
"//a[@title='fn test_docs::unsafe_fn']/..",
99
["clientHeight"]
1010
)
1111

‎tests/rustdoc/cfg_doc_reexport.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#![no_core]
66

77
// @has 'foo/index.html'
8-
// @has - '//*[@class="item-left module-item"]/*[@class="stab portability"]' 'foobar'
9-
// @has - '//*[@class="item-left module-item"]/*[@class="stab portability"]' 'bar'
8+
// @has - '//*[@class="item-left"]/*[@class="stab portability"]' 'foobar'
9+
// @has - '//*[@class="item-left"]/*[@class="stab portability"]' 'bar'
1010

1111
#[doc(cfg(feature = "foobar"))]
1212
mod imp_priv {

‎tests/rustdoc/deprecated.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// @has deprecated/index.html '//*[@class="item-left module-item"]/span[@class="stab deprecated"]' \
1+
// @has deprecated/index.html '//*[@class="item-left"]/span[@class="stab deprecated"]' \
22
// 'Deprecated'
33
// @has - '//*[@class="item-right docblock-short"]' 'Deprecated docs'
44

‎tests/rustdoc/doc-cfg.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct Portable;
1212
// @has doc_cfg/unix_only/index.html \
1313
// '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
1414
// 'Available on Unix only.'
15-
// @matches - '//*[@class="item-left module-item"]//*[@class="stab portability"]' '\AARM\Z'
15+
// @matches - '//*[@class="item-left"]//*[@class="stab portability"]' '\AARM\Z'
1616
// @count - '//*[@class="stab portability"]' 2
1717
#[doc(cfg(unix))]
1818
pub mod unix_only {
@@ -42,7 +42,7 @@ pub mod unix_only {
4242
// @has doc_cfg/wasi_only/index.html \
4343
// '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \
4444
// 'Available on WASI only.'
45-
// @matches - '//*[@class="item-left module-item"]//*[@class="stab portability"]' '\AWebAssembly\Z'
45+
// @matches - '//*[@class="item-left"]//*[@class="stab portability"]' '\AWebAssembly\Z'
4646
// @count - '//*[@class="stab portability"]' 2
4747
#[doc(cfg(target_os = "wasi"))]
4848
pub mod wasi_only {
@@ -74,7 +74,7 @@ pub mod wasi_only {
7474

7575
// the portability header is different on the module view versus the full view
7676
// @has doc_cfg/index.html
77-
// @matches - '//*[@class="item-left module-item"]//*[@class="stab portability"]' '\Aavx\Z'
77+
// @matches - '//*[@class="item-left"]//*[@class="stab portability"]' '\Aavx\Z'
7878

7979
// @has doc_cfg/fn.uses_target_feature.html
8080
// @has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \

‎tests/rustdoc/duplicate-cfg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#![feature(doc_cfg)]
33

44
// @has 'foo/index.html'
5-
// @matches '-' '//*[@class="item-left module-item"]//*[@class="stab portability"]' '^sync$'
6-
// @has '-' '//*[@class="item-left module-item"]//*[@class="stab portability"]/@title' 'Available on crate feature `sync` only'
5+
// @matches '-' '//*[@class="item-left"]//*[@class="stab portability"]' '^sync$'
6+
// @has '-' '//*[@class="item-left"]//*[@class="stab portability"]/@title' 'Available on crate feature `sync` only'
77

88
// @has 'foo/struct.Foo.html'
99
// @has '-' '//*[@class="stab portability"]' 'sync'

‎tests/rustdoc/glob-shadowing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @has 'glob_shadowing/index.html'
2-
// @count - '//div[@class="item-left module-item"]' 6
2+
// @count - '//div[@class="item-left"]' 6
33
// @!has - '//div[@class="item-right docblock-short"]' 'sub1::describe'
44
// @has - '//div[@class="item-right docblock-short"]' 'sub2::describe'
55

‎tests/rustdoc/inline_cross/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
extern crate macros;
88

9-
// @has foo/index.html '//*[@class="item-left unstable deprecated module-item"]/span[@class="stab deprecated"]' \
9+
// @has foo/index.html '//*[@class="item-left unstable deprecated"]/span[@class="stab deprecated"]' \
1010
// Deprecated
11-
// @has - '//*[@class="item-left unstable deprecated module-item"]/span[@class="stab unstable"]' \
11+
// @has - '//*[@class="item-left unstable deprecated"]/span[@class="stab unstable"]' \
1212
// Experimental
1313

1414
// @has foo/macro.my_macro.html

‎tests/rustdoc/issue-32374.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#![doc(issue_tracker_base_url = "https://issue_url/")]
33
#![unstable(feature = "test", issue = "32374")]
44

5-
// @matches issue_32374/index.html '//*[@class="item-left unstable deprecated module-item"]/span[@class="stab deprecated"]' \
5+
// @matches issue_32374/index.html '//*[@class="item-left unstable deprecated"]/span[@class="stab deprecated"]' \
66
// 'Deprecated'
7-
// @matches issue_32374/index.html '//*[@class="item-left unstable deprecated module-item"]/span[@class="stab unstable"]' \
7+
// @matches issue_32374/index.html '//*[@class="item-left unstable deprecated"]/span[@class="stab unstable"]' \
88
// 'Experimental'
99
// @matches issue_32374/index.html '//*[@class="item-right docblock-short"]/text()' 'Docs'
1010

‎tests/rustdoc/issue-55364.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ pub mod subone {
2929
// @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.foo.html"]' 'foo'
3030
// @has - '//section[@id="main-content"]/details/div[@class="docblock"]//a[@href="../fn.bar.html"]' 'bar'
3131
// Though there should be such links later
32-
// @has - '//section[@id="main-content"]/div[@class="item-table"]//div[@class="item-left module-item"]/a[@class="fn"][@href="fn.foo.html"]' 'foo'
33-
// @has - '//section[@id="main-content"]/div[@class="item-table"]//div[@class="item-left module-item"]/a[@class="fn"][@href="fn.bar.html"]' 'bar'
32+
// @has - '//section[@id="main-content"]/div[@class="item-table"]//div[@class="item-left"]/a[@class="fn"][@href="fn.foo.html"]' 'foo'
33+
// @has - '//section[@id="main-content"]/div[@class="item-table"]//div[@class="item-left"]/a[@class="fn"][@href="fn.bar.html"]' 'bar'
3434
/// See either [foo] or [bar].
3535
pub mod subtwo {
3636

‎tests/rustdoc/issue-83375-multiple-mods-w-same-name-doc-inline-last-item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ pub mod sub {
1111
#[doc(inline)]
1212
pub use sub::*;
1313

14-
// @count foo/index.html '//a[@class="mod"][@title="foo::prelude mod"]' 1
14+
// @count foo/index.html '//a[@class="mod"][@title="mod foo::prelude"]' 1
1515
// @count foo/prelude/index.html '//div[@class="item-row"]' 0
1616
pub mod prelude {}

‎tests/rustdoc/issue-83375-multiple-mods-w-same-name-doc-inline.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ pub mod sub {
88
}
99
}
1010

11-
// @count foo/index.html '//a[@class="mod"][@title="foo::prelude mod"]' 1
11+
// @count foo/index.html '//a[@class="mod"][@title="mod foo::prelude"]' 1
1212
// @count foo/prelude/index.html '//div[@class="item-row"]' 0
1313
pub mod prelude {}
1414

‎tests/rustdoc/issue-95873.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// @has issue_95873/index.html "//*[@class='item-left import-item']" "pub use ::std as x;"
1+
// @has issue_95873/index.html "//*[@class='item-left']" "pub use ::std as x;"
22
pub use ::std as x;

‎tests/rustdoc/issue-99221-multiple-structs-w-same-name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ extern crate issue_99221_aux;
99

1010
pub use issue_99221_aux::*;
1111

12-
// @count foo/index.html '//a[@class="struct"][@title="foo::Print struct"]' 1
12+
// @count foo/index.html '//a[@class="struct"][@title="struct foo::Print"]' 1
1313

1414
pub struct Print;

‎tests/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern crate issue_99734_aux;
99

1010
pub use issue_99734_aux::*;
1111

12-
// @count foo/index.html '//a[@class="fn"][@title="foo::main fn"]' 1
12+
// @count foo/index.html '//a[@class="fn"][@title="fn foo::main"]' 1
1313

1414
extern "C" {
1515
pub fn main() -> std::ffi::c_int;

‎tests/rustdoc/issue-99734-multiple-mods-w-same-name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ extern crate issue_99734_aux;
99

1010
pub use issue_99734_aux::*;
1111

12-
// @count foo/index.html '//a[@class="mod"][@title="foo::task mod"]' 1
12+
// @count foo/index.html '//a[@class="mod"][@title="mod foo::task"]' 1
1313

1414
pub mod task {}

‎tests/rustdoc/playground-arg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
pub fn dummy() {}
1111

1212
// ensure that `extern crate foo;` was inserted into code snips automatically:
13-
// @matches foo/index.html '//a[@class="test-arrow"][@href="https://example.com/?code=%23!%5Ballow(unused)%5D%0Aextern%20crate%20r%23foo%3B%0Afn%20main()%20%7B%0Ause%20foo%3A%3Adummy%3B%0Adummy()%3B%0A%7D&edition=2015"]' "Run"
13+
// @matches foo/index.html '//a[@class="test-arrow"][@href="https://example.com/?code=%23!%5Ballow(unused)%5D%0Aextern+crate+r%23foo;%0Afn+main()+%7B%0Ause+foo::dummy;%0Adummy();%0A%7D&edition=2015"]' "Run"

‎tests/rustdoc/playground.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@
2222
//! }
2323
//! ```
2424
25-
// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22Hello%2C%20world!%22)%3B%0A%7D&edition=2015"]' "Run"
26-
// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Aprintln!(%22Hello%2C%20world!%22)%3B%0A%7D&edition=2015"]' "Run"
27-
// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0A%23!%5Bfeature(something)%5D%0A%0Afn%20main()%20%7B%0A%20%20%20%20println!(%22Hello%2C%20world!%22)%3B%0A%7D&version=nightly&edition=2015"]' "Run"
25+
// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0Afn+main()+%7B%0Aprintln!(%22Hello,+world!%22);%0A%7D&edition=2015"]' "Run"
26+
// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0Afn+main()+%7B%0A++++println!(%22Hello,+world!%22);%0A%7D&edition=2015"]' "Run"
27+
// @matches foo/index.html '//a[@class="test-arrow"][@href="https://www.example.com/?code=%23!%5Ballow(unused)%5D%0A%23!%5Bfeature(something)%5D%0A%0Afn+main()+%7B%0A++++println!(%22Hello,+world!%22);%0A%7D&version=nightly&edition=2015"]' "Run"

‎tests/rustdoc/reexport-check.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
extern crate reexport_check;
55

66
// @!has 'foo/index.html' '//code' 'pub use self::i32;'
7-
// @has 'foo/index.html' '//div[@class="item-left deprecated module-item"]' 'i32'
7+
// @has 'foo/index.html' '//div[@class="item-left deprecated"]' 'i32'
88
// @has 'foo/i32/index.html'
99
#[allow(deprecated, deprecated_in_future)]
1010
pub use std::i32;
1111
// @!has 'foo/index.html' '//code' 'pub use self::string::String;'
12-
// @has 'foo/index.html' '//div[@class="item-left module-item"]' 'String'
12+
// @has 'foo/index.html' '//div[@class="item-left"]' 'String'
1313
pub use std::string::String;
1414

1515
// @has 'foo/index.html' '//div[@class="item-right docblock-short"]' 'Docs in original'

0 commit comments

Comments
 (0)
Please sign in to comment.