Commit Graph

418 Commits

Author SHA1 Message Date
SLASHLogin
ddbb650289 Import ErrorWritingDEFFile 2022-11-09 14:56:21 +01:00
SLASHLogin
d32caf9ced Port ArchiveBuildFailure 2022-11-09 14:56:21 +01:00
SLASHLogin
978b5f73e4 Port SanitizerMemtagRequiresMte 2022-11-09 14:56:21 +01:00
SLASHLogin
60ee496c74 Port LinkageConstOrMutType error 2022-11-09 14:56:20 +01:00
SLASHLogin
5d79d3c4bb Port InvalidMinimumAlignment 2022-11-09 14:56:20 +01:00
SLASHLogin
39d363fd58 Port layout size overflow 2022-11-09 14:56:20 +01:00
SLASHLogin
f031823ecd Formatting 2022-11-09 14:56:20 +01:00
SLASHLogin
59b8aedf0e Port branch protection on aarch64 2022-11-09 14:56:20 +01:00
SLASHLogin
9f0c16576b Port symbol_already_defined error 2022-11-09 14:56:20 +01:00
SLASHLogin
4c625dc682 Port Instrument coverage requires llvm 12 to the new struct 2022-11-09 14:56:20 +01:00
SLASHLogin
05ae7ecb74 Import error creating import library 2022-11-09 14:56:20 +01:00
SLASHLogin
21b04265c1 Trailing whitespaces 2022-11-09 14:56:20 +01:00
SLASHLogin
1c4bd835ec locales formatting 2022-11-09 14:56:20 +01:00
SLASHLogin
575f6098da Port unknown feature diagnostic to the new framework 2022-11-09 14:56:20 +01:00
Manish Goregaokar
7dfe1e1664
Rollup merge of #103559 - AndyJado:var_span_label, r=davidtwco
first move on a nested span_label

trying not to be smart this time.
2022-11-08 21:03:53 -05:00
Matthias Krüger
58f5d57b5d
Rollup merge of #103012 - chenyukang:fix-102806, r=davidtwco,compiler-errors
Suggest use .. to fill in the rest of the fields of Struct

Fixes #102806
2022-11-06 08:35:26 +01:00
AndyJado
e49d10db14 first move on a nested span_label
Apply suggestions from code review

Co-authored-by: David Wood <agile.lion3441@fuligin.ink>
2022-11-05 19:43:48 +08:00
clubby789
2f882c014f Specify that break cannot be used outside of loop *or* labeled block 2022-11-05 01:12:58 +00:00
Matthias Krüger
1cb8684dde
Rollup merge of #103792 - JhonnyBillM:migrate-codegen-ssa-to-diagnostics-structs-pt2, r=davidtwco
Migrate `codegen_ssa` to diagnostics structs - [Part 2]

Completes migrating `link.rs` in `codegen_ssa` module.

_Part 1 - https://github.com/rust-lang/rust/pull/102612_

r? `@davidtwco`
2022-11-04 18:52:27 +01:00
Matthias Krüger
612bb7890c
Rollup merge of #103397 - crlf0710:port_dead_code_lint, r=davidtwco
Port `dead_code` lints to be translatable.

This adds an additional comma to lists with three or more items, to be consistent with list formatters like `icu4x`.

r? `@davidtwco`
2022-11-04 18:52:26 +01:00
Jhonny Bill Mena
2678765d08 FIX - Migrate missing errors in link.rs 2022-11-04 01:17:02 -04:00
Jhonny Bill Mena
1f4c5a624f ADD - ExtractBundledLibsError. Migrated extract_bundled_libs to translatable diagnostics 2022-11-04 01:17:02 -04:00
Jhonny Bill Mena
4c80f50fc6 UPDATE - Complete link.rs migration to new diagnostics infraestructure 2022-11-04 01:17:02 -04:00
yukang
1e25882944 fix #102806, suggest use .. to fill in the rest of the fields of Struct 2022-11-04 10:35:36 +08:00
Charles Lew
a777c46dff Use derive(Subdiagnostic) for ChangeFieldsToBeOfUnitType. 2022-11-04 03:02:09 +08:00
Dylan DPC
43634675f6
Rollup merge of #103061 - Amanieu:rewrite_alloc_error_handler, r=bjorn3
Rewrite implementation of `#[alloc_error_handler]`

The new implementation doesn't use weak lang items and instead changes `#[alloc_error_handler]` to an attribute macro just like `#[global_allocator]`.

