authorbors <bors@rust-lang.org> 2026-06-22 19:20:35 UTC
committerbors <bors@rust-lang.org> 2026-06-22 19:20:35 UTC
log4429659e4745016bd3f26a4a421843edc7fbc422
tree160a37350d4c487d39377ddaab99637198a7cbcf
parentcddcbec198760511240bf0e728193bf4d700acb4
parent3809a10081595a5399485d8d59382e1d7d934aad

Auto merge of #158268 - JonathanBrouwer:rollup-gqPk01p, r=JonathanBrouwer

Rollup of 8 pull requests Successful merges: - rust-lang/rust#158242 (Fix linking for wasm with crate metadata included) - rust-lang/rust#157978 (Avoid `&raw` recovery ICE after trailing comma) - rust-lang/rust#158119 (Refactor `proc_macro_decls_static`) - rust-lang/rust#158171 (rustdoc: Avoid ICE on unevaluated `type const` projections in array lengths) - rust-lang/rust#158172 (update `asm_experimental_reg` comments) - rust-lang/rust#158230 (Include `Item::stability` info in rustdoc JSON.) - rust-lang/rust#158258 (Use an unexpanded span for actually written down opt out params) - rust-lang/rust#158262 (Change compiler leads in triagebot.toml)

37 files changed, 753 insertions(+), 109 deletions(-)

