about summary refs log tree commit diff
path: root/src/test/ui/lint/unused
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-4965/+0
2022-12-28Rollup merge of #104024 - noeddl:unused-must-use, r=compiler-errorsfee1-dead-1/+1
Fix `unused_must_use` warning for `Box::from_raw`
2022-12-09Don't warn about unused parens when they are used by yeet exprMaybe Waffle-20/+34
2022-12-02Rollup merge of #104614 - Nilstrieb:type-ascribe!, r=TaKO8KiMatthias Krüger-12/+3
Add `type_ascribe!` macro as placeholder syntax for type ascription This makes it still possible to test the internal semantics of type ascription even once the `:`-syntax is removed from the parser. The macro now gets used in a bunch of UI tests that test the semantics and not syntax of type ascription. I might have forgotten a few tests but this should hopefully be most of them. The remaining ones will certainly be found once type ascription is removed from the parser altogether. Part of #101728
2022-11-23lint: do not warn unused parens around higher-ranked function pointersMichael Howell-0/+18
Fixes #104397
2022-11-19Use `type_ascribe!` in many UI testsNilstrieb-12/+3
Use it in all UI tests that are about the semantics and not the syntax of type ascription.
2022-11-19Refactor `must_use` lint into two partsNilstrieb-33/+56
Before, the lint did the checking for `must_use` and pretty printing the types in a special format in one pass, causing quite complex and untranslatable code. Now the collection and printing is split in two. That should also make it easier to translate or extract the type pretty printing in the future. Also fixes an integer overflow in the array length pluralization calculation.
2022-11-10Fix tests after rebaseEsteban Küber-2/+2
2022-11-10review commentsEsteban Küber-4/+4
2022-11-10Consider `#[must_use]` annotation on `async fn` as also affecting the ↵Esteban Küber-30/+78
`Future::Output` No longer lint against `#[must_use] async fn foo()`. When encountering a statement that awaits on a `Future`, check if the `Future`'s parent item is annotated with `#[must_use]` and emit a lint if so. This effectively makes `must_use` an annotation on the `Future::Output` instead of only the `Future` itself. Fix #78149.
2022-11-10Tweak span for `#[must_use]`Esteban Küber-33/+33
Do not point at whole statement, only at the expression (skip pointing at `;`)
2022-11-05Fix unused_must_use warning for Box::from_rawAnett Seeker-1/+1
2022-10-20Elaborate supertrait bounds when triggering unused_must_use on impl TraitMichael Goulet-0/+26
2022-10-01bless ui testsMaybe Waffle-18/+18
2022-08-23Use par_body_owners for livenessSeo Sanghyeon-20/+20
2022-08-11Add visitors for PatField and ExprField.Eric Huss-1/+1
This helps simplify the code. It also fixes it to use the correct parent when lowering. One consequence is the `non_snake_case` lint needed to change the way it looked for parent nodes in a struct pattern. This also includes a small fix to use the correct `Target` for expression field attribute validation.
2022-08-11Check attributes on struct expression fields.Eric Huss-2/+8
Attributes on struct expression fields were not being checked for validity. This adds the fields as HIR nodes so that `CheckAttrVisitor` can visit those nodes to check their attributes.
2022-08-11Check attributes on pattern fields.Eric Huss-1/+13
Attributes on pattern struct fields were not being checked for validity. This adds the fields as HIR nodes so that the `CheckAttrVisitor` can visit those nodes to check their attributes.
2022-08-04Rollup merge of #100093 - wcampbell0x2a:unused-parens-for-match-arms, ↵Matthias Krüger-0/+41
r=petrochenkov Enable unused_parens for match arms Fixes: https://github.com/rust-lang/rust/issues/92751 Currently I can't get the `stderr` to work with `./x.py test`, but this should fix the issue. Help would be appreciated!
2022-08-04Enable unused_parens for match armswcampbell-0/+41
2022-08-02Add items to `DocAliasBadLocation` check error match armhdelc-2/+2
- Added `Impl`, `Closure`, ForeignMod` targets - `Target::name` changed for `Target::Impl` - Error output for `Target::ForeignMod` changed to "foreign module"
2022-07-15add `#[must_use]` to `Box::from_raw`rhysd-0/+26
2022-06-30fix grammar in useless doc comment lintAndy Russell-1/+1
2022-06-21Remove `#[doc(hidden)]` logic from `unused_attributes` lintLeón Orell Valerian Liehr-177/+0
2022-06-16diagnostics: fix trailing spaceklensy-32/+32
2022-06-09Test that the unused_macros lint works correctly if rules are malformedest31-0/+41
The unused_macro_rules lint had a bug where it would regard all rules of a macro as unused if one rule were malformed. This bug doesn't exist with the unused_macros lint. To ensure it doesn't appear in the future, we add a test for it.
2022-06-09Suppress the unused_macro_rules lint if malformed rules are encounteredest31-0/+19
Prior to this commit, if a macro had any malformed rules, all rules would be reported as unused, regardless of whether they were used or not. So we just turn off unused rule checking completely for macros with malformed rules.
2022-06-09Never regard macro rules with compile_error! invocations as unusedest31-0/+53
The very point of compile_error! is to never be reached, and one of the use cases of the macro, currently also listed as examples in the documentation of compile_error, is to create nicer errors for wrong macro invocations. Thus, we shuuld never warn about unused macro arms that contain invocations of compile_error.
2022-05-20Do not warn on inherent doc(hidden) assoc itemsLeón Orell Valerian Liehr-9/+35
2022-05-12Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkovbors-43/+195
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-08Warn on unused doc(hidden) on trait impl itemsLeón Orell Valerian Liehr-0/+151
2022-05-05Add testsest31-43/+195
Also rename the test files for the unused_macros lint to avoid confusion. The test files now follow a <lint_name><-maybe-decl>.rs scheme.
2022-04-10Fix crate_type attribute to not warn on duplicatesEric Huss-60/+44
2022-03-20Filter OnceNote in diagnostic infra.Camille GILLOT-10/+0
2022-03-02Update unused_doc_comments ui testGuillaume Gomez-1/+41
2022-03-01Rollup merge of #93926 - PatchMixolydic:bugfix/must_use-on-exprs, r=cjgillotDylan DPC-0/+300
Lint against more useless `#[must_use]` attributes This expands the existing `#[must_use]` check in `unused_attributes` to lint against pretty much everything `#[must_use]` doesn't support. Fixes #93906.
2022-02-27Lint against more useless `#[must_use]` attributesRuby Lazuli-0/+300
This expands the existing `#[must_use]` check in `unused_attributes` to lint against pretty much everything `#[must_use]` doesn't support. Fixes #93906.
2022-02-25Fix debug_assert in unused lint passflip1995-6/+6
This fixes a debug assertion in the unused lint pass. As a side effect, this also improves the span generated for tuples in the `unused_must_use` lint.
2021-12-19Rollup merge of #91956 - notriddle:notriddle/unused-parens-range, r=nagisaMatthias Krüger-0/+48
fix(rustc_lint): better detect when parens are necessary Fixes #90807
2021-12-17fix(rustc_lint): mark the parens around `(1..loop {})` as unusedMichael Howell-0/+40
2021-12-15fix(rustc_lint): better detect when parens are necessaryMichael Howell-0/+8
Fixes #90807
2021-12-11Show the unused type for `unused_results` lintNoah Lev-2/+2
I think it's helpful to know what type was unused when looking at these warnings. The type will likely determine whether the result *should* be used, or whether it should just be ignored. Including the type also matches the behavior of the `must_use` lint: unused `SomeType` that must be used.
2021-11-30Emit a warning on generic parameters with doc commentsJoshua Nelson-1/+12
2021-11-18Check for duplicate attributes.Eric Huss-0/+414
2021-11-17Rollup merge of #89610 - guswynn:must_use_future, r=wesleywiserMatthias Krüger-0/+69
warn on must_use use on async fn's As referenced in #78149 This only works on `async` fn's for now, I can also look into if I can get `Box<dyn Future>` and `impl Future` working at this level (hir)
2021-11-16Update compiler/rustc_passes/src/check_attr.rsWesley Wiser-2/+2
Co-authored-by: Yuki Okushi <jtitor@2k36.org>
2021-11-11Shorten Span of unused macro lintsMarcel Hellwig-48/+28
The span has been recuded to the actual ident, instead of linting the *whole* macro.
2021-11-08warn on must_use use on async fn'sGus Wynn-0/+69
2021-10-15Bless testsCameron Steffen-1/+1
2021-09-26Remove box syntax from most places in src/test outside of the issues direst31-2/+2