Commit Graph

19037 Commits

Author SHA1 Message Date
Michael Goulet
c4165f3a96 drive-by: Add is_async fn to hir::IsAsync 2022-11-19 02:22:24 +00:00
bors
fd3bfb3551 Auto merge of #104330 - CastilloDel:ast_lowering, r=cjgillot
Remove allow(rustc::potential_query_instability) from rustc_ast_lowering

Related to https://github.com/rust-lang/rust/issues/84447.

`@cjgillot` Thanks for helping me!
2022-11-18 13:12:18 +00:00
Matthias Krüger
239f84bc51
Rollup merge of #104545 - flip1995:diag_item_matches_macro, r=compiler-errors
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.)
2022-11-17 22:33:22 +01:00
Matthias Krüger
58292874e1
Rollup merge of #104515 - chenyukang:yukang/fix-104510-ice, r=compiler-errors
ICE fixing, remove is_tainted_by_errors since we have ty_error for delay bug

Fixes #104510
2022-11-17 22:33:21 +01:00
Matthias Krüger
43fa2918d1
Rollup merge of #104508 - compiler-errors:dyn-return, r=oli-obk
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
2022-11-17 22:33:21 +01:00
Matthias Krüger
ed97f245f1
Rollup merge of #104483 - oli-obk:santa-clauses-make-goals, r=compiler-errors
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).
2022-11-17 22:33:19 +01:00
Matthias Krüger
1c52c247f9
Rollup merge of #104444 - chenyukang:yukang/fix-104390, r=compiler-errors
Fix ICE in in_operand for ty error

Fixes #104390

By the way, moving some test cases to proper directory for tidy bless.
2022-11-17 22:33:19 +01:00
Matthias Krüger
c9ccb0ba28
Rollup merge of #104433 - TaKO8Ki:fix-104392, r=estebank
Fix `emit_unused_delims_expr` ICE

Fixes #104392
2022-11-17 22:33:18 +01:00
Matthias Krüger
1521795a7d
Rollup merge of #103852 - compiler-errors:rpitit-early-from-impl, r=lcnr
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
2022-11-17 22:33:17 +01:00
Philipp Krones
34a14349b7
Readd the matches_macro diag item
This is now used by Clippy
2022-11-17 19:32:28 +01:00
bors
83356b78c4 Auto merge of #104361 - vladimir-ea:watchos_fix_linking, r=oli-obk
[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.
2022-11-17 17:15:31 +00:00
bors
b6097f2e1b Auto merge of #104219 - bryangarza:async-track-caller-dup, r=eholk
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.
2022-11-17 13:47:03 +00:00
bors
7c75fe4c85 Auto merge of #104170 - cjgillot:hir-def-id, r=fee1-dead
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.
2022-11-17 07:42:27 +00:00
bors
251831ece9 Auto merge of #103138 - nnethercote:merge-BBs, r=bjorn3
Merge basic blocks where possible when generating LLVM IR.

r? `@ghost`
2022-11-17 01:56:24 +00:00
bors
bebd57a960 Auto merge of #102944 - nnethercote:ast-Lit-third-time-lucky, r=petrochenkov
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`
2022-11-16 23:03:14 +00:00
Michael Goulet
75afb22331 Check dyn* return type correctly 2022-11-16 22:21:41 +00:00
Matthias Krüger
163a7090b8
Rollup merge of #104394 - oli-obk:suggest_method_call, r=lcnr
various cleanups to try to reduce the use of spans inside method resolution

definitely review commit by commit.
2022-11-16 15:39:46 +01:00
Matthias Krüger
e033a389e1
Rollup merge of #104335 - Nilstrieb:macrowo, r=compiler-errors
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
2022-11-16 15:39:46 +01:00
Matthias Krüger
353b915fec
Rollup merge of #104317 - RalfJung:ctfe-error-reporting, r=oli-obk
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
2022-11-16 15:39:45 +01:00
Matthias Krüger
fbcd751ea1
Rollup merge of #104137 - StackDoubleFlow:err-lsc-unsupported, r=bjorn3
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
2022-11-16 15:39:45 +01:00
Matthias Krüger
56a28a65f5
Rollup merge of #103750 - calebzulawski:master, r=workingjubilee
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```
2022-11-16 15:39:44 +01:00
yukang
9c2d4dd529 fix #104510, Remove is_tainted_by_errors since we have ty_error for delay bug 2022-11-16 19:41:08 +08:00
yukang
20ea083d87 fix #104390, fix ICE in in_operand for ty error 2022-11-16 17:48:13 +08:00
Oli Scherer
4f11f3b257 Convert predicates into Predicate in the Obligation constructor 2022-11-16 09:25:19 +00:00
Oli Scherer
634df06fae Generalize the ToPredicate trait
Its name is now not accurate anymore, but we'll adjust that later
2022-11-16 09:20:28 +00:00
Ralf Jung
1115ec601a cleanup and dedupe CTFE and Miri error reporting 2022-11-16 10:13:29 +01:00
Matthias Krüger
3a8cacd7fb
Rollup merge of #104348 - fmease:iat-vis-stab, r=cjgillot
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)
2022-11-16 08:36:11 +01:00
Matthias Krüger
88a19197b9
Rollup merge of #104193 - TaKO8Ki:fix-104142, r=cjgillot
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.
2022-11-16 08:36:11 +01:00
Matthias Krüger
5140bbd102
Rollup merge of #103484 - saschanaz:patch-2, r=ehuss
Add `rust` to `let_underscore_lock` example

