Commit Graph

1265 Commits

Author SHA1 Message Date
bors
5c786a7fe3 Auto merge of #121516 - RalfJung:platform-intrinsics-begone, r=oli-obk
remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics

`@Amanieu` `@workingjubilee` I don't think there is any reason these need to be "special"? The [original RFC](https://rust-lang.github.io/rfcs/1199-simd-infrastructure.html) indicated eventually making them stable, but I think that is no longer the plan, so seems to me like we can clean this up a bit.

Blocked on https://github.com/rust-lang/stdarch/pull/1538, https://github.com/rust-lang/rust/pull/121542.
2024-02-26 22:24:16 +00:00
Lieselotte
a3fce72a27
Add ast::ExprKind::Dummy 2024-02-25 22:22:09 +01:00
Ralf Jung
cc3df0af7b remove platform-intrinsics ABI; make SIMD intrinsics be regular intrinsics 2024-02-25 08:14:52 +01:00
Matthias Krüger
60cb794181
Rollup merge of #121391 - Nadrieril:fix-liveness, r=compiler-errors
never patterns: Fix liveness analysis in the presence of never patterns

There's a bunch of code that only looks at the first alternative of an or-pattern, under the assumption that all alternatives have the same set of bindings. This is true except for never pattern alternatives  (e.g. `Ok(x) | Err(!)`), so we skip these. I expect there's other code with this problem, I'll have to check that later.

I don't have tests for this yet because mir lowering causes other issues; I'll have some in the next PR.

r? ``@compiler-errors``
2024-02-21 22:48:58 +01:00
Nicholas Nethercote
72b172bdf6 Overhaul the handling of errors at the top-level.
Currently `emit_stashed_diagnostic` is called from four(!) different
places: `print_error_count`, `DiagCtxtInner::drop`, `abort_if_errors`,
and `compile_status`.

And `flush_delayed` is called from two different places:
`DiagCtxtInner::drop` and `Queries`.

This is pretty gross! Each one should really be called from a single
place, but there's a bunch of entanglements. This commit cleans up this
mess.

Specifically, it:
- Removes all the existing calls to `emit_stashed_diagnostic`, and adds
  a single new call in `finish_diagnostics`.
- Removes the early `flush_delayed` call in `codegen_and_build_linker`,
  replacing it with a simple early return if delayed bugs are present.
- Changes `DiagCtxtInner::drop` and `DiagCtxtInner::flush_delayed` so
  they both assert that the stashed diagnostics are empty (i.e.
  processed beforehand).
- Changes `interface::run_compiler` so that any errors emitted during
  `finish_diagnostics` (i.e. late-emitted stashed diagnostics) are
  counted and cannot be overlooked. This requires adding
  `ErrorGuaranteed` return values to several functions.
- Removes the `stashed_err_count` call in `analysis`. This is possible
  now that we don't have to worry about calling `flush_delayed` early
  from `codegen_and_build_linker` when stashed diagnostics are pending.
- Changes the `span_bug` case in `handle_tuple_field_pattern_match` to a
  `delayed_span_bug`, because it now can be reached due to the removal
  of the `stashed_err_count` call in `analysis`.
- Slightly changes the expected output of three tests. If no errors are
  emitted but there are delayed bugs, the error count is no longer
  printed. This is because delayed bugs are now always printed after the
  error count is printed (or not printed, if the error count is zero).

There is a lot going on in this commit. It's hard to break into smaller
pieces because the existing code is very tangled. It took me a long time
and a lot of effort to understand how the different pieces interact, and
I think the new code is a lot simpler and easier to understand.
2024-02-22 08:03:47 +11:00
Nadrieril
5e0e5b1efb Fix liveness analysis in the presence of never patterns 2024-02-21 12:04:39 +01:00
Nilstrieb
073d2983a4
Rollup merge of #121167 - petrochenkov:unload2, r=wesleywiser
resolve: Scale back unloading of speculatively loaded crates

