Commit Graph

28 Commits

Author SHA1 Message Date
David Wood ec5328b3d9 errors: only eagerly translate subdiagnostics
Subdiagnostics don't need to be lazily translated, they can always be
eagerly translated. Eager translation is slightly more complex as we need
to have a `DiagCtxt` available to perform the translation, which involves
slightly more threading of that context.

This slight increase in complexity should enable later simplifications -
like passing `DiagCtxt` into `AddToDiagnostic` and moving Fluent messages
into the diagnostic structs rather than having them in separate files
(working on that was what led to this change).

Signed-off-by: David Wood <david@davidtw.co>
2024-02-15 10:34:41 +00:00
Nicholas Nethercote b9d44eef7a 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
Nicholas Nethercote a56eff2b41 Rename some Diagnostic setters.
`Diagnostic` has 40 methods that return `&mut Self` and could be
considered setters. Four of them have a `set_` prefix. This doesn't seem
necessary for a type that implements the builder pattern. This commit
removes the `set_` prefixes on those four methods.
2024-01-03 19:40:20 +11:00
Nicholas Nethercote 472ea06999 Add level arg to into_diagnostic.
And make all hand-written `IntoDiagnostic` impls generic, by using
`DiagnosticBuilder::new(dcx, level, ...)` instead of e.g.
`dcx.struct_err(...)`.

This means the `create_*` functions are the source of the error level.
This change will let us remove `struct_diagnostic`.

Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`,
it's necessary to pass diagnostics tests now that it's used in
`into_diagnostic` functions.
2023-12-19 09:19:25 +11:00
Nicholas Nethercote 5ea71c1150 Rename many DiagCtxt arguments. 2023-12-18 16:06:22 +11:00
Nicholas Nethercote 590e0d9573 Rename Handler as DiagCtxt. 2023-12-18 16:06:19 +11:00
Nicholas Nethercote f9a228df48 Rename some arguments.
`sess` is a terribly misleading name for a `Handler`! This confused me
for a bit.
2023-12-04 18:57:41 +11:00
Antoni Boucher 242a482c88 Merge commit '11a0cceab966e5ff1058ddbcab5977e8a1d6d290' into subtree-update_cg_gcc_2023-10-09 2023-10-09 15:53:34 -04:00
Jhonny Bill Mena f746fe1e6c UPDATE - replace expected_simd error with one from codegen_ssa
Here I am assuming we want to treat these parameters (input, first, second, third, return) as translatable
2023-07-20 00:20:00 -04:00
Jhonny Bill Mena 5f56f49946 UPDATE - replace gcc monomorphization errors with ssa ones
Reduces error duplication and makes it more consistent across backends
2023-07-19 23:40:08 -04:00
Antoni Boucher cf9c2f840f Fix for diagnostics 2023-03-05 12:31:16 -05:00
Antoni Boucher d725cfb6ab Merge commit '08a6d6e16b5efe217123e780398969946266268f' into sync-cg_gcc-2023-03-04 2023-03-05 12:03:19 -05:00
Peter Collingbourne 6181cb2929 Move linkage type check to HIR analysis and fix semantics issues.
This ensures that the error is printed even for unused variables,
as well as unifying the handling between the LLVM and GCC backends.

This also fixes unusual behavior around exported Rust-defined variables
with linkage attributes. With the previous behavior, it appears to be
impossible to define such a variable such that it can actually be imported
and used by another crate. This is because on the importing side, the
variable is required to be a pointer, but on the exporting side, the
type checker rejects static variables of pointer type because they do
not implement `Sync`. Even if it were possible to import such a type, it
appears that code generation on the importing side would add an unexpected
additional level of pointer indirection, which would break type safety.

This highlighted that the semantics of linkage on Rust-defined variables
is different to linkage on foreign items. As such, we now model the
difference with two different codegen attributes: linkage for Rust-defined
variables, and import_linkage for foreign items.

This change gives semantics to the test
src/test/ui/linkage-attr/auxiliary/def_illtyped_external.rs which was
previously expected to fail to compile. Therefore, convert it into a
test that is expected to successfully compile.

The update to the GCC backend is speculative and untested.
2022-12-05 15:05:43 -08:00
bjorn3 690085c2da Rewrite LLVM's archive writer in Rust
This allows it to be used by other codegen backends
2022-11-26 19:35:32 +00:00
Nilstrieb d3b02e3186 Migrate all diagnostics 2022-10-23 10:09:44 +02:00
Ellis Hoag 5ae3bf2ed3 print <signal> when ranlib failed without an exit code 2022-09-28 19:02:38 -07:00
Ellis Hoag 277b997adc lint and remove unused diagnostic 2022-09-26 19:57:40 -07:00
Ellis Hoag 0ae1e27b17 fix lifetime error 2022-09-24 11:36:16 -07:00
Ellis Hoag 43b3206571 rebase and update trait names 2022-09-24 11:06:05 -07:00
Ellis Hoag 059326c4bd Add monomorphization errors 2022-09-24 10:24:48 -07:00
Ellis Hoag 70ab0548a0 lint type 2022-09-24 10:24:48 -07:00
Ellis Hoag d3bb849fe9 Add wrapper type for ExitCode for use in RanlibFailure 2022-09-24 10:24:48 -07:00
Ellis Hoag ff9bf7b6b3 remove IntoDiagnosticArg impl for Option 2022-09-24 10:24:48 -07:00
Ellis Hoag 534ce39aac Add LayoutSizeOverflow 2022-09-24 10:24:48 -07:00
Ellis Hoag 33b58ebf22 Add LTONotSupported 2022-09-24 10:24:48 -07:00
Ellis Hoag 7fc07caf67 Add UnwindingInlineAsm 2022-09-24 10:24:48 -07:00
Ellis Hoag 7277046d84 Add LinkageConstOrMutType 2022-09-24 10:24:48 -07:00
Ellis Hoag 23eae52d45 Add RanlibFailure 2022-09-24 10:24:48 -07:00