Enable varargs support for calling conventions other than C or cdecl
This patch makes it possible to use varargs for calling conventions,
which are either based on C (efiapi) or C is based on them (sysv64 and win64).
Also pinging ``@phlopsi,`` because he noticed first this oversight when writing a library for UEFI.
Accept `TyCtxt` instead of `TyCtxtAt` in `Ty::is_*` functions
Functions in answer:
- `Ty::is_freeze`
- `Ty::is_sized`
- `Ty::is_unpin`
- `Ty::is_copy_modulo_regions`
This allows to remove a lot of useless `.at(DUMMY_SP)`, making the code a bit nicer :3
r? `@compiler-errors`
Rename some `OwnerId` fields.
`@spastorino` noticed some silly expressions like `item_id.def_id.def_id`.
This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`.
`item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
r? `@compiler-errors`
spastorino noticed some silly expressions like `item_id.def_id.def_id`.
This commit renames several `def_id: OwnerId` fields as `owner_id`, so
those expressions become `item_id.owner_id.def_id`.
`item_id.owner_id.local_def_id` would be even clearer, but the use of
`def_id` for values of type `LocalDefId` is *very* widespread, so I left
that alone.
Note scope of TAIT more accurately
This maybe explains why the person was confused in #101897, since we say "same module" but really should've said "same impl".
r? ``@oli-obk``
Introduce UnordMap, UnordSet, and UnordBag (MCP 533)
This is the start of implementing [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).
I followed `@eddyb's` suggestion of naming the collection types `Unord(Map/Set/Bag)` which is a bit easier to type than `Unordered(Map/Set/Bag)`
r? `@eddyb`
Emit a nicer error on `impl Self {`
currently it emits a "cycle detected error" but this PR makes it emit a more user friendly error specifically saying that `Self` is disallowed in that position. this is a pretty hacky fix so i dont expect this to be merged (I basically only made this PR because i wanted to see if CI passes)
r? ``@compiler-errors``
Remap early bound lifetimes in return-position `impl Trait` in traits too
Fixes part of #103457
r? ``@cjgillot,`` though feel free to reassign, just thought you'd have sufficient context to review.
Add suggestions for unsafe impl error codes
Adds suggestions for users to add `unsafe` to trait impls that should be `unsafe`, and remove `unsafe` from trait impls that do not require `unsafe`
With the folllowing code:
```rust
struct Foo {}
struct Bar {}
trait Safe {}
unsafe trait Unsafe {}
impl Safe for Foo {} // ok
impl Unsafe for Foo {} // E0200
unsafe impl Safe for Bar {} // E0199
unsafe impl Unsafe for Bar {} // ok
// omitted empty main fn
```
The current rustc output is:
```
error[E0199]: implementing the trait `Safe` is not unsafe
--> e0200.rs:13:1
|
13 | unsafe impl Safe for Bar {} // E0199
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E0200]: the trait `Unsafe` requires an `unsafe impl` declaration
--> e0200.rs:11:1
|
11 | impl Unsafe for Foo {} // E0200
| ^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0199, E0200.
For more information about an error, try `rustc --explain E0199`.
```
With this PR, the future rustc output would be:
```
error[E0199]: implementing the trait `Safe` is not unsafe
--> ../../temp/e0200.rs:13:1
|
13 | unsafe impl Safe for Bar {} // E0199
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: remove `unsafe` from this trait implementation
|
13 - unsafe impl Safe for Bar {} // E0199
13 + impl Safe for Bar {} // E0199
|
error[E0200]: the trait `Unsafe` requires an `unsafe impl` declaration
--> ../../temp/e0200.rs:11:1
|
11 | impl Unsafe for Foo {} // E0200
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: the trait `Unsafe` enforces invariants that the compiler can't check. Review the trait documentation and make sure this implementation upholds those invariants before adding the `unsafe` keyword
help: add `unsafe` to this trait implementation
|
11 | unsafe impl Unsafe for Foo {} // E0200
| ++++++
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0199, E0200.
For more information about an error, try `rustc --explain E0199`.
```
``@rustbot`` label +T-compiler +A-diagnostics +A-suggestion-diagnostics
This patch makes it possible to use varargs for calling conventions,
which are either based on C (like efiapi) or C is based
on them (for example sysv64 and win64).
Flatten diagnostic slug modules
This makes it easier to grep for the slugs in the code.
See https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Localization.20infra.20interferes.20with.20grepping.20for.20error for more discussion about it.
This was mostly done with a few regexes and a bunch of manual work. This also exposes a pretty annoying inconsistency for the extra labels. Some of the extra labels are defined as additional properties in the fluent message (which makes them not prefixed with the crate name) and some of them are new fluent messages themselves (which makes them prefixed with the crate name). I don't know whether we want to clean this up at some point but it's useful to know.
r? `@davidtwco`
Introduce `subst_iter` and `subst_iter_copied` on `EarlyBinder`
Makes working with bounds lists a bit easier, which I seem to do a lot.
Specifically, means that we don't need to do `.transpose_iter().map(|(pred, _)| *pred)` every time we want to iterate through an `EarlyBinder<&'tcx [(Predicate, Span)]>` (and even then, still have to call `subst` later), which was a very awkward idiom imo.
stop using `ty::UnevaluatedConst` directly
best reviewed commit by commit.
simplifies #99798 because we now don't have to expand `ty::UnevaluatedConst` to `ty::Const`.
I also remember some other places where using `ty::UnevaluatedConst` directly was annoying and caused issues, though I don't quite remember what they were rn '^^
r? `@oli-obk` cc `@JulianKnodt`
Rollup of 6 pull requests
Successful merges:
- #102287 (Elaborate supertrait bounds when triggering `unused_must_use` on `impl Trait`)
- #102922 (Filtering spans when emitting json)
- #103051 (translation: doc comments with derives, subdiagnostic-less enum variants, more derive use)
- #103111 (Account for hygiene in typo suggestions, and use them to point to shadowed names)
- #103260 (Fixup a few tests needing asm support)
- #103321 (rustdoc: improve appearance of source page navigation bar)
Failed merges:
- #103209 (Diagnostic derives: allow specifying multiple alternative suggestions)
r? `@ghost`
`@rustbot` modify labels: rollup
Use already checked RHS ty for LHS deref suggestions
There's no reason to do the `check_lhs_assignable` and RHS `check_expr_with_hint` in that order, so invert them and use the typeck results to avoid exponential blowup on error.
Fixes#103219
Let expressions on RHS shouldn't be terminating scopes
Fixes#100276.
Before this PR, we were unconditionally marking the RHS of short-circuiting binary expressions as a terminating scope.
In the case of a let chain where the `let` expression was on the RHS, this meant that temporaries within the `let` expr would only live until the end of the expression. Since this only affected the RHS, this led to surprising behavior ([example](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=d1b0a5d1f01882f9c89c2194a75eb19f)).
After this PR, we only mark the RHS as a terminating scope if it is not a `let` expression.