Fixes https://github.com/rust-lang/rust/issues/120830 and fixes https://github.com/rust-lang/rust/issues/120909 while still unblocking https://github.com/rust-lang/rust/pull/117772.

I cannot reproduce https://github.com/parasyte/crash-rustc as an UI test for some reason, but I tested all the cases linked above manually.
2024-02-20 15:13:50 +01:00
Nicholas Nethercote
f6f8779843 Reduce capabilities of Diagnostic.
Currently many diagnostic modifier methods are available on both
`Diagnostic` and `DiagnosticBuilder`. This commit removes most of them
from `Diagnostic`. To minimize the diff size, it keeps them within
`diagnostic.rs` but changes the surrounding `impl Diagnostic` block to
`impl DiagnosticBuilder`. (I intend to move things around later, to give
a more sensible code layout.)

`Diagnostic` keeps a few methods that it still needs, like `sub`,
`arg`, and `replace_args`.

The `forward!` macro, which defined two additional methods per call
(e.g. `note` and `with_note`), is replaced by the `with_fn!` macro,
which defines one additional method per call (e.g. `with_note`). It's
now also only used when necessary -- not all modifier methods currently
need a `with_*` form. (New ones can be easily added as necessary.)

All this also requires changing `trait AddToDiagnostic` so its methods
take `DiagnosticBuilder` instead of `Diagnostic`, which leads to many
mechanical changes. `SubdiagnosticMessageOp` gains a type parameter `G`.

There are three subdiagnostics -- `DelayedAtWithoutNewline`,
`DelayedAtWithNewline`, and `InvalidFlushedDelayedDiagnosticLevel` --
that are created within the diagnostics machinery and appended to
external diagnostics. These are handled at the `Diagnostic` level, which
means it's now hard to construct them via `derive(Diagnostic)`, so
instead we construct them by hand. This has no effect on what they look
like when printed.

There are lots of new `allow` markers for `untranslatable_diagnostics`
and `diagnostics_outside_of_impl`. This is because
`#[rustc_lint_diagnostics]` annotations were present on the `Diagnostic`
modifier methods, but missing from the `DiagnosticBuilder` modifier
methods. They're now present.
2024-02-20 13:22:17 +11:00
Vadim Petrochenkov
24cffbf703 resolve: Scale back unloading of speculatively loaded crates 2024-02-18 20:59:19 +03:00
bors
1be468815c Auto merge of #120486 - reitermarkus:use-generic-nonzero, r=dtolnay
Use generic `NonZero` internally.

Tracking issue: https://github.com/rust-lang/rust/issues/120257
2024-02-16 07:46:31 +00:00
Markus Reiter
a90cc05233
Replace NonZero::<_>::new with NonZero::new. 2024-02-15 08:09:42 +01:00
Markus Reiter
746a58d435
Use generic NonZero internally. 2024-02-15 08:09:42 +01:00
Nicholas Nethercote
5233bc91da Add an ErrorGuaranteed to ast::TyKind::Err.
This makes it more like `hir::TyKind::Err`, and avoids a
`span_delayed_bug` call in `LoweringContext::lower_ty_direct`.

It also requires adding `ast::TyKind::Dummy`, now that
`ast::TyKind::Err` can't be used for that purpose in the absence of an
error emission.

There are a couple of cases that aren't as neat as I would have liked,
marked with `FIXME` comments.
2024-02-15 09:35:11 +11:00
clubby789
4de3a3af4a Bump indexmap
`swap` has been deprecated in favour of `swap_remove` - the behaviour
is the same though.
2024-02-13 21:03:34 +00:00
Matthias Krüger
cb0d74be28
Rollup merge of #120958 - ShoyuVanilla:remove-subst, r=oli-obk
Dejargonize `subst`

In favor of #110793, replace almost every occurence of `subst` and `substitution` from rustc codes, but they still remains in subtrees under `src/tools/` like clippy and test codes (I'd like to replace them after this)
2024-02-12 23:18:54 +01:00
Matthias Krüger
15896bdd18
Rollup merge of #120950 - compiler-errors:miri-async-closurs, r=RalfJung,oli-obk
Fix async closures in CTFE

