Commit Graph

243651 Commits

Author SHA1 Message Date
Nadrieril
d8b72e796e Typecheck never patterns 2024-01-18 21:15:24 +01:00
Nadrieril
a947c4c2c3 Add tests 2024-01-18 21:14:31 +01:00
bors
8424f8e8cd Auto merge of #120089 - matthiaskrgr:rollup-xyfqrb5, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #119172 (Detect `NulInCStr` error earlier.)
 - #119833 (Make tcx optional from StableMIR run macro and extend it to accept closures)
 - #119967 (Add `PatKind::Err` to AST/HIR)
 - #119978 (Move async closure parameters into the resultant closure's future eagerly)
 - #120021 (don't store const var origins for known vars)
 - #120038 (Don't create a separate "basename" when naming and opening a MIR dump file)
 - #120057 (Don't ICE when deducing future output if other errors already occurred)
 - #120073 (Remove spastorino from users_on_vacation)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-18 16:39:32 +00:00
bors
a34faab155 Auto merge of #118553 - jackh726:lint-implied-bounds, r=lcnr
error on incorrect implied bounds in wfcheck except for Bevy dependents

Rebase of #109763

Additionally, special cases Bevy `ParamSet` types to not trigger the lint. This is tracked in #119956.

Fixes #109628
2024-01-18 14:16:55 +00:00
Matthias Krüger
054a435a2d
Rollup merge of #120073 - spastorino:remove-spastorino-on-vacations, r=fmease
Remove spastorino from users_on_vacation
2024-01-18 10:34:20 +01:00
Matthias Krüger
34362b826d
Rollup merge of #120057 - oli-obk:not_sure_wtf_is_going_on, r=compiler-errors
Don't ICE when deducing future output if other errors already occurred

The situation can't really happen outside of erroneous code. What was interesting is that it ICEd before emitting any other diagnostics. This was because the other errors were silenced due to cycle_delay_bug cycle errors.

r? ```@compiler-errors```

fixes #119890
2024-01-18 10:34:20 +01:00
Matthias Krüger
c526cce281
Rollup merge of #120038 - Zalathar:dump-path, r=WaffleLapkin
Don't create a separate "basename" when naming and opening a MIR dump file

These functions were split up by #77080, in order to support passing the dump file's “basename” (filename without extension) to the implementation of `-Zdump-mir-spanview`, so that it could be used as a page title.

