Skip to content

Commit 540f43a

Browse files
committed
Auto merge of #155185 - matthiaskrgr:rollup-JYNqFhW, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #155171 (Patch musl's CVE-2026-6042 and CVE-2026-40200) - #153630 (Deprioritize doc(hidden) re-exports in diagnostic paths) - #152613 (unsafe keyword docs: bring back unsafe_op_in_unsafe_fn lint discussion) - #155142 (impl const Residual for ControlFlow)
2 parents d32e620 + 11469dc commit 540f43a

16 files changed

Lines changed: 582 additions & 16 deletions

File tree

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,11 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
455455

456456
let mut visible_parent_map: DefIdMap<DefId> = Default::default();
457457
// This is a secondary visible_parent_map, storing the DefId of
458-
// parents that re-export the child as `_` or module parents
459-
// which are `#[doc(hidden)]`. Since we prefer paths that don't
460-
// do this, merge this map at the end, only if we're missing
461-
// keys from the former.
458+
// parents that re-export the child as `_`, module parents
459+
// which are `#[doc(hidden)]`, or `use` items that are themselves
460+
// `#[doc(hidden)]`. Since we prefer paths that don't do this,
461+
// merge this map at the end, only if we're missing keys from
462+
// the former.
462463
// This is a rudimentary check that does not catch all cases,
463464
// just the easiest.
464465
let mut fallback_map: Vec<(DefId, DefId)> = Default::default();
@@ -500,6 +501,18 @@ pub(in crate::rmeta) fn provide(providers: &mut Providers) {
500501
return;
501502
}
502503

