Skip to content

Commit 2862500

Browse files
committed
Auto merge of #118919 - matthiaskrgr:rollup-02udckl, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #118759 (Support bare unit structs in destructuring assignments) - #118871 (Coroutine variant fields can be uninitialized) - #118883 (Change a typo mistake in the-doc-attribute.md) - #118906 (Fix LLD thread flags in bootstrap on Windows) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 7176b8b + 251d1af commit 2862500

File tree

20 files changed

+121
-49
lines changed

20 files changed

+121
-49
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
12221222
| ExprKind::Struct(..)
12231223
| ExprKind::Tup(..)
12241224
| ExprKind::Underscore => false,
1225+
// Check for unit struct constructor.
1226+
ExprKind::Path(..) => lower_ctx.extract_unit_struct_path(lhs).is_none(),
12251227
// Check for tuple struct constructor.
12261228
ExprKind::Call(callee, ..) => lower_ctx.extract_tuple_struct_path(callee).is_none(),
12271229
ExprKind::Paren(e) => {

compiler/rustc_ty_utils/src/layout.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,10 @@ fn coroutine_layout<'tcx>(
831831
Assigned(_) => bug!("assignment does not match variant"),
832832
Ineligible(_) => false,
833833
})
834-
.map(|local| subst_field(info.field_tys[*local].ty));
834+
.map(|local| {
835+
let field_ty = subst_field(info.field_tys[*local].ty);
836+
Ty::new_maybe_uninit(tcx, field_ty)
837+
});
835838