compiler/rustc_codegen_ssa/src/back/linker.rs+7-1
......@@ -1817,7 +1817,13 @@ pub(crate) fn exported_symbols(
18171817 exported_symbols_for_non_proc_macro(tcx, crate_type)
18181818 };
18191819
1820 if crate_type == CrateType::Dylib || crate_type == CrateType::ProcMacro {
1820 // Preserve the metadata symbol to ensure the metadata section doesn't get removed by the
1821 // linker. On wasm however the metadata is put in a custom section, to which symbols can't
1822 // refer, so there is no metadata symbol there. Luckily custom sections are always preserved by
1823 // the linker.
1824 if (crate_type == CrateType::Dylib || crate_type == CrateType::ProcMacro)
1825 && !tcx.sess.target.is_like_wasm
1826 {
18211827 let metadata_symbol_name = exported_symbols::metadata_symbol_name(tcx);
18221828 symbols.push((metadata_symbol_name, SymbolExportKind::Data));
18231829 }
compiler/rustc_hir/src/hir.rs+1
......@@ -4570,6 +4570,7 @@ impl<'hir> Item<'hir> {
45704570 HirId::make_owner(self.owner_id.def_id)
45714571 }
45724572
4573 #[inline]
45734574 pub fn item_id(&self) -> ItemId {
45744575 ItemId { owner_id: self.owner_id }
45754576 }
compiler/rustc_hir_analysis/src/hir_ty_lowering/bounds.rs+9-10
......@@ -25,17 +25,17 @@ use crate::hir_ty_lowering::{
2525#[derive(Debug, Default)]
2626struct CollectedBound {
2727 /// `Trait`
28 positive: bool,
28 positive: Option<Span>,
2929 /// `?Trait`
30 maybe: bool,
30 maybe: Option<Span>,
3131 /// `!Trait`
32 negative: bool,
32 negative: Option<Span>,
3333}
3434
3535impl CollectedBound {
3636 /// Returns `true` if any of `Trait`, `?Trait` or `!Trait` were encountered.
3737 fn any(&self) -> bool {
38 self.positive || self.maybe || self.negative
38 self.positive.is_some() || self.maybe.is_some() || self.negative.is_some()
3939 }
4040}
4141
......@@ -96,9 +96,9 @@ fn collect_bounds<'a, 'tcx>(
9696 }
9797
9898 match ptr.modifiers.polarity {
99 hir::BoundPolarity::Maybe(_) => collect_into.maybe = true,
100 hir::BoundPolarity::Negative(_) => collect_into.negative = true,
101 hir::BoundPolarity::Positive => collect_into.positive = true,
99 hir::BoundPolarity::Maybe(_) => collect_into.maybe = Some(ptr.span),
100 hir::BoundPolarity::Negative(_) => collect_into.negative = Some(ptr.span),
101 hir::BoundPolarity::Positive => collect_into.positive = Some(ptr.span),
102102 }
103103 });
104104 collect_into
......@@ -180,10 +180,9 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
180180 ImpliedBoundsContext::TyParam(..) | ImpliedBoundsContext::AssociatedTypeOrImplTrait => {
181181 }
182182 }
183
184183 let collected = collect_sizedness_bounds(tcx, hir_bounds, context, span);
185 if (collected.sized.maybe || collected.sized.negative)
186 && !collected.sized.positive
184 if let Some(span) = collected.sized.maybe.or(collected.sized.negative)
185 && collected.sized.positive.is_none()
187186 && !collected.meta_sized.any()
188187 && !collected.pointee_sized.any()
189188 {
compiler/rustc_interface/src/lib.rs-1
......@@ -10,7 +10,6 @@ pub mod diagnostics;
1010pub mod interface;
1111mod limits;
1212pub mod passes;
13mod proc_macro_decls;
1413mod queries;
1514pub mod util;
1615
compiler/rustc_interface/src/passes.rs+2-2
......@@ -49,7 +49,7 @@ use rustc_trait_selection::{solve, traits};
4949use tracing::{info, instrument};
5050
5151use crate::interface::Compiler;
52use crate::{diagnostics, limits, proc_macro_decls, util};
52use crate::{diagnostics, limits, util};
5353
5454pub fn parse<'a>(sess: &'a Session) -> ast::Crate {
5555 let mut krate = sess
......@@ -897,9 +897,9 @@ pub static DEFAULT_QUERY_PROVIDERS: LazyLock<Providers> = LazyLock::new(|| {
897897 providers.queries.resolutions = |tcx, ()| tcx.resolver_for_lowering_raw(()).2;
898898 providers.queries.early_lint_checks = early_lint_checks;
899899 providers.queries.env_var_os = env_var_os;
900 providers.queries.proc_macro_decls_static = |tcx, _| tcx.hir_crate_items(()).proc_macro_decls();
900901 rustc_ast_lowering::provide(&mut providers.queries);
901902 limits::provide(&mut providers.queries);
902 proc_macro_decls::provide(&mut providers.queries);
903903 rustc_expand::provide(&mut providers.queries);
904904 rustc_const_eval::provide(providers);
905905 rustc_middle::hir::provide(&mut providers.queries);
compiler/rustc_interface/src/proc_macro_decls.rs deleted-20
......@@ -1,20 +0,0 @@
1use rustc_hir::def_id::LocalDefId;
2use rustc_hir::find_attr;
3use rustc_middle::query::Providers;
4use rustc_middle::ty::TyCtxt;
5
6fn proc_macro_decls_static(tcx: TyCtxt<'_>, (): ()) -> Option<LocalDefId> {
7 let mut decls = None;
8
9 for id in tcx.hir_free_items() {
10 if find_attr!(tcx, id.hir_id(), RustcProcMacroDecls) {
11 decls = Some(id.owner_id.def_id);
12 }
13 }
14
15 decls
16}
17
18pub(crate) fn provide(providers: &mut Providers) {
19 *providers = Providers { proc_macro_decls_static, ..*providers };
20}
compiler/rustc_middle/src/hir/map.rs+28-23
......@@ -1275,8 +1275,10 @@ pub(super) fn hir_module_items(tcx: TyCtxt<'_>, module_id: LocalModDefId) -> Mod
12751275 opaques,
12761276 nested_bodies,
12771277 eiis,
1278 proc_macro_decls,
12781279 ..
12791280 } = collector;
1281
12801282 ModuleItems {
12811283 add_root: false,
12821284 submodules: submodules.into_boxed_slice(),
......@@ -1288,6 +1290,7 @@ pub(super) fn hir_module_items(tcx: TyCtxt<'_>, module_id: LocalModDefId) -> Mod
12881290 opaques: opaques.into_boxed_slice(),
12891291 nested_bodies: nested_bodies.into_boxed_slice(),
12901292 eiis: eiis.into_boxed_slice(),
1293 proc_macro_decls,
12911294 }
12921295}
12931296
......@@ -1310,6 +1313,7 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
13101313 opaques,
13111314 nested_bodies,
13121315 eiis,
1316 proc_macro_decls,
13131317 ..
13141318 } = collector;
13151319
......@@ -1324,40 +1328,32 @@ pub(crate) fn hir_crate_items(tcx: TyCtxt<'_>, _: ()) -> ModuleItems {
13241328 opaques: opaques.into_boxed_slice(),
13251329 nested_bodies: nested_bodies.into_boxed_slice(),
13261330 eiis: eiis.into_boxed_slice(),
1331 proc_macro_decls,
13271332 }
13281333}
13291334
13301335struct ItemCollector<'tcx> {
13311336 // When true, it collects all items in the create,
13321337 // otherwise it collects items in some module.
1338 // Converting this to generic const didn't lead to significant perf improvements
1339 // (see <https://github.com/rust-lang/rust/pull/158119#issuecomment-4751513679>).
13331340 crate_collector: bool,
13341341 tcx: TyCtxt<'tcx>,
1335 submodules: Vec<OwnerId>,
1336 items: Vec<ItemId>,
1337 trait_items: Vec<TraitItemId>,
1338 impl_items: Vec<ImplItemId>,
1339 foreign_items: Vec<ForeignItemId>,
1340 body_owners: Vec<LocalDefId>,
1341 opaques: Vec<LocalDefId>,
1342 nested_bodies: Vec<LocalDefId>,
1343 eiis: Vec<LocalDefId>,
1342 submodules: Vec<OwnerId> = vec![],
1343 items: Vec<ItemId> = vec![],
1344 trait_items: Vec<TraitItemId> = vec![],
1345 impl_items: Vec<ImplItemId> = vec![],
1346 foreign_items: Vec<ForeignItemId> = vec![],
1347 body_owners: Vec<LocalDefId> = vec![],
1348 opaques: Vec<LocalDefId> = vec![],
1349 nested_bodies: Vec<LocalDefId> = vec![],
1350 eiis: Vec<LocalDefId> = vec![],
1351 proc_macro_decls: Option<LocalDefId> = None,
13441352}
13451353
13461354impl<'tcx> ItemCollector<'tcx> {
13471355 fn new(tcx: TyCtxt<'tcx>, crate_collector: bool) -> ItemCollector<'tcx> {
1348 ItemCollector {
1349 crate_collector,
1350 tcx,
1351 submodules: Vec::default(),
1352 items: Vec::default(),
1353 trait_items: Vec::default(),
1354 impl_items: Vec::default(),
1355 foreign_items: Vec::default(),
1356 body_owners: Vec::default(),
1357 opaques: Vec::default(),
1358 nested_bodies: Vec::default(),
1359 eiis: Vec::default(),
1360 }
1356 ItemCollector { crate_collector, tcx, .. }
13611357 }
13621358}
13631359
......@@ -1373,7 +1369,16 @@ impl<'hir> Visitor<'hir> for ItemCollector<'hir> {
13731369 self.body_owners.push(item.owner_id.def_id);
13741370 }
13751371
1376 self.items.push(item.item_id());
1372 let item_id = item.item_id();
1373
1374 if self.crate_collector
1375 && self.proc_macro_decls.is_none()
1376 && find_attr!(self.tcx, item_id.hir_id(), RustcProcMacroDecls)
1377 {
1378 self.proc_macro_decls = Some(item_id.owner_id.def_id);
1379 }
1380
1381 self.items.push(item_id);
13771382
13781383 if let ItemKind::Static(..) | ItemKind::Fn { .. } | ItemKind::Macro(..) = &item.kind
13791384 && item.eii
compiler/rustc_middle/src/hir/mod.rs+8
......@@ -39,6 +39,9 @@ pub struct ModuleItems {
3939
4040 /// Statics and functions with an `EiiImpls` or `EiiExternTarget` attribute
4141 eiis: Box<[LocalDefId]>,
42
43 // only filled with hir_crate_items, not with hir_module_items
44 proc_macro_decls: Option<LocalDefId>,
4245}
4346
4447impl ModuleItems {
......@@ -56,6 +59,11 @@ impl ModuleItems {
5659 self.trait_items.iter().copied()
5760 }
5861
62 #[inline]
63 pub fn proc_macro_decls(&self) -> Option<LocalDefId> {
64 self.proc_macro_decls
65 }
66
5967 pub fn eiis(&self) -> impl Iterator<Item = LocalDefId> {
6068 self.eiis.iter().copied()
6169 }
compiler/rustc_parse/src/parser/expr.rs+4-2
......@@ -1304,8 +1304,10 @@ impl<'a> Parser<'a> {
13041304 let err_span = self.prev_token.span.to(self.token.span);
13051305 let mut args = thin_vec![self.mk_expr_err(err_span, guar)];
13061306 while !self.token.kind.is_close_delim_or_eof() {
1307 if self.eat(exp!(Comma)) && !self.token.kind.is_close_delim_or_eof() {
1308 args.push(self.mk_expr_err(self.prev_token.span.shrink_to_hi(), guar));
1307 if self.eat(exp!(Comma)) {
1308 if !self.token.kind.is_close_delim_or_eof() {
1309 args.push(self.mk_expr_err(self.prev_token.span.shrink_to_hi(), guar));
1310 }
13091311 } else {
13101312 self.parse_token_tree();
13111313 }
src/doc/unstable-book/src/language-features/asm-experimental-reg.md+1-1
......@@ -1,4 +1,4 @@
1# `asm_experimental_arch`
1# `asm_experimental_reg`
22
33The tracking issue for this feature is: [#133416]
44
src/librustdoc/clean/mod.rs+4-1
......@@ -2152,7 +2152,10 @@ pub(crate) fn clean_middle_ty<'tcx>(
21522152 format!("{pat:?}").into_boxed_str(),
21532153 ),
21542154 ty::Array(ty, n) => {
2155 let n = cx.tcx.normalize_erasing_regions(cx.typing_env(), Unnormalized::new_wip(n));
2155 let n = cx
2156 .tcx
2157 .try_normalize_erasing_regions(cx.typing_env(), Unnormalized::new_wip(n))
2158 .unwrap_or(n);
21562159 let n = print_const(cx.tcx, n);
21572160 Array(Box::new(clean_middle_ty(bound_ty.rebind(ty), cx, None, None)), n.into())
21582161 }
src/librustdoc/clean/utils.rs+10-2
......@@ -351,8 +351,16 @@ pub(crate) fn name_from_pat(p: &hir::Pat<'_>) -> Symbol {
351351pub(crate) fn print_const(tcx: TyCtxt<'_>, n: ty::Const<'_>) -> String {
352352 match n.kind() {
353353 ty::ConstKind::Unevaluated(ty::UnevaluatedConst { kind, .. }) => match kind {
354 ty::UnevaluatedConstKind::Projection { def_id }
355 | ty::UnevaluatedConstKind::Inherent { def_id }
354 ty::UnevaluatedConstKind::Projection { def_id } => {
355 if let Some(local_def_id) = def_id.as_local()
356 && let Some(body_id) = tcx.hir_maybe_body_owned_by(local_def_id)
357 {
358 rendered_const(tcx, body_id, local_def_id)
359 } else {
360 n.to_string()
361 }
362 }
363 ty::UnevaluatedConstKind::Inherent { def_id }
356364 | ty::UnevaluatedConstKind::Free { def_id }
357365 | ty::UnevaluatedConstKind::Anon { def_id } => {
358366 if let Some(local_def_id) = def_id.as_local()
src/librustdoc/json/conversions.rs+45
......@@ -69,12 +69,37 @@ impl JsonRenderer<'_> {
6969 }
7070 _ => from_clean_item(item, self),
7171 };
72
73 // Rustdoc JSON keeps re-exports as `Use` items, so their stability describes
74 // the local `pub use` declaration. The imported target item's stability
75 // remains available through `inner.use.id`.
76 //
77 // We use raw stability attributes here instead of `clean::Item::stability()`,
78 // which is the effective stability rustdoc uses for rendering paths.
79 // For example, a stable `pub use` inside an unstable module is effectively unstable
80 // through that module path, but the `Use` declaration itself is still stable.
81 // In that example, `clean::Item::stability()` would return "unstable" as
82 // the effective stability, which is appropriate for HTML but makes JSON uses harder.
83 //
84 // JSON consumers already have to do path-based reasoning to reconstruct item reachability,
85 // names, and stability. Keeping component-wise stability allows them to easily reconstruct
86 // stability from the module, use item, and target item records.
87 let stability_def_id = if matches!(&item.kind, clean::ImportItem(_)) {
88 item.inline_stmt_id
89 .map(|def_id| def_id.to_def_id())
90 .or_else(|| item.item_id.as_def_id())
91 } else {
92 item.item_id.as_def_id()
93 };
94 let stability = stability_def_id.and_then(|def_id| self.tcx.lookup_stability(def_id));
95
7296 Some(Item {
7397 id,
7498 crate_id: item_id.krate().as_u32(),
7599 name: name.map(|sym| sym.to_string()),
76100 span: span.and_then(|span| span.into_json(self)),
77101 visibility: visibility.into_json(self),
102 stability: stability.map(|s| Box::new(s.into_json(self))),
78103 docs,
79104 attrs,
80105 deprecation: deprecation.into_json(self),
......@@ -203,6 +228,24 @@ impl FromClean<attrs::Deprecation> for Deprecation {
203228 }
204229}
205230
231impl FromClean<hir::Stability> for Stability {
232 fn from_clean(stab: &hir::Stability, _renderer: &JsonRenderer<'_>) -> Self {
233 let feature = stab.feature.to_string();
234 let level = match stab.level {
235 hir::StabilityLevel::Stable { since, .. } => StabilityLevel::Stable {
236 since: match since {
237 hir::StableSince::Version(since) => Some(since.to_string()),
238 hir::StableSince::Current => Some(hir::RustcVersion::CURRENT.to_string()),
239 // Match rustdoc HTML: malformed stable-since values are omitted.
240 hir::StableSince::Err(_) => None,
241 },
242 },
243 hir::StabilityLevel::Unstable { .. } => StabilityLevel::Unstable,
244 };
245 Stability { feature, level }
246 }
247}
248
206249impl FromClean<clean::GenericArgs> for Option<Box<GenericArgs>> {
207250 fn from_clean(generic_args: &clean::GenericArgs, renderer: &JsonRenderer<'_>) -> Self {
208251 use clean::GenericArgs::*;
......@@ -922,6 +965,8 @@ fn maybe_from_hir_attr(attr: &hir::Attribute, item_id: ItemId, tcx: TyCtxt<'_>)
922965
923966 vec![match kind {
924967 AK::Deprecated { .. } => return Vec::new(), // Handled separately into Item::deprecation.
968 AK::Stability { .. } => return Vec::new(), // Handled separately into Item::stability
969
925970 AK::DocComment { .. } => unreachable!("doc comments stripped out earlier"),
926971
927972 AK::MacroExport { .. } => Attribute::MacroExport,
src/librustdoc/json/mod.rs+1-1
......@@ -361,6 +361,6 @@ mod size_asserts {
361361 // tidy-alphabetical-end
362362
363363 // These contains a `PathBuf`, which is different sizes on different OSes.
364 static_assert_size!(Item, 528 + size_of::<std::path::PathBuf>());
364 static_assert_size!(Item, 536 + size_of::<std::path::PathBuf>());
365365 static_assert_size!(ExternalCrate, 48 + size_of::<std::path::PathBuf>());
366366}
src/rustdoc-json-types/lib.rs+61-3
......@@ -114,8 +114,8 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc
114114// will instead cause conflicts. See #94591 for more. (This paragraph and the "Latest feature" line
115115// are deliberately not in a doc comment, because they need not be in public docs.)
116116//
117// Latest feature: Add `ExternCrate::path`.
118pub const FORMAT_VERSION: u32 = 57;
117// Latest feature: Add `Item::stability`.
118pub const FORMAT_VERSION: u32 = 58;
119119
120120/// The root of the emitted JSON blob.
121121///
......@@ -282,7 +282,10 @@ pub struct Item {
282282 pub links: HashMap<String, Id>,
283283 /// Attributes on this item.
284284 ///
285 /// Does not include `#[deprecated]` attributes: see the [`Self::deprecation`] field instead.
285 /// Does not include:
286 /// - `#[doc = "Doc Comment"]` or `/// Doc comment`: see [`Self::docs`] instead.
287 /// - `#[deprecated]` attributes: see the [`Self::deprecation`] field instead.
288 /// - `#[stable]` and `#[unstable]` attributes: see the [`Self::stability`] field instead.
286289 ///
287290 /// Attributes appear in pretty-printed Rust form, regardless of their formatting
288291 /// in the original source code. For example:
......@@ -294,10 +297,64 @@ pub struct Item {
294297 pub attrs: Vec<Attribute>,
295298 /// Information about the item’s deprecation, if present.
296299 pub deprecation: Option<Deprecation>,
300
301 /// Stability information for this item, if any.
302 ///
303 /// This describes whether the item itself is stable or unstable, as noted by a `#[stable]` or
304 /// `#[unstable]` attribute. It does not capture const stability, default-body stability, etc.
305 ///
306 /// Whether a path to an item is stable depends on the stability of containing modules
307 /// or re-exports along that path. For example, a stable item can be reachable through both an
308 /// unstable module and a stable re-export.
309 ///
310 /// For items whose inner kind is [`ItemEnum::Use`], this is the stability of the import itself,
311 /// not the item being imported. This allows users to determine the stability of paths
312 /// that involve re-exports.
313 ///
314 /// Associated items can inherit instability from their enclosing unstable trait or impl.
315 /// Unannotated associated items in stable traits or impls may have no separate stability value.
316 ///
317 /// Currently, Rust's `#[stable]` and `#[unstable]` attributes are themselves not stable.
318 /// As a result, this field is primarily populated for standard-library items;
319 /// most ordinary third-party crates usually have no data here.
320 pub stability: Option<Box<Stability>>,
321
297322 /// The type-specific fields describing this item.
298323 pub inner: ItemEnum,
299324}
300325
326/// Stability information for an item.
327///
328/// This only refers to regular item stability: whether the item is stable or unstable
329/// as represented by the `#[stable]` or `#[unstable]` attributes.
330/// Const stability and default-body stability are different things and not captured here.
331#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
332#[cfg_attr(feature = "rkyv_0_8", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
333#[cfg_attr(feature = "rkyv_0_8", rkyv(derive(Debug)))]
334pub struct Stability {
335 /// The stability feature associated with this item.
336 ///
337 /// For unstable items, this is the feature gate associated with the item.
338 /// For stable items, this is the historical label recorded when the item was stabilized.
339 pub feature: String,
340
341 #[serde(flatten)]
342 pub level: StabilityLevel,
343}
344
345/// Whether an item is stable or unstable as regular public API.
346#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
347#[cfg_attr(feature = "rkyv_0_8", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
348#[cfg_attr(feature = "rkyv_0_8", rkyv(derive(Debug)))]
349#[serde(tag = "level", rename_all = "snake_case")]
350pub enum StabilityLevel {
351 Stable {
352 /// The Rust version in which this item became stable, if available.
353 since: Option<String>,
354 },
355 Unstable,
356}
357
301358#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
302359#[cfg_attr(feature = "rkyv_0_8", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
303360#[cfg_attr(feature = "rkyv_0_8", rkyv(derive(Debug)))]
......@@ -307,6 +364,7 @@ pub struct Item {
307364/// This doesn't include:
308365/// - `#[doc = "Doc Comment"]` or `/// Doc comment`. These are in [`Item::docs`] instead.
309366/// - `#[deprecated]`. These are in [`Item::deprecation`] instead.
367/// - `#[stable]` and `#[unstable]`. These are in [`Item::stability`] instead.
310368pub enum Attribute {
311369 /// `#[non_exhaustive]`
312370 NonExhaustive,
src/tools/jsondoclint/src/validator/tests.rs+7
......@@ -33,6 +33,7 @@ fn errors_on_missing_links() {
3333 links: FxHashMap::from_iter([("Not Found".to_owned(), Id(1))]),
3434 attrs: vec![],
3535 deprecation: None,
36 stability: None,
3637 inner: ItemEnum::Module(Module {
3738 is_crate: true,
3839 items: vec![],
......@@ -81,6 +82,7 @@ fn errors_on_local_in_paths_and_not_index() {
8182 links: FxHashMap::from_iter([("prim@i32".to_owned(), Id(2))]),
8283 attrs: Vec::new(),
8384 deprecation: None,
85 stability: None,
8486 inner: ItemEnum::Module(Module {
8587 is_crate: true,
8688 items: vec![Id(1)],
......@@ -100,6 +102,7 @@ fn errors_on_local_in_paths_and_not_index() {
100102 links: FxHashMap::default(),
101103 attrs: Vec::new(),
102104 deprecation: None,
105 stability: None,
103106 inner: ItemEnum::Primitive(Primitive { name: "i32".to_owned(), impls: vec![] }),
104107 },
105108 ),
......@@ -153,6 +156,7 @@ fn errors_on_missing_path() {
153156 links: FxHashMap::default(),
154157 attrs: Vec::new(),
155158 deprecation: None,
159 stability: None,
156160 inner: ItemEnum::Module(Module {
157161 is_crate: true,
158162 items: vec![Id(1), Id(2)],
......@@ -172,6 +176,7 @@ fn errors_on_missing_path() {
172176 links: FxHashMap::default(),
173177 attrs: Vec::new(),
174178 deprecation: None,
179 stability: None,
175180 inner: ItemEnum::Struct(Struct {
176181 kind: StructKind::Unit,
177182 generics: generics.clone(),
......@@ -191,6 +196,7 @@ fn errors_on_missing_path() {
191196 links: FxHashMap::default(),
192197 attrs: Vec::new(),
193198 deprecation: None,
199 stability: None,
194200 inner: ItemEnum::Function(Function {
195201 sig: FunctionSignature {
196202 inputs: vec![],
......@@ -253,6 +259,7 @@ fn checks_local_crate_id_is_correct() {
253259 links: FxHashMap::default(),
254260 attrs: Vec::new(),
255261 deprecation: None,
262 stability: None,
256263 inner: ItemEnum::Module(Module {
257264 is_crate: true,
258265 items: vec![],
tests/rustdoc-html/type-const-associated-const-no-body.rs created+20
......@@ -0,0 +1,20 @@
1//! Regression test for <https://github.com/rust-lang/rust/issues/149287>
2//! and <https://github.com/rust-lang/rust/issues/158155>
3
4#![crate_name = "foo"]
5#![feature(min_generic_const_args)]
6#![expect(incomplete_features)]
7
8pub trait Tr {
9 type const SIZE: usize;
10}
11
12//@ has 'foo/fn.mk_array.html'
13//@ has - '//pre[@class="rust item-decl"]/code' '[(); <T as Tr>::SIZE]'
14pub fn mk_array<T: Tr>() -> [(); <T as Tr>::SIZE] {
15 [(); T::SIZE]
16}
17
18//@ has 'foo/type.Arr.html'
19//@ has - '//pre[@class="rust item-decl"]/code' '[(); <T as Tr>::SIZE]'
20pub type Arr<T> = [(); <T as Tr>::SIZE];
tests/rustdoc-json/attrs/stability/associated_items.rs created+66
......@@ -0,0 +1,66 @@
1#![feature(staged_api)]
2
3// Trait-associated item declarations only. Items defined inside impl blocks are tested in
4// `impls.rs` because they have different parent-item behavior.
5
6//@ is "$.index[?(@.name=='StableTraitWithAssociatedItems')].stability.level" '"stable"'
7//@ is "$.index[?(@.name=='StableTraitWithAssociatedItems')].stability.feature" '"stable_trait_with_associated_items"'
8//@ is "$.index[?(@.name=='StableTraitWithAssociatedItems')].stability.since" '"1.0.0"'
9#[stable(feature = "stable_trait_with_associated_items", since = "1.0.0")]
10pub trait StableTraitWithAssociatedItems {
11 // Stable trait-associated items need their own stability attributes in staged API crates.
12 //@ is "$.index[?(@.name=='StableAssocType')].stability.level" '"stable"'
13 //@ is "$.index[?(@.name=='StableAssocType')].stability.feature" '"stable_assoc_type_feature"'
14 //@ is "$.index[?(@.name=='StableAssocType')].stability.since" '"1.1.0"'
15 //@ is "$.index[?(@.name=='StableAssocType')].attrs" []
16 #[stable(feature = "stable_assoc_type_feature", since = "1.1.0")]
17 type StableAssocType;
18
19 //@ is "$.index[?(@.name=='UNSTABLE_ASSOC_CONST_IN_STABLE_TRAIT')].stability.level" '"unstable"'
20 //@ is "$.index[?(@.name=='UNSTABLE_ASSOC_CONST_IN_STABLE_TRAIT')].stability.feature" '"unstable_assoc_const_in_stable_trait"'
21 //@ !has "$.index[?(@.name=='UNSTABLE_ASSOC_CONST_IN_STABLE_TRAIT')].stability.since"
22 #[unstable(feature = "unstable_assoc_const_in_stable_trait", issue = "none")]
23 const UNSTABLE_ASSOC_CONST_IN_STABLE_TRAIT: usize = 0;
24
25 //@ is "$.index[?(@.name=='unstable_provided_method')].stability.level" '"unstable"'
26 //@ is "$.index[?(@.name=='unstable_provided_method')].stability.feature" '"unstable_provided_method_feature"'
27 //@ !has "$.index[?(@.name=='unstable_provided_method')].stability.since"
28 #[unstable(feature = "unstable_provided_method_feature", issue = "none")]
29 fn unstable_provided_method(&self) {}
30}
31
32//@ is "$.index[?(@.name=='UnstableTraitWithUnannotatedAssociatedItems')].stability.level" '"unstable"'
33//@ is "$.index[?(@.name=='UnstableTraitWithUnannotatedAssociatedItems')].stability.feature" '"unstable_trait_with_unannotated_associated_items"'
34//@ !has "$.index[?(@.name=='UnstableTraitWithUnannotatedAssociatedItems')].stability.since"
35#[unstable(feature = "unstable_trait_with_unannotated_associated_items", issue = "none")]
36pub trait UnstableTraitWithUnannotatedAssociatedItems {
37 // Unannotated associated items in unstable traits inherit the trait's unstable stability.
38 //@ is "$.index[?(@.name=='UnannotatedAssocTypeInUnstableTrait')].stability.level" '"unstable"'
39 //@ is "$.index[?(@.name=='UnannotatedAssocTypeInUnstableTrait')].stability.feature" '"unstable_trait_with_unannotated_associated_items"'
40 //@ !has "$.index[?(@.name=='UnannotatedAssocTypeInUnstableTrait')].stability.since"
41 type UnannotatedAssocTypeInUnstableTrait;
42
43 //@ is "$.index[?(@.name=='UNANNOTATED_ASSOC_CONST_IN_UNSTABLE_TRAIT')].stability.level" '"unstable"'
44 //@ is "$.index[?(@.name=='UNANNOTATED_ASSOC_CONST_IN_UNSTABLE_TRAIT')].stability.feature" '"unstable_trait_with_unannotated_associated_items"'
45 //@ !has "$.index[?(@.name=='UNANNOTATED_ASSOC_CONST_IN_UNSTABLE_TRAIT')].stability.since"
46 const UNANNOTATED_ASSOC_CONST_IN_UNSTABLE_TRAIT: usize;
47
48 //@ is "$.index[?(@.name=='unannotated_required_method_in_unstable_trait')].stability.level" '"unstable"'
49 //@ is "$.index[?(@.name=='unannotated_required_method_in_unstable_trait')].stability.feature" '"unstable_trait_with_unannotated_associated_items"'
50 //@ !has "$.index[?(@.name=='unannotated_required_method_in_unstable_trait')].stability.since"
51 fn unannotated_required_method_in_unstable_trait(&self);
52}
53
54//@ is "$.index[?(@.name=='UnstableTraitWithExplicitAssociatedItem')].stability.level" '"unstable"'
55//@ is "$.index[?(@.name=='UnstableTraitWithExplicitAssociatedItem')].stability.feature" '"unstable_trait_with_explicit_associated_item"'
56//@ !has "$.index[?(@.name=='UnstableTraitWithExplicitAssociatedItem')].stability.since"
57#[unstable(feature = "unstable_trait_with_explicit_associated_item", issue = "none")]
58pub trait UnstableTraitWithExplicitAssociatedItem {
59 // It's possble to override the parent's instability with another `#[unstable]` attribute,
60 // for example to specify a different feature gate for that item.
61 //@ is "$.index[?(@.name=='UnstableAssocTypeInUnstableTrait')].stability.level" '"unstable"'
62 //@ is "$.index[?(@.name=='UnstableAssocTypeInUnstableTrait')].stability.feature" '"unstable_assoc_type_in_unstable_trait"'
63 //@ !has "$.index[?(@.name=='UnstableAssocTypeInUnstableTrait')].stability.since"
64 #[unstable(feature = "unstable_assoc_type_in_unstable_trait", issue = "none")]
65 type UnstableAssocTypeInUnstableTrait;
66}
tests/rustdoc-json/attrs/stability/impls.rs created+136
......@@ -0,0 +1,136 @@
1#![feature(staged_api)]
2
3// Impl blocks and items defined inside impl blocks only. Trait-associated item declarations are
4// tested in `associated_items.rs`; any trait items below are scaffolding for impl-item assertions.
5// Staged API still requires stability attributes on stable trait items even when the assertions
6// below focus on the corresponding impl items.
7
8#[stable(feature = "stable_impl_target", since = "1.0.0")]
9pub struct StableImplTarget;
10
11#[stable(feature = "stable_trait_for_impl", since = "1.0.0")]
12pub trait StableTraitForImpl {
13 #[stable(feature = "stable_trait_output", since = "1.0.0")]
14 type StableOutput;
15
16 #[stable(feature = "stable_trait_assoc_const", since = "1.0.0")]
17 const STABLE_ASSOC_CONST: usize;
18
19 #[stable(feature = "stable_trait_method", since = "1.0.0")]
20 fn stable_trait_method(&self);
21}
22
23#[stable(feature = "stable_trait_with_unstable_method_for_impl", since = "1.0.0")]
24pub trait StableTraitWithUnstableMethodForImpl {
25 #[unstable(feature = "unstable_trait_method_for_stable_impl", issue = "none")]
26 fn unstable_trait_method_for_stable_impl(&self);
27}
28
29#[unstable(feature = "unstable_trait_for_impl", issue = "none")]
30pub trait UnstableTraitForImpl {
31 type UnstableOutput;
32 const UNSTABLE_ASSOC_CONST: usize;
33 fn unstable_trait_method(&self);
34}
35
36//@ is "$.index[?(@.docs=='stable inherent impl')].stability.level" '"stable"'
37//@ is "$.index[?(@.docs=='stable inherent impl')].stability.feature" '"stable_inherent_impl"'
38//@ is "$.index[?(@.docs=='stable inherent impl')].stability.since" '"2.0.0"'
39/// stable inherent impl
40#[stable(feature = "stable_inherent_impl", since = "2.0.0")]
41impl StableImplTarget {
42 //@ is "$.index[?(@.name=='stable_inherent_method')].stability.level" '"stable"'
43 //@ is "$.index[?(@.name=='stable_inherent_method')].stability.feature" '"stable_inherent_method_feature"'
44 //@ is "$.index[?(@.name=='stable_inherent_method')].stability.since" '"2.1.0"'
45 //@ is "$.index[?(@.name=='stable_inherent_method')].attrs" []
46 #[stable(feature = "stable_inherent_method_feature", since = "2.1.0")]
47 pub fn stable_inherent_method(&self) {}
48
49 //@ is "$.index[?(@.name=='UNSTABLE_ASSOC_CONST_IN_IMPL')].stability.level" '"unstable"'
50 //@ is "$.index[?(@.name=='UNSTABLE_ASSOC_CONST_IN_IMPL')].stability.feature" '"unstable_assoc_const_in_impl_feature"'
51 //@ !has "$.index[?(@.name=='UNSTABLE_ASSOC_CONST_IN_IMPL')].stability.since"
52 #[unstable(feature = "unstable_assoc_const_in_impl_feature", issue = "none")]
53 pub const UNSTABLE_ASSOC_CONST_IN_IMPL: usize = 2;
54}
55
56//@ is "$.index[?(@.docs=='unstable inherent impl')].stability.level" '"unstable"'
57//@ is "$.index[?(@.docs=='unstable inherent impl')].stability.feature" '"unstable_inherent_impl"'
58//@ !has "$.index[?(@.docs=='unstable inherent impl')].stability.since"
59/// unstable inherent impl
60#[unstable(feature = "unstable_inherent_impl", issue = "none")]
61impl StableImplTarget {
62 // The instability of the inherent `impl` block is inherited by the item.
63 //@ is "$.index[?(@.name=='method_inside_unstable_inherent_impl')].stability.level" '"unstable"'
64 //@ is "$.index[?(@.name=='method_inside_unstable_inherent_impl')].stability.feature" '"unstable_inherent_impl"'
65 //@ !has "$.index[?(@.name=='method_inside_unstable_inherent_impl')].stability.since"
66 pub fn method_inside_unstable_inherent_impl(&self) {}
67}
68
69// For trait impl items, `stability: null` means the implementation item has no separate
70// stability attribute of its own. To decide whether the implemented method/type/const is usable,
71// consumers need to combine the trait item stability with the impl block stability.
72//
73// The stable impl below intentionally does not copy either stable or unstable trait-item
74// stability onto the implemented item. The unstable impl case is different: rustc records the
75// impl block's instability on contained impl items, so JSON exposes that inherited instability.
76
77//@ is "$.index[?(@.docs=='stable trait impl with unstable trait method')].stability.level" '"stable"'
78//@ is "$.index[?(@.docs=='stable trait impl with unstable trait method')].stability.feature" '"stable_trait_impl_with_unstable_trait_method"'
79//@ is "$.index[?(@.docs=='stable trait impl with unstable trait method')].stability.since" '"3.0.0"'
80/// stable trait impl with unstable trait method
81#[stable(feature = "stable_trait_impl_with_unstable_trait_method", since = "3.0.0")]
82impl StableTraitWithUnstableMethodForImpl for StableImplTarget {
83 // The impl item has no separate stability record; the trait method is unstable.
84 //@ is "$.index[?(@.docs=='method for unstable trait item inside stable trait impl')].stability" null
85 /// method for unstable trait item inside stable trait impl
86 fn unstable_trait_method_for_stable_impl(&self) {}
87}
88
89//@ is "$.index[?(@.docs=='stable trait impl')].stability.level" '"stable"'
90//@ is "$.index[?(@.docs=='stable trait impl')].stability.feature" '"stable_trait_impl"'
91//@ is "$.index[?(@.docs=='stable trait impl')].stability.since" '"3.0.0"'
92/// stable trait impl
93#[stable(feature = "stable_trait_impl", since = "3.0.0")]
94impl StableTraitForImpl for StableImplTarget {
95 // These impl items likewise have no separate stability records.
96 // Their trait item declarations and the impl block are all stable.
97
98 //@ is "$.index[?(@.docs=='assoc type inside stable trait impl')].stability" null
99 /// assoc type inside stable trait impl
100 type StableOutput = usize;
101
102 //@ is "$.index[?(@.docs=='assoc const inside stable trait impl')].stability" null
103 /// assoc const inside stable trait impl
104 const STABLE_ASSOC_CONST: usize = 0;
105
106 //@ is "$.index[?(@.docs=='method inside stable trait impl')].stability" null
107 /// method inside stable trait impl
108 fn stable_trait_method(&self) {}
109}
110
111//@ is "$.index[?(@.docs=='unstable trait impl')].stability.level" '"unstable"'
112//@ is "$.index[?(@.docs=='unstable trait impl')].stability.feature" '"unstable_trait_impl"'
113//@ !has "$.index[?(@.docs=='unstable trait impl')].stability.since"
114/// unstable trait impl
115#[unstable(feature = "unstable_trait_impl", issue = "none")]
116impl UnstableTraitForImpl for StableImplTarget {
117 // These associated items inherit the impl block's instability in rustdoc JSON.
118
119 //@ is "$.index[?(@.docs=='assoc type inside unstable trait impl')].stability.level" '"unstable"'
120 //@ is "$.index[?(@.docs=='assoc type inside unstable trait impl')].stability.feature" '"unstable_trait_impl"'
121 //@ !has "$.index[?(@.docs=='assoc type inside unstable trait impl')].stability.since"
122 /// assoc type inside unstable trait impl
123 type UnstableOutput = usize;
124
125 //@ is "$.index[?(@.docs=='assoc const inside unstable trait impl')].stability.level" '"unstable"'
126 //@ is "$.index[?(@.docs=='assoc const inside unstable trait impl')].stability.feature" '"unstable_trait_impl"'
127 //@ !has "$.index[?(@.docs=='assoc const inside unstable trait impl')].stability.since"
128 /// assoc const inside unstable trait impl
129 const UNSTABLE_ASSOC_CONST: usize = 0;
130
131 //@ is "$.index[?(@.docs=='method inside unstable trait impl')].stability.level" '"unstable"'
132 //@ is "$.index[?(@.docs=='method inside unstable trait impl')].stability.feature" '"unstable_trait_impl"'
133 //@ !has "$.index[?(@.docs=='method inside unstable trait impl')].stability.since"
134 /// method inside unstable trait impl
135 fn unstable_trait_method(&self) {}
136}
tests/rustdoc-json/attrs/stability/item_kinds.rs created+46
......@@ -0,0 +1,46 @@
1#![feature(staged_api)]
2
3// Mirrors standard-library stability on item kinds that are distinct from ordinary functions,
4// modules, structs, enums, traits, and impls.
5
6//@ is "$.index[?(@.name=='STABLE_CONST')].stability.level" '"stable"'
7//@ is "$.index[?(@.name=='STABLE_CONST')].stability.feature" '"stable_const_feature"'
8//@ is "$.index[?(@.name=='STABLE_CONST')].stability.since" '"1.0.0"'
9#[stable(feature = "stable_const_feature", since = "1.0.0")]
10pub const STABLE_CONST: usize = 0;
11
12//@ is "$.index[?(@.name=='UNSTABLE_STATIC')].stability.level" '"unstable"'
13//@ is "$.index[?(@.name=='UNSTABLE_STATIC')].stability.feature" '"unstable_static_feature"'
14//@ !has "$.index[?(@.name=='UNSTABLE_STATIC')].stability.since"
15#[unstable(feature = "unstable_static_feature", issue = "none")]
16pub static UNSTABLE_STATIC: usize = 0;
17
18//@ is "$.index[?(@.name=='StableTypeAlias')].stability.level" '"stable"'
19//@ is "$.index[?(@.name=='StableTypeAlias')].stability.feature" '"stable_type_alias_feature"'
20//@ is "$.index[?(@.name=='StableTypeAlias')].stability.since" '"1.1.0"'
21#[stable(feature = "stable_type_alias_feature", since = "1.1.0")]
22pub type StableTypeAlias = usize;
23
24//@ is "$.index[?(@.name=='StableUnion')].stability.level" '"stable"'
25//@ is "$.index[?(@.name=='StableUnion')].stability.feature" '"stable_union_feature"'
26//@ is "$.index[?(@.name=='StableUnion')].stability.since" '"1.3.0"'
27#[stable(feature = "stable_union_feature", since = "1.3.0")]
28pub union StableUnion {
29 storage: usize,
30}
31
32//@ is "$.index[?(@.inner.extern_crate.name=='stable_extern_crate_self')].stability.level" '"stable"'
33//@ is "$.index[?(@.inner.extern_crate.name=='stable_extern_crate_self')].stability.feature" '"stable_extern_crate_feature"'
34//@ is "$.index[?(@.inner.extern_crate.name=='stable_extern_crate_self')].stability.since" '"1.4.0"'
35#[stable(feature = "stable_extern_crate_feature", since = "1.4.0")]
36pub extern crate self as stable_extern_crate_self;
37
38//@ is "$.index[?(@.name=='unstable_macro_rules')].stability.level" '"unstable"'
39//@ is "$.index[?(@.name=='unstable_macro_rules')].stability.feature" '"unstable_macro_rules_feature"'
40//@ !has "$.index[?(@.name=='unstable_macro_rules')].stability.since"
41//@ is "$.index[?(@.name=='unstable_macro_rules')].attrs" '["macro_export"]'
42#[unstable(feature = "unstable_macro_rules_feature", issue = "none")]
43#[macro_export]
44macro_rules! unstable_macro_rules {
45 () => {};
46}
tests/rustdoc-json/attrs/stability/members.rs created+72
......@@ -0,0 +1,72 @@
1#![feature(staged_api)]
2
3// Mirrors standard-library cases where stable parent items have unstable variants or fields.
4
5#[stable(feature = "stable_enum_feature", since = "1.0.0")]
6pub enum StableEnumWithUnstableVariant {
7 StableVariant,
8
9 //@ is "$.index[?(@.name=='UnstableVariant')].stability.level" '"unstable"'
10 //@ is "$.index[?(@.name=='UnstableVariant')].stability.feature" '"unstable_variant_feature"'
11 //@ !has "$.index[?(@.name=='UnstableVariant')].stability.since"
12 #[unstable(feature = "unstable_variant_feature", issue = "none")]
13 UnstableVariant,
14}
15
16#[stable(feature = "stable_struct_feature", since = "2.0.0")]
17pub struct StableStructWithUnstableField {
18 pub stable_field: usize,
19
20 //@ is "$.index[?(@.name=='unstable_field')].stability.level" '"unstable"'
21 //@ is "$.index[?(@.name=='unstable_field')].stability.feature" '"unstable_field_feature"'
22 //@ !has "$.index[?(@.name=='unstable_field')].stability.since"
23 #[unstable(feature = "unstable_field_feature", issue = "none")]
24 pub unstable_field: usize,
25}
26
27#[stable(feature = "stable_union_with_unstable_field", since = "2.5.0")]
28pub union StableUnionWithUnstableField {
29 pub stable_union_field: usize,
30
31 //@ is "$.index[?(@.name=='unstable_union_field')].stability.level" '"unstable"'
32 //@ is "$.index[?(@.name=='unstable_union_field')].stability.feature" '"unstable_union_field_feature"'
33 //@ !has "$.index[?(@.name=='unstable_union_field')].stability.since"
34 #[unstable(feature = "unstable_union_field_feature", issue = "none")]
35 pub unstable_union_field: usize,
36}
37
38#[stable(feature = "stable_tuple_struct_feature", since = "3.0.0")]
39pub struct StableTupleStructWithUnstableField(
40 pub usize,
41 //@ is "$.index[?(@.docs=='unstable tuple struct field')].stability.level" '"unstable"'
42 //@ is "$.index[?(@.docs=='unstable tuple struct field')].stability.feature" '"unstable_tuple_struct_field_feature"'
43 //@ !has "$.index[?(@.docs=='unstable tuple struct field')].stability.since"
44 /// unstable tuple struct field
45 #[unstable(feature = "unstable_tuple_struct_field_feature", issue = "none")]
46 pub usize,
47);
48
49#[stable(feature = "stable_enum_field_variants_feature", since = "4.0.0")]
50pub enum StableEnumWithFieldVariants {
51 #[stable(feature = "stable_tuple_variant_feature", since = "4.1.0")]
52 TupleVariant(
53 usize,
54 //@ is "$.index[?(@.docs=='unstable tuple variant field')].stability.level" '"unstable"'
55 //@ is "$.index[?(@.docs=='unstable tuple variant field')].stability.feature" '"unstable_tuple_variant_field_feature"'
56 //@ !has "$.index[?(@.docs=='unstable tuple variant field')].stability.since"
57 /// unstable tuple variant field
58 #[unstable(feature = "unstable_tuple_variant_field_feature", issue = "none")]
59 usize,
60 ),
61
62 #[stable(feature = "stable_struct_variant_feature", since = "4.3.0")]
63 StructVariant {
64 stable_struct_variant_field: usize,
65
66 //@ is "$.index[?(@.name=='unstable_struct_variant_field')].stability.level" '"unstable"'
67 //@ is "$.index[?(@.name=='unstable_struct_variant_field')].stability.feature" '"unstable_struct_variant_field_feature"'
68 //@ !has "$.index[?(@.name=='unstable_struct_variant_field')].stability.since"
69 #[unstable(feature = "unstable_struct_variant_field_feature", issue = "none")]
70 unstable_struct_variant_field: usize,
71 },
72}
tests/rustdoc-json/attrs/stability/modules.rs created+49
......@@ -0,0 +1,49 @@
1//! Module items, including the crate root and containing-module stability facts that consumers
2//! need when deciding whether a particular path is stable.
3
4#![feature(staged_api)]
5#![stable(feature = "stable_crate_feature", since = "1.0.0")]
6//@ is "$.index[?(@.name=='modules')].stability.level" '"stable"'
7//@ is "$.index[?(@.name=='modules')].stability.feature" '"stable_crate_feature"'
8//@ is "$.index[?(@.name=='modules')].stability.since" '"1.0.0"'
9
10pub mod inner_stable_module {
11 #![stable(feature = "inner_stable_module_feature", since = "1.1.0")]
12
13 //@ is "$.index[?(@.name=='inner_stable_module')].stability.level" '"stable"'
14 //@ is "$.index[?(@.name=='inner_stable_module')].stability.feature" '"inner_stable_module_feature"'
15 //@ is "$.index[?(@.name=='inner_stable_module')].stability.since" '"1.1.0"'
16}
17
18#[unstable(feature = "unstable_module_feature", issue = "none")]
19pub mod unstable_module {
20 //@ is "$.index[?(@.name=='unstable_module')].stability.level" '"unstable"'
21 //@ is "$.index[?(@.name=='unstable_module')].stability.feature" '"unstable_module_feature"'
22 //@ !has "$.index[?(@.name=='unstable_module')].stability.since"
23}
24
25#[stable(feature = "stable_parent_feature", since = "2.0.0")]
26pub mod stable_parent {
27 //@ is "$.index[?(@.name=='stable_parent')].stability.level" '"stable"'
28 //@ is "$.index[?(@.name=='stable_parent')].stability.feature" '"stable_parent_feature"'
29 //@ is "$.index[?(@.name=='stable_parent')].stability.since" '"2.0.0"'
30
31 //@ is "$.index[?(@.name=='UnstableChildInStable')].stability.level" '"unstable"'
32 //@ is "$.index[?(@.name=='UnstableChildInStable')].stability.feature" '"unstable_child_in_stable"'
33 //@ !has "$.index[?(@.name=='UnstableChildInStable')].stability.since"
34 #[unstable(feature = "unstable_child_in_stable", issue = "none")]
35 pub struct UnstableChildInStable;
36}
37
38#[unstable(feature = "unstable_parent_feature", issue = "27")]
39pub mod unstable_parent {
40 //@ is "$.index[?(@.name=='unstable_parent')].stability.level" '"unstable"'
41 //@ is "$.index[?(@.name=='unstable_parent')].stability.feature" '"unstable_parent_feature"'
42 //@ !has "$.index[?(@.name=='unstable_parent')].stability.since"
43
44 //@ is "$.index[?(@.name=='StableChildInUnstable')].stability.level" '"stable"'
45 //@ is "$.index[?(@.name=='StableChildInUnstable')].stability.feature" '"stable_child_in_unstable"'
46 //@ is "$.index[?(@.name=='StableChildInUnstable')].stability.since" '"3.0.0"'
47 #[stable(feature = "stable_child_in_unstable", since = "3.0.0")]
48 pub struct StableChildInUnstable;
49}
tests/rustdoc-json/attrs/stability/reexports.rs created+98
......@@ -0,0 +1,98 @@
1#![feature(staged_api)]
2
3// The stability of an item is a function of both the item and the path by which it is used.
4// It's possible for a stable item to be available under both a stable and an unstable path,
5// depending on re-exports and module stability. This file tests such edge cases.
6//
7// To determine if a path is stable, users of rustdoc JSON should walk all path components
8// (including `Use` items' `inner.use.id` value) and check for (in)stability.
9// The path is unstable if any traversed component (modules, re-exports, or the final item)
10// is marked unstable.
11
12#[unstable(feature = "unstable_source_mod", issue = "none")]
13pub mod unstable_source_mod {
14 //@ set stable_in_unstable = "$.index[?(@.name=='StableInUnstable')].id"
15 //@ is "$.index[?(@.name=='StableInUnstable')].stability.level" '"stable"'
16 //@ is "$.index[?(@.name=='StableInUnstable')].stability.feature" '"stable_in_unstable"'
17 //@ is "$.index[?(@.name=='StableInUnstable')].stability.since" '"1.0.0"'
18 #[stable(feature = "stable_in_unstable", since = "1.0.0")]
19 pub struct StableInUnstable;
20
21 //@ set second_stable_in_unstable = "$.index[?(@.name=='SecondStableInUnstable')].id"
22 #[stable(feature = "second_stable_in_unstable", since = "1.1.0")]
23 pub struct SecondStableInUnstable;
24
25 #[stable(feature = "glob_stable_in_unstable", since = "1.2.0")]
26 pub struct GlobStableInUnstable;
27}
28
29//@ is "$.index[?(@.inner.use.name=='ReexportedStableInUnstable')].inner.use.id" $stable_in_unstable
30//@ is "$.index[?(@.inner.use.name=='ReexportedStableInUnstable')].stability.level" '"stable"'
31//@ is "$.index[?(@.inner.use.name=='ReexportedStableInUnstable')].stability.feature" '"stable_reexport"'
32//@ is "$.index[?(@.inner.use.name=='ReexportedStableInUnstable')].stability.since" '"3.0.0"'
33//@ is "$.index[?(@.inner.use.name=='ReexportedStableInUnstable')].attrs" []
34#[stable(feature = "stable_reexport", since = "3.0.0")]
35pub use crate::unstable_source_mod::StableInUnstable as ReexportedStableInUnstable;
36//@ is "$.index[?(@.inner.use.source=='crate::unstable_source_mod')].inner.use.is_glob" true
37//@ is "$.index[?(@.inner.use.source=='crate::unstable_source_mod')].stability.level" '"stable"'
38//@ is "$.index[?(@.inner.use.source=='crate::unstable_source_mod')].stability.feature" '"stable_glob_reexport"'
39//@ is "$.index[?(@.inner.use.source=='crate::unstable_source_mod')].stability.since" '"4.0.0"'
40#[stable(feature = "stable_glob_reexport", since = "4.0.0")]
41pub use crate::unstable_source_mod::*;
42//@ is "$.index[?(@.inner.use.name=='GroupedStableReexport')].inner.use.id" $stable_in_unstable
43//@ is "$.index[?(@.inner.use.name=='GroupedStableReexport')].stability.level" '"stable"'
44//@ is "$.index[?(@.inner.use.name=='GroupedStableReexport')].stability.feature" '"stable_grouped_reexport"'
45//@ is "$.index[?(@.inner.use.name=='GroupedStableReexport')].stability.since" '"3.5.0"'
46//@ is "$.index[?(@.inner.use.name=='SecondGroupedStableReexport')].inner.use.id" $second_stable_in_unstable
47//@ is "$.index[?(@.inner.use.name=='SecondGroupedStableReexport')].stability.level" '"stable"'
48//@ is "$.index[?(@.inner.use.name=='SecondGroupedStableReexport')].stability.feature" '"stable_grouped_reexport"'
49//@ is "$.index[?(@.inner.use.name=='SecondGroupedStableReexport')].stability.since" '"3.5.0"'
50#[stable(feature = "stable_grouped_reexport", since = "3.5.0")]
51pub use crate::unstable_source_mod::{
52 SecondStableInUnstable as SecondGroupedStableReexport,
53 StableInUnstable as GroupedStableReexport,
54};
55
56#[unstable(feature = "unstable_reexport_source_mod", issue = "none")]
57pub mod unstable_reexport_source_mod {
58 //@ set stable_for_unstable_reexport = "$.index[?(@.name=='StableForUnstableReexport')].id"
59 #[stable(feature = "stable_for_unstable_reexport", since = "6.0.0")]
60 pub struct StableForUnstableReexport;
61
62 //@ set grouped_stable_for_unstable_reexport = "$.index[?(@.name=='GroupedStableForUnstableReexport')].id"
63 #[stable(feature = "grouped_stable_for_unstable_reexport", since = "6.1.0")]
64 pub struct GroupedStableForUnstableReexport;
65
66 //@ set second_grouped_stable_for_unstable_reexport = "$.index[?(@.name=='SecondGroupedStableForUnstableReexport')].id"
67 #[stable(feature = "second_grouped_stable_for_unstable_reexport", since = "6.2.0")]
68 pub struct SecondGroupedStableForUnstableReexport;
69
70 #[stable(feature = "glob_stable_for_unstable_reexport", since = "6.3.0")]
71 pub struct GlobStableForUnstableReexport;
72}
73
74//@ is "$.index[?(@.inner.use.name=='UnstableReexportedStable')].inner.use.id" $stable_for_unstable_reexport
75//@ is "$.index[?(@.inner.use.name=='UnstableReexportedStable')].stability.level" '"unstable"'
76//@ is "$.index[?(@.inner.use.name=='UnstableReexportedStable')].stability.feature" '"unstable_reexport"'
77//@ !has "$.index[?(@.inner.use.name=='UnstableReexportedStable')].stability.since"
78#[unstable(feature = "unstable_reexport", issue = "none")]
79pub use crate::unstable_reexport_source_mod::StableForUnstableReexport as UnstableReexportedStable;
80//@ is "$.index[?(@.inner.use.source=='crate::unstable_reexport_source_mod')].inner.use.is_glob" true
81//@ is "$.index[?(@.inner.use.source=='crate::unstable_reexport_source_mod')].stability.level" '"unstable"'
82//@ is "$.index[?(@.inner.use.source=='crate::unstable_reexport_source_mod')].stability.feature" '"unstable_glob_reexport"'
83//@ !has "$.index[?(@.inner.use.source=='crate::unstable_reexport_source_mod')].stability.since"
84#[unstable(feature = "unstable_glob_reexport", issue = "none")]
85pub use crate::unstable_reexport_source_mod::*;
86//@ is "$.index[?(@.inner.use.name=='GroupedUnstableReexport')].inner.use.id" $grouped_stable_for_unstable_reexport
87//@ is "$.index[?(@.inner.use.name=='GroupedUnstableReexport')].stability.level" '"unstable"'
88//@ is "$.index[?(@.inner.use.name=='GroupedUnstableReexport')].stability.feature" '"unstable_grouped_reexport"'
89//@ !has "$.index[?(@.inner.use.name=='GroupedUnstableReexport')].stability.since"
90//@ is "$.index[?(@.inner.use.name=='SecondGroupedUnstableReexport')].inner.use.id" $second_grouped_stable_for_unstable_reexport
91//@ is "$.index[?(@.inner.use.name=='SecondGroupedUnstableReexport')].stability.level" '"unstable"'
92//@ is "$.index[?(@.inner.use.name=='SecondGroupedUnstableReexport')].stability.feature" '"unstable_grouped_reexport"'
93//@ !has "$.index[?(@.inner.use.name=='SecondGroupedUnstableReexport')].stability.since"
94#[unstable(feature = "unstable_grouped_reexport", issue = "none")]
95pub use crate::unstable_reexport_source_mod::{
96 GroupedStableForUnstableReexport as GroupedUnstableReexport,
97 SecondGroupedStableForUnstableReexport as SecondGroupedUnstableReexport,
98};
tests/rustdoc-json/attrs/stability/stable.rs created+8
......@@ -0,0 +1,8 @@
1#![feature(staged_api)]
2
3//@ is "$.index[?(@.name=='foo')].stability.level" '"stable"'
4//@ is "$.index[?(@.name=='foo')].stability.feature" '"eeeee"'
5//@ is "$.index[?(@.name=='foo')].stability.since" '"2.71.8"'
6//@ is "$.index[?(@.name=='foo')].attrs" []
7#[stable(since = "2.71.8", feature = "eeeee")]
8pub fn foo() {}
tests/rustdoc-json/attrs/stability/unmarked.rs created+3
......@@ -0,0 +1,3 @@
1//@ is "$.index[?(@.name=='foo')].stability" null
2//@ is "$.index[?(@.name=='foo')].attrs" []
3pub fn foo() {}
tests/rustdoc-json/attrs/stability/unstable.rs created+8
......@@ -0,0 +1,8 @@
1#![feature(staged_api)]
2
3//@ is "$.index[?(@.name=='foo')].stability.level" '"unstable"'
4//@ is "$.index[?(@.name=='foo')].stability.feature" '"delights"'
5//@ !has "$.index[?(@.name=='foo')].stability.since"
6//@ is "$.index[?(@.name=='foo')].attrs" []
7#[unstable(feature = "delights", issue = "26")]
8pub fn foo() {}
tests/rustdoc-json/attrs/stability/unstable_crate.rs created+6
......@@ -0,0 +1,6 @@
1#![feature(staged_api)]
2#![unstable(feature = "unstable_crate_feature", issue = "none")]
3
4//@ is "$.index[?(@.name=='unstable_crate')].stability.level" '"unstable"'
5//@ is "$.index[?(@.name=='unstable_crate')].stability.feature" '"unstable_crate_feature"'
6//@ !has "$.index[?(@.name=='unstable_crate')].stability.since"
tests/rustdoc-ui/type-const-associated-const-no-body.rs deleted-16
......@@ -1,16 +0,0 @@
1//! Regression test for <https://github.com/rust-lang/rust/issues/149287>
2//! Ensure that rustdoc does not ICE when a body-less type const is used
3//! as an associated const.
4//@ check-pass
5
6#![feature(min_generic_const_args)]
7
8pub trait Tr {
9 type const SIZE: usize;
10}
11
12fn mk_array<T: Tr>() -> [(); <T as Tr>::SIZE] {
13 [(); T::SIZE]
14}
15
16fn main() {}
tests/ui/asm/s390x/bad-reg.rs+7-7
......@@ -68,13 +68,13 @@ fn f() {
6868
6969 // vreg
7070 asm!("", out("v0") _); // always ok
71 asm!("", in("v0") v); // requires vector & asm_experimental_reg
71 asm!("", in("v0") v);
7272 //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
73 asm!("", out("v0") v); // requires vector & asm_experimental_reg
73 asm!("", out("v0") v);
7474 //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
75 asm!("", in("v0") x); // requires vector & asm_experimental_reg
75 asm!("", in("v0") x);
7676 //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
77 asm!("", out("v0") x); // requires vector & asm_experimental_reg
77 asm!("", out("v0") x);
7878 //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
7979 asm!("", in("v0") b);
8080 //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
......@@ -82,14 +82,14 @@ fn f() {
8282 asm!("", out("v0") b);
8383 //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
8484 //[s390x_vector]~^^ ERROR type `u8` cannot be used with this register class
85 asm!("/* {} */", in(vreg) v); // requires vector & asm_experimental_reg
85 asm!("/* {} */", in(vreg) v);
8686 //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
87 asm!("/* {} */", in(vreg) x); // requires vector & asm_experimental_reg
87 asm!("/* {} */", in(vreg) x);
8888 //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
8989 asm!("/* {} */", in(vreg) b);
9090 //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
9191 //[s390x_vector]~^^ ERROR type `u8` cannot be used with this register class
92 asm!("/* {} */", out(vreg) _); // requires vector & asm_experimental_reg
92 asm!("/* {} */", out(vreg) _);
9393 //[s390x]~^ ERROR register class `vreg` requires the `vector` target feature
9494
9595 // Clobber-only registers
tests/ui/asm/s390x/bad-reg.s390x.stderr+7-7
......@@ -279,25 +279,25 @@ LL | asm!("", out("v16") _, out("f16") _);
279279error: register class `vreg` requires the `vector` target feature
280280 --> $DIR/bad-reg.rs:71:18
281281 |
282LL | asm!("", in("v0") v); // requires vector & asm_experimental_reg
282LL | asm!("", in("v0") v);
283283 | ^^^^^^^^^^
284284
285285error: register class `vreg` requires the `vector` target feature
286286 --> $DIR/bad-reg.rs:73:18
287287 |
288LL | asm!("", out("v0") v); // requires vector & asm_experimental_reg
288LL | asm!("", out("v0") v);
289289 | ^^^^^^^^^^^
290290
291291error: register class `vreg` requires the `vector` target feature
292292 --> $DIR/bad-reg.rs:75:18
293293 |
294LL | asm!("", in("v0") x); // requires vector & asm_experimental_reg
294LL | asm!("", in("v0") x);
295295 | ^^^^^^^^^^
296296
297297error: register class `vreg` requires the `vector` target feature
298298 --> $DIR/bad-reg.rs:77:18
299299 |
300LL | asm!("", out("v0") x); // requires vector & asm_experimental_reg
300LL | asm!("", out("v0") x);
301301 | ^^^^^^^^^^^
302302
303303error: register class `vreg` requires the `vector` target feature
......@@ -315,13 +315,13 @@ LL | asm!("", out("v0") b);
315315error: register class `vreg` requires the `vector` target feature
316316 --> $DIR/bad-reg.rs:85:26
317317 |
318LL | asm!("/* {} */", in(vreg) v); // requires vector & asm_experimental_reg
318LL | asm!("/* {} */", in(vreg) v);
319319 | ^^^^^^^^^^
320320
321321error: register class `vreg` requires the `vector` target feature
322322 --> $DIR/bad-reg.rs:87:26
323323 |
324LL | asm!("/* {} */", in(vreg) x); // requires vector & asm_experimental_reg
324LL | asm!("/* {} */", in(vreg) x);
325325 | ^^^^^^^^^^
326326
327327error: register class `vreg` requires the `vector` target feature
......@@ -333,7 +333,7 @@ LL | asm!("/* {} */", in(vreg) b);
333333error: register class `vreg` requires the `vector` target feature
334334 --> $DIR/bad-reg.rs:92:26
335335 |
336LL | asm!("/* {} */", out(vreg) _); // requires vector & asm_experimental_reg
336LL | asm!("/* {} */", out(vreg) _);
337337 | ^^^^^^^^^^^
338338
339339error: type `i32` cannot be used with this register class
tests/ui/const-generics/unused-type-param-suggestion.rs+1-2
......@@ -1,4 +1,4 @@
1#![crate_type="lib"]
1#![crate_type = "lib"]
22
33struct S<N>;
44//~^ ERROR type parameter `N` is never used
......@@ -25,4 +25,3 @@ type C<N: Sized> = ();
2525type D<N: ?Sized> = ();
2626//~^ ERROR type parameter `N` is never used
2727//~| HELP consider removing `N`
28//~| HELP if you intended `N` to be a const parameter
tests/ui/const-generics/unused-type-param-suggestion.stderr-1
......@@ -47,7 +47,6 @@ LL | type D<N: ?Sized> = ();
4747 | ^ unused type parameter
4848 |
4949 = help: consider removing `N` or referring to it in the body of the type alias
50 = help: if you intended `N` to be a const parameter, use `const N: /* Type */` instead
5150
5251error: aborting due to 6 previous errors
5352
tests/ui/extern/extern-types-unsized.stderr+4-4
......@@ -67,10 +67,10 @@ LL | assert_sized::<Bar<A>>();
6767 |
6868 = help: the nightly-only, unstable trait `MetaSized` is not implemented for `A`
6969note: required by a bound in `Bar`
70 --> $DIR/extern-types-unsized.rs:14:12
70 --> $DIR/extern-types-unsized.rs:14:15
7171 |
7272LL | struct Bar<T: ?Sized> {
73 | ^ required by this bound in `Bar`
73 | ^^^^^^ required by this bound in `Bar`
7474
7575error[E0277]: the size for values of type `A` cannot be known at compilation time
7676 --> $DIR/extern-types-unsized.rs:32:20
......@@ -102,10 +102,10 @@ LL | assert_sized::<Bar<Bar<A>>>();
102102 |
103103 = help: the nightly-only, unstable trait `MetaSized` is not implemented for `A`
104104note: required by a bound in `Bar`
105 --> $DIR/extern-types-unsized.rs:14:12
105 --> $DIR/extern-types-unsized.rs:14:15
106106 |
107107LL | struct Bar<T: ?Sized> {
108 | ^ required by this bound in `Bar`
108 | ^^^^^^ required by this bound in `Bar`
109109
110110error: aborting due to 6 previous errors
111111
tests/ui/parser/recover/raw-no-const-mut-trailing-comma.rs created+7
......@@ -0,0 +1,7 @@
1// Regression test for https://github.com/rust-lang/rust/issues/157950.
2
3fn main() {
4 takes_raw_ptr_args(&raw x,)
5 //~^ ERROR expected one of
6 //~| ERROR cannot find function `takes_raw_ptr_args` in this scope
7}
tests/ui/parser/recover/raw-no-const-mut-trailing-comma.stderr created+22
......@@ -0,0 +1,22 @@
1error: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `const`, `mut`, `{`, or an operator, found `x`
2 --> $DIR/raw-no-const-mut-trailing-comma.rs:4:29
3 |
4LL | takes_raw_ptr_args(&raw x,)
5 | ^ expected one of 10 possible tokens
6 |
7help: `&raw` must be followed by `const` or `mut` to be a raw reference expression
8 |
9LL | takes_raw_ptr_args(&raw const x,)
10 | +++++
11LL | takes_raw_ptr_args(&raw mut x,)
12 | +++
13
14error[E0425]: cannot find function `takes_raw_ptr_args` in this scope
15 --> $DIR/raw-no-const-mut-trailing-comma.rs:4:5
16 |
17LL | takes_raw_ptr_args(&raw x,)
18 | ^^^^^^^^^^^^^^^^^^ not found in this scope
19
20error: aborting due to 2 previous errors
21
22For more information about this error, try `rustc --explain E0425`.
tests/ui/sized-hierarchy/overflow.current.stderr+3-3
......@@ -8,9 +8,9 @@ note: required for `Box<Element>` to implement `ParseTokens`
88 --> $DIR/overflow.rs:13:31
99 |
1010LL | impl<T: ParseTokens + ?Sized> ParseTokens for Box<T> {
11 | - ^^^^^^^^^^^ ^^^^^^
12 | |
13 | unsatisfied trait bound introduced here
11 | ------ ^^^^^^^^^^^ ^^^^^^
12 | |
13 | unsatisfied trait bound introduced here
1414 = note: 1 redundant requirement hidden
1515 = note: required for `Box<Box<Element>>` to implement `ParseTokens`
1616
triagebot.toml+2-2
......@@ -1270,7 +1270,7 @@ message = "`src/tools/x` was changed. Bump version of Cargo.toml in `src/tools/x
12701270
12711271[mentions."src/tools/tidy/src/deps.rs"]
12721272message = "The list of allowed third-party dependencies may have been modified! You must ensure that any new dependencies have compatible licenses before merging."
1273cc = ["@davidtwco", "@wesleywiser"]
1273cc = ["@davidtwco", "@boxyuwu"]
12741274
12751275[mentions."src/tools/tidy/src/extra_checks"]
12761276message = "`tidy` extra checks were modified."
......@@ -1517,7 +1517,7 @@ branch = "stable"
15171517[assign.adhoc_groups]
15181518compiler_leads = [
15191519 "@davidtwco",
1520 "@wesleywiser",
1520 "@boxyuwu",
15211521]
15221522libs = [
15231523 "@Mark-Simulacrum",