You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rollup merge of rust-lang#126956 - joboet:fmt_no_extern_ty, r=RalfJung
core: avoid `extern type`s in formatting infrastructure
```@RalfJung``` [said](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Use.20of.20.60extern.20type.60.20in.20formatting.20machinery/near/446552837):
>How attached are y'all to using `extern type` in the formatting machinery?
Seems like this was introduced a [long time ago](rust-lang@34ef8f5). However, it's also [not really compatible with Stacked Borrows](rust-lang/unsafe-code-guidelines#256), and only works currently because we effectively treat references-to-extern-type almost like raw pointers in Stacked Borrows -- which of course is unsound, it's not how LLVM works. I was planning to make Miri emit a warning when this happens to avoid cases like [this](rust-lang#126814 (comment)) where people use extern type specifically to silence Miri without realizing what happens. but with the formatting machinery using extern type, this warning would just show up everywhere...
>
> The "proper" way to do this in Stacked Borrows is to use raw pointers (or `NonNull`).
This PR does just that.
r? ```@RalfJung```
Copy file name to clipboardexpand all lines: tests/ui/fmt/send-sync.stderr
+6-24
Original file line number
Diff line number
Diff line change
@@ -1,45 +1,27 @@
1
-
error[E0277]: `core::fmt::rt::Opaque` cannot be shared between threads safely
1
+
error[E0277]: `Arguments<'_>` cannot be sent between threads safely
2
2
--> $DIR/send-sync.rs:8:10
3
3
|
4
4
LL | send(format_args!("{:?}", c));
5
-
| ---- ^^^^^^^^^^^^^^^^^^^^^^^ `core::fmt::rt::Opaque` cannot be shared between threads safely
5
+
| ---- ^^^^^^^^^^^^^^^^^^^^^^^ `Arguments<'_>` cannot be sent between threads safely
6
6
| |
7
7
| required by a bound introduced by this call
8
8
|
9
-
= help: within `[core::fmt::rt::Argument<'_>]`, the trait `Sync` is not implemented for `core::fmt::rt::Opaque`, which is required by `Arguments<'_>: Send`
10
-
= note: required because it appears within the type `&core::fmt::rt::Opaque`
11
-
note: required because it appears within the type `core::fmt::rt::ArgumentType<'_>`
12
-
--> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
13
-
note: required because it appears within the type `core::fmt::rt::Argument<'_>`
14
-
--> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
15
-
= note: required because it appears within the type `[core::fmt::rt::Argument<'_>]`
16
-
= note: required for `&[core::fmt::rt::Argument<'_>]` to implement `Send`
17
-
note: required because it appears within the type `Arguments<'_>`
18
-
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
9
+
= help: the trait `Send` is not implemented for `Arguments<'_>`
19
10
note: required by a bound in `send`
20
11
--> $DIR/send-sync.rs:1:12
21
12
|
22
13
LL | fn send<T: Send>(_: T) {}
23
14
| ^^^^ required by this bound in `send`
24
15
25
-
error[E0277]: `core::fmt::rt::Opaque` cannot be shared between threads safely
16
+
error[E0277]: `Arguments<'_>` cannot be shared between threads safely
26
17
--> $DIR/send-sync.rs:9:10
27
18
|
28
19
LL | sync(format_args!("{:?}", c));
29
-
| ---- ^^^^^^^^^^^^^^^^^^^^^^^ `core::fmt::rt::Opaque` cannot be shared between threads safely
20
+
| ---- ^^^^^^^^^^^^^^^^^^^^^^^ `Arguments<'_>` cannot be shared between threads safely
30
21
| |
31
22
| required by a bound introduced by this call
32
23
|
33
-
= help: within `Arguments<'_>`, the trait `Sync` is not implemented for `core::fmt::rt::Opaque`, which is required by `Arguments<'_>: Sync`
34
-
= note: required because it appears within the type `&core::fmt::rt::Opaque`
35
-
note: required because it appears within the type `core::fmt::rt::ArgumentType<'_>`
36
-
--> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
37
-
note: required because it appears within the type `core::fmt::rt::Argument<'_>`
38
-
--> $SRC_DIR/core/src/fmt/rt.rs:LL:COL
39
-
= note: required because it appears within the type `[core::fmt::rt::Argument<'_>]`
40
-
= note: required because it appears within the type `&[core::fmt::rt::Argument<'_>]`
41
-
note: required because it appears within the type `Arguments<'_>`
42
-
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
24
+
= help: the trait `Sync` is not implemented for `Arguments<'_>`
0 commit comments