Currently https://doc.rust-lang.org/beta/rustc/lints/listing/deny-by-default.html#let-underscore-lock has no colored grammar and raw `{{produces}}` command is exposed.
2022-11-16 08:36:10 +01:00
Nicholas Nethercote
54082dd216 Merge basic blocks where possible when generating LLVM IR.
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.
2022-11-16 15:46:39 +11:00
Nicholas Nethercote
68194aa8d5 Use &mut Bx more.
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`.
2022-11-16 15:46:39 +11:00
bors
79146baa9c Auto merge of #102570 - cjgillot:deagg-debuginfo, r=oli-obk
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.
2022-11-15 23:52:22 +00:00
Nicholas Nethercote
358a603f11 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.

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
2022-11-16 09:41:28 +11:00
Kagami Sascha Rosylight
0a528b16fc
Merge branch 'master' into patch-2 2022-11-15 21:16:11 +01:00
Nilstrieb
b7b67228f9
Only do parser recovery on retried macro matching
This prevents issues with eager parser recovery during macro matching.
2022-11-15 19:34:35 +01:00
Camille GILLOT
779007da06 Enable SROA by at mir-opt level 3. 2022-11-15 17:59:36 +00:00
Camille GILLOT
e4f343191a Flatten aggregates into locals. 2022-11-15 17:55:11 +00:00
Camille GILLOT
b550eabfa6 Introduce composite debuginfo. 2022-11-15 17:53:50 +00:00
bors
a00f8ba7fc Auto merge of #104054 - RalfJung:byte-provenance, r=oli-obk
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`
2022-11-15 17:37:15 +00:00
Daniel del Castillo
557226348f Update compiler/rustc_ast_lowering/src/item.rs
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2022-11-15 13:57:25 +01:00
CastilloDel
fdb5fe2ed8 Change LoweringContext.children to Vec 2022-11-15 13:57:24 +01:00
CastilloDel
d1eab51f47 Make clobber_abis use an FxIndexMap
It seems to be used more for lookup than iteration, so this could be a
perf hit
2022-11-15 13:57:24 +01:00
CastilloDel
769cc733b1 Remove allow(rustc::potential_query_instability) from rustc_ast_lowering 2022-11-15 13:57:24 +01:00
bors
6d651a295e Auto merge of #104437 - matthiaskrgr:rollup-n5jdg9v, r=matthiaskrgr
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
2022-11-15 12:35:57 +00:00
Oli Scherer
e2fbd01ac3 Compare picks via Self type and associated item id 2022-11-15 11:26:17 +00:00
Oli Scherer
d06aac1783 Expose the fallibilty of the unstable lint emission in the method name 2022-11-15 11:26:12 +00:00
Oli Scherer
e65688386b Pull the unstable name collision hint emission out of method probing 2022-11-15 11:26:07 +00:00
Oli Scherer
e694ef5f20 Remove the fishy need for a PartialEq impl 2022-11-15 11:26:02 +00:00
Oli Scherer
c3c3719fdd Remove some redundant span arguments 2022-11-15 11:25:57 +00:00
Oli Scherer
44c4a7b6c4 Remove an unnecessary resolve_vars_if_possible 2022-11-15 11:05:59 +00:00