That flag has since been removed (#119566), so now there's no particular reason for this code to handle the basename separately from the filename or full path.

This PR therefore restores things to (roughly) how they were before #77080.
2024-01-18 10:34:19 +01:00
Matthias Krüger
b185606961
Rollup merge of #120021 - lcnr:const-var-value, r=compiler-errors
don't store const var origins for known vars

r? types
2024-01-18 10:34:19 +01:00
Matthias Krüger
536fc22917
Rollup merge of #119978 - compiler-errors:async-closure-captures, r=oli-obk
Move async closure parameters into the resultant closure's future eagerly

Move async closure parameters into the closure's resultant future eagerly.

Before, we used to desugar `async |p1, p2, ..| { body }` as `|p1, p2, ..| { || async { body } }`. Now, we desugar the above like `|p1, p2, ..| { async move { let p1 = p1; let p2 = p2; ... body } }`. This mirrors the same desugaring that `async fn` does with its parameter types, and the compiler literally uses the same code via a shared helper function.

This removes the necessity for E0708, since now expressions like `async |x: i32| { x }` will not give you confusing borrow errors.

This does *not* fix the case where async closures have self-borrows. This will come with a general implementation of async closures, which is still in the works.

r? oli-obk
2024-01-18 10:34:18 +01:00
Matthias Krüger
1f93d2b411
Rollup merge of #119967 - ShE3py:patkind-err, r=WaffleLapkin
Add `PatKind::Err` to AST/HIR

#116715 added `thir::PatKind::Error`; this PR adds `hir::PatKind::Err` and `ast::PatKind::Err` (see https://github.com/rust-lang/rust/pull/118625#discussion_r1446587901.)

---

``@rustbot`` label +A-patterns
r? WaffleLapkin
2024-01-18 10:34:18 +01:00
Matthias Krüger
c3e237c3ac
Rollup merge of #119833 - celinval:smir-accept-closures, r=oli-obk
Make tcx optional from StableMIR run macro and extend it to accept closures

Change `run` macro to avoid sometimes unnecessary dependency on `TyCtxt`, and introduce `run_with_tcx` to capture use cases where `tcx` is required. Additionally, extend both macros to accept closures that may capture variables.

I've also modified the `internal()` method to make it safer, by accepting the type context to force the `'tcx` lifetime to match the context lifetime.

These are non-backward compatible changes, but they only affect internal APIs which are provided today as helper functions until we have a stable API to start the compiler.
2024-01-18 10:34:17 +01:00
Matthias Krüger
ff8c7a7816
Rollup merge of #119172 - nnethercote:earlier-NulInCStr, r=petrochenkov
Detect `NulInCStr` error earlier.

By making it an `EscapeError` instead of a `LitError`. This makes it like the other errors produced when checking string literals contents, e.g. for invalid escape sequences or bare CR chars.

NOTE: this means these errors are issued earlier, before expansion, which changes behaviour. It will be possible to move the check back to the later point if desired. If that happens, it's likely that all the string literal contents checks will be delayed together.

One nice thing about this: the old approach had some code in `report_lit_error` to calculate the span of the nul char from a range. This code used a hardwired `+2` to account for the `c"` at the start of a C string literal, but this should have changed to a `+3` for raw C string literals to account for the `cr"`, which meant that the caret in `cr"` nul error messages was one short of where it should have been. The new approach doesn't need any of this and avoids the off-by-one error.

r? ```@fee1-dead```
2024-01-18 10:34:17 +01:00
bors
c485ee7147 Auto merge of #120071 - weihanglo:update-cargo, r=weihanglo
Update cargo

2 commits in 1cff2ee6b92e0ad3f87c44b70b28f788b2528b3c..1ae631085f01c1a72d05df1ec81f3759a8360042
2024-01-16 16:56:57 +0000 to 2024-01-17 17:26:41 +0000
- fix(json-msg): use pkgid spec in in JSON messages (rust-lang/cargo#13311)
- doc(features): Highlight the non-blocking feature gating technique (rust-lang/cargo#13307)

r? oli-obk

Could you check if this fixes miri build?
2024-01-18 07:19:02 +00:00
bors
2457c028c9 Auto merge of #120068 - matthiaskrgr:rollup-vxugut5, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #115291 (Save liveness results for DestinationPropagation)
 - #119855 (Enable Static Builds for FreeBSD)
 - #119975 (Don't ICE if TAIT-defining fn contains a closure with `_` in return type)
 - #120001 (Consistently unset RUSTC_BOOTSTRAP when compiling bootstrap)
 - #120020 (Gracefully handle missing typeck information if typeck errored)
 - #120031 (Construct closure type eagerly)
 - #120032 (Fix `rustc_abi` build on stable)
 - #120039 (pat_analysis: Don't rely on contiguous `VariantId`s outside of rustc)
 - #120044 (Fix typo in comments (in_place_collect))
 - #120056 (Use FnOnceOutput instead of FnOnce where expected)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-01-18 05:15:25 +00:00
Celina G. Val
6a573cbc60 Revert changes to internal method for now
- Move fix to a separate PR
2024-01-17 19:59:57 -08:00
Jack Huey
a9e30e6cdf Don't use compat versions of implied bounds in ImpliedOutlivesBounds query 2024-01-17 22:03:06 -05:00
Jack Huey
acab76573f Add -Zno-implied-bounds-compat option and use it 2024-01-17 21:27:34 -05:00
Ali MJ Al-Nasrawy
d96003dd2a Correctly handle normalization in implied bounds
Special-case Bevy dependents to not error
2024-01-17 21:27:34 -05:00
Santiago Pastorino
eb8c1f8998
Remove spastorino from users_on_vacation 2024-01-17 18:02:14 -03:00
Weihang Lo
c70773d8a1
Update cargo 2024-01-17 14:47:59 -05:00
Matthias Krüger
99a8b6aa67
Rollup merge of #120056 - oli-obk:arg_mismatch_ice, r=compiler-errors
Use FnOnceOutput instead of FnOnce where expected

fixes #119847
2024-01-17 20:21:24 +01:00
Matthias Krüger
a2eefd2718
Rollup merge of #120044 - Storyyeller:patch-2, r=lqd
Fix typo in comments (in_place_collect)
2024-01-17 20:21:23 +01:00
Matthias Krüger
3a3242a0f9
Rollup merge of #120039 - Nadrieril:remove-idx, r=compiler-errors
pat_analysis: Don't rely on contiguous `VariantId`s outside of rustc

Today's pattern_analysis uses `BitSet` and `IndexVec` on the provided enum variant ids, which only makes sense if these ids count the variants from 0. In rust-analyzer, the variant ids are global interning ids, which would make `BitSet` and `IndexVec` ridiculously wasteful. In this PR I add some shims to use `FxHashSet`/`FxHashMap` instead outside of rustc.

r? ```@compiler-errors```
2024-01-17 20:21:23 +01:00
Matthias Krüger
e0aa4df798
Rollup merge of #120032 - Nadrieril:fix-rustc_abi, r=Nilstrieb
Fix `rustc_abi` build on stable

https://github.com/rust-lang/rust/pull/119446 broke the ability of `rustc_abi` to build on stable, which is required by rust-analyzer. This fixes it.
2024-01-17 20:21:22 +01:00
Matthias Krüger
cd5eb6a896
Rollup merge of #120031 - compiler-errors:construct-closure-ty-eagerly, r=oli-obk
Construct closure type eagerly

Construct the returned closure type *before* checking the body, in the same match as we were previously deducing the coroutine types based off of the closure kind.

This simplifies some changes I'm doing in the async closure PR, and imo just seems easier to read (since we only need one match on closure kind, instead of two). There's no reason I can tell that we needed to create the closure type *after* the body was checked.

~~This also has the side-effect of making it so that the universe of the closure synthetic infer vars are lower than any infer vars that come from checking the body. We can also get rid of `next_root_ty_var` hack from closure checking (though in general we still need this, #119106). cc ```@lcnr``` since you may care about this hack 😆~~

r? ```@oli-obk```
2024-01-17 20:21:22 +01:00
Matthias Krüger
6ca77ff722
Rollup merge of #120020 - oli-obk:long_const_eval_err_taint, r=compiler-errors
Gracefully handle missing typeck information if typeck errored

fixes #116893

I created some logs and the typeck of `fn main` is exactly the same, no matter whether the constant's body is what it is, or if it is replaced with `panic!()`. The latter will cause the ICE not to be emitted though. The reason for that is that we abort compilation if *errors* were emitted, but not if *lint errors* were emitted. This took me way too long to debug, and is another reason why I would have liked https://github.com/rust-lang/compiler-team/issues/633
2024-01-17 20:21:21 +01:00
Matthias Krüger
cc9a4a2134
Rollup merge of #120001 - dtolnay:bootstrapbootstrap, r=onur-ozkan
Consistently unset RUSTC_BOOTSTRAP when compiling bootstrap

Since https://github.com/rust-lang/rust/pull/113906, all x.py invocations performed by rust-analyzer have RUSTC_BOOTSTRAP=1 set. This was to fix https://github.com/rust-lang/rust/issues/112391#issuecomment-1597224941 — rust-analyzer uses some default cargo from the system when fetching workspace layout, and the standard library uses some unstable cargo feature, so x.py would previously fail if the system toolchain wasn't nightly.

82e1608dfa/library/std/Cargo.toml (L1)

This PR changes x.py to cancel out this RUSTC_BOOTSTRAP=1 when compiling bootstrap. It will only remain set when running the compiled bootstrap executable. This fixes spurious bootstrap rebuilds in the event that a rust-analyzer x.py invocation is alternated with someone running x.py themself on the command line, if any dependency of bootstrap looks at `option_env!("RUSTC_BOOTSTRAP")`, which is the case since https://github.com/rust-lang/rust/pull/119654.

**Before:**

```console
$ RUSTC_BOOTSTRAP=1 ./x.py check library/core
Building bootstrap
   Compiling proc-macro2 v1.0.76
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling clap_derive v4.4.7
   Compiling serde_derive v1.0.195
   Compiling clap v4.4.13
   Compiling clap_complete v4.4.6
   Compiling build_helper v0.1.0
   Compiling bootstrap v0.0.0
    Finished dev [unoptimized] target(s) in 6.31s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.23s
Build completed successfully in 0:00:07

$ ./x.py check library/core
Building bootstrap
   Compiling proc-macro2 v1.0.76
   Compiling quote v1.0.35
   Compiling syn v2.0.48
   Compiling clap_derive v4.4.7
   Compiling serde_derive v1.0.195
   Compiling clap v4.4.13
   Compiling clap_complete v4.4.6
   Compiling build_helper v0.1.0
   Compiling bootstrap v0.0.0
    Finished dev [unoptimized] target(s) in 5.30s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.25s
Build completed successfully in 0:00:06
```

**After:**

```console
$ RUSTC_BOOTSTRAP=1 ./x.py check library/core
Building bootstrap
    Finished dev [unoptimized] target(s) in 0.06s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.14s
Build completed successfully in 0:00:01

$ ./x.py check library/core
Building bootstrap
    Finished dev [unoptimized] target(s) in 0.04s
Checking stage0 library artifacts {core} (x86_64-unknown-linux-gnu)
    Finished release [optimized] target(s) in 0.13s
Build completed successfully in 0:00:01
```
2024-01-17 20:21:21 +01:00
Matthias Krüger
22f19130df
Rollup merge of #119975 - lukas-code:inferring-return-types-and-opaque-types-do-mix-sometimes, r=compiler-errors
Don't ICE if TAIT-defining fn contains a closure with `_` in return type

The `delay_span_bug` got added in 0e82aaeb67 to reduce the amount of errors emitted for functions that have `_` in their return type, because inference doesn't apply to function items. But this logic shouldn't apply to closures, because their return types *can* be inferred.

Fixes https://github.com/rust-lang/rust/issues/119916.
2024-01-17 20:21:20 +01:00
Matthias Krüger
c9779afc9c
Rollup merge of #119855 - rellerreller:freebsd-static, r=wesleywiser
Enable Static Builds for FreeBSD

Enable crt-static for FreeBSD to enable statically compiled binaries.
2024-01-17 20:21:19 +01:00
Matthias Krüger
3ae7ab698f
Rollup merge of #115291 - cjgillot:dest-prop-save, r=JakobDegen
Save liveness results for DestinationPropagation

`DestinationPropagation` needs to verify that merge candidates do not conflict with each other. This is done by verifying that a local is not live when its counterpart is written to.

To get the liveness information, the pass runs `MaybeLiveLocals` dataflow analysis repeatedly, once for each propagation round. This is quite costly, and the main driver for the perf impact on `ucd` and `diesel`. (See https://github.com/rust-lang/rust/pull/115105#issuecomment-1689205908)

In order to mitigate this cost, this PR proposes to save the result of the analysis into a `SparseIntervalMatrix`, and mirror merges of locals into that matrix: `liveness(destination) := liveness(destination) union liveness(source)`.

<details>
<summary>Proof</summary>

We denote by `'` all the quantities of the transformed program. Let $\varphi$ be a mapping of locals, which maps `source` to `destination`, and is identity otherwise. The exact liveness set after a statement is $out'(statement)$, and the proposed liveness set is $\varphi(out(statement))$.

Consider a statement. Suppose that the output state verifies $out' \subset phi(out)$. We want to prove that $in' \subset \varphi(in)$ where $in = (out - kill) \cup gen$, and conclude by induction.

We have 2 cases: either that statement is kept with locals renumbered by $\varphi$, or it is a tautological assignment and it removed.

1. If the statement is kept: the gen-set and the kill-set of $statement' = \varphi(statement)$ are $gen' = \varphi(gen)$ and $kill' = \varphi(kill)$ exactly.
From soundness requirement 3, $\varphi(in)$ is disjoint from $\varphi(kill)$.
This implies that $\varphi(out - kill)$ is disjoint from $\varphi(kill)$, and so $\varphi(out - kill) = \varphi(out) - \varphi(kill)$. Then $\varphi(in) = (\varphi(out) - \varphi(kill)) \cup \varphi(gen) = (\varphi(out) - kill') \cup gen'$.
We can conclude that $out' \subset \varphi(out) \implies in' \subset \varphi(in)$.

2. If the statement is removed. As $\varphi(statement)$ is a tautological assignment, we know that $\varphi(gen) = \varphi(kill) = \\{ destination \\}$, while $gen' = kill' = \emptyset$. So $\varphi(in) = \varphi(out) \cup \\{ destination \\}$. Then $in' = out' \subset out \subset \varphi(in)$.

By recursion, we can conclude by that $in' \subset \varphi(in)$ everywhere.
</details>

This approximate liveness results is only suboptimal if there are locals that fully disappear from the CFG due to an assignment cycle. These cases are quite unlikely, so we do not bother with them.

This change allows to reduce the perf impact of DestinationPropagation by half on diesel and ucd (https://github.com/rust-lang/rust/pull/115105#issuecomment-1694701904).

cc ````@JakobDegen````
2024-01-17 20:21:19 +01:00
Oli Scherer
f1ef930c9d Don't ICE when deducing future output if other errors already occurred 2024-01-17 16:27:57 +00:00
bors
6ae4cfbbb0 Auto merge of #118708 - davidtwco:target-tier-assembly-test, r=Mark-Simulacrum
tests: add sanity-check assembly test for every target

Fixes #119910.

Adds a basic assembly test checking that each target can produce assembly and update the target tier policy to require this.

cc rust-lang/compiler-team#655
r? `@wesleywiser`
2024-01-17 16:18:28 +00:00
Oli Scherer
d6b99b9c92 Use FnOnceOutput instead of FnOnce where expected 2024-01-17 14:23:41 +00:00
bors
c58a5da7d4 Auto merge of #119930 - Urgau:check-cfg-empty-values-means-empty, r=petrochenkov
Add way to express that no values are expected with check-cfg

This PR adds way to express no-values (no values expected) with `--check-cfg` by making empty `values()` no longer mean `values(none())` (internal: `&[None]`) and now be an empty list (internal: `&[]`).

### Context

Currently `--check-cfg` has a way to express that _any value is expected_ with `values(any())`, but has no way to do the inverse and say that _no value is expected_.

This would be particularly useful for build systems that control a config name and it's values as they could always declare a config name as expected and if in the current state they have values pass them and if not pass an empty list.

To give a more concrete example, Cargo `--check-cfg` currently needs to generate:
 - `--check-cfg=cfg(feature, values(...))` for the case with declared features
 - and `--check-cfg=cfg()` for the case without any features declared

This means that when there are no features declared, users will get an `unexpected config name` but from the point of view of Cargo the config name `feature` is expected, it's just that for now there aren't any values for it.

See [Cargo `check_cfg_args` function](92395d9010/src/cargo/core/compiler/mod.rs (L1263-L1281)) for more details.

### De-specializing *empty* `values()`

To solve this issue I propose that we "de-specialize" empty `values()` to no longer mean `values(none())` but to actually mean empty set/list. This is one of the last source of confusion for my-self and others with the `--check-cfg` syntax.

> The confusing part here is that an empty `values()` currently means the same as `values(none())`, i.e. an expected list of values with the _none_ variant (as in `#[cfg(name)]` where the value is none) instead of meaning an empty set.

Before the new `cfg()` syntax, defining the _none_ variant was only possible under certain circumstances, so in https://github.com/rust-lang/rust/pull/111068 I decided to make `values()` to mean the _none_ variant, but it is no longer necessary since https://github.com/rust-lang/rust/pull/119473 which introduced the `none()` syntax.

A simplified representation of the proposed "de-specialization" would be:

| Syntax                                  | List/set of expected values |
|-----------------------------------------|-----------------------------|
| `cfg(name)`/`cfg(name, values(none()))` | `&[None]`                   |
| `cfg(name, values())`                   | `&[]`                       |

Note that I have my-self made the mistake of using an empty `values()` as meaning empty set, see https://github.com/rust-lang/cargo/pull/13011.

`@rustbot` label +F-check-cfg
r? `@petrochenkov`
cc `@epage`
2024-01-17 14:01:05 +00:00
bors
52790a98e5 Auto merge of #119670 - cjgillot:gvn-arithmetic, r=oli-obk
Fold arithmetic identities in GVN

Extracted from https://github.com/rust-lang/rust/pull/111344

This PR implements a few arithmetic folds for unary and binary operations.
This should take care of the missed optimizations introduced by https://github.com/rust-lang/rust/pull/116012.
2024-01-17 11:46:49 +00:00
David Wood
12c19a2bb7
target: fix powerpc64-unknown-linux-musl datalayout
In LLVM 17, PowerPC targets started including function pointer alignments
in data layouts, and in Rust's update to that version (#114048), we added
the function pointer alignments. `powerpc64-unknown-linux-musl` had
`Fi64` set but this seems incorrect, and the code in LLVM would always
have computed `Fn32` because it is a MUSL target.

Signed-off-by: David Wood <david@davidtw.co>
2024-01-17 10:38:50 +00:00
David Wood
a87034c297
tests: add sanity-check assembly test for every target
Adds a basic assembly test checking that each target can produce assembly
and update the target tier policy to require this.

Signed-off-by: David Wood <david@davidtw.co>
2024-01-17 09:44:11 +00:00
bors
25b706cde3 Auto merge of #119111 - michaelwoerister:measureme-11, r=Mark-Simulacrum
Update measureme crate to version 11

perf.rlo has been updated to use 11.0.0 already, so it should be able to handle the new file format.

r? `@Mark-Simulacrum`

Fixes https://github.com/rust-lang/rust/issues/99282
Fixes https://github.com/rust-lang/rust/issues/119103
2024-01-17 09:32:03 +00:00
bors
16f4b02dd8 Auto merge of #119922 - nnethercote:fix-Diag-code-is_lint, r=oli-obk
Rework how diagnostic lints are stored.

`Diagnostic::code` has the type `DiagnosticId`, which has `Error` and
`Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be
redundant w.r.t. `Diagnostic::code`.

Seems simple. Except it's possible for a lint to have an error code, in
which case its `code` field is recorded as `Error`, and `is_lint` is
required to indicate that it's a lint. This is what happens with
`derive(LintDiagnostic)` lints. Which means those lints don't have a
lint name or a `has_future_breakage` field because those are stored in
the `DiagnosticId::Lint`.

It's all a bit messy and confused and seems unintentional.

This commit:
- removes `DiagnosticId`;
- changes `Diagnostic::code` to `Option<String>`, which means both
  errors and lints can straightforwardly have an error code;
- changes `Diagnostic::is_lint` to `Option<IsLint>`, where `IsLint` is a
  new type containing a lint name and a `has_future_breakage` bool, so
  all lints can have those, error code or not.

r? `@oli-obk`
2024-01-17 07:33:52 +00:00
bors
f45fe573a5 Auto merge of #119651 - novafacing:proc_macro_c_str_literals, r=Amanieu
proc_macro: Add Literal::c_string constructor

Adds a constructor for C string literals, hopefully starts addressing #118560.

Tracking issue: #119750
2024-01-17 05:07:38 +00:00
Robert Grosse
db7125f008
Fix typo in comments (in_place_collect) 2024-01-16 20:48:22 -08:00
bors
6bf600bc98 Auto merge of #120019 - lcnr:fn-wf, r=BoxyUwU
fix fn/const items implied bounds and wf check (rebase)

A rebase of #104098, see that PR for discussion. This is pretty much entirely the work of `@aliemjay.` I received his permission for this rebase.

---

These are two distinct changes (edit: actually three, see below):
1. Wf-check all fn item args. This is a soundness fix.
Fixes #104005

2. Use implied bounds from impl header in borrowck of associated functions/consts. This strictly accepts more code and helps to mitigate the impact of other breaking changes.
Fixes #98852
Fixes #102611

The first is a breaking change and will likely have a big impact without the the second one. See the first commit for how it breaks libstd.

Landing the second one without the first will allow more incorrect code to pass. For example an exploit of #104005 would be as simple as:
```rust
use core::fmt::Display;

trait ExtendLt<Witness> {
    fn extend(self) -> Box<dyn Display>;
}

impl<T: Display> ExtendLt<&'static T> for T {
    fn extend(self) -> Box<dyn Display> {
        Box::new(self)
    }
}

fn main() {
    let val = (&String::new()).extend();
    println!("{val}");
}
```

The third change is to to check WF of user type annotations before normalizing them (fixes #104764, fixes #104763). It is mutually dependent on the second change above: an attempt to land it separately in #104746 caused several crater regressions that can all be mitigated by using the implied from the impl header. It is also necessary for the soundness of associated consts that use the implied bounds of impl header. See #104763 and how the third commit fixes the soundness issue in `tests/ui/wf/wf-associated-const.rs` that was introduces by the previous commit.

r? types
2024-01-17 02:35:06 +00:00
Lieselotte
7889e99b55
Add PatKind::Err 2024-01-17 03:14:16 +01:00
Nadrieril
19d6f068ee Don't rely on contiguous VariantIds outside of rustc 2024-01-17 03:09:06 +01:00
Zalathar
1ec567b99a Inline dump_file_basename into dump_path 2024-01-17 11:46:20 +11:00
Zalathar
b82d1d32b4 Inline create_dump_file_with_basename 2024-01-17 11:46:20 +11:00
Michael Goulet
37a5464bc8 Eagerly instantiate closure ty 2024-01-17 00:43:44 +00:00
bors
6ed31aba1a Auto merge of #120036 - weihanglo:update-cargo, r=weihanglo
Update cargo

10 commits in 84976cd699f4aea56cb3a90ce3eedeed9e20d5a5..1cff2ee6b92e0ad3f87c44b70b28f788b2528b3c
2024-01-12 15:55:43 +0000 to 2024-01-16 16:56:57 +0000
- doc: add a heading to highlight "How to find features enabled on dependencies" (rust-lang/cargo#13305)
- fix(cargo-update): `--precise` accept arbitrary git revisions (rust-lang/cargo#13250)
- Strip debuginfo when debuginfo is not requested (rust-lang/cargo#13257)
- Update ahash dependency to 0.8.7 (rust-lang/cargo#13301)
- docs: add more links to pkgid spec chapter (rust-lang/cargo#13298)
- fix(metadata): Stabilize id format as PackageIDSpec (rust-lang/cargo#12914)
- Introduce `-Zprecise-pre-release` unstable flag (rust-lang/cargo#13296)
- Delete sentence about parentheses being unsupported in license (rust-lang/cargo#13292)
- Add guidance on setting homepage in manifest (rust-lang/cargo#13293)
- Clarify the function of the test options (rust-lang/cargo#13236)

r? ghost
2024-01-17 00:03:51 +00:00
Weihang Lo
7e1e61a447
Update cargo 2024-01-16 18:34:44 -05:00
Celina G. Val
2564811e7b Remove tcx function and make internal fn safer
I added `tcx` argument to `internal` to force 'tcx to be the same
lifetime as TyCtxt. The only other solution I could think is to change
this function to be `unsafe`.
2024-01-16 14:35:18 -08:00