about summary refs log tree commit diff
path: root/compiler/rustc_session/src
AgeCommit message (Collapse)AuthorLines
2024-02-07Rollup merge of #119162 - heiher:direct-access-external-data, r=petrochenkovGuillaume Boisseau-0/+9
Add unstable `-Z direct-access-external-data` cmdline flag for `rustc` The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/707 Fixes #118053
2024-02-07Remove return value from `emit_stashed_diagnostics`.Nicholas Nethercote-1/+1
It's never used.
2024-02-06Invert diagnostic lints.Nicholas Nethercote-2/+0
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-03Simplify future breakage control flow.Nicholas Nethercote-12/+2
`emit_future_breakage` calls `self.dcx().take_future_breakage_diagnostics()` and then passes the result to `self.dcx().emit_future_breakage_report(diags)`. This commit removes the first of these and lets `emit_future_breakage_report` do the taking. It also inlines and removes what is left of `emit_future_breakage`, which has a single call site.
2024-02-03`SilentEmitter::fatal_note` doesn't need to be optional.Nicholas Nethercote-1/+1
2024-01-30Remove the lifetime from `DiagnosticArgValue`.Nicholas Nethercote-2/+2
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-29Stop using `String` for error codes.Nicholas Nethercote-7/+5
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-27Auto merge of #118636 - h1467792822:dev, r=michaelwoeristerbors-2/+19
Add the unstable option to reduce the binary size of dynamic library… # Motivation The average length of symbol names in the rust standard library is about 100 bytes, while the average length of symbol names in the C++ standard library is about 65 bytes. In some embedded environments where dynamic library are widely used, rust dynamic library symbol name space hash become one of the key bottlenecks of application, Especially when the existing C/C++ module is reconstructed into the rust module. The unstable option `-Z symbol_mangling_version=hashed` is added to solve the bottleneck caused by too long dynamic library symbol names. ## Test data The following is a set of test data on the ubuntu 18.04 LTS environment. With this plug-in, the space saving rate of dynamic libraries can reach about 20%. The test object is the standard library of rust (built based on Xargo), tokio crate, and hyper crate. The contents of the Cargo.toml file in the construction project of the three dynamic libraries are as follows: ```txt # Cargo.toml [profile.release] panic = "abort" opt-leve="z" codegen-units=1 strip=true debug=true ``` The built dynamic library also removes the `.rustc` segments that are not needed at run time and then compares the size. The detailed data is as follows: 1. libstd.so > | symbol_mangling_version | size | saving rate | > | --- | --- | --- | > | legacy | 804896 || > | hashed | 608288 | 0.244 | > | v0 | 858144 || > | hashed | 608288 | 0.291 | 2. libhyper.so > | symbol_mangling_version(libhyper.so) | symbol_mangling_version(libstd.so) | size | saving rate | > | --- | --- | --- | --- | > | legacy | legacy | 866312 || > | hashed | legacy | 645128 |0.255| > | legacy | hashed | 854024 || > | hashed | hashed | 632840 |0.259|
2024-01-26MCP #705: Provide the option `-Csymbol-mangling-version=hashed -Z ↵h1467792822-2/+19
unstable-options` to shorten symbol names by replacing them with a digest. Enrich test cases
2024-01-25Remove unused featuresclubby789-2/+0
2024-01-25Rollup merge of #120230 - Urgau:for_scope-single-scope, r=michaelwoeristerMatthias Krüger-5/+18
Assert that a single scope is passed to `for_scope` Addresses https://github.com/rust-lang/rust/pull/118518#issuecomment-1903680468 r? ``@michaelwoerister``
2024-01-24Assert that a single scope is passed to `for_scope`Urgau-5/+18
2024-01-23Remove track_errors entirelyOli Scherer-14/+0
2024-01-23Auto merge of #120017 - nnethercote:lint-api, r=oli-obkbors-1/+1
Fix naming in the lint API Methods for emit lints are named very inconsistently. This PR fixes that up. r? `@compiler-errors`
2024-01-22Rollup merge of #120159 - jyn514:track-verbose, r=wesleywiserMatthias Krüger-2/+2
Track `verbose` and `verbose_internals` `verbose_internals` has been UNTRACKED since it was introduced. When i added `verbose` in https://github.com/rust-lang/rust/pull/119129 i made it UNTRACKED as well. ``@bjorn3`` says: https://github.com/rust-lang/rust/pull/119286#discussion_r1436134354 > On errors we don't finalize the incr comp cache, but non-fatal diagnostics are cached afaik. Otherwise we would have to replay the query in question, which we may not be able to do if the query key is not reconstructible from the dep node fingerprint. So we must track these flags to avoid replaying incorrect diagnostics. r? incremental
2024-01-23Rename `struct_lint_level` as `lint_level`.Nicholas Nethercote-1/+1
2024-01-22Tweak error counting.Nicholas Nethercote-0/+1
We have several methods indicating the presence of errors, lint errors, and delayed bugs. I find it frustrating that it's very unclear which one you should use in any particular spot. This commit attempts to instill a basic principle of "use the least general one possible", because that reflects reality in practice -- `has_errors` is the least general one and has by far the most uses (esp. via `abort_if_errors`). Specifics: - Add some comments giving some usage guidelines. - Prefer `has_errors` to comparing `err_count` to zero. - Remove `has_errors_or_span_delayed_bugs` because it's a weird one: in the cases where we need to count delayed bugs, we should really be counting lint errors as well. - Rename `is_compilation_going_to_fail` as `has_errors_or_lint_errors_or_span_delayed_bugs`, for consistency with `has_errors` and `has_errors_or_lint_errors`. - Change a few other `has_errors_or_lint_errors` calls to `has_errors`, as per the "least general" principle. This didn't turn out to be as neat as I hoped when I started, but I think it's still an improvement.
2024-01-20Auto merge of #116185 - Zoxc:rem-one-thread, r=cjgillotbors-7/+8
Remove `OneThread` This removes `OneThread` by switching `incr_comp_session` over to `RwLock`.
2024-01-20Track `verbose` and `verbose_internals`jyn-2/+2
bjorn3 says: > On errors we don't finalize the incr comp cache, but non-fatal diagnostics are cached afaik. Otherwise we would have to replay the query in question, which we may not be able to do if the query key is not reconstructible from the dep node fingerprint. So we must track these flags to avoid replaying incorrect diagnostics.
2024-01-18Rollup merge of #119828 - azhogin:azhogin/collapse_debuginfo_improved_attr, ↵Matthias Krüger-6/+43
r=petrochenkov Improved collapse_debuginfo attribute, added command-line flag Improved attribute collapse_debuginfo with variants: `#[collapse_debuginfo=(no|external|yes)]`. Added command-line flag for default behaviour. Work-in-progress: will add more tests. cc https://github.com/rust-lang/rust/issues/100758
2024-01-18Auto merge of #120089 - matthiaskrgr:rollup-xyfqrb5, r=matthiaskrgrbors-14/+1
Rollup of 8 pull requests Successful merges: - #119172 (Detect `NulInCStr` error earlier.) - #119833 (Make tcx optional from StableMIR run macro and extend it to accept closures) - #119967 (Add `PatKind::Err` to AST/HIR) - #119978 (Move async closure parameters into the resultant closure's future eagerly) - #120021 (don't store const var origins for known vars) - #120038 (Don't create a separate "basename" when naming and opening a MIR dump file) - #120057 (Don't ICE when deducing future output if other errors already occurred) - #120073 (Remove spastorino from users_on_vacation) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-18Rollup merge of #119172 - nnethercote:earlier-NulInCStr, r=petrochenkovMatthias Krüger-14/+1
Detect `NulInCStr` error earlier. By making it an `EscapeError` instead of a `LitError`. This makes it like the other errors produced when checking string literals contents, e.g. for invalid escape sequences or bare CR chars. NOTE: this means these errors are issued earlier, before expansion, which changes behaviour. It will be possible to move the check back to the later point if desired. If that happens, it's likely that all the string literal contents checks will be delayed together. One nice thing about this: the old approach had some code in `report_lit_error` to calculate the span of the nul char from a range. This code used a hardwired `+2` to account for the `c"` at the start of a C string literal, but this should have changed to a `+3` for raw C string literals to account for the `cr"`, which meant that the caret in `cr"` nul error messages was one short of where it should have been. The new approach doesn't need any of this and avoids the off-by-one error. r? ```@fee1-dead```
2024-01-18Remove `OneThread`John Kåre Alsaker-7/+8
2024-01-17Add -Zno-implied-bounds-compat option and use itJack Huey-0/+2
2024-01-17Improved collapse_debuginfo attribute, added command-line flag (no|external|yes)Andrew Zhogin-6/+43
2024-01-17Auto merge of #119922 - nnethercote:fix-Diag-code-is_lint, r=oli-obkbors-7/+5
Rework how diagnostic lints are stored. `Diagnostic::code` has the type `DiagnosticId`, which has `Error` and `Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be redundant w.r.t. `Diagnostic::code`. Seems simple. Except it's possible for a lint to have an error code, in which case its `code` field is recorded as `Error`, and `is_lint` is required to indicate that it's a lint. This is what happens with `derive(LintDiagnostic)` lints. Which means those lints don't have a lint name or a `has_future_breakage` field because those are stored in the `DiagnosticId::Lint`. It's all a bit messy and confused and seems unintentional. This commit: - removes `DiagnosticId`; - changes `Diagnostic::code` to `Option<String>`, which means both errors and lints can straightforwardly have an error code; - changes `Diagnostic::is_lint` to `Option<IsLint>`, where `IsLint` is a new type containing a lint name and a `has_future_breakage` bool, so all lints can have those, error code or not. r? `@oli-obk`
2024-01-16Add unstable `-Z direct-access-external-data` cmdline flag for `rustc`WANG Rui-0/+9
The new flag has been described in the Major Change Proposal at https://github.com/rust-lang/compiler-team/issues/707
2024-01-15Replace `TrimmedDefPaths` with a bool.Nicholas Nethercote-20/+4
It's a tri-state enum but the `Always` variant is never used, so a bool is simpler.
2024-01-14Rework how diagnostic lints are stored.Nicholas Nethercote-7/+5
`Diagnostic::code` has the type `DiagnosticId`, which has `Error` and `Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be redundant w.r.t. `Diagnostic::code`. Seems simple. Except it's possible for a lint to have an error code, in which case its `code` field is recorded as `Error`, and `is_lint` is required to indicate that it's a lint. This is what happens with `derive(LintDiagnostic)` lints. Which means those lints don't have a lint name or a `has_future_breakage` field because those are stored in the `DiagnosticId::Lint`. It's all a bit messy and confused and seems unintentional. This commit: - removes `DiagnosticId`; - changes `Diagnostic::code` to `Option<String>`, which means both errors and lints can straightforwardly have an error code; - changes `Diagnostic::is_lint` to `Option<IsLint>`, where `IsLint` is a new type containing a lint name and a `has_future_breakage` bool, so all lints can have those, error code or not.
2024-01-13Add todo commentGeorge-lewis-0/+1
2024-01-13Add check for ui_testing via promoting parameters from `ParseSess` to `Session`George-lewis-18/+28
2024-01-13Add suggestion to upgrade the compilerGeorge-lewis-0/+19
2024-01-13Auto merge of #117285 - joboet:move_platforms_to_pal, r=ChrisDentonbors-2/+2
Move platform modules into `sys::pal` This is the initial step of #117276. `sys` just re-exports everything from the current `sys` for now, I'll move the implementations for the individual features one-by-one after this PR merges.
2024-01-13Auto merge of #118924 - Urgau:check-cfg-exclude-well-known-from-diag, ↵bors-2/+5
r=petrochenkov Exclude well known names from showing a suggestion in check-cfg This PR adds an exclusion for well known names from showing in suggestions of check-cfg/`unexpected_cfgs`. Follow-up to https://github.com/rust-lang/rust/pull/118213 and fixes https://github.com/rust-lang/rust/pull/118213#issuecomment-1854189934. r? `@petrochenkov`
2024-01-12Exclude well known names from showing a suggestion in check-cfgUrgau-2/+5
2024-01-12Rollup merge of #119884 - GuillaumeGomez:rename-env-opt, r=davidtwcoGuillaume Gomez-3/+3
Rename `--env` option flag to `--env-set` As discussed [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Stabilizing.20.60--env.60.20option.20flag.3F). We rename `--env` to not conflicting names with the [RFC](https://github.com/rust-lang/rfcs/pull/2794). r? `@davidtwco`
2024-01-12Rename `--env` option flag to `--env-set`Guillaume Gomez-3/+3
2024-01-12Detect `NulInCStr` error earlier.Nicholas Nethercote-14/+1
By making it an `EscapeError` instead of a `LitError`. This makes it like the other errors produced when checking string literals contents, e.g. for invalid escape sequences or bare CR chars. NOTE: this means these errors are issued earlier, before expansion, which changes behaviour. It will be possible to move the check back to the later point if desired. If that happens, it's likely that all the string literal contents checks will be delayed together. One nice thing about this: the old approach had some code in `report_lit_error` to calculate the span of the nul char from a range. This code used a hardwired `+2` to account for the `c"` at the start of a C string literal, but this should have changed to a `+3` for raw C string literals to account for the `cr"`, which meant that the caret in `cr"` nul error messages was one short of where it should have been. The new approach doesn't need any of this and avoids the off-by-one error.
2024-01-12Give me a way to emit all the delayed bugsMichael Goulet-0/+4
2024-01-12update paths in commentsjoboet-2/+2
2024-01-11Change how `force-warn` lint diagnostics are recorded.Nicholas Nethercote-5/+1
`is_force_warn` is only possible for diagnostics with `Level::Warning`, but it is currently stored in `Diagnostic::code`, which every diagnostic has. This commit: - removes the boolean `DiagnosticId::Lint::is_force_warn` field; - adds a `ForceWarning` variant to `Level`. Benefits: - The common `Level::Warning` case now has no arguments, replacing lots of `Warning(None)` occurrences. - `rustc_session::lint::Level` and `rustc_errors::Level` are more similar, both having `ForceWarning` and `Warning`.
2024-01-10Rename consuming chaining methods on `DiagnosticBuilder`.Nicholas Nethercote-3/+3
In #119606 I added them and used a `_mv` suffix, but that wasn't great. A `with_` prefix has three different existing uses. - Constructors, e.g. `Vec::with_capacity`. - Wrappers that provide an environment to execute some code, e.g. `with_session_globals`. - Consuming chaining methods, e.g. `Span::with_{lo,hi,ctxt}`. The third case is exactly what we want, so this commit changes `DiagnosticBuilder::foo_mv` to `DiagnosticBuilder::with_foo`. Thanks to @compiler-errors for the suggestion.
2024-01-10Add `DiagCtxt::delayed_bug`.Nicholas Nethercote-4/+1
We have `span_delayed_bug` and often pass it a `DUMMY_SP`. This commit adds `delayed_bug`, which matches pairs like `err`/`span_err` and `warn`/`span_warn`.
2024-01-10Rename `{create,emit}_warning` as `{create,emit}_warn`.Nicholas Nethercote-4/+4
For consistency with `warn`/`struct_warn`, and also `{create,emit}_err`, all of which use an abbreviated form.
2024-01-10Shorten some error invocations.Nicholas Nethercote-4/+4
- `struct_foo` + `emit` -> `foo` - `create_foo` + `emit` -> `emit_foo` I have made recent commits in other PRs that have removed some of these shortcuts for combinations with few uses, e.g. `struct_span_err_with_code`. But for the remaining combinations that have high levels of use, we might as well use them wherever possible.
2024-01-09Rollup merge of #118680 - djkoloski:shell_argfiles, r=compiler-errorsGuillaume Gomez-0/+2
Add support for shell argfiles Closes https://github.com/rust-lang/compiler-team/issues/684
2024-01-09Rollup merge of #119723 - nnethercote:rm-Zdont-buffer-diagnostics, ↵Guillaume Gomez-4/+0
r=compiler-errors Remove `-Zdont-buffer-diagnostics`. It was added in #54232. It seems like it was aimed at NLL development, which is well in the past. Also, it looks like `-Ztreat-err-as-bug` can be used to achieve the same effect. So it doesn't seem necessary. r? ``@pnkfelix``
2024-01-09Rollup merge of #119527 - klensy:ordering, r=compiler-errorsGuillaume Gomez-4/+2
don't reexport atomic::ordering via rustc_data_structures, use std import This looks simpler.
2024-01-09Rollup merge of #117744 - quininer:add-z-sync-uw, r=bjorn3Matthias Krüger-0/+2
Add -Zuse-sync-unwind Currently Rust uses async unwind by default, but async unwind will bring non-negligible size overhead. it would be nice to allow users to choose this. In addition, async unwind currently prevents LLVM from generate compact unwind for MachO, if one wishes to generate compact unwind for MachO, then also needs this flag.
2024-01-09Remove `-Zdont-buffer-diagnostics`.Nicholas Nethercote-4/+0
It was added in #54232. It seems like it was aimed at NLL development, which is well in the past. Also, it looks like `-Ztreat-err-as-bug` can be used to achieve the same effect. So it doesn't seem necessary.