Skip to content

Commit 6ce00b9

Browse files
committed
Auto merge of #128819 - matthiaskrgr:rollup-fxa0ow3, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #128795 (Update E0517 message to reflect RFC 2195.) - #128804 (run-make: enable msvc for redundant-libs) - #128807 (run-make: run fmt-write-bloat on Windows) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d3a3939 + dc5b289 commit 6ce00b9

File tree

5 files changed

+25
-21
lines changed

5 files changed

+25
-21
lines changed

compiler/rustc_error_codes/src/error_codes/E0517.md

+12-7
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,17 @@ impl Foo {
2525
These attributes do not work on typedefs, since typedefs are just aliases.
2626

2727
Representations like `#[repr(u8)]`, `#[repr(i64)]` are for selecting the
28-
discriminant size for enums with no data fields on any of the variants, e.g.
29-
`enum Color {Red, Blue, Green}`, effectively setting the size of the enum to
30-
the size of the provided type. Such an enum can be cast to a value of the same
31-
type as well. In short, `#[repr(u8)]` makes the enum behave like an integer
32-
with a constrained set of allowed values.
28+
discriminant size for enums. For enums with no data fields on any of the
29+
variants, e.g. `enum Color {Red, Blue, Green}`, this effectively sets the size
30+
of the enum to the size of the provided type. Such an enum can be cast to a
31+
value of the same type as well. In short, `#[repr(u8)]` makes a field-less enum
32+
behave like an integer with a constrained set of allowed values.
3333

34-
Only field-less enums can be cast to numerical primitives, so this attribute
35-
will not apply to structs.
34+
For a description of how `#[repr(C)]` and representations like `#[repr(u8)]`
35+
affect the layout of enums with data fields, see [RFC 2195][rfc2195].
36+
37+
Only field-less enums can be cast to numerical primitives. Representations like
38+
`#[repr(u8)]` will not apply to structs.
3639

3740
`#[repr(packed)]` reduces padding to make the struct size smaller. The
3841
representation of enums isn't strictly defined in Rust, and this attribute
@@ -42,3 +45,5 @@ won't work on enums.
4245
types (i.e., `u8`, `i32`, etc) a representation that permits vectorization via
4346
SIMD. This doesn't make much sense for enums since they don't consist of a
4447
single list of data.
48+
49+
[rfc2195]: https://github.com/rust-lang/rfcs/blob/master/text/2195-really-tagged-unions.md

tests/run-make/fmt-write-bloat/main.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
use core::fmt;
66
use core::fmt::Write;
77

8-
#[link(name = "c")]
8+
#[cfg_attr(not(target_env = "msvc"), link(name = "c"))]
9+
#[cfg_attr(all(target_env = "msvc", target_feature = "crt-static"), link(name = "libcmt"))]
10+
#[cfg_attr(all(target_env = "msvc", not(target_feature = "crt-static")), link(name = "msvcrt"))]
911
extern "C" {}
1012

1113
struct Dummy;

tests/run-make/fmt-write-bloat/rmake.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@
1515
//! `NO_DEBUG_ASSERTIONS=1`). If debug assertions are disabled, then we can check for the absence of
1616
//! additional `usize` formatting and padding related symbols.
1717
18-
// Reason: This test is `ignore-windows` because the `no_std` test (using `#[link(name = "c")])`
19-
// doesn't link on windows.
20-
//@ ignore-windows
2118
//@ ignore-cross-compile
2219

2320
use run_make_support::env::no_debug_assertions;
24-
use run_make_support::rustc;
2521
use run_make_support::symbols::any_symbol_contains;
22+
use run_make_support::{bin_name, rustc};
2623

2724
fn main() {
2825
rustc().input("main.rs").opt().run();
@@ -33,5 +30,5 @@ fn main() {
3330
// otherwise, add them to the list of symbols to deny.
3431
panic_syms.extend_from_slice(&["panicking", "panic_fmt", "pad_integral", "Display"]);
3532
}
36-
assert!(!any_symbol_contains("main", &panic_syms));
33+
assert!(!any_symbol_contains(&bin_name("main"), &panic_syms));
3734
}

tests/run-make/redundant-libs/foo.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
void foo1() {}
2-
void foo2() {}
1+
#ifdef _MSC_VER
2+
#define DllExport __declspec(dllexport)
3+
#else
4+
#define DllExport
5+
#endif
6+
7+
DllExport void foo1() {}
8+
DllExport void foo2() {}

tests/run-make/redundant-libs/rmake.rs

-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@
1010

1111
//@ ignore-cross-compile
1212
// Reason: the compiled binary is executed
13-
//@ ignore-windows-msvc
14-
// Reason: this test links libraries via link.exe, which only accepts the import library
15-
// for the dynamic library, i.e. `foo.dll.lib`. However, build_native_dynamic_lib only
16-
// produces `foo.dll` - the dynamic library itself. To make this test work on MSVC, one
17-
// would need to derive the import library from the dynamic library.
18-
// See https://stackoverflow.com/questions/9360280/
1913

2014
use run_make_support::{
2115
build_native_dynamic_lib, build_native_static_lib, cwd, is_msvc, rfs, run, rustc,

0 commit comments

Comments
 (0)