summary refs log tree commit diff
path: root/compiler/rustc_lint/src/context
AgeCommit message (Collapse)AuthorLines
2024-06-06Auto merge of #124482 - spastorino:unsafe-extern-blocks, r=oli-obkbors-0/+3
Unsafe extern blocks This implements RFC 3484. Tracking issue #123743 and RFC https://github.com/rust-lang/rfcs/pull/3484 This is better reviewed commit by commit.
2024-06-05Make MISSING_UNSAFE_ON_EXTERN lint emit future compat info with suggestion ↵Santiago Pastorino-2/+2
to prepend unsafe
2024-06-04Make extern blocks without unsafe warn in edition 2024Santiago Pastorino-0/+3
2024-05-28Convert `proc_macro_back_compat` lint to an unconditional error.Nicholas Nethercote-3/+0
We still check for the `rental`/`allsorts-rental` crates. But now if they are detected we just emit a fatal error, instead of emitting a warning and providing alternative behaviour. The original "hack" implementing alternative behaviour was added in #73345. The lint was added in #83127. The tracking issue is #83125. The direct motivation for the change is that providing the alternative behaviour is interfering with #125174 and follow-on work.
2024-05-27Auto merge of #125410 - fmease:adj-lint-diag-api, r=nnethercotebors-230/+153
[perf] Delay the construction of early lint diag structs Attacks some of the perf regressions from https://github.com/rust-lang/rust/pull/124417#issuecomment-2123700666. See individual commits for details. The first three commits are not strictly necessary. However, the 2nd one (06bc4fc67145e3a7be9b5a2cf2b5968cef36e587, *Remove `LintDiagnostic::msg`*) makes the main change way nicer to implement. It's also pretty sweet on its own if I may say so myself.
2024-05-24Auto merge of #125463 - GuillaumeGomez:rollup-287wx4y, r=GuillaumeGomezbors-12/+18
Rollup of 6 pull requests Successful merges: - #125263 (rust-lld: fallback to rustc's sysroot if there's no path to the linker in the target sysroot) - #125345 (rustc_codegen_llvm: add support for writing summary bitcode) - #125362 (Actually use TAIT instead of emulating it) - #125412 (Don't suggest adding the unexpected cfgs to the build-script it-self) - #125445 (Migrate `run-make/rustdoc-with-short-out-dir-option` to `rmake.rs`) - #125452 (Cleanup check-cfg handling in core and std) r? `@ghost` `@rustbot` modify labels: rollup
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_lint`.Nicholas Nethercote-0/+1
2024-05-23Delay the construction of early lint diag structsLeón Orell Valerian Liehr-230/+153
Fixes a slew of perf regressions.
2024-05-22Don't suggest adding the unexpected cfgs the build-script it-selfUrgau-12/+18
2024-05-21Make early lints translatableXiretza-447/+336
2024-05-21Convert uses of BuiltinLintDiag::Normal to custom variantsXiretza-12/+125
This ensures all diagnostic messages are created at diagnostic emission time, making them translatable.
2024-05-21Port DeprecatedMacro to diag structsXiretza-4/+21
2024-05-21Generate lint diagnostic message from BuiltinLintDiagXiretza-14/+136
Translation of the lint message happens when the actual diagnostic is created, not when the lint is buffered. Generating the message from BuiltinLintDiag ensures that all required data to construct the message is preserved in the LintBuffer, eventually allowing the messages to be moved to fluent. Remove the `msg` field from BufferedEarlyLint, it is either generated from the data in the BuiltinLintDiag or stored inside BuiltinLintDiag::Normal.
2024-05-21Convert unexpected_cfg_{name,value} to struct diagnosticsXiretza-152/+151
2024-05-21Convert NAMED_ASM_LABELS lint to diag structXiretza-4/+0
2024-05-20Fix quote escaping inside check-cfg valueUrgau-3/+2
2024-05-19Refer to the Cargo specific doc in the check-cfg diagnosticsUrgau-2/+4
2024-05-19Prefer suggesting string-literal for Cargo `check-cfg` lint configUrgau-18/+29
2024-05-16Update `unexpected_cfgs` lint for Cargo new `check-cfg` configUrgau-6/+8
2024-05-15Add `on_unimplemented" typo suggestionsmejrs-0/+8
2024-05-04Update Cargo diagnostics in check-cfgUrgau-4/+4
2024-04-29Remove `extern crate rustc_middle` from numerous crates.Nicholas Nethercote-0/+1
2024-04-21Move "elided lifetime in path" to subdiagnostic structXiretza-8/+10
This requires nested subdiagnostics.
2024-04-15Move --check-cfg documentation to stable booksUrgau-2/+2
2024-04-11Rollup merge of #122954 - fmease:defined-by-extern-prelude, r=petrochenkovLeón Orell Valerian Liehr-1/+1
Be more specific when flagging imports as redundant due to the extern prelude There are multiple distinct kinds of [preludes](https://doc.rust-lang.org/reference/names/preludes.html). Be more specific when flagging imports as redundant due to the [extern prelude](https://doc.rust-lang.org/reference/names/preludes.html#extern-prelude). r? Nilstrieb or compiler
2024-04-09Add a helper for extending a span to include any trailing whitespaceMichael Goulet-4/+1
2024-04-08Be more specific when flagging imports that are redundant due to the extern ↵León Orell Valerian Liehr-1/+1
prelude
2024-03-16Move check-cfg diagnostic logic into it's own moduleUrgau-274/+282
2024-03-06Fix redundant import errors for preload extern crateyukang-1/+5
2024-03-05Limit the number of names and values in check-cfg diagnosticsUrgau-20/+51
2024-03-05Rename `BuiltinLintDiagnostics` as `BuiltinLintDiag`.Nicholas Nethercote-47/+38
Not the dropping of the trailing `s` -- this type describes a single diagnostic and its name should be singular.
2024-03-05Rename all `ParseSess` variables/fields/lifetimes as `psess`.Nicholas Nethercote-7/+5
Existing names for values of this type are `sess`, `parse_sess`, `parse_session`, and `ps`. `sess` is particularly annoying because that's also used for `Session` values, which are often co-located, and it can be difficult to know which type a value named `sess` refers to. (That annoyance is the main motivation for this change.) `psess` is nice and short, which is good for a name used this much. The commit also renames some `parse_sess_created` values as `psess_created`.
2024-03-01Rollup merge of #121580 - Suyashtnt:issue-121502-fix, r=michaelwoeristerMatthias Krüger-1/+1
make unused_imports less assertive in test modules closes #121502 This is a fairly small change and I used the fix suggested in the example expected error message. Not sure if I should've rather used the alternatives but this one seems the most descriptive. Some alternatives: - if this is meant to be a test module, add `#[cfg(test)]` to the containing module - try adding #[cfg(test)] to this test module - consider adding #[allow(unused_imports)] if you want to silent the lint on the unused import - consider removing the unused import
2024-02-29Detect empty leading where-clauses on type aliasesLeón Orell Valerian Liehr-9/+16
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-85/+85
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-25make unused_imports less assertive in test modulesSuyashtnt-1/+1
closes #121502
2024-02-20Reduce capabilities of `Diagnostic`.Nicholas Nethercote-0/+3
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-17Use better heuristic for printing Cargo specific diagnosticsUrgau-2/+2
2024-02-06Rollup merge of #120435 - chenyukang:yukang-fix-120427-cfg-name, ↵Matthias Krüger-10/+40
r=Urgau,Nilstrieb Suggest name value cfg when only value is used for check-cfg Fixes #120427 r? `````````````@Nilstrieb`````````````
2024-01-30add missing potential_query_instability for keys and values in hashmapyukang-0/+1
2024-01-30limit the names_possiblilities to less than 3Yukang-1/+1
Co-authored-by: Urgau <3616612+Urgau@users.noreply.github.com>
2024-01-28Suggest name value cfg when only value is used for check-cfgyukang-10/+40
2024-01-13Add way to express no-values with check-cfgUrgau-0/+11
2024-01-12Exclude well known names from showing a suggestion in check-cfgUrgau-2/+10
2023-12-31rustc_lint: Enforce `rustc::potential_query_instability` lintMartin Nordholts-0/+5
Stop allowing `rustc::potential_query_instability` on all of `rustc_lint` and instead allow it on a case-by-case basis if it is safe to do so. In this particular crate, all lints were safe to allow.
2023-12-30Move around the code responsible for decorating builtin diagnosticsUrgau-0/+532