Skip to content

Commit 6a436aa

Browse files
authored
Rollup merge of #83787 - digama0:patch-1, r=bjorn3
Monomorphization doc fix Only public items are monomorphization roots. This can be confirmed by noting that this program compiles: ```rust fn foo<T>() { if true { foo::<Option<T>>() } } fn bar() { foo::<()>() } ``` See also the [zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Why.20are.20non.20public.20items.20monomorphization.20roots.3F).
2 parents 961fa63 + 99f3e88 commit 6a436aa

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

compiler/rustc_mir/src/monomorphize/collector.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,15 @@
5959
//!
6060
//! ### Discovering roots
6161
//!
62-
//! The roots of the mono item graph correspond to the non-generic
62+
//! The roots of the mono item graph correspond to the public non-generic
6363
//! syntactic items in the source code. We find them by walking the HIR of the
64-
//! crate, and whenever we hit upon a function, method, or static item, we
65-
//! create a mono item consisting of the items DefId and, since we only
66-
//! consider non-generic items, an empty type-substitution set.
64+
//! crate, and whenever we hit upon a public function, method, or static item,
65+
//! we create a mono item consisting of the items DefId and, since we only
66+
//! consider non-generic items, an empty type-substitution set. (In eager
67+
//! collection mode, during incremental compilation, all non-generic functions
68+
//! are considered as roots, as well as when the `-Clink-dead-code` option is
69+
//! specified. Functions marked `#[no_mangle]` and functions called by inlinable
70+
//! functions also always act as roots.)
6771
//!
6872
//! ### Finding neighbor nodes
6973
//! Given a mono item node, we can discover neighbors by inspecting its

0 commit comments

Comments
 (0)