Skip to content

Commit 90b7dbb

Browse files
committed
Auto merge of #131539 - matthiaskrgr:rollup-lxbdzlf, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #131464 (Update wasm-component-ld to 0.5.10) - #131498 (Consider outermost const-anon in `non_local_def` lint) - #131512 (Fixing rustDoc for LayoutError.) - #131529 (rustdoc-json-types: fix typo in comment) - #131531 (move dummy commit logic into x86_64-gnu-llvm-18) Failed merges: - #131476 (coverage: Include the highest counter ID seen in `.cov-map` dumps) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ce697f9 + bf3eecf commit 90b7dbb

File tree

13 files changed

+193
-78
lines changed

13 files changed

+193
-78
lines changed

Cargo.lock

+24-24
Original file line numberDiff line numberDiff line change
@@ -5804,16 +5804,16 @@ checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484"
58045804

58055805
[[package]]
58065806
name = "wasm-component-ld"
5807-
version = "0.5.9"
5807+
version = "0.5.10"
58085808
source = "registry+https://github.com/rust-lang/crates.io-index"
5809-
checksum = "fde17bc96539700198e12516230c76095cc215c84ef39ad206e1af3f84243e0f"
5809+
checksum = "4d4aa6bd7fbe7cffbed29fe3e236fda74419def1bdef6f80f989ec51137edf44"
58105810
dependencies = [
58115811
"anyhow",
58125812
"clap",
58135813
"lexopt",
58145814
"tempfile",
58155815
"wasi-preview1-component-adapter-provider",
5816-
"wasmparser 0.218.0",
5816+
"wasmparser 0.219.0",
58175817
"wat",
58185818
"wit-component",
58195819
"wit-parser",
@@ -5837,28 +5837,28 @@ dependencies = [
58375837

58385838
[[package]]
58395839
name = "wasm-encoder"
5840-
version = "0.218.0"
5840+
version = "0.219.0"
58415841
source = "registry+https://github.com/rust-lang/crates.io-index"
5842-
checksum = "22b896fa8ceb71091ace9bcb81e853f54043183a1c9667cf93422c40252ffa0a"
5842+
checksum = "e2b1b95711b3ad655656a341e301cc64e33cbee94de9a99a1c5a2ab88efab79d"
58435843
dependencies = [
58445844
"leb128",
5845-
"wasmparser 0.218.0",
5845+
"wasmparser 0.219.0",
58465846
]
58475847

58485848
[[package]]
58495849
name = "wasm-metadata"
5850-
version = "0.218.0"
5850+
version = "0.219.0"
58515851
source = "registry+https://github.com/rust-lang/crates.io-index"
5852-
checksum = "aa5eeb071abe8a2132fdd5565dabffee70775ee8c24fc7e300ac43f51f4a8a91"
5852+
checksum = "96132fe00dd17d092d2be289eeed5a0a68ad3cf30b68e8875bc953b96f55f0be"
58535853
dependencies = [
58545854
"anyhow",
58555855
"indexmap",
58565856
"serde",
58575857
"serde_derive",
58585858
"serde_json",
58595859
"spdx",
5860-
"wasm-encoder 0.218.0",
5861-
"wasmparser 0.218.0",
5860+
"wasm-encoder 0.219.0",
5861+
"wasmparser 0.219.0",
58625862
]
58635863

58645864
[[package]]
@@ -5873,9 +5873,9 @@ dependencies = [
58735873

58745874
[[package]]
58755875
name = "wasmparser"
5876-
version = "0.218.0"
5876+
version = "0.219.0"
58775877
source = "registry+https://github.com/rust-lang/crates.io-index"
5878-
checksum = "b09e46c7fceceaa72b2dd1a8a137ea7fd8f93dfaa69806010a709918e496c5dc"
5878+
checksum = "324b4e56d24439495b88cd81439dad5e97f3c7b1eedc3c7e10455ed1e045e9a2"
58795879
dependencies = [
58805880
"ahash",
58815881
"bitflags 2.6.0",
@@ -5887,22 +5887,22 @@ dependencies = [
58875887

58885888
[[package]]
58895889
name = "wast"
5890-
version = "218.0.0"
5890+
version = "219.0.0"
58915891
source = "registry+https://github.com/rust-lang/crates.io-index"
5892-
checksum = "8a53cd1f0fa505df97557e36a58bddb8296e2fcdcd089529545ebfdb18a1b9d7"
5892+
checksum = "06880ecb25662bc21db6a83f4fcc27c41f71fbcba4f1980b650c88ada92728e1"
58935893
dependencies = [
58945894
"bumpalo",
58955895
"leb128",
58965896
"memchr",
58975897
"unicode-width",
5898-
"wasm-encoder 0.218.0",
5898+
"wasm-encoder 0.219.0",
58995899
]
59005900

59015901
[[package]]
59025902
name = "wat"
5903-
version = "1.218.0"
5903+
version = "1.219.0"
59045904
source = "registry+https://github.com/rust-lang/crates.io-index"
5905-
checksum = "4f87f8e14e776762e07927c27c2054d2cf678aab9aae2d431a79b3e31e4dd391"
5905+
checksum = "11e56dbf9fc89111b0d97c91e683d7895b1a6e5633a729f2ccad2303724005b6"
59065906
dependencies = [
59075907
"wast",
59085908
]
@@ -6179,9 +6179,9 @@ dependencies = [
61796179

61806180
[[package]]
61816181
name = "wit-component"
6182-
version = "0.218.0"
6182+
version = "0.219.0"
61836183
source = "registry+https://github.com/rust-lang/crates.io-index"
6184-
checksum = "aa53aa7e6bf2b3e8ccaffbcc963fbdb672a603dc0af393a481b6cec24c266406"
6184+
checksum = "99a76111c20444a814019de20499d30940ecd219b9512ee296f034a5edb18a2d"
61856185
dependencies = [
61866186
"anyhow",
61876187
"bitflags 2.6.0",
@@ -6190,17 +6190,17 @@ dependencies = [
61906190
"serde",
61916191
"serde_derive",
61926192
"serde_json",
6193-
"wasm-encoder 0.218.0",
6193+
"wasm-encoder 0.219.0",
61946194
"wasm-metadata",
6195-
"wasmparser 0.218.0",
6195+
"wasmparser 0.219.0",
61966196
"wit-parser",
61976197
]
61986198

61996199
[[package]]
62006200
name = "wit-parser"
6201-
version = "0.218.0"
6201+
version = "0.219.0"
62026202
source = "registry+https://github.com/rust-lang/crates.io-index"
6203-
checksum = "0d3d1066ab761b115f97fef2b191090faabcb0f37b555b758d3caf42d4ed9e55"
6203+
checksum = "23102e180c0c464f36e293d31a27b524e3ece930d7b5527d2f33f9d2c963de64"
62046204
dependencies = [
62056205
"anyhow",
62066206
"id-arena",
@@ -6211,7 +6211,7 @@ dependencies = [
62116211
"serde_derive",
62126212
"serde_json",
62136213
"unicode-xid",
6214-
"wasmparser 0.218.0",
6214+
"wasmparser 0.219.0",
62156215
]
62166216

62176217
[[package]]

compiler/rustc_lint/src/non_local_def.rs

+59-31
Original file line numberDiff line numberDiff line change
@@ -124,16 +124,6 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
124124
// If that's the case this means that this impl block declaration
125125
// is using local items and so we don't lint on it.
126126

127-
// We also ignore anon-const in item by including the anon-const
128-
// parent as well.
129-
let parent_parent = if parent_def_kind == DefKind::Const
130-
&& parent_opt_item_name == Some(kw::Underscore)
131-
{
132-
Some(cx.tcx.parent(parent))
133-
} else {
134-
None
135-
};
136-
137127
// 1. We collect all the `hir::Path` from the `Self` type and `Trait` ref
138128
// of the `impl` definition
139129
let mut collector = PathCollector { paths: Vec::new() };
@@ -148,13 +138,33 @@ impl<'tcx> LateLintPass<'tcx> for NonLocalDefinitions {
148138
|p| matches!(p.res, Res::Def(def_kind, _) if def_kind != DefKind::TyParam),
149139
);
150140

151-
// 2. We check if any of path reference a "local" parent and if that the case
152-
// we bail out as asked by T-lang, even though this isn't correct from a
153-
// type-system point of view, as inference exists and could still leak the impl.
141+
// 1.9. We retrieve the parent def id of the impl item, ...
142+
//
143+
// ... modulo const-anons items, for enhanced compatibility with the ecosystem
144+
// as that pattern is common with `serde`, `bevy`, ...
145+
//
146+
// For this example we want the `DefId` parent of the outermost const-anon items.
147+
// ```
148+
// const _: () = { // the parent of this const-anon
149+
// const _: () = {
150+
// impl Foo {}
151+
// };
152+
// };
153+
// ```
154+
let outermost_impl_parent = peel_parent_while(cx.tcx, parent, |tcx, did| {
155+
tcx.def_kind(did) == DefKind::Const
156+
&& tcx.opt_item_name(did) == Some(kw::Underscore)
157+
});
158+
159+
// 2. We check if any of the paths reference a the `impl`-parent.
160+
//
161+
// If that the case we bail out, as was asked by T-lang, even though this isn't
162+
// correct from a type-system point of view, as inference exists and one-impl-rule
163+
// make its so that we could still leak the impl.
154164
if collector
155165
.paths
156166
.iter()
157-
.any(|path| path_has_local_parent(path, cx, parent, parent_parent))
167+
.any(|path| path_has_local_parent(path, cx, parent, outermost_impl_parent))
158168
{
159169
return;
160170
}
@@ -253,8 +263,8 @@ impl<'tcx> Visitor<'tcx> for PathCollector<'tcx> {
253263
}
254264
}
255265

256-
/// Given a path and a parent impl def id, this checks if the if parent resolution
257-
/// def id correspond to the def id of the parent impl definition.
266+
/// Given a path, this checks if the if the parent resolution def id corresponds to
267+
/// the def id of the parent impl definition (the direct one and the outermost one).
258268
///
259269
/// Given this path, we will look at the path (and ignore any generic args):
260270
///
@@ -267,32 +277,50 @@ fn path_has_local_parent(
267277
path: &Path<'_>,
268278
cx: &LateContext<'_>,
269279
impl_parent: DefId,
270-
impl_parent_parent: Option<DefId>,
280+
outermost_impl_parent: Option<DefId>,
271281
) -> bool {
272282
path.res
273283
.opt_def_id()
274-
.is_some_and(|did| did_has_local_parent(did, cx.tcx, impl_parent, impl_parent_parent))
284+
.is_some_and(|did| did_has_local_parent(did, cx.tcx, impl_parent, outermost_impl_parent))
275285
}
276286

277-
/// Given a def id and a parent impl def id, this checks if the parent
278-
/// def id (modulo modules) correspond to the def id of the parent impl definition.
287+
/// Given a def id this checks if the parent def id (modulo modules) correspond to
288+
/// the def id of the parent impl definition (the direct one and the outermost one).
279289
#[inline]
280290
fn did_has_local_parent(
281291
did: DefId,
282292
tcx: TyCtxt<'_>,
283293
impl_parent: DefId,
284-
impl_parent_parent: Option<DefId>,
294+
outermost_impl_parent: Option<DefId>,
285295
) -> bool {
286-
did.is_local()
287-
&& if let Some(did_parent) = tcx.opt_parent(did) {
288-
did_parent == impl_parent
289-
|| Some(did_parent) == impl_parent_parent
290-
|| !did_parent.is_crate_root()
291-
&& tcx.def_kind(did_parent) == DefKind::Mod
292-
&& did_has_local_parent(did_parent, tcx, impl_parent, impl_parent_parent)
293-
} else {
294-
false
295-
}
296+
if !did.is_local() {
297+
return false;
298+
}
299+
300+
let Some(parent_did) = tcx.opt_parent(did) else {
301+
return false;
302+
};
303+
304+
peel_parent_while(tcx, parent_did, |tcx, did| tcx.def_kind(did) == DefKind::Mod)
305+
.map(|parent_did| parent_did == impl_parent || Some(parent_did) == outermost_impl_parent)
306+
.unwrap_or(false)
307+
}
308+
309+
/// Given a `DefId` checks if it satisfies `f` if it does check with it's parent and continue
310+
/// until it doesn't satisfies `f` and return the last `DefId` checked.
311+
///
312+
/// In other word this method return the first `DefId` that doesn't satisfies `f`.
313+
#[inline]
314+
fn peel_parent_while(
315+
tcx: TyCtxt<'_>,
316+
mut did: DefId,
317+
mut f: impl FnMut(TyCtxt<'_>, DefId) -> bool,
318+
) -> Option<DefId> {
319+
while !did.is_crate_root() && f(tcx, did) {
320+
did = tcx.opt_parent(did).filter(|parent_did| parent_did.is_local())?;
321+
}
322+
323+
Some(did)
296324
}
297325

298326
/// Return for a given `Path` the span until the last args

library/core/src/alloc/layout.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,8 @@ impl Layout {
540540
)]
541541
pub type LayoutErr = LayoutError;
542542

543-
/// The parameters given to `Layout::from_size_align`
543+
/// The `LayoutError` is returned when the parameters given
544+
/// to `Layout::from_size_align`
544545
/// or some other `Layout` constructor
545546
/// do not satisfy its documented constraints.
546547
#[stable(feature = "alloc_layout_error", since = "1.50.0")]

src/ci/docker/host-x86_64/mingw-check/Dockerfile

-12
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,6 @@ ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1
4747
# We disable optimized compiler built-ins because that requires a C toolchain for the target.
4848
# We also skip the x86_64-unknown-linux-gnu target as it is well-tested by other jobs.
4949
ENV SCRIPT \
50-
# `core::builder::tests::ci_rustc_if_unchanged_logic` bootstrap test covers the `rust.download-rustc=if-unchanged` logic.
51-
# Here we are adding a dummy commit on compiler and running that test to ensure when there is a change on the compiler,
52-
# we never download ci rustc with `rust.download-rustc=if-unchanged` option.
53-
echo \"\" >> ../compiler/rustc/src/main.rs && \
54-
git config --global user.email \"[email protected]\" && \
55-
git config --global user.name \"dummy\" && \
56-
git add ../compiler/rustc/src/main.rs && \
57-
git commit -m \"test commit for rust.download-rustc=if-unchanged logic\" && \
58-
DISABLE_CI_RUSTC_IF_INCOMPATIBLE=0 python3 ../x.py test bootstrap -- core::builder::tests::ci_rustc_if_unchanged_logic && \
59-
# Revert the dummy commit
60-
git reset --hard HEAD~1 && \
61-
6250
python3 ../x.py check --stage 0 --set build.optimized-compiler-builtins=false core alloc std --target=aarch64-unknown-linux-gnu,i686-pc-windows-msvc,i686-unknown-linux-gnu,x86_64-apple-darwin,x86_64-pc-windows-gnu,x86_64-pc-windows-msvc && \
6351
/scripts/check-default-config-profiles.sh && \
6452
python3 ../x.py check --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu && \

src/ci/docker/scripts/x86_64-gnu-llvm.sh

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
set -ex
44

5+
# `core::builder::tests::ci_rustc_if_unchanged_logic` bootstrap test ensures that
6+
# "download-rustc=if-unchanged" logic don't use CI rustc while there are changes on
7+
# compiler and/or library. Here we are adding a dummy commit on compiler and running
8+
# that test to make sure we never download CI rustc with a change on the compiler tree.
9+
echo "" >> ../compiler/rustc/src/main.rs
10+
git config --global user.email "[email protected]"
11+
git config --global user.name "dummy"
12+
git add ../compiler/rustc/src/main.rs
13+
git commit -m "test commit for rust.download-rustc=if-unchanged logic"
14+
DISABLE_CI_RUSTC_IF_INCOMPATIBLE=0 ../x.py test bootstrap \
15+
-- core::builder::tests::ci_rustc_if_unchanged_logic
16+
# Revert the dummy commit
17+
git reset --hard HEAD~1
18+
519
# Only run the stage 1 tests on merges, not on PR CI jobs.
620
if [[ -z "${PR_CI_JOB}" ]]; then
721
../x.py --stage 1 test --skip src/tools/tidy

src/ci/github-actions/jobs.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,15 @@ envs:
8585
# it in each job definition.
8686
pr:
8787
- image: mingw-check
88-
env:
89-
# We are adding (temporarily) a dummy commit on the compiler
90-
READ_ONLY_SRC: "0"
9188
<<: *job-linux-4c
9289
- image: mingw-check-tidy
9390
continue_on_error: true
9491
<<: *job-linux-4c
9592
- image: x86_64-gnu-llvm-18
9693
env:
9794
ENABLE_GCC_CODEGEN: "1"
95+
# We are adding (temporarily) a dummy commit on the compiler
96+
READ_ONLY_SRC: "0"
9897
<<: *job-linux-16c
9998
- image: x86_64-gnu-tools
10099
<<: *job-linux-16c
@@ -210,8 +209,6 @@ auto:
210209
<<: *job-linux-8c
211210

212211
- image: mingw-check
213-
env:
214-
READ_ONLY_SRC: 0
215212
<<: *job-linux-4c
216213

217214
- image: test-various
@@ -264,6 +261,7 @@ auto:
264261
- image: x86_64-gnu-llvm-18
265262
env:
266263
RUST_BACKTRACE: 1
264+
READ_ONLY_SRC: "0"
267265
<<: *job-linux-8c
268266

269267
- image: x86_64-gnu-nopt

src/rustdoc-json-types/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ pub struct FunctionHeader {
677677
/// on unwinding for more info.
678678
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
679679
pub enum Abi {
680-
// We only have a concrete listing here for stable ABI's because their are so many
680+
// We only have a concrete listing here for stable ABI's because there are so many
681681
// See rustc_ast_passes::feature_gate::PostExpansionVisitor::check_abi for the list
682682
/// The default ABI, but that can also be written explicitly with `extern "Rust"`.
683683
Rust,

src/tools/wasm-component-ld/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ name = "wasm-component-ld"
1010
path = "src/main.rs"
1111

1212
[dependencies]
13-
wasm-component-ld = "0.5.9"
13+
wasm-component-ld = "0.5.10"

tests/ui/lint/non-local-defs/consts.rs

+7
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ fn main() {
6363

6464
1
6565
};
66+
67+
const _: () = {
68+
const _: () = {
69+
impl Test {}
70+
//~^ WARN non-local `impl` definition
71+
};
72+
};
6673
}
6774

6875
trait Uto9 {}

0 commit comments

Comments
 (0)