Readd the matches_macro diag item
This is now used by Clippy
r? `@compiler-errors`
This was removed in #104383. But in the meantime Clippy now makes use of it dac600e32f/clippy_lints/src/manual_is_ascii_check.rs (L153)
---
This is blocking the Clippy sync. (kinda. I could work around it, but I don't want to play ping-pong with this change.)
Check `dyn*` return type correctly
In `check_fn`, if the declared return type is `dyn Trait`, then we check the return type separately to produce better diagnostics, because this is never valid -- however, when `dyn*` was introduced, this check was never adjusted to only account for *unsized* `dyn Trait` and not *sized* `dyn* Trait`.
Fixes#104501
Convert predicates into Predicate in the Obligation constructor
instead of having almost all callers do that.
This reduces a bit of boilerplate, and also paves the way for my work towards https://github.com/rust-lang/compiler-team/issues/531 (as it makes it easier to accept both goals and clauses where right now it only accepts predicates).
Don't remap early-bound regions for return-position `impl Trait` in trait originating from `impl`
long title 😓
We don't want to remap early-bound regions that originate from the `impl`s themselves, since they have no corresponding region in the trait. Not sure if there's a better condition than checking if the EBR's def-id's parent is the impl -- maybe we should be checking if the region comes from the method or RPITIT... 🤷
r? types
Fixes#103850
[watchos] Dynamic linking is not allowed for watchos targets
Dynamic linking of all apple targets was (re-) enabled in PR #100636. However, dynamic linking is not allowed on WatchOS so this broke the build of standard library for WatchOS.
This change disables dynamic linking for WatchOS non-simulator targets.
Support `#[track_caller]` on async fns
Adds `#[track_caller]` to the generator that is created when we desugar the async fn.
Fixes#78840
Open questions:
- What is the performance impact of adding `#[track_caller]` to every `GenFuture`'s `poll(...)` function, even if it's unused (i.e., the parent span does not set `#[track_caller]`)? We might need to set it only conditionally, if the indirection causes overhead we don't want.
Record `LocalDefId` in HIR nodes instead of a side table
This is part of an attempt to remove the `HirId -> LocalDefId` table from HIR.
This attempt is a prerequisite to creation of `LocalDefId` after HIR lowering (https://github.com/rust-lang/rust/pull/96840), by controlling how `def_id` information is accessed.
This first part adds the information to HIR nodes themselves instead of a table.
The second part is https://github.com/rust-lang/rust/pull/103902
The third part will be to make `hir::Visitor::visit_fn` take a `LocalDefId` as last parameter.
The fourth part will be to completely remove the side table.
Use `token::Lit` in `ast::ExprKind::Lit`.
Instead of `ast::Lit`.
Literal lowering now happens at two different times. Expression literals are lowered when HIR is crated. Attribute literals are lowered during parsing.
r? `@petrochenkov`
Only do parser recovery on retried macro matching
Eager parser recovery can break macros, so we don't do it at first. But when we already know that the macro failed, we can retry it with recovery enabled to still emit useful diagnostics.
Helps with #103534
cleanup and dedupe CTFE and Miri error reporting
It looks like most of the time, this error raised from const_prop_lint is just redundant -- it duplicates the error reported when evaluating the const-eval query. This lets us make `ConstEvalErr` private to the const_eval module which I think is a good step.
The Miri change mostly replaces a `match` by `if let`, and dedupes the "this error is impossible in Miri" checks.
r? ``@oli-obk``
Fixes https://github.com/rust-lang/rust/issues/75461
Issue error when -C link-self-contained option is used on unsupported platforms
The documentation was also updated to reflect this.
I'm assuming the supported platforms are the same as initially written in [RELEASES.md](https://github.com/rust-lang/rust/blob/master/RELEASES.md#compiler-17).
Fixes#103576
Fix some misleading target feature aliases
This is the first half of a fix for #100752. It looks like these aliases were added in #78361 and slipped under the radar, as these features are not AVX512. These features _do_ add AVX512 instructions when used _in combination_ with AVX512F, but without AVX512F, these features still provide 128-bit and 256-bit vector instructions. A user might be mislead into thinking these features imply AVX512F (which is true of the actual AVX512 features). This PR allows using the names as defined by LLVM, which matches Intel documentation.
A future PR should change the `std::arch` intrinsics to use these names, and finally remove these aliases from rustc.
r? ```@workingjubilee```
cc ```@Amanieu```
Respect visibility & stability of inherent associated types
As discussed in #103621, this probably won't be the final location of the code that resolves inherent associated types. Still, I think it's valuable to push correctness fixes for this feature (in regards to visibility and stability).
Let me know if I should write a translatable diagnostic instead and if I should move the tests to `privacy/` and `stability-attribute/` respectively.
Fixes#104243.
````@rustbot```` label A-visibility F-inherent_associated_types
r? ````@cjgillot```` (since you reviewed #103621, feel free to reroll though)
Shift no characters when using raw string literals
Fixes#104142
Given the following code:
```rust
fn main() {
println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#);
}
```
The current output is:
```
error: invalid format string: unmatched `}` found
--> src/main.rs:2:59
|
2 | println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#); //~ ERROR invalid format string: unmatched `}` found
| ^ unmatched `}` in format string
|
= note: if you intended to print `}`, you can escape it using `}}`
error: could not compile `debug_playground` due to previous error
```
The output should look like:
```
error: invalid format string: unmatched `}` found
--> src/main.rs:2:45
|
2 | println!(r#"\'\'\'\'\'\'\'\'\'\'\'\'\'\'}"#); //~ ERROR invalid format string: unmatched `}` found
| ^ unmatched `}` in format string
|
= note: if you intended to print `}`, you can escape it using `}}`
error: could not compile `debug_playground` due to previous error
```
This pull request fixes the wrong span for `invalid format string` error and also solves the ICE.
In `codegen_assert_terminator` we decide if a BB's successor is a
candidate for merging, which requires that it be the only successor, and
that it only have one predecessor. That result then gets passed down,
and if it reaches `funclet_br` with the appropriate BB characteristics,
then no `br` instruction is issued, a `MergingSucc::True` result is
passed back, and the merging proceeds in `codegen_block`.
The commit also adds `CachedLlbb`, a new type to help keep track of
each BB that has been merged into its predecessor.
For the next commit, `FunctionCx::codegen_*_terminator` need to take a
`&mut Bx` instead of consuming a `Bx`. This triggers a cascade of
similar changes across multiple functions. The resulting code is more
concise and replaces many `&mut bx` expressions with `bx`.
Perform simple scalar replacement of aggregates (SROA) MIR opt
This is a re-open of https://github.com/rust-lang/rust/pull/85796
I copied the debuginfo implementation (first commit) from `@eddyb's` own SROA PR.
This pass replaces plain field accesses by simple locals when possible.
To be eligible, the replaced locals:
- must not be enums or unions;
- must not be used whole;
- must not have their address taken.
The storage and deinit statements are duplicated on each created local.
cc `@tmiasko` who reviewed the former version of this PR.
Instead of `ast::Lit`.
Literal lowering now happens at two different times. Expression literals
are lowered when HIR is crated. Attribute literals are lowered during
parsing.
This commit changes the language very slightly. Some programs that used
to not compile now will compile. This is because some invalid literals
that are removed by `cfg` or attribute macros will no longer trigger
errors. See this comment for more details:
https://github.com/rust-lang/rust/pull/102944#issuecomment-1277476773
interpret: support for per-byte provenance
Also factors the provenance map into its own module.
The third commit does the same for the init mask. I can move it in a separate PR if you prefer.
Fixes https://github.com/rust-lang/miri/issues/2181
r? `@oli-obk`
Rollup of 9 pull requests
Successful merges:
- #103439 (Show note where the macro failed to match)
- #103734 (Adjust stabilization version to 1.65.0 for wasi fds)
- #104148 (Visit attributes of trait impl items during AST validation)
- #104241 (Move most of unwind's build script to lib.rs)
- #104258 (Deduce closure signature from a type alias `impl Trait`'s supertraits)
- #104296 (Walk types more carefully in `ProhibitOpaqueTypes` visitor)
- #104309 (Slightly improve error message for invalid identifier)
- #104316 (Simplify suggestions for errors in generators.)
- #104339 (Add `rustc_deny_explicit_impl`)
Failed merges:
- #103484 (Add `rust` to `let_underscore_lock` example)
r? `@ghost`
`@rustbot` modify labels: rollup