Skip to content

Commit 484c8e7

Browse files
committed
Auto merge of #131540 - matthiaskrgr:rollup-elbgu1w, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #131464 (Update wasm-component-ld to 0.5.10) - #131476 (coverage: Include the highest counter ID seen in `.cov-map` dumps) - #131497 (Add myself to bootstrap review rotation) - #131498 (Consider outermost const-anon in `non_local_def` lint) - #131512 (Fixing rustDoc for LayoutError.) - #131529 (rustdoc-json-types: fix typo in comment) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ce697f9 + d590d21 commit 484c8e7

File tree

99 files changed

+515
-61
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+515
-61
lines changed

Diff for: 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]]

Diff for: 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

Diff for: 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")]

Diff for: 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,

Diff for: src/tools/coverage-dump/src/covfun.rs

+42
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,19 @@ pub(crate) fn dump_covfun_mappings(
5656
expression_resolver.push_operands(lhs, rhs);
5757
}
5858

59+
let mut max_counter = None;
5960
for i in 0..num_files {
6061
let num_mappings = parser.read_uleb128_u32()?;
6162
println!("Number of file {i} mappings: {num_mappings}");
6263

6364
for _ in 0..num_mappings {
6465
let (kind, region) = parser.read_mapping_kind_and_region()?;
6566
println!("- {kind:?} at {region:?}");
67+
kind.for_each_term(|term| {
68+
if let CovTerm::Counter(n) = term {
69+
max_counter = max_counter.max(Some(n));
70+
}
71+
});
6672

6773
match kind {
6874
// Also print expression mappings in resolved form.
@@ -83,6 +89,16 @@ pub(crate) fn dump_covfun_mappings(
8389
}
8490

8591
parser.ensure_empty()?;
92+
93+
// Printing the highest counter ID seen in the functions mappings makes
94+
// it easier to determine whether a change to coverage instrumentation
95+
// has increased or decreased the number of physical counters needed.
96+
// (It's possible for the generated code to have more counters that
97+
// aren't used by any mappings, but that should hopefully be rare.)
98+
println!("Highest counter ID seen: {}", match max_counter {
99+
Some(id) => format!("c{id}"),
100+
None => "(none)".to_owned(),
101+
});
86102
println!();
87103
}
88104
Ok(())
@@ -271,6 +287,32 @@ enum MappingKind {
271287
},
272288
}
273289

290+
impl MappingKind {
291+
fn for_each_term(&self, mut callback: impl FnMut(CovTerm)) {
292+
match *self {
293+
Self::Code(term) => callback(term),
294+
Self::Gap(term) => callback(term),
295+
Self::Expansion(_id) => {}
296+
Self::Skip => {}
297+
Self::Branch { r#true, r#false } => {
298+
callback(r#true);
299+
callback(r#false);
300+
}
301+
Self::MCDCBranch {
302+
r#true,
303+
r#false,
304+
condition_id: _,
305+
true_next_id: _,
306+
false_next_id: _,
307+
} => {
308+
callback(r#true);
309+
callback(r#false);
310+
}
311+
Self::MCDCDecision { bitmap_idx: _, conditions_num: _ } => {}
312+
}
313+
}
314+
}
315+
274316
struct MappingRegion {
275317
/// Offset of this region's start line, relative to the *start line* of
276318
/// the *previous mapping* (or 0). Line numbers are 1-based.

Diff for: 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"

Diff for: tests/coverage/abort.cov-map

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Number of file 0 mappings: 13
3434
- Code(Expression(9, Add)) at (prev + 1, 9) to (start + 0, 23)
3535
= (c1 + c2)
3636
- Code(Counter(3)) at (prev + 2, 5) to (start + 1, 2)
37+
Highest counter ID seen: c5
3738

3839
Function name: abort::might_abort
3940
Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 03, 01, 01, 14, 05, 02, 09, 01, 24, 02, 02, 0c, 03, 02]
@@ -46,4 +47,5 @@ Number of file 0 mappings: 3
4647
- Code(Counter(1)) at (prev + 2, 9) to (start + 1, 36)
4748
- Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 3, 2)
4849
= (c0 - c1)
50+
Highest counter ID seen: c1
4951

Diff for: tests/coverage/assert-ne.cov-map

+1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ Number of file 0 mappings: 4
1010
- Code(Expression(0, Sub)) at (prev + 2, 13) to (start + 0, 19)
1111
= (c0 - c1)
1212
- Code(Counter(2)) at (prev + 3, 5) to (start + 1, 2)
13+
Highest counter ID seen: c2
1314

Diff for: tests/coverage/assert.cov-map

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Number of file 0 mappings: 9
2525
- Code(Expression(6, Add)) at (prev + 1, 9) to (start + 0, 23)
2626
= (c1 + (c2 + c3))
2727
- Code(Counter(4)) at (prev + 2, 5) to (start + 1, 2)
28+
Highest counter ID seen: c4
2829

2930
Function name: assert::might_fail_assert
3031
Raw bytes (21): 0x[01, 01, 01, 01, 05, 03, 01, 04, 01, 02, 0f, 02, 02, 25, 00, 3d, 05, 01, 01, 00, 02]
@@ -37,4 +38,5 @@ Number of file 0 mappings: 3
3738
- Code(Expression(0, Sub)) at (prev + 2, 37) to (start + 0, 61)
3839
= (c0 - c1)
3940
- Code(Counter(1)) at (prev + 1, 1) to (start + 0, 2)
41+
Highest counter ID seen: c1
4042

0 commit comments

Comments
 (0)