about summary refs log tree commit diff
path: root/compiler/rustc_lint_defs/src
AgeCommit message (Collapse)AuthorLines
2022-08-17Reenable early feature-gates as future-compat warningsChristopher Durham-0/+51
2022-08-03Warn about dead tuple struct fieldsFabian Wolff-0/+27
2022-08-02Improve position named arguments lint underline and formatting namesPreston From-1/+13
For named arguments used as implicit position arguments, underline both the opening curly brace and either: * if there is formatting, the next character (which will either be the closing curl brace or the `:` denoting the start of formatting args) * if there is no formatting, the entire arg span (important if there is whitespace like `{ }`) This should make it more obvious where the named argument should be. Additionally, in the lint message, emit the formatting argument names without a dollar sign to avoid potentially confusion. Fixes #99907
2022-07-27Make forward compatibility lint deprecated_cfg_attr_crate_type_name deny by ↵est31-2/+2
default
2022-07-25Generate correct suggestion with named arguments used positionallyPreston From-1/+1
Address issue #99265 by checking each positionally used argument to see if the argument is named and adding a lint to use the name instead. This way, when named arguments are used positionally in a different order than their argument order, the suggested lint is correct. For example: ``` println!("{b} {}", a=1, b=2); ``` This will now generate the suggestion: ``` println!("{b} {a}", a=1, b=2); ``` Additionally, this check now also correctly replaces or inserts only where the positional argument is (or would be if implicit). Also, width and precision are replaced with their argument names when they exists. Since the issues were so closely related, this fix for issue #99265 also fixes issue #99266. Fixes #99265 Fixes #99266
2022-07-20avoid a `Symbol` to `String` conversionTakayuki Maeda-1/+1
2022-07-15Only suggest if span is not erroneousMichael Goulet-1/+1
2022-07-13Emit warning when named arguments are used positionally in formatPreston From-0/+32
Addresses Issue 98466 by emitting a warning if a named argument is used like a position argument (i.e. the name is not used in the string to be formatted). Fixes rust-lang#98466
2022-07-13fix documentationDeadbeef-6/+10
2022-07-12check non_exhaustive attr and private fields for transparent typesDeadbeef-0/+51
2022-07-07Rollup merge of #98507 - xFrednet:rfc-2383-manual-expectation-magic, ↵Dylan DPC-0/+12
r=wesleywiser Finishing touches for `#[expect]` (RFC 2383) This PR adds documentation and some functionality to rustc's lint passes, to manually fulfill expectations. This is needed for some lints in Clippy. Hopefully, it should be one of the last things before we can move forward with stabilizing this feature. As part of this PR, I've also updated `clippy::duplicate_mod` to showcase how this new functionality can be used and to ensure that it works correctly. --- changelog: [`duplicate_mod`]: Fixed lint attribute interaction r? `@wesleywiser` cc: https://github.com/rust-lang/rust/issues/97660, https://github.com/rust-lang/rust/issues/85549 And I guess that's it. Here have a magical unicorn :unicorn:
2022-07-06Add function to manually fulfill lint expectations (RFC 2383)xFrednet-0/+7
2022-07-06Document, that some lint have to be expected on the crate level (RFC 2383)xFrednet-0/+5
Examples: NON_ASCII_IDENTS, UNCOMMON_CODEPOINTS, CONFUSABLE_IDENTS, MIXED_SCRIPT_CONFUSABLES
2022-07-02Auto merge of #97235 - nbdd0121:unwind, r=Amanieubors-0/+40
Fix FFI-unwind unsoundness with mixed panic mode UB maybe introduced when an FFI exception happens in a `C-unwind` foreign function and it propagates through a crate compiled with `-C panic=unwind` into a crate compiled with `-C panic=abort` (#96926). To prevent this unsoundness from happening, we will disallow a crate compiled with `-C panic=unwind` to be linked into `panic-abort` *if* it contains a call to `C-unwind` foreign function or function pointer. If no such call exists, then we continue to allow such mixed panic mode linking because it's sound (and stable). In fact we still need the ability to do mixed panic mode linking for std, because we only compile std once with `-C panic=unwind` and link it regardless panic strategy. For libraries that wish to remain compile-once-and-linkable-to-both-panic-runtimes, a `ffi_unwind_calls` lint is added (gated under `c_unwind` feature gate) to flag any FFI unwind calls that will cause the linkable panic runtime be restricted. In summary: ```rust #![warn(ffi_unwind_calls)] mod foo { #[no_mangle] pub extern "C-unwind" fn foo() {} } extern "C-unwind" { fn foo(); } fn main() { // Call to Rust function is fine regardless ABI. foo::foo(); // Call to foreign function, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`. unsafe { foo(); } //~^ WARNING call to foreign function with FFI-unwind ABI let ptr: extern "C-unwind" fn() = foo::foo; // Call to function pointer, will cause the crate to be unlinkable to panic-abort if compiled with `-Cpanic=unwind`. ptr(); //~^ WARNING call to function pointer with FFI-unwind ABI } ``` Fix #96926 `@rustbot` label: T-compiler F-c_unwind
2022-06-25make const_err show up in future breakage reportsRalf Jung-0/+1
2022-06-23Rollup merge of #98283 - TaKO8Ki:point-at-private-fields-in-struct-literal, ↵Michael Goulet-0/+3
r=compiler-errors Point at private fields in struct literal closes #95872
2022-06-22add "was" to pluralize macro and use itTakayuki Maeda-0/+3
2022-06-18Auto merge of #97652 - RalfJung:cenum_impl_drop_cast, r=nagisabors-3/+3
make cenum_impl_drop_cast deny-by-default Also make it show up as future breakage diagnostic. In https://github.com/rust-lang/rust/pull/96862 we are proposing to change behavior of those drops *again*, so this looks like a good opportunity to increase our pressure on getting them out of the ecosystem. Looking at the [tracking issue](https://github.com/rust-lang/rust/issues/73333), so far nobody spoke up in favor of this (accidental) feature. Cc https://github.com/rust-lang/rust/issues/73333 `@oli-obk`
2022-06-16Support lint expectations for `--force-warn` lints (RFC 2383)xFrednet-4/+10
2022-06-08Fix FFI-unwind unsoundness with mixed panic modeGary Guo-0/+40
2022-06-03Use serde_json for json error messagesbjorn3-1/+3
2022-06-02fix lint doctestsRalf Jung-2/+1
2022-06-02make cenum_impl_drop_cast deny-by-default and show up as future breakage ↵Ralf Jung-1/+2
diagnostic
2022-05-23Fix typoest31-1/+1
2022-05-20Lint single-use-lifetimes on the AST.Camille GILLOT-1/+15
2022-05-14Allow the unused_macro_rules lint for nowest31-1/+2
This makes the transition easier as e.g. allow directives won't fire the unknown lint warning once it is turned to warn by default in the future. This is especially important compared to other lints in the unused group because the _ prefix trick doesn't exist for macro rules, so allowing is the only option (either of unused_macro_rules, or of the entire unused group, but that is not as informative to readers). Allowing the lint also makes it possible to work on possible heuristics for disabling the macro in specific cases.
2022-05-12Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkovbors-0/+44
Implement a lint to warn about unused macro rules This implements a new lint to warn about unused macro rules (arms/matchers), similar to the `unused_macros` lint added by #41907 that warns about entire macros. ```rust macro_rules! unused_empty { (hello) => { println!("Hello, world!") }; () => { println!("empty") }; //~ ERROR: 1st rule of macro `unused_empty` is never used } fn main() { unused_empty!(hello); } ``` Builds upon #96149 and #96156. Fixes #73576
2022-05-09Auto merge of #95960 - jhpratt:remove-rustc_deprecated, r=compiler-errorsbors-6/+5
Remove `#[rustc_deprecated]` This removes `#[rustc_deprecated]` and introduces diagnostics to help users to the right direction (that being `#[deprecated]`). All uses of `#[rustc_deprecated]` have been converted. CI is expected to fail initially; this requires #95958, which includes converting `stdarch`. I plan on following up in a short while (maybe a bootstrap cycle?) removing the diagnostics, as they're only intended to be short-term.
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-1/+2
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-06Auto merge of #96268 - ↵bors-35/+0
jackh726:remove-mutable_borrow_reservation_conflict-lint, r=nikomatsakis Remove mutable_borrow_reservation_conflict lint and allow the code pattern This was the only breaking issue with the NLL stabilization PR. Lang team decided to go ahead and allow this. r? `@nikomatsakis` Closes #59159 Closes #56254
2022-05-04Add unused_macro_rules lint definitionest31-0/+44
Not fired yet.
2022-05-02fix most compiler/ doctestsElliot Roberts-1/+2
2022-04-27Plumb through rustc_lint_defs::Level as enum rather than string.Jeremy Fitzhardinge-0/+7
2022-04-20Remove mutable_borrow_reservation_conflict lintJack Huey-35/+0
2022-04-20Auto merge of #96082 - michaelwoerister:less_impl_stable_hash_via_hash, ↵bors-3/+2
r=compiler-errors incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it. Fixes https://github.com/rust-lang/rust/issues/96013.
2022-04-19Rollup merge of #96086 - jsgf:remove-extern-location, r=davidtwcoDylan DPC-9/+0
Remove `--extern-location` and all associated code `--extern-location` was an experiment to investigate the best way to generate useful diagnostics for unused dependency warnings by enabling a build system to identify the corresponding build config. While I did successfully use this, I've since been convinced the alternative `--json unused-externs` mechanism is the way to go, and there's no point in having two mechanisms with basically the same functionality. This effectively reverts https://github.com/rust-lang/rust/pull/72603
2022-04-19incr. comp.: Don't export impl_stable_hash_via_hash!() and warn about using it.Michael Woerister-3/+2
2022-04-17Lint elided lifetimes in path on the AST.Camille GILLOT-0/+1
2022-04-15Remove `--extern-location` and all associated codeJeremy Fitzhardinge-9/+0
`--extern-location` was an experiment to investigate the best way to generate useful diagnostics for unused dependency warnings by enabling a build system to identify the corresponding build config. While I did successfully use this, I've since been convinced the alternative `--json unused-externs` mechanism is the way to go, and there's no point in having two mechanisms with basically the same functionality. This effectively reverts https://github.com/rust-lang/rust/pull/72603
2022-04-14make unaligned_reference warning visible in future compat reportRalf Jung-0/+1
2022-04-14Update error code docsJacob Pratt-1/+1
2022-04-14Error on `#[rustc_deprecated]`Jacob Pratt-5/+4
2022-04-14make unaligned_references lint deny-by-defaultRalf Jung-3/+1
2022-04-08Split `fuzzy_provenance_casts` into lossy and fuzzy, feature gate and test itniluxv-16/+72
* split `fuzzy_provenance_casts` into a ptr2int and a int2ptr lint * feature gate both lints * update documentation to be more realistic short term * add tests for these lints
2022-04-08WIP PROOF-OF-CONCEPT: Make the compiler complain about all int<->ptr casts.Aria Beingessner-0/+36
ALL OF THEM
2022-04-05span: move `MultiSpan`David Wood-1/+2
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-03-30Spellchecking compiler commentsYuri Astrakhan-3/+3
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-16resolve the conflict in compiler/rustc_session/src/parse.rscodehorseman-1/+1
Signed-off-by: codehorseman <cricis@yeah.net>
2022-03-15Rollup merge of #94958 - est31:pluralize, r=oli-obkMatthias Krüger-0/+6
Support other types of pluralization in pluralize macro
2022-03-15Support other types of pluralization in pluralize macroest31-0/+6