Skip to content

Commit 2df8dbb

Browse files
committed
Auto merge of #132277 - workingjubilee:rollup-5e6q6e4, r=workingjubilee
Rollup of 9 pull requests Successful merges: - #130259 (Lower AST node id only once) - #131441 (Add a new trait `proc_macro::ToTokens`) - #132247 (stable_mir: Directly use types from rustc_abi) - #132249 (compiler: Add rustc_abi dependence to the compiler) - #132255 (Add `LayoutData::is_uninhabited` and use it) - #132258 ([rustdoc] Unify variant struct fields margins with struct fields) - #132260 (cg_llvm: Use a type-safe helper to cast `&str` and `&[u8]` to `*const c_char`) - #132261 (refactor: cleaner check to return None) - #132271 (Updating Fuchsia platform-support documentation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a9d1762 + 89ac69f commit 2df8dbb

File tree

81 files changed

+748
-339
lines changed

Some content is hidden

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

81 files changed

+748
-339
lines changed

Cargo.lock

+10
Original file line numberDiff line numberDiff line change
@@ -3621,6 +3621,7 @@ version = "0.0.0"
36213621
dependencies = [
36223622
"annotate-snippets 0.11.4",
36233623
"derive_setters",
3624+
"rustc_abi",
36243625
"rustc_ast",
36253626
"rustc_ast_pretty",
36263627
"rustc_data_structures",
@@ -3718,6 +3719,7 @@ name = "rustc_hir_analysis"
37183719
version = "0.0.0"
37193720
dependencies = [
37203721
"itertools",
3722+
"rustc_abi",
37213723
"rustc_arena",
37223724
"rustc_ast",
37233725
"rustc_attr",
@@ -3906,6 +3908,7 @@ dependencies = [
39063908
name = "rustc_lint"
39073909
version = "0.0.0"
39083910
dependencies = [
3911+
"rustc_abi",
39093912
"rustc_ast",
39103913
"rustc_ast_pretty",
39113914
"rustc_attr",
@@ -3980,6 +3983,7 @@ dependencies = [
39803983
"bitflags 2.6.0",
39813984
"libloading",
39823985
"odht",
3986+
"rustc_abi",
39833987
"rustc_ast",
39843988
"rustc_attr",
39853989
"rustc_data_structures",
@@ -4074,6 +4078,7 @@ version = "0.0.0"
40744078
dependencies = [
40754079
"polonius-engine",
40764080
"regex",
4081+
"rustc_abi",
40774082
"rustc_ast",
40784083
"rustc_data_structures",
40794084
"rustc_errors",
@@ -4095,6 +4100,7 @@ version = "0.0.0"
40954100
dependencies = [
40964101
"either",
40974102
"itertools",
4103+
"rustc_abi",
40984104
"rustc_arena",
40994105
"rustc_ast",
41004106
"rustc_attr",
@@ -4187,6 +4193,7 @@ dependencies = [
41874193
name = "rustc_passes"
41884194
version = "0.0.0"
41894195
dependencies = [
4196+
"rustc_abi",
41904197
"rustc_ast",
41914198
"rustc_ast_pretty",
41924199
"rustc_attr",
@@ -4213,6 +4220,7 @@ name = "rustc_pattern_analysis"
42134220
version = "0.0.0"
42144221
dependencies = [
42154222
"rustc-hash 2.0.0",
4223+
"rustc_abi",
42164224
"rustc_apfloat",
42174225
"rustc_arena",
42184226
"rustc_data_structures",
@@ -4352,6 +4360,7 @@ dependencies = [
43524360
"bitflags 2.6.0",
43534361
"getopts",
43544362
"libc",
4363+
"rustc_abi",
43554364
"rustc_ast",
43564365
"rustc_data_structures",
43574366
"rustc_errors",
@@ -4415,6 +4424,7 @@ version = "0.0.0"
44154424
dependencies = [
44164425
"punycode",
44174426
"rustc-demangle",
4427+
"rustc_abi",
44184428
"rustc_data_structures",
44194429
"rustc_errors",
44204430
"rustc_hir",

compiler/rustc_abi/src/layout.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ where
2828
VariantIdx: Idx,
2929
F: Deref<Target = &'a LayoutData<FieldIdx, VariantIdx>> + fmt::Debug,
3030
{
31-
let uninhabited = fields.iter().any(|f| f.abi.is_uninhabited());
31+
let uninhabited = fields.iter().any(|f| f.is_uninhabited());
3232
// We cannot ignore alignment; that might lead us to entirely discard a variant and
3333
// produce an enum that is less aligned than it should be!
3434
let is_1zst = fields.iter().all(|f| f.is_1zst());
@@ -681,7 +681,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
681681
let discr_type = repr.discr_type();
682682
let bits = Integer::from_attr(dl, discr_type).size().bits();
683683
for (i, mut val) in discriminants {
684-
if !repr.c() && variants[i].iter().any(|f| f.abi.is_uninhabited()) {
684+
if !repr.c() && variants[i].iter().any(|f| f.is_uninhabited()) {
685685
continue;
686686
}
687687
if discr_type.is_signed() {

compiler/rustc_abi/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1652,6 +1652,11 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
16521652
}
16531653
}
16541654

1655+
/// Returns `true` if this is an uninhabited type
1656+
pub fn is_uninhabited(&self) -> bool {
1657+
self.abi.is_uninhabited()
1658+
}
1659+
16551660
pub fn scalar<C: HasDataLayout>(cx: &C, scalar: Scalar) -> Self {
16561661
let largest_niche = Niche::from_scalar(cx, Size::ZERO, scalar);
16571662
let size = scalar.size(cx);

compiler/rustc_ast_lowering/src/block.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
1010
b: &Block,
1111
targeted_by_break: bool,
1212
) -> &'hir hir::Block<'hir> {
13-
self.arena.alloc(self.lower_block_noalloc(b, targeted_by_break))
13+
let hir_id = self.lower_node_id(b.id);
14+
self.arena.alloc(self.lower_block_noalloc(hir_id, b, targeted_by_break))
1415
}
1516

1617
pub(super) fn lower_block_noalloc(
1718
&mut self,
19+
hir_id: hir::HirId,
1820
b: &Block,
1921
targeted_by_break: bool,
2022
) -> hir::Block<'hir> {
2123
let (stmts, expr) = self.lower_stmts(&b.stmts);
2224
let rules = self.lower_block_check_mode(&b.rules);
23-
let hir_id = self.lower_node_id(b.id);
2425
hir::Block { hir_id, stmts, expr, rules, span: self.lower_span(b.span), targeted_by_break }
2526
}
2627

compiler/rustc_ast_lowering/src/delegation.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
259259
self_param_id: pat_node_id,
260260
};
261261
self_resolver.visit_block(block);
262+
// Target expr needs to lower `self` path.
263+
this.ident_and_label_to_local_id.insert(pat_node_id, param.pat.hir_id.local_id);
262264
this.lower_target_expr(&block)
263265
} else {
264-
let pat_hir_id = this.lower_node_id(pat_node_id);
265-
this.generate_arg(pat_hir_id, span)
266+
this.generate_arg(param.pat.hir_id, span)
266267
};
267268
args.push(arg);
268269
}

0 commit comments

Comments
 (0)