"cargo fmt" works fine but "rustfmt" fails to format some files.
$ rustfmt crates/ide-db/src/search.rs
error: let chains are only allowed in Rust 2024 or later
--> /home/johannes/git/rust-analyzer/crates/ide-db/src/search.rs:298:12
|
298 | if let &Definition::Module(module) = self
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I guess I could work around this by setting my format command to
"cargo fmt -- $filename" instead of "rustfmt $filename".
But it'd be nice if this worked OOTB. Make it so by adding specifying
the edition in rustfmt.toml. We already have several other places
specifying the edition.
changelog internal
I had a test I was confused by; the root issue is that `error-pattern`
runs before normalization, even though `//~ ERROR` runs after
normalization. This logging caught the issue immediately.
Add TidyFlags and merge DiagCtx
Adds a struct `TidyFlags` and merges it with `DiagCtx` into `TidyCtx`. Removes the need to pass `bless` into individual check functions in tidy.
Document MaybeUninit bit validity
Partially addresses https://github.com/rust-lang/unsafe-code-guidelines/issues/555 by clarifying that it is sound to write any byte values (initialized or uninitialized) to any `MaybeUninit<T>` regardless of `T`.
r? `@RalfJung`
Revert constification of `AsRef for Cow` due to inference failure
Reported issue: rust-lang/rust#147964
Original PR: rust-lang/rust#145279
`const AsRef` tracking issue: rust-lang/rust#143773
Should have additional crater run to verify this fixes the issue.
Add `String::replace_first` and `String::replace_last`
Rebase of #97977 (cc `@WilliamVenner)`
> Convenience methods that use `match_indices` and `replace_range` to efficiently replace a substring in a string without reallocating, if capacity (and the implementation of `Vec::splice`) allows.
The intra-doc link to `str::replacen` is a direct url-based link to `str::replacen` in `std`'s docs to work around #98941. This means that when building only `alloc`'s docs (and not `std`'s), it will be a broken link. There is precedent for this e.g. in [`core::hint::spin_loop`](https://doc.rust-lang.org/nightly/src/core/hint.rs.html#214) which links to `std:🧵:yield_now` using a [url-based link](https://github.com/rust-lang/rust/blob/master/library/core/src/hint.rs#L265) and thus is a dead link when only building `core`'s docs.
ACP: https://github.com/rust-lang/libs-team/issues/506
fix: Don't add diff symbol to unchanged lines
When rendering a "multi-line" suggestion with the [`Diff`](dc1feabef2/compiler/rustc_errors/src/emitter.rs (L3078)) format, `rustc` uses a [diff symbol](dc1feabef2/compiler/rustc_errors/src/emitter.rs (L3017-L3022)) for
[any line that has a highlight part](dc1feabef2/compiler/rustc_errors/src/emitter.rs (L2705-L2713)). This includes highlight parts that are highlighting nothing, i.e., a span of `0..0`. This leads `rustc` to add a diff symbol unnecessarily to lines that have no changes and are not highlighted. This PR makes it so that `rustc` will not add a diff symbol to lines that contain no changes/highlights.
Note: This PR is part of my ongoing effort to have `rustc` use `annotate-snippets` for rendering. This change will make it so that `rustc` and `annotate-snippets` will match in this case.
feat(rustdoc): `--emit=depinfo` output to stdout via `-`
rustdoc's `--emit=depinfo` flag now supports using `-` to write the output to stdout,
aligning with rustc's behavior.
This will fix <https://github.com/rust-lang/rust/issues/147649>.
### How to review
* The first commit demonstrates that `rustdoc --emit=depinfo=-` hasn't yet supported emitting to stdout.
* The second implements it and the diff shows how the behavior changes.
std: reorganize the UNIX-internal `weak` module
This moves the `dlsym`-based and weak-linkage versions of the `weak!` macro into separate files, both of which include a common test file. As a result, both versions will be tested on all the platforms where they are used.
Since the `#[link_name]` arm of the `dlsym` version was unused, I've removed it. I've also removed the unused `raw_syscall!` and non-Linux `syscall!` macros and gated the `#[allow(dead_code, unused_macros)]` to only apply on non-Linux platforms, so compilation will fail if `weak` turns out to be unused on all platforms.
The last change concerns the use of `dlsym!` on FreeBSD: it is only used once, to link against `sysctlbyname`. But that symbol is always available, so there is no need for weak linkage.