First commit renames `is_coroutine_or_closure` into `is_closure_like`, because `is_coroutine_or_closure_or_coroutine_closure` seems confusing and long.

Second commit fixes some forgotten cases where we want to handle `TyKind::CoroutineClosure` the same as closures and coroutines.

The test exercises the change to `ValidityVisitor::aggregate_field_path_elem` which is the source of #120946, but not the change to `UsedParamsNeedSubstVisitor`, though I feel like it's not that big of a deal. Let me know if you'd like for me to look into constructing a test for the latter, though I have no idea what it'd look like (we can't assert against `TooGeneric` anywhere?).

Fixes #120946

r? oli-obk cc ``@RalfJung``
2024-02-12 23:18:53 +01:00
bors
b381d3ab27 Auto merge of #120980 - matthiaskrgr:rollup-dsjsqql, r=matthiaskrgr
Rollup of 11 pull requests

Successful merges:

 - #120765 (Reorder diagnostics API)
 - #120833 (More internal emit diagnostics cleanups)
 - #120899 (Gracefully handle non-WF alias in `assemble_alias_bound_candidates_recur`)
 - #120917 (Remove a bunch of dead parameters in functions)
 - #120928 (Add test for recently fixed issue)
 - #120933 (check_consts: fix duplicate errors, make importance consistent)
 - #120936 (improve `btree_cursors` functions documentation)
 - #120944 (Check that the ABI of the instance we are inlining is correct)
 - #120956 (Clean inlined type alias with correct param-env)
 - #120962 (Add myself to library/std review)
 - #120972 (fix ICE for deref coercions with type errors)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-12 17:06:22 +00:00
Matthias Krüger
ebe36ac815
Rollup merge of #120917 - chenyukang:yukang-dead-parameters, r=compiler-errors
Remove a bunch of dead parameters in functions

Found this kind of issue when working on https://github.com/rust-lang/rust/pull/119650
I wrote a trivial toy lint and manual review to find these.
2024-02-12 18:04:08 +01:00
Shoyu Vanilla
3856df059e Dejargnonize subst 2024-02-12 15:46:35 +09:00
Frank King
879a1e5713 Lower anonymous structs or unions to HIR 2024-02-12 12:47:23 +08:00
yukang
2bcbc16caf remove a bunch of dead parameters in fn 2024-02-12 09:51:35 +08:00
Matthias Krüger
4c154a1a48
Rollup merge of #120872 - petrochenkov:opthirpar, r=cjgillot
hir: Refactor getters for HIR parents

See individual commits.

I ended up removing on of the FIXMEs from https://github.com/rust-lang/rust/pull/120206 instead of addressing it.
2024-02-11 23:19:08 +01:00
Michael Goulet
cb024ba6e3 is_closure_like 2024-02-11 22:09:52 +00:00
Vadim Petrochenkov
b07283815b hir: Remove hir::Map::{opt_parent_id,parent_id,get_parent,find_parent} 2024-02-10 12:24:46 +03:00
Zalathar
cf1096eb72 Remove unnecessary #![feature(min_specialization)] 2024-02-10 12:26:14 +11:00
Matthias Krüger
46a0448405
Rollup merge of #120693 - nnethercote:invert-diagnostic-lints, r=davidtwco
Invert diagnostic lints.

That is, change `diagnostic_outside_of_impl` and `untranslatable_diagnostic` from `allow` to `deny`, because more than half of the compiler has been converted to use translated diagnostics.

This commit removes more `deny` attributes than it adds `allow` attributes, which proves that this change is warranted.

