Skip to content

Commit 52401ec

Browse files
committed
Auto merge of #143627 - matthiaskrgr:rollup-3elo6xo, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #134628 (Make `Default` const and add some `const Default` impls) - #143555 (Don't mark `#[target_feature]` safe fns as unsafe in rustdoc JSON.) - #143600 (Update intro blurb in `wasm32-wasip1` docs) - #143603 (Clarify the meaning of `AttributeOrder::KeepFirst` and `AttributeOrder::KeepLast`) - #143620 (fix: Remove newline from multiple crate versions note) - #143622 (Add target maintainer information for mips64-unknown-linux-muslabi64) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f838cbc + 612e0a3 commit 52401ec

File tree

8 files changed

+127
-29
lines changed

8 files changed

+127
-29
lines changed

compiler/rustc_attr_parsing/src/attributes/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,14 @@ impl<S: Stage> OnDuplicate<S> {
217217
// them will be merged in another PR
218218
#[allow(unused)]
219219
pub(crate) enum AttributeOrder {
220-
/// Duplicates after the first attribute will be an error.
220+
/// Duplicates after the first attribute will be an error. I.e. only keep the lowest attribute.
221+
///
222+
/// Attributes are processed from bottom to top, so this raises an error on all the attributes
223+
/// further above the lowest one:
224+
/// ```
225+
/// #[stable(since="1.0")] //~ WARNING duplicated attribute
226+
/// #[stable(since="2.0")]
227+
/// ```
221228
///
222229
/// This should be used where duplicates would be ignored, but carry extra
223230
/// meaning that could cause confusion. For example, `#[stable(since="1.0")]
@@ -227,6 +234,13 @@ pub(crate) enum AttributeOrder {
227234
/// Duplicates preceding the last instance of the attribute will be a
228235
/// warning, with a note that this will be an error in the future.
229236
///
237+
/// Attributes are processed from bottom to top, so this raises a warning on all the attributes
238+
/// below the higher one:
239+
/// ```
240+
/// #[path="foo.rs"]
241+
/// #[path="bar.rs"] //~ WARNING duplicated attribute
242+
/// ```
243+
///
230244
/// This is the same as `FutureWarnFollowing`, except the last attribute is
231245
/// the one that is "used". Ideally these can eventually migrate to
232246
/// `ErrorPreceding`.

compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
19331933
StringPart::highlighted("multiple different versions".to_string()),
19341934
StringPart::normal(" of crate `".to_string()),
19351935
StringPart::highlighted(format!("{crate_name}")),
1936-
StringPart::normal("` in the dependency graph\n".to_string()),
1936+
StringPart::normal("` in the dependency graph".to_string()),
19371937
],
19381938
);
19391939
if points_at_type {

src/doc/rustc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
- [m68k-unknown-linux-gnu](platform-support/m68k-unknown-linux-gnu.md)
8484
- [m68k-unknown-none-elf](platform-support/m68k-unknown-none-elf.md)
8585
- [mips64-openwrt-linux-musl](platform-support/mips64-openwrt-linux-musl.md)
86+
- [mips64-unknown-linux-muslabi64](platform-support/mips64-unknown-linux-muslabi64.md)
8687
- [mipsel-sony-psx](platform-support/mipsel-sony-psx.md)
8788
- [mipsel-unknown-linux-gnu](platform-support/mipsel-unknown-linux-gnu.md)
8889
- [mips\*-mti-none-elf](platform-support/mips-mti-none-elf.md)

src/doc/rustc/src/platform-support.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ target | std | host | notes
333333
`mips-unknown-linux-uclibc` | ✓ | | MIPS Linux with uClibc
334334
[`mips64-openwrt-linux-musl`](platform-support/mips64-openwrt-linux-musl.md) | ? | | MIPS64 for OpenWrt Linux musl 1.2.3
335335
`mips64-unknown-linux-gnuabi64` | ✓ | ✓ | MIPS64 Linux, N64 ABI (kernel 4.4, glibc 2.23)
336-
`mips64-unknown-linux-muslabi64` | ✓ | | MIPS64 Linux, N64 ABI, musl 1.2.3
336+
[`mips64-unknown-linux-muslabi64`](platform-support/mips64-unknown-linux-muslabi64.md) | ✓ | | MIPS64 Linux, N64 ABI, musl 1.2.3
337337
`mips64el-unknown-linux-gnuabi64` | ✓ | ✓ | MIPS64 (little endian) Linux, N64 ABI (kernel 4.4, glibc 2.23)
338338
`mips64el-unknown-linux-muslabi64` | ✓ | | MIPS64 (little endian) Linux, N64 ABI, musl 1.2.3
339339
`mipsel-sony-psp` | * | | MIPS (LE) Sony PlayStation Portable (PSP)
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# mips64-unknown-linux-muslabi64
2+
3+
**Tier: 3**
4+
5+
Target for 64-bit big endian MIPS Linux programs using musl libc and the N64 ABI.
6+
7+
## Target maintainers
8+
9+
[@Gelbpunkt](https://github.com/Gelbpunkt)
10+
11+
## Requirements
12+
13+
Building the target itself requires a 64-bit big endian MIPS compiler that is
14+
supported by `cc-rs`.
15+
16+
## Building the target
17+
18+
The target can be built by enabling it for a `rustc` build.
19+
20+
```toml
21+
[build]
22+
target = ["mips64-unknown-linux-muslabi64"]
23+
```
24+
25+
Make sure your C compiler is included in `$PATH`, then add it to the
26+
`bootstrap.toml`:
27+
28+
```toml
29+
[target.mips64-unknown-linux-muslabi64]
30+
cc = "mips64-linux-musl-gcc"
31+
cxx = "mips64-linux-musl-g++"
32+
ar = "mips64-linux-musl-ar"
33+
linker = "mips64-linux-musl-gcc"
34+
```
35+
36+
## Building Rust programs
37+
38+
Rust does not yet ship pre-compiled artifacts for this target. To compile for
39+
this target, you will first need to build Rust with the target enabled (see
40+
"Building the target" above).
41+
42+
## Cross-compilation
43+
44+
This target can be cross-compiled from any host.
45+
46+
## Testing
47+
48+
This target can be tested as normal with `x.py` on a 64-bit big endian MIPS
49+
host or via QEMU emulation.

src/doc/rustc/src/platform-support/wasm32-wasip1.md

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,35 @@
44

55
The `wasm32-wasip1` target is a WebAssembly compilation target which
66
assumes that the [WASIp1] (aka "WASI preview1") set of "syscalls" are available
7-
for use in the standard library. Historically this target in the Rust compiler
8-
was one of the first for WebAssembly where Rust and C code are explicitly
9-
intended to interoperate as well.
10-
11-
There's a bit of history to the target and current development which is also
12-
worth explaining before going much further. Historically this target was
13-
originally called `wasm32-wasi` in both rustc and Clang. This was first added
14-
to Rust in 2019. In the intervening years leading up to 2024 the WASI standard
15-
continued to be developed and was eventually "rebased" on top of the [Component
16-
Model]. This was a large change to the WASI specification and was released as
17-
0.2.0 ("WASIp2" colloquially) in January 2024. The previous target's name in
18-
rustc, `wasm32-wasi`, was then renamed to `wasm32-wasip1`, to avoid
19-
confusion with this new target to be added to rustc as `wasm32-wasip2`.
20-
Some more context can be found in these MCPs:
21-
22-
* [Rename wasm32-wasi target to wasm32-wasip1](https://github.com/rust-lang/compiler-team/issues/607)
23-
* [Smooth the renaming transition of wasm32-wasi](https://github.com/rust-lang/compiler-team/issues/695)
24-
25-
At this point the `wasm32-wasip1` target is intended for historical
26-
compatibility with the first version of the WASI standard. As of now (January
27-
2024) the 0.2.0 target of WASI ("WASIp2") is relatively new. The state of
28-
WASI will likely change in few years after which point this documentation will
29-
probably receive another update.
30-
31-
[WASI Preview1]: https://github.com/WebAssembly/WASI/tree/main/legacy/preview1
7+
for use in the standard library. This target explicitly supports interop with
8+
non-Rust code such as C and C++.
9+
10+
The [WASIp1] set of syscalls is standard insofar as it was written down once by
11+
a set of folks and has not changed since then. Additionally the [WASIp1]
12+
syscalls have been adapted and adopted into a number of runtimes and embeddings.
13+
It is not standard in the sense that there are no formal semantics for each
14+
syscall and APIs are no longer receiving any maintenance (e.g. no new APIs, no
15+
new documentation, etc). After [WASIp1] was originally developed in 2019 the
16+
WASI standard effort has since been "rebased" on top of the [Component Model].
17+
This was a large change to the WASI specification and was released as 0.2.0
18+
("WASIp2" colloquially) in January 2024. Current standardization efforts are
19+
focused on the Component Model-based definition of WASI. At this point the
20+
`wasm32-wasip1` Rust target is intended for historical compatibility with
21+
[WASIp1] set of syscalls.
22+
23+
[WASIp1]: https://github.com/WebAssembly/WASI/tree/main/legacy/preview1
3224
[Component Model]: https://github.com/webassembly/component-model
3325

3426
Today the `wasm32-wasip1` target will generate core WebAssembly modules
3527
which will import functions from the `wasi_snapshot_preview1` module for
3628
OS-related functionality (e.g. printing).
3729

30+
> **Note**: Prior to March 2024 this target was known as `wasm32-wasi` with some
31+
> historical context found in old MCPs:
32+
>
33+
> * [Rename wasm32-wasi target to wasm32-wasip1](https://github.com/rust-lang/compiler-team/issues/607)
34+
> * [Smooth the renaming transition of wasm32-wasi](https://github.com/rust-lang/compiler-team/issues/695)
35+
3836
## Target maintainers
3937

4038
When this target was added to the compiler platform-specific documentation here

src/librustdoc/json/conversions.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_ast::ast;
77
use rustc_attr_data_structures::{self as attrs, DeprecatedSince};
88
use rustc_hir::def::CtorKind;
99
use rustc_hir::def_id::DefId;
10+
use rustc_hir::{HeaderSafety, Safety};
1011
use rustc_metadata::rendered_const;
1112
use rustc_middle::{bug, ty};
1213
use rustc_span::{Pos, kw, sym};
@@ -381,10 +382,22 @@ impl FromClean<clean::Union> for Union {
381382

382383
impl FromClean<rustc_hir::FnHeader> for FunctionHeader {
383384
fn from_clean(header: &rustc_hir::FnHeader, renderer: &JsonRenderer<'_>) -> Self {
385+
let is_unsafe = match header.safety {
386+
HeaderSafety::SafeTargetFeatures => {
387+
// The type system's internal implementation details consider
388+
// safe functions with the `#[target_feature]` attribute to be analogous
389+
// to unsafe functions: `header.is_unsafe()` returns `true` for them.
390+
// For rustdoc, this isn't the right decision, so we explicitly return `false`.
391+
// Context: https://github.com/rust-lang/rust/issues/142655
392+
false
393+
}
394+
HeaderSafety::Normal(Safety::Safe) => false,
395+
HeaderSafety::Normal(Safety::Unsafe) => true,
396+
};
384397
FunctionHeader {
385398
is_async: header.is_async(),
386399
is_const: header.is_const(),
387-
is_unsafe: header.is_unsafe(),
400+
is_unsafe,
388401
abi: header.abi.into_json(renderer),
389402
}
390403
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
11
//@ only-x86_64
22

33
//@ is "$.index[?(@.name=='test1')].attrs" '["#[target_feature(enable=\"avx\")]"]'
4+
//@ is "$.index[?(@.name=='test1')].inner.function.header.is_unsafe" false
45
#[target_feature(enable = "avx")]
56
pub fn test1() {}
67

78
//@ is "$.index[?(@.name=='test2')].attrs" '["#[target_feature(enable=\"avx\", enable=\"avx2\")]"]'
9+
//@ is "$.index[?(@.name=='test1')].inner.function.header.is_unsafe" false
810
#[target_feature(enable = "avx,avx2")]
911
pub fn test2() {}
1012

1113
//@ is "$.index[?(@.name=='test3')].attrs" '["#[target_feature(enable=\"avx\", enable=\"avx2\")]"]'
14+
//@ is "$.index[?(@.name=='test1')].inner.function.header.is_unsafe" false
1215
#[target_feature(enable = "avx", enable = "avx2")]
1316
pub fn test3() {}
1417

1518
//@ is "$.index[?(@.name=='test4')].attrs" '["#[target_feature(enable=\"avx\", enable=\"avx2\", enable=\"avx512f\")]"]'
19+
//@ is "$.index[?(@.name=='test1')].inner.function.header.is_unsafe" false
1620
#[target_feature(enable = "avx", enable = "avx2,avx512f")]
1721
pub fn test4() {}
22+
23+
//@ is "$.index[?(@.name=='test_unsafe_fn')].attrs" '["#[target_feature(enable=\"avx\")]"]'
24+
//@ is "$.index[?(@.name=='test_unsafe_fn')].inner.function.header.is_unsafe" true
25+
#[target_feature(enable = "avx")]
26+
pub unsafe fn test_unsafe_fn() {}
27+
28+
pub struct Example;
29+
30+
impl Example {
31+
//@ is "$.index[?(@.name=='safe_assoc_fn')].attrs" '["#[target_feature(enable=\"avx\")]"]'
32+
//@ is "$.index[?(@.name=='safe_assoc_fn')].inner.function.header.is_unsafe" false
33+
#[target_feature(enable = "avx")]
34+
pub fn safe_assoc_fn() {}
35+
36+
//@ is "$.index[?(@.name=='unsafe_assoc_fn')].attrs" '["#[target_feature(enable=\"avx\")]"]'
37+
//@ is "$.index[?(@.name=='unsafe_assoc_fn')].inner.function.header.is_unsafe" true
38+
#[target_feature(enable = "avx")]
39+
pub unsafe fn unsafe_assoc_fn() {}
40+
}

0 commit comments

Comments
 (0)