about summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2020-10-30Auto merge of #78182 - LeSeulArtichaut:ty-visitor-contolflow, r=lcnr,oli-obkbors-3/+9
TypeVisitor: use `std::ops::ControlFlow` instead of `bool` Implements MCP rust-lang/compiler-team#374. Blocked on FCP in rust-lang/compiler-team#374. r? `@lcnr` cc `@jonas-schievink`
2020-10-30Fix some more clippy warningsJoshua Nelson-32/+22
2020-10-30Remove implicit `Continue` typeLeSeulArtichaut-1/+1
2020-10-30TypeVisitor: use `ControlFlow` in rustc_{infer,lint,trait_selection}LeSeulArtichaut-3/+9
2020-10-29Improve panic_fmt lint messages.Mara Bos-5/+5
(From the PR feedback.) Co-authored-by: Esteban Küber <esteban@kuber.com.ar>
2020-10-29Rollup merge of #78431 - Rustin-Liu:rustin-patch-lint, r=estebankJonas Schievink-1/+1
Prefer new associated numeric consts in float error messages Fix https://github.com/rust-lang/rust/issues/78382
2020-10-29Rollup merge of #78244 - workingjubilee:dogfood-fancy-ranges, r=varkorJonas Schievink-3/+5
Dogfood {exclusive,half-open} ranges in compiler (nfc) In particular, this allows us to write more explicit matches that avoid the pitfalls of using a fully general fall-through case, yet remain fairly ergonomic. Less logic is in guard cases, more is in the actual exhaustive case analysis. No functional changes.
2020-10-28Dogfood {exclusive,half-open} ranges in compiler (nfc)Jubilee Young-3/+5
In particular, this allows us to write more explicit matches that avoid the pitfalls of using a fully general fall-through case, yet remain fairly ergonomic. Less logic is in guard cases, more is in the actual exhaustive case analysis. No functional changes.
2020-10-28Mark panic_fmt suggestion as machine applicable.Mara Bos-1/+1
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2020-10-27Prefer new associated numeric consts in float error messagesRustin-Liu-1/+1
2020-10-26Fix doctestNathan Whitaker-0/+1
2020-10-26Write docs for lint / fix review nitNathan Whitaker-2/+20
2020-10-26Address review commentsNathan Whitaker-11/+8
2020-10-26Change to warn by default / fix typoNathan Whitaker-1/+1
2020-10-26Tweak diagnosticNathan Whitaker-4/+6
2020-10-26Address review commentsNathan Whitaker-49/+35
2020-10-26Uplift temporary-cstring-as-ptr into rustcNathan Whitaker-0/+105
2020-10-24Fix inconsistencies in handling of inert attributes on statementsAaron Hill-9/+33
When the 'early' and 'late' visitors visit an attribute target, they activate any lint attributes (e.g. `#[allow]`) that apply to it. This can affect warnings emitted on sibiling attributes. For example, the following code does not produce an `unused_attributes` for `#[inline]`, since the sibiling `#[allow(unused_attributes)]` suppressed the warning. ```rust trait Foo { #[allow(unused_attributes)] #[inline] fn first(); #[inline] #[allow(unused_attributes)] fn second(); } ``` However, we do not do this for statements - instead, the lint attributes only become active when we visit the struct nested inside `StmtKind` (e.g. `Item`). Currently, this is difficult to observe due to another issue - the `HasAttrs` impl for `StmtKind` ignores attributes for `StmtKind::Item`. As a result, the `unused_doc_comments` lint will never see attributes on item statements. This commit makes two interrelated fixes to the handling of inert (non-proc-macro) attributes on statements: * The `HasAttr` impl for `StmtKind` now returns attributes for `StmtKind::Item`, treating it just like every other `StmtKind` variant. The only place relying on the old behavior was macro which has been updated to explicitly ignore attributes on item statements. This allows the `unused_doc_comments` lint to fire for item statements. * The `early` and `late` lint visitors now activate lint attributes when invoking the callback for `Stmt`. This ensures that a lint attribute (e.g. `#[allow(unused_doc_comments)]`) can be applied to sibiling attributes on an item statement. For now, the `unused_doc_comments` lint is explicitly disabled on item statements, which preserves the current behavior. The exact locatiosn where this lint should fire are being discussed in PR #78306
2020-10-22Rollup merge of #78155 - est31:rustc_lint_types_refactor, r=davidtwcoYuki Okushi-17/+18
Fix two small issues in compiler/rustc_lint/src/types.rs Two small improvements of `compiler/rustc_lint/src/types.rs`
2020-10-20Improve panic_fmt error messages for invalid format strings too.Mara Bos-4/+18
2020-10-20Parse the format string for the panic_fmt lint for better warnings.Mara Bos-9/+33
2020-10-20Make {u,}int_range functions a bit nicerest31-14/+15
.into() guarantees safety of the conversion. Furthermore, the minimum value of all uints is known to be 0.
2020-10-20rustc_lint: remove unused to_stringest31-3/+3
In this instance, we can just pass a &str slice and save an allocation.
2020-10-20Rollup merge of #77931 - aticu:fix_60336, r=petrochenkovYuki Okushi-2/+9
Fix false positive for `unused_parens` lint Fixes #60336
2020-10-19Small cleanups in assert!() and panic_fmt lint.Mara Bos-4/+4
(From the PR feedback.) Co-authored-by: Esteban Küber <esteban@kuber.com.ar>
2020-10-19Also apply panic_fmt lint suggestions to debug_assert!().Mara Bos-9/+7
2020-10-19Don't see `{{}}` as placeholder in panic_fmt lint.Mara Bos-8/+7
2020-10-18Formatting.Mara Bos-4/+5
2020-10-18Improve panic_fmt message for panic!("{}") with a fmt placeholder.Mara Bos-17/+45
2020-10-18Make panic_fmt lint work properly for assert!(expr, msg) too.Mara Bos-0/+12
2020-10-18Specialize panic_fmt lint for the {core,std}::panic!() macros.Mara Bos-5/+22
It now only reacts to expansion of those macros, and suggests inserting `"{}", ` in the right place.
2020-10-18Add lint to warn about braces in a panic message.Mara Bos-0/+60
2020-11-17Auto merge of #78779 - LeSeulArtichaut:ty-visitor-return, r=oli-obkbors-9/+5
Introduce `TypeVisitor::BreakTy` Implements MCP rust-lang/compiler-team#383. r? `@ghost` cc `@lcnr` `@oli-obk` ~~Blocked on FCP in rust-lang/compiler-team#383.~~
2020-11-16compiler: fold by valueBastian Kauschke-4/+4
2020-11-14Use `TypeVisitor::BreakTy` in `ProhibitOpaqueTypes`LeSeulArtichaut-9/+3
2020-11-14Set the default `BreakTy` to `!`LeSeulArtichaut-0/+2
2020-11-14Introduce `TypeVisitor::BreakTy`LeSeulArtichaut-1/+1
2020-11-13Reserve space in advanceDániel Buga-0/+2
2020-10-18Auto merge of #78066 - bugadani:wat, r=jonas-schievinkbors-1/+1
Clean up small, surprising bits of code This PR clean up a small number of unrelated, small things I found while browsing the code base.
2020-10-18Replace unnecessary map_or_else with map_orDániel Buga-1/+1
2020-10-17Auto merge of #77124 - spastorino:const-exprs-rfc-2920, r=oli-obkbors-18/+60
Implement const expressions and patterns (RFC 2920) cc `@ecstatic-morse` `@lcnr` `@oli-obk` `@petrochenkov`
2020-10-16Do not check unused braces on inline constsSantiago Pastorino-18/+53
2020-10-16Add check_generic_arg early passSantiago Pastorino-0/+7
2020-10-17Suggest minimal subset features in `incomplete_features` lintYuki Okushi-0/+8
2020-10-15Replace target.target with target and target.ptr_width with target.pointer_widthest31-2/+2
Preparation for a subsequent change that replaces rustc_target::config::Config with its wrapped Target. On its own, this commit breaks the build. I don't like making build-breaking commits, but in this instance I believe that it makes review easier, as the "real" changes of this PR can be seen much more easily. Result of running: find compiler/ -type f -exec sed -i -e 's/target\.target\([)\.,; ]\)/target\1/g' {} \; find compiler/ -type f -exec sed -i -e 's/target\.target$/target/g' {} \; find compiler/ -type f -exec sed -i -e 's/target.ptr_width/target.pointer_width/g' {} \; ./x.py fmt
2020-10-14Remove unused code from remaining compiler cratesest31-4/+0
2020-10-14Fixed false positive for `unused_parens` lintaticu-2/+9
2020-10-11Do not provide suggestions for non standard charactersYuki Okushi-19/+35
2020-10-07Auto merge of #77119 - GuillaumeGomez:unclosed-html-tag-lint, r=jyn514bors-3/+4
Unclosed html tag lint Part of #67799. I think `@ollie27` will be interested (`@Manishearth` too since they opened the issue ;) ). r? `@jyn514`
2020-10-06Separate bounds and predicates for associated/opaque typesMatthew Jasper-1/+1