about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/lint.rs
AgeCommit message (Collapse)AuthorLines
2021-10-05Auto merge of #89266 - cjgillot:session-ich, r=michaelwoeristerbors-1/+1
Move ICH to rustc_query_system Based on https://github.com/rust-lang/rust/pull/89183 The StableHashingContext does not need to be in rustc_middle. This PR moves it to rustc_query_system. This will avoid a dependency between rustc_ast_lowering and rustc_middle in https://github.com/rust-lang/rust/pull/89124.
2021-10-03Remove re-export.Camille GILLOT-1/+1
2021-10-02Add desugaring mark to while loopCameron Steffen-3/+3
2021-09-04Fix #88256, remove duplicated diagnosticyukang-0/+1
2021-07-21Rename force-warns to force-warnRyan Levick-1/+1
2021-07-14Add -Zfuture-incompat-test to assist with testing future-incompat reports.Eric Huss-7/+7
2021-07-11Simplify future incompatible reporting.Eric Huss-3/+8
2021-07-10rustc_span: Revert addition of `proc_macro` field to `ExpnKind::Macro`Vadim Petrochenkov-1/+1
The flag has a vague meaning and is used for a single diagnostic change that is low benefit and appears only under `-Z macro_backtrace`.
2021-07-06Auto merge of #86572 - rylev:force-warnings-always, r=nikomatsakisbors-5/+13
Force warnings even when can_emit_warnings == false Fixes an issue mentioned in #85512 with --cap-lints overriding --force-warnings. Fixes https://github.com/rust-lang/rust/issues/86751 r? `@ehuss`
2021-07-06Add missing docs and remove dead codeRyan Levick-3/+1
2021-07-01New force_warn diagnostic builder and ensure cap-lints doesn't reduce ↵Ryan Levick-14/+11
force_warn level
2021-06-30Force warnings even when can_emit_warnings == falseRyan Levick-1/+14
2021-06-29Encode CommandLine in the index only.Camille GILLOT-24/+13
2021-06-29Use a newtype_index instead of a u32.Camille GILLOT-7/+15
2021-06-29Use the macro to implement HashStable.Camille GILLOT-25/+3
2021-06-29Auto merge of #86009 - cjgillot:fwarn, r=davidtwcobors-28/+7
Make ForceWarn a lint level. Follow-up to #85788 cc `@rylev`
2021-06-27Add `explain_reason: false` in future_incompatible.Mara Bos-3/+8
This allows supressing the default warning message for future incompatible ints, for lints that already provide a more detailed warning.
2021-06-26Make ForceWarn a lint level.Camille GILLOT-28/+7
2021-06-25Address PR feedbackRyan Levick-1/+1
2021-06-25Change how edition based future compatibility warnings are handledRyan Levick-8/+17
2021-06-02Add a page on force-warns in unstable bookRyan Levick-1/+1
2021-06-02Force warn on lint groups as wellRyan Levick-2/+2
2021-06-01Fix issues and add testRyan Levick-1/+0
2021-05-28Initial support for force-warnsRyan Levick-4/+27
2021-05-12Implement span quoting for proc-macrosAaron Hill-1/+1
This PR implements span quoting, allowing proc-macros to produce spans pointing *into their own crate*. This is used by the unstable `proc_macro::quote!` macro, allowing us to get error messages like this: ``` error[E0412]: cannot find type `MissingType` in this scope --> $DIR/auxiliary/span-from-proc-macro.rs:37:20 | LL | pub fn error_from_attribute(_args: TokenStream, _input: TokenStream) -> TokenStream { | ----------------------------------------------------------------------------------- in this expansion of procedural macro `#[error_from_attribute]` ... LL | field: MissingType | ^^^^^^^^^^^ not found in this scope | ::: $DIR/span-from-proc-macro.rs:8:1 | LL | #[error_from_attribute] | ----------------------- in this macro invocation ``` Here, `MissingType` occurs inside the implementation of the proc-macro `#[error_from_attribute]`. Previosuly, this would always result in a span pointing at `#[error_from_attribute]` This will make many proc-macro-related error message much more useful - when a proc-macro generates code containing an error, users will get an error message pointing directly at that code (within the macro definition), instead of always getting a span pointing at the macro invocation site. This is implemented as follows: * When a proc-macro crate is being *compiled*, it causes the `quote!` macro to get run. This saves all of the sapns in the input to `quote!` into the metadata of *the proc-macro-crate* (which we are currently compiling). The `quote!` macro then expands to a call to `proc_macro::Span::recover_proc_macro_span(id)`, where `id` is an opaque identifier for the span in the crate metadata. * When the same proc-macro crate is *run* (e.g. it is loaded from disk and invoked by some consumer crate), the call to `proc_macro::Span::recover_proc_macro_span` causes us to load the span from the proc-macro crate's metadata. The proc-macro then produces a `TokenStream` containing a `Span` pointing into the proc-macro crate itself. The recursive nature of 'quote!' can be difficult to understand at first. The file `src/test/ui/proc-macro/quote-debug.stdout` shows the output of the `quote!` macro, which should make this eaier to understand. This PR also supports custom quoting spans in custom quote macros (e.g. the `quote` crate). All span quoting goes through the `proc_macro::quote_span` method, which can be called by a custom quote macro to perform span quoting. An example of this usage is provided in `src/test/ui/proc-macro/auxiliary/custom-quote.rs` Custom quoting currently has a few limitations: In order to quote a span, we need to generate a call to `proc_macro::Span::recover_proc_macro_span`. However, proc-macros support renaming the `proc_macro` crate, so we can't simply hardcode this path. Previously, the `quote_span` method used the path `crate::Span` - however, this only works when it is called by the builtin `quote!` macro in the same crate. To support being called from arbitrary crates, we need access to the name of the `proc_macro` crate to generate a path. This PR adds an additional argument to `quote_span` to specify the name of the `proc_macro` crate. Howver, this feels kind of hacky, and we may want to change this before stabilizing anything quote-related. Additionally, using `quote_span` currently requires enabling the `proc_macro_internals` feature. The builtin `quote!` macro has an `#[allow_internal_unstable]` attribute, but this won't work for custom quote implementations. This will likely require some additional tricks to apply `allow_internal_unstable` to the span of `proc_macro::Span::recover_proc_macro_span`.
2021-04-14Cancel emitting FCW lint if it is an edition fixing lintRyan Levick-5/+7
2021-02-25Rollup merge of #81713 - estebank:unstable-assoc-item-lint, r=oli-obkDylan DPC-4/+4
Account for associated consts in the "unstable assoc item name colission" lint Fix #81663.
2021-02-24Account for associated consts in the "unstable assoc item name colission" lintEsteban Küber-4/+4
Fix #81663.
2021-02-02introduce future-compatibility warning for forbidden lint groupsNiko Matsakis-2/+10
We used to ignore `forbid(group)` scenarios completely. This changed in #78864, but that led to a number of regressions (#80988, #81218). This PR introduces a future compatibility warning for the case where a group is forbidden but then an individual lint within that group is allowed. We now issue a FCW when we see the "allow", but permit it to take effect.
2021-01-16Enforce that query results implement DebugAaron Hill-1/+4
2021-01-11Rename `rustc_middle::lint::LevelSource` to `LevelAndSource`pierwill-7/+7
2020-12-25Rollup merge of #80274 - pierwill:lintlevelsource, r=petrochenkovDylan DPC-16/+17
Rename rustc_middle::lint::LintSource Rename [`rustc_middle::lint::LintSource`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/lint/enum.LintSource.html) to `rustc_middle::lint::LintLevelSource`. This enum represents the source of a *lint level*, not a lint. This should improve code readability. Update: Also documents `rustc_middle::lint::LevelSource` to clarify.
2020-12-21Document rustc_middle::lint::LevelSourcepierwill-0/+1
This is to clarify the difference between `LevelSource` and `LintLevelSource`. Appease x.py fmt.
2020-12-21Rename rustc_middle::lint::LintSourcepierwill-16/+16
Rename rustc_middle::lint::LintSource to rustc_middle::lint::LintLevelSource.
2020-12-19Edit rustc_middle::lint::LintSource docspierwill-2/+2
Edit punctuation in doc comment for rustc_middle::lint::LintSource::CommandLine.
2020-11-03Auto merge of #76931 - oli-obk:const_prop_inline_lint_madness, r=wesleywiserbors-1/+3
Properly handle lint spans after MIR inlining The first commit shows what happens when we apply mir inlining and then cause lints on the inlined MIR. The second commit fixes that. r? `@wesleywiser`
2020-11-02Fix ICE when a future-incompat-report has its command-line level cappedAaron Hill-6/+8
Fixes #78660 With PR https://github.com/rust-lang/rust/pull/75534 merged, we now run more lint-related code for future-incompat-report, even when their final level is Allow. Some lint-related code was not expecting `Level::Allow`, and had an explicit panic. This PR explicitly tracks the lint level set on the command line before `--cap-lints` is applied. This is used to emit a more precise error note (e.g. we don't say that `-W lint-name` was specified on the command line just because a lint was capped to Warn). As a result, we can now correctly emit a note that `-A` was used if we got `Level::Allow` from the command line (before the cap is applied).
2020-10-30Implement rustc side of report-future-incompatAaron Hill-7/+18
2020-10-27Show the inline stack of MIR lints that only occur after inliningOliver Scherer-1/+3
2020-10-04Prevent forbid from being ignored if overriden at the same level.Felix S. Klock II-1/+19
That is, this changes `#[forbid(foo)] #[allow(foo)]` from allowing foo to forbidding foo.
2020-08-30mv compiler to compiler/mark-0/+351