about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/defaults/config.library.toml3
-rw-r--r--src/bootstrap/defaults/config.tools.toml2
-rw-r--r--src/bootstrap/src/utils/change_tracker.rs5
-rw-r--r--src/librustdoc/passes/propagate_stability.rs74
4 files changed, 66 insertions, 18 deletions
diff --git a/src/bootstrap/defaults/config.library.toml b/src/bootstrap/defaults/config.library.toml
index 5447565a4b0..3d697be8156 100644
--- a/src/bootstrap/defaults/config.library.toml
+++ b/src/bootstrap/defaults/config.library.toml
@@ -8,6 +8,9 @@ bench-stage = 0
 [rust]
 # This greatly increases the speed of rebuilds, especially when there are only minor changes. However, it makes the initial build slightly slower.
 incremental = true
+# Download rustc from CI instead of building it from source.
+# For stage > 1 builds, this cuts compile times significantly when there are no changes on "compiler" tree.
+download-rustc = "if-unchanged"
 # Make the compiler and standard library faster to build, at the expense of a ~20% runtime slowdown.
 lto = "off"
 
diff --git a/src/bootstrap/defaults/config.tools.toml b/src/bootstrap/defaults/config.tools.toml
index efb56996bcd..27c1d1cf26d 100644
--- a/src/bootstrap/defaults/config.tools.toml
+++ b/src/bootstrap/defaults/config.tools.toml
@@ -4,7 +4,7 @@
 # This greatly increases the speed of rebuilds, especially when there are only minor changes. However, it makes the initial build slightly slower.
 incremental = true
 # Download rustc from CI instead of building it from source.
-# This cuts compile times by almost 60x, but means you can't modify the compiler.
+# For stage > 1 builds, this cuts compile times significantly when there are no changes on "compiler" tree.
 # Using these defaults will download the stage2 compiler (see `download-rustc`
 # setting) and the stage2 toolchain should therefore be used for these defaults.
 download-rustc = "if-unchanged"
diff --git a/src/bootstrap/src/utils/change_tracker.rs b/src/bootstrap/src/utils/change_tracker.rs
index b9cf8f05316..0915ec15a2f 100644
--- a/src/bootstrap/src/utils/change_tracker.rs
+++ b/src/bootstrap/src/utils/change_tracker.rs
@@ -290,4 +290,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
         severity: ChangeSeverity::Info,
         summary: "New option `llvm.offload` to control whether the llvm offload runtime for GPU support is built. Implicitly enables the openmp runtime as dependency.",
     },
+    ChangeInfo {
+        change_id: 132494,
+        severity: ChangeSeverity::Info,
+        summary: "`download-rustc='if-unchanged'` is now a default option for library profile.",
+    },
 ];
diff --git a/src/librustdoc/passes/propagate_stability.rs b/src/librustdoc/passes/propagate_stability.rs
index f55479687f8..a28487cc79e 100644
--- a/src/librustdoc/passes/propagate_stability.rs
+++ b/src/librustdoc/passes/propagate_stability.rs
@@ -9,7 +9,7 @@
 use rustc_attr::{Stability, StabilityLevel};
 use rustc_hir::def_id::CRATE_DEF_ID;
 
-use crate::clean::{Crate, Item, ItemId};
+use crate::clean::{Crate, Item, ItemId, ItemKind};
 use crate::core::DocContext;
 use crate::fold::DocFolder;
 use crate::passes::Pass;
@@ -38,22 +38,45 @@ impl<'a, 'tcx> DocFolder for StabilityPropagator<'a, 'tcx> {
             ItemId::DefId(def_id) => {
                 let own_stability = self.cx.tcx.lookup_stability(def_id);
 
-                // If any of the item's parents was stabilized later or is still unstable,
-                // then use the parent's stability instead.
-                if let Some(own_stab) = own_stability
-                    && let StabilityLevel::Stable {
-                        since: own_since,
-                        allowed_through_unstable_modules: false,
-                    } = own_stab.level
-                    && let Some(parent_stab) = parent_stability
-                    && (parent_stab.is_unstable()
-                        || parent_stab
-                            .stable_since()
-                            .is_some_and(|parent_since| parent_since > own_since))
-                {
-                    parent_stability
-                } else {
-                    own_stability
+                let (ItemKind::StrippedItem(box kind) | kind) = &item.kind;
+                match kind {
+                    ItemKind::ExternCrateItem { .. }
+                    | ItemKind::ImportItem(..)
+                    | ItemKind::StructItem(..)
+                    | ItemKind::UnionItem(..)
+                    | ItemKind::EnumItem(..)
+                    | ItemKind::FunctionItem(..)
+                    | ItemKind::ModuleItem(..)
+                    | ItemKind::TypeAliasItem(..)
+                    | ItemKind::StaticItem(..)
+                    | ItemKind::TraitItem(..)
+                    | ItemKind::TraitAliasItem(..)
+                    | ItemKind::StructFieldItem(..)
+                    | ItemKind::VariantItem(..)
+                    | ItemKind::ForeignFunctionItem(..)
+                    | ItemKind::ForeignStaticItem(..)
+                    | ItemKind::ForeignTypeItem
+                    | ItemKind::MacroItem(..)
+                    | ItemKind::ProcMacroItem(..)
+                    | ItemKind::ConstantItem(..) => {
+                        // If any of the item's parents was stabilized later or is still unstable,
+                        // then use the parent's stability instead.
+                        merge_stability(own_stability, parent_stability)
+                    }
+
+                    // Don't inherit the parent's stability for these items, because they
+                    // are potentially accessible even if the parent is more unstable.
+                    ItemKind::ImplItem(..)
+                    | ItemKind::TyMethodItem(..)
+                    | ItemKind::MethodItem(..)
+                    | ItemKind::TyAssocConstItem(..)
+                    | ItemKind::AssocConstItem(..)
+                    | ItemKind::TyAssocTypeItem(..)
+                    | ItemKind::AssocTypeItem(..)
+                    | ItemKind::PrimitiveItem(..)
+                    | ItemKind::KeywordItem => own_stability,
+
+                    ItemKind::StrippedItem(..) => unreachable!(),
                 }
             }
             ItemId::Auto { .. } | ItemId::Blanket { .. } => {
@@ -70,3 +93,20 @@ impl<'a, 'tcx> DocFolder for StabilityPropagator<'a, 'tcx> {
         Some(item)
     }
 }
+
+fn merge_stability(
+    own_stability: Option<Stability>,
+    parent_stability: Option<Stability>,
+) -> Option<Stability> {
+    if let Some(own_stab) = own_stability
+        && let StabilityLevel::Stable { since: own_since, allowed_through_unstable_modules: false } =
+            own_stab.level
+        && let Some(parent_stab) = parent_stability
+        && (parent_stab.is_unstable()
+            || parent_stab.stable_since().is_some_and(|parent_since| parent_since > own_since))
+    {
+        parent_stability
+    } else {
+        own_stability
+    }
+}