about summary refs log tree commit diff
path: root/compiler/rustc_lint/src/unused.rs
AgeCommit message (Collapse)AuthorLines
2023-12-19Plumb awaitness of for loopsEric Holk-3/+3
2023-12-08Auto merge of #118527 - Nadrieril:never_patterns_parse, r=compiler-errorsbors-9/+11
never_patterns: Parse match arms with no body Never patterns are meant to signal unreachable cases, and thus don't take bodies: ```rust let ptr: *const Option<!> = ...; match *ptr { None => { foo(); } Some(!), } ``` This PR makes rustc accept the above, and enforces that an arm has a body xor is a never pattern. This affects parsing of match arms even with the feature off, so this is delicate. (Plus this is my first non-trivial change to the parser). ~~The last commit is optional; it introduces a bit of churn to allow the new suggestions to be machine-applicable. There may be a better solution? I'm not sure.~~ EDIT: I removed that commit r? `@compiler-errors`
2023-12-03Parse a pattern with no armNadrieril-9/+11
2023-11-30Enforce must_use on associated types and RPITITsMichael Goulet-1/+1
2023-11-29Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errorsMatthias Krüger-1/+1
Add `never_patterns` feature gate This PR adds the feature gate and most basic parsing for the experimental `never_patterns` feature. See the tracking issue (https://github.com/rust-lang/rust/issues/118155) for details on the experiment. `@scottmcm` has agreed to be my lang-team liaison for this experiment.
2023-11-29Add `never_patterns` feature gateNadrieril-1/+1
2023-11-28Rename `BinOpKind::lazy` as `BinOpKind::is_lazy`.Nicholas Nethercote-2/+2
To match `BinOpKind::is_comparison` and `hir::BinOpKind::is_lazy`.
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-8/+8
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-18catch pinned `must_use` types in `unused_must_use`Max Niederman-0/+18
2023-10-30Fix missing leading space in suggestionGurinder Singh-1/+1
For a local pattern with no space between `let` and `(` e.g.: let(_a) = 3; we were previously suggesting this illegal code: let_a =3; After this change the suggestion will instead be: let _a =3; (Note the space after `let`)
2023-10-20s/generator/coroutine/Oli Scherer-2/+2
2023-10-20s/Generator/Coroutine/Oli Scherer-7/+7
2023-10-15Auto merge of #116688 - compiler-errors:rustfmt-up, r=WaffleLapkin,Nilstriebbors-36/+44
Format all the let-chains in compiler crates Since rust-lang/rustfmt#5910 has landed, soon we will have support for formatting let-chains (as soon as rustfmt syncs and beta gets bumped). This PR applies the changes [from master rustfmt to rust-lang/rust eagerly](https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/out.20formatting.20of.20prs/near/374997516), so that the next beta bump does not have to deal with a 200+ file diff and can remain concerned with other things like `cfg(bootstrap)` -- #113637 was a pain to land, for example, because of let-else. I will also add this commit to the ignore list after it has landed. The commands that were run -- I'm not great at bash-foo, but this applies rustfmt to every compiler crate, and then reverts the two crates that should probably be formatted out-of-tree. ``` ~/rustfmt $ ls -1d ~/rust/compiler/* | xargs -I@ cargo run --bin rustfmt -- `@/src/lib.rs` --config-path ~/rust --edition=2021 # format all of the compiler crates ~/rust $ git checkout HEAD -- compiler/rustc_codegen_{gcc,cranelift} # revert changes to cg-gcc and cg-clif ``` cc `@rust-lang/rustfmt` r? `@WaffleLapkin` or `@Nilstrieb` who said they may be able to review this purely mechanical PR :> cc `@Mark-Simulacrum` and `@petrochenkov,` who had some thoughts on the order of operations with big formatting changes in https://github.com/rust-lang/rust/pull/95262#issue-1178993801. I think the situation has changed since then, given that let-chains support exists on master rustfmt now, and I'm fairly confident that this formatting PR should land even if *bootstrap* rustfmt doesn't yet format let-chains in order to lessen the burden of the next beta bump.
2023-10-13Remove some unnecessary `unwrap`sEsteban Küber-1/+1
2023-10-13Format all the let chains in compilerMichael Goulet-36/+44
2023-09-11Move let expression checking to parsingMatthew Jasper-7/+5
There was an incomplete version of the check in parsing and a second version in AST validation. This meant that some, but not all, invalid uses were allowed inside macros/disabled cfgs. It also means that later passes have a hard time knowing when the let expression is in a valid location, sometimes causing ICEs. - Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location. - Suppress later errors and MIR construction for invalid let expressions.
2023-08-31Use terminology more sensiblyMichael Howell-1/+1
2023-08-31diagnostics: avoid wrong `unused_parens` on `x as (T) < y`Michael Howell-1/+28
2023-08-14match scrutinee need necessary parentheses for structsyukang-0/+18
2023-08-04Improve spans for indexing expressionsNilstrieb-2/+2
Indexing is similar to method calls in having an arbitrary left-hand-side and then something on the right, which is the main part of the expression. Method calls already have a span for that right part, but indexing does not. This means that long method chains that use indexing have really bad spans, especially when the indexing panics and that span in coverted into a panic location. This does the same thing as method calls for the AST and HIR, storing an extra span which is then put into the `fn_span` field in THIR.
2023-07-25inline format!() args from rustc_codegen_llvm to the end (4)Matthias Krüger-5/+5
r? @WaffleLapkin
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-16/+19
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-1/+3
2023-06-22Migrate item_bounds to ty::ClauseMichael Goulet-3/+2
2023-06-19s/Clause/ClauseKindMichael Goulet-1/+1
2023-06-15Extend `unused_must_use` to cover block exprs许杰友 Jieyou Xu (Joe)-13/+81
2023-06-05Ensure space is inserted after keyword in `unused_delims`clubby789-17/+42
2023-05-24Use `Option::is_some_and` and `Result::is_ok_and` in the compilerMaybe Waffle-2/+2
2023-05-12Dont check `must_use` on nested `impl Future` from fnMichael Goulet-1/+3
2023-04-20add subst_identity_iter and subst_identity_iter_copied methods on ↵Kyle Matsuda-23/+17
EarlyBinder; use this to simplify some EarlyBinder noise around explicit_item_bounds calls
2023-04-20add EarlyBinder to output of explicit_item_bounds; replace ↵Kyle Matsuda-1/+1
bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query
2023-04-20change usages of explicit_item_bounds to bound_explicit_item_boundsKyle Matsuda-17/+23
2023-04-17Rollup merge of #110257 - ↵Matthias Krüger-18/+32
lukas-code:why-would-anyone-write-code-like-that-anyway, r=oli-obk fix false positives for `unused_parens` around unary and binary operations fix https://github.com/rust-lang/rust/issues/110251
2023-04-16fix clippy::toplevel_ref_arg and ::manual_mapMatthias Krüger-23/+16
2023-04-13emit `unused_parens` for `break` if it is not immediately followed by a blockLukas Markeffsky-4/+6
2023-04-13fix false positives for `unused_parens` around unary and binary operationsLukas Markeffsky-18/+30
2023-04-11Allow the elaborator to only filter to real supertraitsMichael Goulet-0/+2
2023-04-06Make elaborator genericMichael Goulet-19/+16
2023-04-04Rename `ast::Static` to `ast::StaticItem` to match `ast::ConstItem`Oli Scherer-1/+1
2023-04-04box a bunch of large typesOli Scherer-2/+2
2023-04-04Split out ast::ItemKind::Const into its own structOli Scherer-1/+3
2023-04-04rust-analyzer guided tuple field to named fieldOli Scherer-1/+1
2023-04-04rust-analyzer guided enum variant structificationOli Scherer-1/+1
2023-03-26Don't elaborate non-obligations into obligationsMichael Goulet-2/+2
2023-03-15error-msg: expand suggestion for unused lintEzra Shaw-19/+12
2023-03-12Remove uses of `box_syntax` in rustc and toolsclubby789-1/+0
2023-03-11Rollup merge of #104363 - WaffleLapkin:bonk_box_new, r=NilstriebMatthias Krüger-2/+6
Make `unused_allocation` lint against `Box::new` too Previously it only linted against `box` syntax, which likely won't ever be stabilized, which is pretty useless. Even now I'm not sure if it's a meaningful lint, but it's at least something :shrug: This means that code like the following will be linted against: ```rust Box::new([1, 2, 3]).len(); f(&Box::new(1)); // where f : &i32 -> () ``` The lint works by checking if a `Box::new` (or `box`) expression has an a borrow adjustment, meaning that the code that first stores the box in a variable won't be linted against: ```rust let boxed = Box::new([1, 2, 3]); // no lint boxed.len(); ```
2023-03-03Make `unused_allocation` lint warn against `Box::new`Maybe Waffle-2/+6
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-1/+1
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-02-14s/eval_usize/eval_target_usize/ for clarityOli Scherer-1/+1