The attribute will generate the `__rg_oom` function which is called by the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom` function is defined in any crate then the compiler shim will call `__rdl_oom` in the alloc crate which will simply panic.

This also fixes link errors with `-C link-dead-code` with `default_alloc_error_handler`: `__rg_oom` was previously defined in the alloc crate and would attempt to reference the `oom` lang item, even if it didn't exist. This worked as long as `__rg_oom` was excluded from linking since it was not called.

This is a prerequisite for the stabilization of `default_alloc_error_handler` (#102318).
2022-11-01 14:12:25 +05:30
Yuki Okushi
5bf9d617cb
Rollup merge of #103772 - compiler-errors:better-strict-coherence-err, r=davidtwco
better error for `rustc_strict_coherence` misuse

Fixes #103753
2022-11-01 12:03:42 +09:00
Amanieu d'Antras
56074b5231 Rewrite implementation of #[alloc_error_handler]
The new implementation doesn't use weak lang items and instead changes
`#[alloc_error_handler]` to an attribute macro just like
`#[global_allocator]`.

The attribute will generate the `__rg_oom` function which is called by
the compiler-generated `__rust_alloc_error_handler`. If no `__rg_oom`
function is defined in any crate then the compiler shim will call
`__rdl_oom` in the alloc crate which will simply panic.

This also fixes link errors with `-C link-dead-code` with
`default_alloc_error_handler`: `__rg_oom` was previously defined in the
alloc crate and would attempt to reference the `oom` lang item, even if
it didn't exist. This worked as long as `__rg_oom` was excluded from
linking since it was not called.

