about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/non_fmt_panic.rs
AgeCommit message (Collapse)AuthorLines
2025-07-28use let chains in hir, lint, mirKivooeo-30/+30
2025-03-25Use `Option<Symbol>` in `panic_call`.Nicholas Nethercote-5/+8
Instead of `kw::Empty`. It makes it clearer that this is a name that is searched for and might not be found.
2025-02-08Rustfmtbjorn3-4/+8
2025-02-02Convert two `rustc_middle::lint` functions to `Span` methods.Nicholas Nethercote-5/+5
`rustc_middle` is a huge crate and it's always good to move stuff out of it. There are lots of similar methods already on `Span`, so these two functions, `in_external_macro` and `is_from_async_await`, fit right in. The diff is big because `in_external_macro` is used a lot by clippy lints.
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-7/+9
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-10-29TypingMode :thinking:lcnr-1/+1
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-10/+6
2024-07-29Reformat `use` declarations.Nicholas Nethercote-5/+6
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-06-14Use is_lang_item more aggressivelyMichael Goulet-4/+4
2024-05-23Remove `LintDiagnostic::msg`León Orell Valerian Liehr-1/+2
* instead simply set the primary message inside the lint decorator functions * it used to be this way before [#]101986 which introduced `msg` to prevent good path delayed bugs (which no longer exist) from firing under certain circumstances when lints were suppressed / silenced * this is no longer necessary for various reasons I presume * it shaves off complexity and makes further changes easier to implement
2024-04-29Remove `extern crate rustc_middle` from numerous crates.Nicholas Nethercote-0/+1
2024-04-29Remove `extern crate rustc_session` from `rustc_lint`.Nicholas Nethercote-0/+1
2024-03-26panic_str only exists for the migration to 2021 panic macrosRalf Jung-1/+1
2024-03-05Rename all `ParseSess` variables/fields/lifetimes as `psess`.Nicholas Nethercote-2/+2
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-01-23Rename `LintContext::emit_spanned_lint` as `LintContext::emit_span_lint`.Nicholas Nethercote-2/+2
2024-01-23Rename `LintContext::struct_span_lint` as `LintContext::span_lint`.Nicholas Nethercote-1/+1
2024-01-06rustc_span: Optimize syntax context comparisonsVadim Petrochenkov-2/+3
Including comparisons with root context
2024-01-03Rename some `Diagnostic` setters.Nicholas Nethercote-3/+3
`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.
2023-12-15Don't pass lint back out of lint decoratorMichael Goulet-2/+1
2023-11-24Replace `option.map(cond) == Some(true)` with `option.is_some_and(cond)`David Tolnay-10/+6
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-1/+1
2023-02-22errors: generate typed identifiers in each crateDavid Wood-9/+9
Instead of loading the Fluent resources for every crate in `rustc_error_messages`, each crate generates typed identifiers for its own diagnostics and creates a static which are pulled together in the `rustc_driver` crate and provided to the diagnostic emitter. Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-13Use is_str instead of string kind comparisonMichael Goulet-1/+1
2023-01-09refactor: cleanupRejyr-2/+0
2023-01-09migrate: `non_fmt_panic.rs`Rejyr-33/+16
2022-12-20rustc: Remove needless lifetimesJeremy Stucki-1/+1
2022-11-21Stop passing the self-type as a separate argument.Oli Scherer-6/+10
2022-11-21Use ty::List instead of InternalSubstsOli Scherer-7/+2
2022-11-18Rm diagnostic item, use lang itemDeadbeef-1/+1
2022-10-23Migrate all diagnosticsNilstrieb-35/+30
2022-10-07Change InferCtxtBuilder from enter to buildCameron Steffen-15/+13
2022-10-01Refactor rustc lint APIMaybe Waffle-49/+55
2022-06-30lint: port non-fmt-panic diagnosticsDavid Wood-39/+34
Signed-off-by: David Wood <david.wood@huawei.com>
2022-05-03Make rustc_parse_format compile on stablebjorn3-1/+4
This allows it to be used by lightweight formatting systems and may allow it to be used by rust-analyzer.
2022-04-29errors: `span_suggestion` takes `impl ToString`David Wood-5/+5
Change `span_suggestion` (and variants) to take `impl ToString` rather than `String` for the suggested code, as this simplifies the requirements on the diagnostic derive. Signed-off-by: David Wood <david.wood@huawei.com>
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-1/+1
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-01-31Take in account the unreachable! macro in the non_fmt_panic lintLoïc BRANSTETT-3/+22
2022-01-27try apply `rustc_pass_by_value` to `Span`lcnr-1/+1
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-1/+1
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-6/+6
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-12-09Remove redundant [..]sest31-1/+1
2021-11-16Use get_diagnostic_name moreCameron Steffen-6/+13
2021-10-08clippy::complexity fixesMatthias Krüger-2/+1
2021-10-06Use get_diagnostic_nameCameron Steffen-3/+4
2021-10-02Make diangostic item names consistentCameron Steffen-3/+3
2021-09-20Adjust documentation for compatibility with 2021Mark Rousskov-1/+1
This also adjusts the lint docs generation to accept (and ignore) an allow attribute, rather than expecting the documentation to be immediately followed by the lint name.
2021-08-17Auto merge of #88083 - m-ou-se:non-fmt-panics-suggest-debug, r=estebankbors-13/+53
Improve non_fmt_panics suggestion based on trait impls. This improves the non_fmt_panics lint suggestions by checking first which trait (Display or Debug) are actually implemented on the type. Fixes https://github.com/rust-lang/rust/issues/87313 Fixes https://github.com/rust-lang/rust/issues/87999 Before: ``` help: add a "{}" format string to Display the message | 2 | panic!("{}", Some(1)); | +++++ help: or use std::panic::panic_any instead | 2 | std::panic::panic_any(Some(1)); | ~~~~~~~~~~~~~~~~~~~~~ ``` After: ``` help: add a "{:?}" format string to use the Debug implementation of `Option<i32>` | 2 | panic!("{:?}", Some(1)); | +++++++ help: or use std::panic::panic_any instead | 2 | std::panic::panic_any(Some(1)); | ~~~~~~~~~~~~~~~~~~~~~ ``` r? `@estebank`
2021-08-16Rollup merge of #87967 - m-ou-se:non-fmt-panic-detect-fake-spans, r=cjgillotMara Bos-3/+11
Detect fake spans in non_fmt_panic lint. This addresses https://github.com/rust-lang/rust/issues/87621 Some proc_macros claim that the user wrote all of the tokens it outputs, by applying a span from the input to all of the produced tokens. That can result in confusing suggestions, as in #87621. This is a simple patch that avoids suggesting anything for `panic!("{}")` if the span of `"{}"` and `panic!(..)` are identical, which is normally not possible.
2021-08-16Show correct macro name in non_fmt_panics message.Mara Bos-1/+1