504+
// If the re-export itself is `#[doc(hidden)]`, deprioritize it.
505+
// See PR #99698 for the case where the *parent* is doc-hidden.
506+
if child
507+
.reexport_chain
508+
.first()
509+
.and_then(|r| r.id())
510+
.is_some_and(|id| tcx.is_doc_hidden(id))
511+
{
512+
fallback_map.push((def_id, parent));
513+
return;
514+
}
515+
503516
match visible_parent_map.entry(def_id) {
504517
Entry::Occupied(mut entry) => {
505518
// If `child` is defined in crate `cnum`, ensure

compiler/rustc_metadata/src/rmeta/encoder.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,10 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
943943
| DefKind::Macro(_)
944944
| DefKind::Field
945945
| DefKind::Impl { .. } => true,
946+
// Encoding attrs for `Use` items allows `#[doc(hidden)]` on re-exports
947+
// to be read cross-crate, which is needed for diagnostic path selection
948+
// in `visible_parent_map`. See #153477.
949+
DefKind::Use => true,
946950
// Tools may want to be able to detect their tool lints on
947951
// closures from upstream crates, too. This is used by
948952
// https://github.com/model-checking/kani and is not a performance
@@ -953,7 +957,6 @@ fn should_encode_attrs(def_kind: DefKind) -> bool {
953957
| DefKind::ConstParam
954958
| DefKind::Ctor(..)
955959
| DefKind::ExternCrate
956-
| DefKind::Use
957960
| DefKind::ForeignMod
958961
| DefKind::AnonConst
959962
| DefKind::InlineConst

library/core/src/ops/control_flow.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ impl<B, C> const ops::FromResidual<ControlFlow<B, convert::Infallible>> for Cont
134134
}
135135

136136
#[unstable(feature = "try_trait_v2_residual", issue = "91285")]
137-
impl<B, C> ops::Residual<C> for ControlFlow<B, convert::Infallible> {
137+
#[rustc_const_unstable(feature = "const_try_residual", issue = "91285")]
138+
impl<B, C> const ops::Residual<C> for ControlFlow<B, convert::Infallible> {
138139
type TryType = ControlFlow<B, C>;
139140
}
140141

library/std/src/keyword_docs.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,10 +2042,19 @@ mod type_keyword {}
20422042
/// system.
20432043
///
20442044
/// The `unsafe` keyword has two uses:
2045-
/// - to declare the existence of contracts the compiler can't check (`unsafe fn` and `unsafe
2046-
/// trait`),
2047-
/// - and to declare that a programmer has checked that these contracts have been upheld (`unsafe
2048-
/// {}` and `unsafe impl`, but also `unsafe fn` -- see below).
2045+
/// - to declare the existence of contracts the compiler can't check,
2046+
/// - and to declare that a programmer has checked that these contracts have been upheld.
2047+
///
2048+
/// Typically, each `unsafe` is either of the first or second kind: `unsafe fn` and `unsafe trait`
2049+
/// declare the existence of an unsafe contract; `unsafe {}` and `unsafe impl` declare that an
2050+
/// unsafe contract (which must have been declared elsewhere) is being upheld.
2051+
///
2052+
/// However, historically, these two are not mutually exclusive: the body of an `unsafe fn` is, on
2053+
/// old editions, treated like an unsafe block, which means that this use of `unsafe` both declares
2054+
/// the existence of a contract to call the current function, and declares that the contracts of the
2055+
/// unsafe operations inside this function are being upheld. The `unsafe_op_in_unsafe_fn` lint can
2056+
/// be enabled to change that and make `unsafe fn` only play the former role. That lint is enabled
2057+
/// by default since edition 2024.
20492058
///
20502059
/// # Unsafe abilities
20512060
///
@@ -2088,6 +2097,13 @@ mod type_keyword {}
20882097
/// - `unsafe impl`: the contract necessary to implement the trait has been
20892098
/// checked by the programmer and is guaranteed to be respected.
20902099
///
2100+
/// On old editions, `unsafe fn` also acts like an `unsafe {}` block around the code inside the
2101+
/// function. This means it is not just a signal to the caller, but also promises that the
2102+
/// preconditions for the operations inside the function are upheld. Mixing these two meanings can
2103+
/// be confusing, so the `unsafe_op_in_unsafe_fn` lint has been introduced and enabled by default
2104+
/// since edition 2024 to warn against that and require explicit unsafe blocks even inside `unsafe
2105+
/// fn`.
2106+
///
20912107
/// See the [Rustonomicon] and the [Reference] for more information.
20922108
///
20932109
/// # Examples

src/ci/docker/host-x86_64/dist-arm-linux-musl/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ RUN sh /scripts/cross-apt-packages.sh
66
WORKDIR /build
77

88
COPY scripts/musl-toolchain.sh /build/
9+
COPY scripts/musl-cve-2026-6042.diff /build/
10+
COPY scripts/musl-cve-2026-40200.diff /build/
911
# We need to mitigate rust-lang/rust#34978 when compiling musl itself as well
1012
RUN CFLAGS="-Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" \
1113
CXXFLAGS="-Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" \

src/ci/docker/host-x86_64/dist-i586-gnu-i586-i686-musl/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ ENV \
3939

4040
WORKDIR /build/
4141
COPY scripts/musl.sh /build/
42+
COPY scripts/musl-cve-2026-6042.diff /build/
43+
COPY scripts/musl-cve-2026-40200.diff /build/
4244
RUN CC=gcc CFLAGS="-m32 -Wa,-mrelax-relocations=no" \
4345
CXX=g++ CXXFLAGS="-m32 -Wa,-mrelax-relocations=no" \
4446
bash musl.sh i686 --target=i686 && \

src/ci/docker/host-x86_64/dist-various-1/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ ENV PATH="/build/emsdk:/build/emsdk/upstream/emscripten:/build/emsdk/node/curren
6565
ENV STAGING_DIR=/tmp
6666

6767
COPY scripts/musl.sh /build
68+
COPY scripts/musl-cve-2026-6042.diff /build/
69+
COPY scripts/musl-cve-2026-40200.diff /build/
6870
RUN env \
6971
CC=arm-linux-gnueabi-gcc CFLAGS="-march=armv5te -marm -mfloat-abi=soft" \
7072
CXX=arm-linux-gnueabi-g++ CXXFLAGS="-march=armv5te -marm -mfloat-abi=soft" \

src/ci/docker/host-x86_64/dist-various-2/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ ENV \
6868

6969
WORKDIR /build
7070
COPY scripts/musl.sh /build
71+
COPY scripts/musl-cve-2026-6042.diff /build/
72+
COPY scripts/musl-cve-2026-40200.diff /build/
7173
RUN env \
7274
CC=arm-linux-gnueabi-gcc-9 CFLAGS="-march=armv7-a" \
7375
CXX=arm-linux-gnueabi-g++-9 CXXFLAGS="-march=armv7-a" \

src/ci/docker/host-x86_64/dist-x86_64-musl/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
2525
WORKDIR /build/
2626

2727
COPY scripts/musl-toolchain.sh /build/
28+
COPY scripts/musl-cve-2026-6042.diff /build/
29+
COPY scripts/musl-cve-2026-40200.diff /build/
2830
# We need to mitigate rust-lang/rust#34978 when compiling musl itself as well
2931
RUN CFLAGS="-Wa,-mrelax-relocations=no -Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" \
3032
CXXFLAGS="-Wa,-mrelax-relocations=no -Wa,--compress-debug-sections=none -Wl,--compress-debug-sections=none" \

src/ci/docker/host-x86_64/test-various/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ ENV PATH="/node/bin:${PATH}"
3535

3636
WORKDIR /build/
3737
COPY scripts/musl-toolchain.sh /build/
38+
COPY scripts/musl-cve-2026-6042.diff /build/
39+
COPY scripts/musl-cve-2026-40200.diff /build/
3840
RUN bash musl-toolchain.sh x86_64 && rm -rf build
3941
WORKDIR /
4042

0 commit comments

Comments
 (0)