r? ````@davidtwco````
2024-02-09 14:41:50 +01:00
bors
1280928a99 Auto merge of #120767 - matthiaskrgr:rollup-0k8ib1c, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #119592 (resolve: Unload speculatively resolved crates before freezing cstore)
 - #120103 (Make it so that async-fn-in-trait is compatible with a concrete future in implementation)
 - #120206 (hir: Make sure all `HirId`s have corresponding HIR `Node`s)
 - #120214 (match lowering: consistently lower bindings deepest-first)
 - #120688 (GVN: also turn moves into copies with projections)
 - #120702 (docs: also check the inline stmt during redundant link check)
 - #120727 (exhaustiveness: Prefer "`0..MAX` not covered" to "`_` not covered")
 - #120734 (Add `SubdiagnosticMessageOp` as a trait alias.)
 - #120739 (improve pretty printing for associated items in trait objects)

r? `@ghost`
`@rustbot` modify labels: rollup
2024-02-08 12:14:19 +00:00
Oli Scherer
eab2adb660 Continue to borrowck even if there were previous errors 2024-02-08 08:10:43 +00:00
Matthias Krüger
87e1e05aa1
Rollup merge of #120734 - nnethercote:SubdiagnosticMessageOp, r=compiler-errors
Add `SubdiagnosticMessageOp` as a trait alias.

It avoids a lot of repetition.

r? matthewjasper
2024-02-08 09:06:36 +01:00
Matthias Krüger
bf2ba8611e
Rollup merge of #120206 - petrochenkov:somehir, r=compiler-errors
hir: Make sure all `HirId`s have corresponding HIR `Node`s

And then remove `tcx.opt_hir_node(hir_id)` in favor of `tcx.hir_node(hir_id)`.
2024-02-08 09:06:32 +01:00
Nicholas Nethercote
6b175a848d Add SubdiagnosticMessageOp as a trait alias.
It avoids a lot of repetition.
2024-02-08 13:02:44 +11:00
Guillaume Boisseau
f5a36cbd73
Rollup merge of #120470 - estebank:issue-54196, r=compiler-errors
Mark "unused binding" suggestion as maybe incorrect

Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change.

Fix #54196.
2024-02-07 18:24:42 +01:00
Vadim Petrochenkov
a61019b290 hir: Remove fn opt_hir_id and fn opt_span 2024-02-07 09:38:24 +03:00
r0cky
40878ca6ea Make traits / trait methods detected by the dead code lint! 2024-02-07 10:22:16 +08:00
Matthias Krüger
59ba8024af
Rollup merge of #120502 - clubby789:remove-ffi-returns-twice, r=compiler-errors
Remove `ffi_returns_twice` feature

