Commit Graph

225051 Commits

Author SHA1 Message Date
Ramon de C Valle
faf31b5052 CFI: Fix cfi with repr(transparent): transform_ty: unexpected Alias(Proj
Fixes #111185 by normalizing ty::Alias before encoding.
2023-06-01 19:56:36 +00:00
bors
a9251b6ce1 Auto merge of #112102 - Nilstrieb:rollup-ivu1hmc, r=Nilstrieb
Rollup of 7 pull requests

Successful merges:

 - #107916 (fix comment on Allocator trait)
 - #111543 (Uplift `clippy::invalid_utf8_in_unchecked` lint)
 - #111872 (fix: dedup `static_candidates` before report)
 - #111955 (bootstrap: Various Step refactors)
 - #112060 (`EarlyBinder::new` -> `EarlyBinder::bind`)
 - #112064 (Migrate GUI colors test to original CSS color format)
 - #112100 (Don't typecheck recovered method call from suggestion)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-30 13:25:42 +00:00
Nilstrieb
cc121828ee
Rollup merge of #112100 - jieyouxu:issue-106929, r=oli-obk
Don't typecheck recovered method call from suggestion

Only make the use-dot-operator-to-call-method suggestion, but do not double down and use the recovered type to perform method call typechecking as it will produce confusing diagnostics relevant for the *fixed* code.

### Code Sample

```rust
struct Client;

impl Client {
    fn post<T: std::ops::Add>(&self, _: T, _: T) {}
}

fn f() {
    let c = Client;
    post(c, ());
}
```

### Before This PR

```
error[[E0277]](https://doc.rust-lang.org/stable/error_codes/E0277.html): cannot add `()` to `()`
 --> src/lib.rs:9:5
  |
9 |     post(c, ());
  |     ^^^^^^^^^^^ no implementation for `() + ()`
  |
  = help: the trait `Add` is not implemented for `()`
note: required by a bound in `Client::post`
 --> src/lib.rs:4:16
  |
4 |     fn post<T: std::ops::Add>(&self, _: T, _: T) {}
  |                ^^^^^^^^^^^^^ required by this bound in `Client::post`

error[[E0061]](https://doc.rust-lang.org/stable/error_codes/E0061.html): this function takes 2 arguments but 1 argument was supplied
 --> src/lib.rs:9:5
  |
9 |     post(c, ());
  |     ^^^^ an argument of type `()` is missing
  |
note: method defined here
 --> src/lib.rs:4:8
  |
4 |     fn post<T: std::ops::Add>(&self, _: T, _: T) {}
  |        ^^^^                   -----  ----  ----
help: provide the argument
  |
9 |     post((), ())(c, ());
  |         ++++++++

error[[E0425]](https://doc.rust-lang.org/stable/error_codes/E0425.html): cannot find function `post` in this scope
 --> src/lib.rs:9:5
  |
9 |     post(c, ());
  |     ^^^^ not found in this scope
  |
help: use the `.` operator to call the method `post` on `&Client`
  |
9 -     post(c, ());
9 +     c.post(());
  |

Some errors have detailed explanations: E0061, E0277, E0425.
For more information about an error, try `rustc --explain E0061`.
```

### After This PR

```
error[E0425]: cannot find function `post` in this scope
 --> tests/ui/typeck/issue-106929.rs:9:5
  |
9 |     post(c, ());
  |     ^^^^ not found in this scope
  |
help: use the `.` operator to call the method `post` on `&Client`
  |
9 -     post(c, ());
9 +     c.post(());
  |

error: aborting due to previous error

For more information about this error, try `rustc --explain E0425`.
```

Fixes #106929.
2023-05-30 12:57:41 +02:00
Nilstrieb
f4b20dac81
Rollup merge of #112064 - GuillaumeGomez:migrate-gui-test-color-9, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

The `browser-ui-test` update is a fix when converting the alpha value to hex format. More information [here](https://github.com/GuillaumeGomez/browser-UI-test/pull/511).

r? ````@notriddle````
2023-05-30 12:57:40 +02:00
Nilstrieb
e7fdba84e2
Rollup merge of #112060 - lcnr:early-binder, r=jackh726
`EarlyBinder::new` -> `EarlyBinder::bind`

for consistency with `Binder::bind`. it may make sense to also add `EarlyBinder::dummy` in places where we know that no parameters exist, but I left that out of this PR.

r? `@jackh726` `@kylematsuda`
2023-05-30 12:57:40 +02:00
Nilstrieb
65833eddb7
Rollup merge of #111955 - jyn514:step-refactors, r=clubby789
bootstrap: Various Step refactors

This ended up being a bunch of only somewhat related changes, sorry 😓 on the bright side, they're all fairly small  and well-commented in the commit messages.

- Document `ShouldRun::crates`

- Switch Steps from crates to crate_or_deps where possible

    and document why the single remaining place can't switch

- Switch doc::{Std, Rustc} to `crate_or_deps`

    Previously they were using `all_krates` and various hacks to determine
    which crates to document. Switch them to `crate_or_deps` so `ShouldRun`
    tells them which crate to document instead of having to guess.

    This also makes a few other refactors:
    - Remove the now unused `all_krates`; new code should only use
      `crate_or_deps`.
    - Add tests for documenting Std
    - Remove the unnecessary `run_cargo_rustdoc_for` closure so that we only
      run cargo once
    - Give a more helpful error message when documenting a no_std target
    - Use `builder.msg` in the Steps instead of `builder.info`

- Extend `msg` and `description` to work with any subcommand

    Previously `description` only supported `Testing` and `Benchmarking`,
    and `msg` gave weird results for `doc` (it would say `Docing`).

- Add a `make_run_crates` function and use it Rustc and Std

    This fixes the panic from the previous commit.

- Allow checking individual crates

    This is useful for profiling metadata generation.

    This comes very close to removing all_krates, but doesn't quite -
    there's one last usage left in `doc`. This is fixed in a later commit.

- Give a more helpful error when calling `cargo_crates_in_set` for an alias

    Before:
    ```
    thread 'main' panicked at 'no entry found for key', builder.rs:110:30
    ```

    After:
    ```
    thread 'main' panicked at 'missing crate for path library', check.rs:89:26
    ```
2023-05-30 12:57:39 +02:00
Nilstrieb
0c9f87c986
Rollup merge of #111872 - bvanjoi:fix-103646, r=cjgillot
fix: dedup `static_candidates` before report

Fixes https://github.com/rust-lang/rust/issues/103646

`record_static_candidate` had been executed twice, resulting in the presence of two identical `CandidateSource::Trait(Cat)`  in static_candidates. This PR aims to deduplication the `static_candidates` list, allowing it to execute `suggest_associated_call_syntax` properly.
2023-05-30 12:57:39 +02:00
Nilstrieb
7a4006cc52
Rollup merge of #111543 - Urgau:uplift_invalid_utf8_in_unchecked, r=WaffleLapkin
Uplift `clippy::invalid_utf8_in_unchecked` lint

This PR aims at uplifting the `clippy::invalid_utf8_in_unchecked` lint into two lints.

## `invalid_from_utf8_unchecked`

(deny-by-default)

The `invalid_from_utf8_unchecked` lint checks for calls to `std::str::from_utf8_unchecked` and `std::str::from_utf8_unchecked_mut` with an invalid UTF-8 literal.

### Example

```rust
unsafe {
    std::str::from_utf8_unchecked(b"cl\x82ippy");
}
```

### Explanation

Creating such a `str` would result in undefined behavior as per documentation for `std::str::from_utf8_unchecked` and `std::str::from_utf8_unchecked_mut`.

## `invalid_from_utf8`

(warn-by-default)

The `invalid_from_utf8` lint checks for calls to `std::str::from_utf8` and `std::str::from_utf8_mut` with an invalid UTF-8 literal.

### Example

```rust
std::str::from_utf8(b"ru\x82st");
```

### Explanation

Trying to create such a `str` would always return an error as per documentation for `std::str::from_utf8` and `std::str::from_utf8_mut`.

-----

Mostly followed the instructions for uplifting a clippy lint described here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751

````@rustbot```` label: +I-lang-nominated
r? compiler

-----

For Clippy:

changelog: Moves: Uplifted `clippy::invalid_utf8_in_unchecked` into rustc
2023-05-30 12:57:38 +02:00
Nilstrieb
18c9baf4fe
Rollup merge of #107916 - reez12g:issue-107040, r=Amanieu
fix comment on Allocator trait

fixes https://github.com/rust-lang/rust/issues/107040
2023-05-30 12:57:38 +02:00
bors
3266c36624 Auto merge of #111768 - oli-obk:pair_const_llvm, r=cjgillot
Optimize scalar and scalar pair representations loaded from ByRef in llvm

in https://github.com/rust-lang/rust/pull/105653 I noticed that we were generating suboptimal LLVM IR if we had a `ConstValue::ByRef` that could be represented by a `ScalarPair`. Before https://github.com/rust-lang/rust/pull/105653 this is probably rare, but after it, every slice will go down this suboptimal code path that requires LLVM to untangle a bunch of indirections and translate static allocations that are only used once to read a scalar pair from.
2023-05-30 10:31:10 +00:00
许杰友 Jieyou Xu (Joe)
e11ffb62df
Don't typecheck suggested method call
Only make the use-dot-operator-to-call-method suggestion, but do not
double down and use the recovered type to perform method call
typechecking as it will produce confusing diagnostics on the "fixed"
code.
2023-05-30 17:57:37 +08:00
bors
578bcbc2b4 Auto merge of #112083 - scottmcm:simpler-range-next, r=thomcc
Make `TrustedStep` require `Copy`

All the implementations of the trait already are `Copy`, and this seems to be enough to simplify the implementations enough to make the MIR inliner willing to inline basics like `Range::next`.

r? `@thomcc`
2023-05-30 07:27:05 +00:00
reez12g
000cd9b5fb fix comment on Allocator trait 2023-05-30 13:56:57 +09:00
bors
45eec0fe93 Auto merge of #112075 - WaffleLapkin:unmkII, r=lcnr
Replace `tcx.mk_re_*` with `Region::new_*`

Second step in implementing https://github.com/rust-lang/compiler-team/issues/616
r? `@lcnr`
2023-05-30 04:26:59 +00:00
bors
165cddafe9 Auto merge of #111989 - klensy:deps-up-26-05-23, r=Mark-Simulacrum
deps: bump crates

Updates few deps:

drops a lot of cxx* crates:
```console
$ cargo update -p iana-time-zone-haiku
    Updating crates.io index
    Updating cc v1.0.77 -> v1.0.79
    Removing codespan-reporting v0.11.1
    Removing cxx v1.0.94
    Removing cxx-build v1.0.94
    Removing cxxbridge-flags v1.0.94
    Removing cxxbridge-macro v1.0.94
    Updating iana-time-zone-haiku v0.1.1 -> v0.1.2
    Removing link-cplusplus v1.0.8
    Removing scratch v1.0.5
```
cc: https://github.com/rust-lang/cc-rs/releases/tag/1.0.78, https://github.com/rust-lang/cc-rs/releases/tag/1.0.79
iana-time-zone-haiku: https://github.com/strawlab/iana-time-zone/releases/tag/haiku%2Fv0.1.2

fixed https://github.com/crossbeam-rs/crossbeam/pull/972 (similar fixed in rust repo https://github.com/rust-lang/rust/pull/110089)
```console
$ cargo update -p crossbeam-channel
    Updating crates.io index
    Updating crossbeam-channel v0.5.6 -> v0.5.8
```
https://github.com/crossbeam-rs/crossbeam/blob/master/crossbeam-channel/CHANGELOG.md#version-058

dedupes memoffset versions:
```console
$ cargo update -p crossbeam-epoch
    Updating crates.io index
    Updating crossbeam-epoch v0.9.13 -> v0.9.14
    Removing memoffset v0.7.1
```
https://github.com/crossbeam-rs/crossbeam/blob/master/crossbeam-epoch/CHANGELOG.md#version-0914
https://github.com/Gilnaa/memoffset/compare/v0.6.5...v0.8.0
https://github.com/rust-lang/rust/pull/108638#discussion_r1193157265

dedupes bstr versions
```console
$ cargo update -p ignore -p opener
    Updating crates.io index
    Removing bstr v0.2.17
    Updating globset v0.4.9 -> v0.4.10
    Updating ignore v0.4.18 -> v0.4.20
    Updating opener v0.5.0 -> v0.5.2
```

globset ac8fecbbf2
ignore https://github.com/BurntSushi/ripgrep/commits/master/crates/ignore hard to track, but drop dep on crossbeam-utils (e95254a86f), don't stat git if require_git is false (009dda1488) and added bunch of formats to ignore list
opener https://github.com/Seeker14491/opener/compare/v0.5.0...v0.5.2 nothing interesting
2023-05-30 01:28:54 +00:00
bors
d9a4d5eca3 Auto merge of #112080 - matthiaskrgr:rollup-pmpbe49, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - #111558 (Move tests)
 - #111827 (Add build instructions for cranelift backend as part of Rust repo)
 - #111988 (Make `TyKind: Debug` have less verbose output)
 - #112022 (Check nested obligations during coercion unify in new solver)
 - #112057 (Suggest correct `self_ty`)
 - #112063 (Add a test for issue 110457/incremental ICE with closures with the same span)

Failed merges:

 - #112068 (Move tests from `ui/discrim` dir)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-29 22:36:23 +00:00
Scott McMurray
50e01f4d68 Update a MIRI fake-time test that this makes "faster" 2023-05-29 13:57:18 -07:00
Scott McMurray
11fa1764ee Make TrustedStep require Copy
All the implementations of the trait already are `Copy`, and this seems to be enough to simplify the implementations enough to make the MIR inliner willing to inline basics like `Range::next`.
2023-05-29 13:19:47 -07:00
Matthias Krüger
36526cf657
Rollup merge of #112063 - WaffleLapkin:test_incremental_ice, r=cjgillot
Add a test for issue 110457/incremental ICE with closures with the same span

Closes #110457

It's probably possible to minimize the test case more, considering that we now know the underlying reason for the ICE, but I didn't.

r? `@cjgillot`
2023-05-29 21:34:18 +02:00
Matthias Krüger
880da380f1
Rollup merge of #112057 - MU001999:fix/self-sugg, r=compiler-errors
Suggest correct `self_ty`

Fixes #112036
2023-05-29 21:34:18 +02:00
Matthias Krüger
ef9a681183
Rollup merge of #112022 - compiler-errors:coercion-check-deep, r=lcnr
Check nested obligations during coercion unify in new solver

Found when triaging failing opaque tests with new solver.

r? `@lcnr`
2023-05-29 21:34:17 +02:00
Matthias Krüger
9f83e56f0d
Rollup merge of #111988 - BoxyUwU:make_tykind_debug_good, r=compiler-errors
Make `TyKind: Debug` have less verbose output

Current `TyKind: Debug` impl is basically unusable for debugging, its too verbose even for verbose debugging 🤣 This PR replaces the debug logic for `TyKind` with a more manual debug impl instead of a hand expanded derived impl. This should help make #107084 more reasonable to land since the output of `Ty: Debug` will be better.

This isn't a fully completed change to the `Debug` impl of `TyKind` as there's still logic from the derive macro for some variants. Some of the variants are also not consisten with the `-Zverbose` printing of `Ty`, ideally `-Zverbose` printing of `Ty` would also just defer to the debug impl instead of having lots of checks in pretty printing. I plan on fixing this in follow up PRs since it seems tricky to do in this one and its already a large PR 😅
2023-05-29 21:34:17 +02:00
Matthias Krüger
3fead07491
Rollup merge of #111827 - AngelicosPhosphoros:add_docs_to_cranelift, r=bjorn3
Add build instructions for cranelift backend as part of Rust repo

All other instructions assume that user works with separate repository than Rust compiler repository. When one follows default instructions, cranelift codegen tries to use different sys-root and compiler internal crates which leads to compiler errors when building it.

I needed to do all this steps while adding new intrinsic to rustc.

r? bjorn3
2023-05-29 21:34:16 +02:00
Matthias Krüger
9e47e90071
Rollup merge of #111558 - c410-f3r:t3st3ss, r=WaffleLapkin
Move tests

r? `@petrochenkov`
2023-05-29 21:34:16 +02:00
jyn
c28ee603c8 Fix bugs in doc refactor
- Switch from `cargo rustdoc` to `cargo doc`

  This allows passing `-p` to multiple packages.

- Remove `OsStr` support

  It doesn't work with RUSTDOCFLAGS, and we don't support non-utf8 paths
  anyway.

- Pass `-p std` for each crate in the standard library

  By default cargo only documents the top-level crate, which is
  `sysroot` and has no docs.
2023-05-29 13:26:44 -05:00
jyn
71770d5e6e Document ShouldRun::paths 2023-05-29 13:26:44 -05:00
jyn
3e765a7f71 Switch Steps from crates to crate_or_deps where possible
and document why the single remaining place can't switch
2023-05-29 13:26:44 -05:00
jyn
58e18ddf86 Switch doc::{Std, Rustc} to crate_or_deps
Previously they were using `all_krates` and various hacks to determine
which crates to document. Switch them to `crate_or_deps` so `ShouldRun`
tells them which crate to document instead of having to guess.

This also makes a few other refactors:
- Remove the now unused `all_krates`; new code should only use
  `crate_or_deps`.
- Add tests for documenting Std
- Remove the unnecessary `run_cargo_rustdoc_for` closure so that we only
  run cargo once
- Give a more helpful error message when documenting a no_std target
- Use `builder.msg` in the Steps instead of `builder.info`
2023-05-29 13:26:44 -05:00
jyn
cb4b7f6319 Extend msg and description to work with any subcommand
Previously `description` only supported `Testing` and `Benchmarking`,
and `msg` gave weird results for `doc` (it would say `Docing`).
2023-05-29 13:26:44 -05:00
jyn
20372f1817 Add a make_run_crates function and use it Rustc and Std
This fixes the panic from the previous commit.
2023-05-29 13:26:44 -05:00
jyn
564e3adfdf Allow checking individual crates
This is useful for profiling metadata generation.

This comes very close to removing all_krates, but doesn't quite -
there's one last usage left in `doc`.
2023-05-29 13:26:44 -05:00
jyn
c571558fd9 Give a more helpful error when calling cargo_crates_in_set for an alias
Before:
```
thread 'main' panicked at 'no entry found for key', builder.rs:110:30
```

After:
```
thread 'main' panicked at 'missing crate for path library', check.rs:89:26
```
2023-05-29 13:24:14 -05:00
Maybe Waffle
e33e20824f Rename tcx.mk_re_* => Region::new_* 2023-05-29 17:54:53 +00:00
Caio
c62d49e75e Address comment 2023-05-29 12:07:41 -03:00
Guillaume Gomez
17e3d1cd4a Migrate GUI colors test to original CSS color format 2023-05-29 16:03:56 +02:00
Guillaume Gomez
f333932ba8 Update browser-ui-test version to 0.16.5 2023-05-29 15:59:45 +02:00
Maybe Waffle
8d406b8459 Add a test for issue 110457 2023-05-29 13:49:20 +00:00
bors
498553fc04 Auto merge of #111235 - loongarch-rs:stabilize-asm, r=Amanieu
Stabilize inline asm for LoongArch64

This PR is used to tracking for stabilize `inline asm` for LoongArch64.

**Status**

- [x] https://github.com/rust-lang/rust/pull/111237
- [x] https://github.com/rust-lang/rust/pull/111332
- [ ] https://github.com/rust-lang/reference/pull/1357

Any others I missed?

r? `@Amanieu`
2023-05-29 13:31:53 +00:00
lcnr
08d149ca85 EarlyBinder::new -> EarlyBinder::bind 2023-05-29 13:46:10 +02:00
bors
99ff5afeb8 Auto merge of #111329 - jyn514:metadata-ice, r=bjorn3
Load only the crate header for `locator::crate_matches`

Previously, we used the following info to determine whether to load the crate:
1. The METADATA_HEADER, which includes a METADATA_VERSION constant
2. The embedded rustc version
3. Various metadata in the `CrateRoot`, including the SVH

This worked ok most of the time. Unfortunately, when building locally the rustc version is always
the same because `omit-git-hash` is on by default. That meant that we depended only on 1 and 3, and
we are not very good about bumping METADATA_VERSION (it's currently at 7) so in practice we were
only depending on 3. `CrateRoot` is a very large struct and changes somewhat regularly, so this led
to a steady stream of crashes from trying to load it.

Change the logic to add an intermediate step between 2 and 3: introduce a new `CrateHeader` struct
that contains only the minimum info needed to decide whether the crate should be loaded or not. That
avoids having to load all of `CrateRoot`, which in practice means we should crash much less often.

Note that this works because the SVH should be different between any two dependencies, even if the
compiler has changed, because we use `-Zbinary-dep-depinfo` in bootstrap. See
https://github.com/rust-lang/rust/pull/111329#issuecomment-1538303474 for more details about how the
original crash happened.
2023-05-29 10:40:32 +00:00
bors
70e04bd88d Auto merge of #111748 - nnethercote:Cow-DiagnosticMessage, r=WaffleLapkin
Use `Cow` in `{D,Subd}iagnosticMessage`.

Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment:
```
// FIXME(davidtwco): can a `Cow<'static, str>` be used here?
```
This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging.

This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths.

Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile.

r? `@WaffleLapkin`
2023-05-29 07:10:44 +00:00
mu001999
2f65aac667 Determine self_ty with expected ty 2023-05-29 12:26:27 +08:00
bors
dc0943d2ee Auto merge of #112055 - matthiaskrgr:rollup-y3exx8c, r=matthiaskrgr
Rollup of 5 pull requests

Successful merges:

 - #112029 (Recover upon mistyped error on typo'd `const` in const param def)
 - #112037 (Add details about `unsafe_op_in_unsafe_fn` to E0133)
 - #112039 (compiler: update solaris/illumos to enable tsan support.)
 - #112042 (Migrate GUI colors test to original CSS color format)
 - #112045 (Followup to #111973)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-05-29 03:04:06 +00:00
Matthias Krüger
e71b3b3cfa
Rollup merge of #112045 - Sp00ph:update_current_impl, r=Amanieu
Followup to #111973

I somehow forgot to update the comment on `select_nth_unstable_by_key` in #111973, so this PR fixes that.

r? `@Amanieu`
2023-05-29 04:03:03 +02:00
Matthias Krüger
760d46ed06
Rollup merge of #112042 - GuillaumeGomez:migrate-gui-test-color-8, r=notriddle
Migrate GUI colors test to original CSS color format

Follow-up of https://github.com/rust-lang/rust/pull/111459.

r? `@notriddle`
2023-05-29 04:03:03 +02:00
Matthias Krüger
1e07e5c1f7
Rollup merge of #112039 - devnexen:solarish_compiler_spec_update, r=jackh726
compiler: update solaris/illumos to enable tsan support.
2023-05-29 04:03:02 +02:00
Matthias Krüger
c5a93ba9fe
Rollup merge of #112037 - Nemo157:e0133-unsafe_op_in_unsafe_fn, r=petrochenkov
Add details about `unsafe_op_in_unsafe_fn` to E0133

This was mentioned in https://github.com/rust-lang/rust/pull/99827#discussion_r933899901
2023-05-29 04:03:02 +02:00
Matthias Krüger
45ca2f732e
Rollup merge of #112029 - jieyouxu:typo-const-in-const-param-def, r=cjgillot
Recover upon mistyped error on typo'd `const` in const param def

And add machine-applicable fix for the typo'd `const` keyword.

### Before

```
error: expected one of `,`, `:`, `=`, or `>`, found `N`
 --> src/lib.rs:1:18
  |
1 | pub fn bar<Const N: u8>() {}
  |                  ^ expected one of `,`, `:`, `=`, or `>`
```

### After This PR

```
error: `const` keyword was mistyped as `Const`
 --> test.rs:1:8
  |
1 | fn bar<Const N: u8>() {}
  |        ^^^^^
  |
help: use the `const` keyword
  |
1 | fn bar<const N: u8>() {}
  |        ~~~~~

```

Fixes #111941.
2023-05-29 04:03:01 +02:00
bors
f8447b9638 Auto merge of #111963 - nnethercote:inline-derived-hash, r=lqd
Inline derived `hash`

Because most of the other derived functions are inlined: `clone`, `default`, `eq`, `partial_cmp`, `cmp`. The exception is `fmt`, but it tends to not be on hot paths as much.

r? `@ghost`
2023-05-29 00:25:54 +00:00
Nicholas Nethercote
781111ef35 Use Cow in {D,Subd}iagnosticMessage.
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment:
```
// FIXME(davidtwco): can a `Cow<'static, str>` be used here?
```
This commit answers that question in the affirmative. It's not the most
compelling change ever, but it might be worth merging.

This requires changing the `impl<'a> From<&'a str>` impls to `impl
From<&'static str>`, which involves a bunch of knock-on changes that
require/result in call sites being a little more precise about exactly
what kind of string they use to create errors, and not just `&str`. This
will result in fewer unnecessary allocations, though this will not have
any notable perf effects given that these are error paths.

Note that I was lazy within Clippy, using `to_string` in a few places to
preserve the existing string imprecision. I could have used `impl
Into<{D,Subd}iagnosticMessage>` in various places as is done in the
compiler, but that would have required changes to *many* call sites
(mostly changing `&format("...")` to `format!("...")`) which didn't seem
worthwhile.
2023-05-29 09:23:43 +10:00