836839
let mut variant = univariant_uninterned(
837840
cx,

src/bootstrap/src/core/build_steps/dist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ impl Step for CodegenBackend {
13191319
return None;
13201320
}
13211321

1322-
if self.compiler.host.contains("windows") {
1322+
if self.compiler.host.is_windows() {
13231323
builder.info(
13241324
"dist currently disabled for windows by rustc_codegen_cranelift. skipping",
13251325
);
@@ -1658,7 +1658,7 @@ impl Step for Extended {
16581658
builder.run(&mut cmd);
16591659
}
16601660

1661-
if target.contains("windows") {
1661+
if target.is_windows() {
16621662
let exe = tmp.join("exe");
16631663
let _ = fs::remove_dir_all(&exe);
16641664

src/bootstrap/src/core/build_steps/llvm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ impl Step for Llvm {
283283
};
284284

285285
builder.update_submodule(&Path::new("src").join("llvm-project"));
286-
if builder.llvm_link_shared() && target.contains("windows") {
286+
if builder.llvm_link_shared() && target.is_windows() {
287287
panic!("shared linking to LLVM is not currently supported on {}", target.triple);
288288
}
289289

@@ -361,7 +361,7 @@ impl Step for Llvm {
361361
// Disable zstd to avoid a dependency on libzstd.so.
362362
cfg.define("LLVM_ENABLE_ZSTD", "OFF");
363363

364-
if !target.contains("windows") {
364+
if !target.is_windows() {
365365
cfg.define("LLVM_ENABLE_ZLIB", "ON");
366366
} else {
367367
cfg.define("LLVM_ENABLE_ZLIB", "OFF");
@@ -607,7 +607,7 @@ fn configure_cmake(
607607
cfg.define("CMAKE_SYSTEM_NAME", "DragonFly");
608608
} else if target.contains("freebsd") {
609609
cfg.define("CMAKE_SYSTEM_NAME", "FreeBSD");
610-
} else if target.contains("windows") {
610+
} else if target.is_windows() {
611611
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
612612
} else if target.contains("haiku") {
613613
cfg.define("CMAKE_SYSTEM_NAME", "Haiku");
@@ -772,7 +772,7 @@ fn configure_cmake(
772772
&& !target.contains("netbsd")
773773
&& !target.contains("solaris")
774774
{
775-
if target.contains("apple") || target.contains("windows") {
775+
if target.contains("apple") || target.is_windows() {
776776
ldflags.push_all("-static-libstdc++");
777777
} else {
778778
ldflags.push_all("-Wl,-Bsymbolic -static-libstdc++");
@@ -1295,7 +1295,7 @@ impl Step for Libunwind {
12951295
cfg.define("__LIBUNWIND_IS_NATIVE_ONLY", None);
12961296
cfg.define("NDEBUG", None);
12971297
}
1298-
if self.target.contains("windows") {
1298+
if self.target.is_windows() {
12991299
cfg.define("_LIBUNWIND_HIDE_SYMBOLS", "1");
13001300
cfg.define("_LIBUNWIND_IS_NATIVE_ONLY", "1");
13011301
}

src/bootstrap/src/core/builder.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,10 +1653,7 @@ impl<'a> Builder<'a> {
16531653
// flesh out rpath support more fully in the future.
16541654
rustflags.arg("-Zosx-rpath-install-name");
16551655
Some(format!("-Wl,-rpath,@loader_path/../{libdir}"))
1656-
} else if !target.contains("windows")
1657-
&& !target.contains("aix")
1658-
&& !target.contains("xous")
1659-
{
1656+
} else if !target.is_windows() && !target.contains("aix") && !target.contains("xous") {
16601657
rustflags.arg("-Clink-args=-Wl,-z,origin");
16611658
Some(format!("-Wl,-rpath,$ORIGIN/../{libdir}"))
16621659
} else {
@@ -1729,8 +1726,7 @@ impl<'a> Builder<'a> {
17291726
let split_debuginfo_is_stable = target.contains("linux")
17301727
|| target.contains("apple")
17311728
|| (target.is_msvc() && self.config.rust_split_debuginfo == SplitDebuginfo::Packed)
1732-
|| (target.contains("windows")
1733-
&& self.config.rust_split_debuginfo == SplitDebuginfo::Off);
1729+
|| (target.is_windows() && self.config.rust_split_debuginfo == SplitDebuginfo::Off);
17341730

17351731
if !split_debuginfo_is_stable {
17361732
rustflags.arg("-Zunstable-options");

src/bootstrap/src/core/config/config.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,10 @@ impl std::str::FromStr for SplitDebuginfo {
421421
impl SplitDebuginfo {
422422
/// Returns the default `-Csplit-debuginfo` value for the current target. See the comment for
423423
/// `rust.split-debuginfo` in `config.example.toml`.
424-
fn default_for_platform(target: &str) -> Self {
424+
fn default_for_platform(target: TargetSelection) -> Self {
425425
if target.contains("apple") {
426426
SplitDebuginfo::Unpacked
427-
} else if target.contains("windows") {
427+
} else if target.is_windows() {
428428
SplitDebuginfo::Packed
429429
} else {
430430
SplitDebuginfo::Off
@@ -527,6 +527,10 @@ impl TargetSelection {
527527
pub fn is_msvc(&self) -> bool {
528528
self.contains("msvc")
529529
}
530+
531+
pub fn is_windows(&self) -> bool {
532+
self.contains("windows")
533+
}
530534
}
531535

532536
impl fmt::Display for TargetSelection {
@@ -1595,7 +1599,7 @@ impl Config {
15951599
.as_deref()
15961600
.map(SplitDebuginfo::from_str)
15971601
.map(|v| v.expect("invalid value for rust.split_debuginfo"))
1598-
.unwrap_or(SplitDebuginfo::default_for_platform(&config.build.triple));
1602+
.unwrap_or(SplitDebuginfo::default_for_platform(config.build));
15991603
optimize = optimize_toml;
16001604
omit_git_hash = omit_git_hash_toml;
16011605
config.rust_new_symbol_mangling = new_symbol_mangling;

src/bootstrap/src/utils/helpers.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub use t;
4949
/// Given an executable called `name`, return the filename for the
5050
/// executable for a particular target.
5151
pub fn exe(name: &str, target: TargetSelection) -> String {
52-
if target.contains("windows") {
52+
if target.is_windows() {
5353
format!("{name}.exe")
5454
} else if target.contains("uefi") {
5555
format!("{name}.efi")
@@ -72,7 +72,7 @@ pub fn is_debug_info(name: &str) -> bool {
7272
/// Returns the corresponding relative library directory that the compiler's
7373
/// dylibs will be found in.
7474
pub fn libdir(target: TargetSelection) -> &'static str {
75-
if target.contains("windows") { "bin" } else { "lib" }
75+
if target.is_windows() { "bin" } else { "lib" }
7676
}
7777

7878
/// Adds a list of lookup paths to `cmd`'s dynamic library lookup path.
@@ -191,7 +191,7 @@ pub fn target_supports_cranelift_backend(target: TargetSelection) -> bool {
191191
|| target.contains("aarch64")
192192
|| target.contains("s390x")
193193
|| target.contains("riscv64gc")
194-
} else if target.contains("darwin") || target.contains("windows") {
194+
} else if target.contains("darwin") || target.is_windows() {
195195
target.contains("x86_64")
196196
} else {
197197
false
@@ -519,7 +519,7 @@ pub fn linker_flags(
519519
if matches!(lld_threads, LldThreads::No) {
520520
args.push(format!(
521521
"-Clink-arg=-Wl,{}",
522-
lld_flag_no_threads(builder.config.lld_mode, target.is_msvc())
522+
lld_flag_no_threads(builder.config.lld_mode, target.is_windows())
523523
));
524524
}
525525
}

src/doc/rustdoc/src/write-documentation/the-doc-attribute.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ mod bar {
201201
# fn main() {}
202202
```
203203

204-
Here, because `bar` is not public, `Bar` wouldn't have its own page, so there's nowhere
204+
Here, because `bar` is not public, `bar` wouldn't have its own page, so there's nowhere
205205
to link to. `rustdoc` will inline these definitions, and so we end up in the same case
206206
as the `#[doc(inline)]` above; `Bar` is in a `Structs` section, as if it were defined at
207207
the top level. If we add the `no_inline` form of the attribute:

tests/ui/async-await/future-sizes/async-awaiting-fut.stdout

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,16 @@ print-type-size variant `Panicked`: 1024 bytes
5252
print-type-size upvar `.arg`: 1024 bytes
5353
print-type-size type: `std::mem::ManuallyDrop<bool>`: 1 bytes, alignment: 1 bytes
5454
print-type-size field `.value`: 1 bytes
55+
print-type-size type: `std::mem::ManuallyDrop<{async fn body@$DIR/async-awaiting-fut.rs:6:17: 6:19}>`: 1 bytes, alignment: 1 bytes
56+
print-type-size field `.value`: 1 bytes
5557
print-type-size type: `std::mem::MaybeUninit<bool>`: 1 bytes, alignment: 1 bytes
5658
print-type-size variant `MaybeUninit`: 1 bytes
5759
print-type-size field `.uninit`: 0 bytes
5860
print-type-size field `.value`: 1 bytes
61+
print-type-size type: `std::mem::MaybeUninit<{async fn body@$DIR/async-awaiting-fut.rs:6:17: 6:19}>`: 1 bytes, alignment: 1 bytes
62+
print-type-size variant `MaybeUninit`: 1 bytes
63+
print-type-size field `.uninit`: 0 bytes
64+
print-type-size field `.value`: 1 bytes
5965
print-type-size type: `std::task::Poll<()>`: 1 bytes, alignment: 1 bytes
6066
print-type-size discriminant: 1 bytes
6167
print-type-size variant `Ready`: 0 bytes

tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
error[E0391]: cycle detected when computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}`
1+
error[E0391]: cycle detected when computing layout of `core::mem::maybe_uninit::MaybeUninit<{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}>`
22
|
3-
= note: ...which requires computing layout of `<<A as First>::Second as Second>::{opaque#0}`...
4-
= note: ...which again requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}`, completing the cycle
3+
= note: ...which requires computing layout of `core::mem::manually_drop::ManuallyDrop<{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}>`...
4+
= note: ...which requires computing layout of `{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}`...
5+
= note: ...which requires computing layout of `core::mem::maybe_uninit::MaybeUninit<<<A as First>::Second as Second>::{opaque#0}>`...
6+
= note: ...which again requires computing layout of `core::mem::maybe_uninit::MaybeUninit<{async fn body@$DIR/indirect-recursion-issue-112047.rs:33:27: 35:6}>`, completing the cycle
57
= note: cycle used when computing layout of `{async block@$DIR/indirect-recursion-issue-112047.rs:6:13: 8:6}`
68
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
79

0 commit comments

Comments
 (0)