The [tracking issue](https://github.com/rust-lang/rust/issues/58314) and [RFC](https://github.com/rust-lang/rfcs/pull/2633) have been closed for a couple of years.

There is also an attribute gate in R-A which should be removed if this lands.
2024-02-06 22:45:42 +01:00
Esteban Küber
aef18c9bfb Mark "unused binding" suggestion as maybe incorrect
Ignoring unused bindings should be a determination made by a human, `rustfix` shouldn't auto-apply the suggested change.

Fix #54196.
2024-02-06 17:13:58 +00:00
Michael Goulet
c567eddec2 Add CoroutineClosure to TyKind, AggregateKind, UpvarArgs 2024-02-06 02:22:58 +00:00
Nicholas Nethercote
0ac1195ee0 Invert diagnostic lints.
That is, change `diagnostic_outside_of_impl` and
`untranslatable_diagnostic` from `allow` to `deny`, because more than
half of the compiler has be converted to use translated diagnostics.

This commit removes more `deny` attributes than it adds `allow`
attributes, which proves that this change is warranted.
2024-02-06 13:12:33 +11:00
Matthias Krüger
326839bf7f
Rollup merge of #120616 - fmease:fix-ice-const-eval-fail-undef-field-access, r=compiler-errors
Fix ICE on field access on a tainted type after const-eval failure

Fixes #120615.

r? oli-obk or compiler
2024-02-03 21:29:45 +01:00
León Orell Valerian Liehr
4f773af1cc
Check for presence of field in typeck results before visiting it
Co-authored-by: Michael Goulet <michael@errs.io>
2024-02-03 19:41:18 +01:00
Nadrieril
032596e34c
Rollup merge of #120472 - Nilstrieb:die, r=compiler-errors
Make duplicate lang items fatal

Prevents terminal spam.
2024-01-31 12:10:52 +01:00
clubby789
7331315898 Remove ffi_returns_twice feature 2024-01-30 22:09:09 +00:00
Guillaume Gomez
ee2e9e1eda
Rollup merge of #118533 - chenyukang:yukang-fix-118455, r=petrochenkov
Suppress unhelpful diagnostics for unresolved top level attributes

Fixes #118455, unresolved top level attribute error didn't imported prelude and already have emitted an error, report builtin macro and attributes error by the way, so `check_invalid_crate_level_attr` in can ignore them.

Also fixes #89566, fixes #67107.

r? `@petrochenkov`
2024-01-30 16:57:46 +01:00
Guillaume Gomez
f99b510429
Rollup merge of #120488 - nnethercote:diag-lifetimes, r=oli-obk
Diagnostic lifetimes cleanups

Some diagnostic simplifications.

r? `@oli-obk`
2024-01-30 11:19:20 +01:00
Nicholas Nethercote
5350edb9e8 Remove the lifetime from DiagnosticArgValue.
Because it's almost always static.

This makes `impl IntoDiagnosticArg for DiagnosticArgValue` trivial,
which is nice.

There are a few diagnostics constructed in
`compiler/rustc_mir_build/src/check_unsafety.rs` and
`compiler/rustc_mir_transform/src/errors.rs` that now need symbols
converted to `String` with `to_string` instead of `&str` with `as_str`,
but that' no big deal, and worth it for the simplifications elsewhere.
2024-01-30 18:46:06 +11:00
Nilstrieb
ad1e6298ed Make duplicate lang items fatal
Prevents terminal spam.
2024-01-29 20:03:14 +01:00
Dylan DPC
eaa100204e
Rollup merge of #120428 - petrochenkov:somehir2, r=compiler-errors
hir: Two preparatory changes for #120206

cc https://github.com/rust-lang/rust/pull/120206
r? ```@compiler-errors```
2024-01-29 12:56:54 +00:00
yukang
492df34eea Supress unhelpful diagnostics for unresolved top level attributes 2024-01-29 17:43:07 +08:00
Nicholas Nethercote
5d9dfbd08f Stop using String for error codes.
Error codes are integers, but `String` is used everywhere to represent
them. Gross!

This commit introduces `ErrCode`, an integral newtype for error codes,
replacing `String`. It also introduces a constant for every error code,
e.g. `E0123`, and removes the `error_code!` macro. The constants are
imported wherever used with `use rustc_errors::codes::*`.

With the old code, we have three different ways to specify an error code
at a use point:
```
error_code!(E0123)  // macro call

struct_span_code_err!(dcx, span, E0123, "msg");  // bare ident arg to macro call

\#[diag(name, code = "E0123")]  // string
struct Diag;
```

With the new code, they all use the `E0123` constant.
```
E0123  // constant

struct_span_code_err!(dcx, span, E0123, "msg");  // constant

\#[diag(name, code = E0123)]  // constant
struct Diag;
```

The commit also changes the structure of the error code definitions:
- `rustc_error_codes` now just defines a higher-order macro listing the
  used error codes and nothing else.
- Because that's now the only thing in the `rustc_error_codes` crate, I
  moved it into the `lib.rs` file and removed the `error_codes.rs` file.
- `rustc_errors` uses that macro to define everything, e.g. the error
  code constants and the `DIAGNOSTIC_TABLES`. This is in its new
  `codes.rs` file.
2024-01-29 07:41:41 +11:00
Vadim Petrochenkov
5f8030dcc9 hir: Remove unnecessary HirId from hir::Let
It has 1-to-1 correspondence to its expression id.

Also remove mostly useless `visit_let_expr`.
2024-01-28 02:04:39 +03:00