This is a prerequisite for the stabilization of
`default_alloc_error_handler` (#102318).
2022-10-31 16:32:57 +00:00
Michael Goulet
953727f574 better error for rustc_strict_coherence misuse 2022-10-30 19:11:55 +00:00
Cameron Steffen
88d71504dd Use tcx.require_lang_item 2022-10-29 16:09:15 -05:00
Matthias Krüger
790a716420
Rollup merge of #103383 - compiler-errors:tait-scope, r=oli-obk
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``
2022-10-29 08:57:35 +02:00
Boxy
b3425587a6 tidy + move logic to fn 2022-10-27 22:29:16 +01:00
Boxy
ca5a6e43dd use proper spans 2022-10-27 22:18:26 +01:00
Boxy
c00ff9c4d0 DoIt 2022-10-27 21:48:47 +01:00
Oli Scherer
1c26a278f3 Split diagnostic details out into a separate function and fluent files 2022-10-25 18:28:04 +00:00
Charles Lew
113e8dfb72 Port dead_code lints to be translatable. 2022-10-24 17:02:31 +08:00
Jakub Beránek
c5c86806c8
Introduce dedicated -Zdylib-lto flag for enabling LTO on dylibs 2022-10-23 13:48:03 +02:00
Michael Goulet
4accf838f6 Note scope of TAIT more accurately 2022-10-22 03:09:49 +00:00
Dylan DPC
e11511dfa6
Rollup merge of #103051 - davidtwco:translation-tidying-up, r=compiler-errors
translation: doc comments with derives, subdiagnostic-less enum variants, more derive use

- Adds support for `doc` attributes in the diagnostic derives so that documentation comments don't result in the derive failing.
- Adds support for enum variants in the subdiagnostic derive to not actually correspond to an addition to a diagnostic.
- Made use of the derive in more places in the `rustc_ast_lowering`, `rustc_ast_passes`, `rustc_lint`, `rustc_session`, `rustc_infer` - taking advantage of recent additions like eager subdiagnostics, multispan suggestions, etc.

cc #100717
2022-10-21 17:29:58 +05:30
Matthias Krüger
66de34b035
Rollup merge of #102454 - chenyukang:fix-102396-missing-parentheses, r=lcnr
Suggest parentheses for possible range method calling

Fixes #102396
2022-10-17 17:15:49 +02:00
David Wood
913f597402 infer: use derive more
Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-17 09:54:24 +01:00
David Wood
f8b628bce4 session: use derive more
Signed-off-by: David Wood <david.wood@huawei.com>
2022-10-17 09:54:24 +01:00
yukang
151001c1cb trivial fix for comments feedback 2022-10-17 08:32:08 +08:00
Guillaume Gomez
f528414e40 Add missing checks for doc(cfg_hide(...)) attribute 2022-10-14 11:29:54 +02:00
bors
1755c85302 Auto merge of #102684 - JhonnyBillM:delete-target-data-layout-errors-wrapper, r=davidtwco
Move `IntoDiagnostic` conformance for `TargetDataLayoutErrors` into `rustc_errors`

Addressed this suggestion https://github.com/rust-lang/rust/pull/101558#issuecomment-1243830009.

This way we comply with the Coherence rule given that `IntoDiagnostic` trait is defined in `rustc_errors`, and almost all other crates depend on it.
2022-10-14 04:35:22 +00:00
Wesley Wiser
097b6d3baf Add suggestion to the "missing native library" error
If we fail to locate a native library that we are linking with, it could
be the case the user entered a complete file name like `foo.lib` or
`libfoo.a` when we expect them to simply provide `foo`.

In this situation, we now detect that case and suggest the user only
provide the library name itself.
2022-10-13 07:35:36 -04:00
Jhonny Bill Mena
5645cd5b09 ADD - IntoDiagnostic conformance for TargetDataLayoutErrors in rustc_errors
This way we comply with the Coherence rule given that IntoDiagnostic trait is defined in rustc_errors, and almost all other crates depend on it.
2022-10-12 16:54:25 -04:00
Dylan DPC
40deecef03
Rollup merge of #102719 - Nilstrieb:tidy-alphabetical, r=jackh726
Enforce alphabetical sorting with tidy

We have many places where things are supposed to be sorted alphabetically. For the smaller and more recent size assertions, this is mostly upheld, but in other more... alive places it's very messy.

This introduces a new tidy directive to check that a section of code is sorted alphabetically and fixes all places where sorting has gone wrong.
2022-10-12 22:13:24 +05:30
Dylan DPC
dc9f6f3243
Rollup merge of #102623 - davidtwco:translation-eager, r=compiler-errors
translation: eager translation

Part of #100717. See [Zulip thread](https://rust-lang.zulipchat.com/#narrow/stream/336883-i18n/topic/.23100717.20lists!/near/295010720) for additional context.

- **Store diagnostic arguments in a `HashMap`**: Eager translation will enable subdiagnostics to be translated multiple times with different arguments - this requires the ability to replace the value of one argument with a new value, which is better suited to a `HashMap` than the previous storage, a `Vec`.
- **Add `AddToDiagnostic::add_to_diagnostic_with`**: `AddToDiagnostic::add_to_diagnostic_with` is similar to the previous `AddToDiagnostic::add_to_diagnostic` but takes a function that can be used by the caller to modify diagnostic messages originating from the subdiagnostic (such as performing translation eagerly). `add_to_diagnostic` now just calls `add_to_diagnostic_with` with an empty closure.
- **Add `DiagnosticMessage::Eager`**: Add variant of `DiagnosticMessage` for eagerly translated messages
(messages in the target language which don't need translated by the emitter during emission). Also adds `eager_subdiagnostic` function which is intended to be invoked by the diagnostic derive for subdiagnostic fields which are marked as needing eager translation.
- **Support `#[subdiagnostic(eager)]`**: Add support for `eager` argument to the `subdiagnostic` attribute which generates a call to `eager_subdiagnostic`.
- **Finish migrating `rustc_query_system`**: Using eager translation, migrate the remaining repeated cycle stack diagnostic.
- **Split formatting initialization and use in diagnostic derives**: Diagnostic derives have previously had to take special care when ordering the generated code so that fields were not used after a move.

  This is unlikely for most fields because a field is either annotated with a subdiagnostic attribute and is thus likely a `Span` and copiable, or is a argument, in which case it is only used once by `set_arg`
anyway.

  However, format strings for code in suggestions can result in fields being used after being moved if not ordered carefully. As a result, the derive currently puts `set_arg` calls last (just before emission), such as:

      let diag = { /* create diagnostic */ };

      diag.span_suggestion_with_style(
          span,
          fluent::crate::slug,
          format!("{}", __binding_0),
          Applicability::Unknown,
          SuggestionStyle::ShowAlways
      );
      /* + other subdiagnostic additions */

      diag.set_arg("foo", __binding_0);
      /* + other `set_arg` calls */

      diag.emit();

  For eager translation, this doesn't work, as the message being translated eagerly can assume that all arguments are available - so arguments _must_ be set first.

  Format strings for suggestion code are now separated into two parts - an initialization line that performs the formatting into a variable, and a usage in the subdiagnostic addition.

  By separating these parts, the initialization can happen before arguments are set, preserving the desired order so that code compiles, while still enabling arguments to be set before subdiagnostics are added.

      let diag = { /* create diagnostic */ };

      let __code_0 = format!("{}", __binding_0);
      /* + other formatting */

      diag.set_arg("foo", __binding_0);
      /* + other `set_arg` calls */

      diag.span_suggestion_with_style(
          span,
          fluent::crate::slug,
          __code_0,
          Applicability::Unknown,
          SuggestionStyle::ShowAlways
      );
      /* + other subdiagnostic additions */

      diag.emit();

- **Remove field ordering logic in diagnostic derive:** Following the approach taken in earlier commits to separate formatting initialization from use in the subdiagnostic derive, simplify the diagnostic derive by removing the field-ordering logic that previously solved this problem.

r? ```@compiler-errors```
2022-10-12 22:13:23 +05:30
Nilstrieb
7bfef19844 Use tidy-alphabetical in the compiler 2022-10-12 17:49:10 +05:30