summary refs log tree commit diff
path: root/compiler/rustc_lint/src
AgeCommit message (Collapse)AuthorLines
2021-11-15Stabilize format_args_captureJosh Triplett-1/+1
Works as expected, and there are widespread reports of success with it, as well as interest in it.
2021-11-12rustc_feature: Convert `BuiltinAttribute` from tuple to a structVadim Petrochenkov-6/+5
2021-11-07Auto merge of #90668 - matthiaskrgr:clippy_nov7, r=jyn514bors-67/+53
more clippy fixes
2021-11-07more clippy fixesMatthias Krüger-67/+53
2021-11-07ast: Fix naming conventions in AST structuresVadim Petrochenkov-5/+4
TraitKind -> Trait TyAliasKind -> TyAlias ImplKind -> Impl FnKind -> Fn All `*Kind`s in AST are supposed to be enums. Tuple structs are converted to braced structs for the types above, and fields are reordered in syntactic order. Also, mutable AST visitor now correctly visit spans in defaultness, unsafety, impl polarity and constness.
2021-11-04Optimize literal, doc comment lint as well, extract function.Hans Kratz-10/+6
2021-11-01Auto merge of #90463 - matthiaskrgr:rollup-eljk9vo, r=matthiaskrgrbors-1/+0
Rollup of 8 pull requests Successful merges: - #89826 (Feature gate + make must_not_suspend allow-by-default) - #89929 (Handling submodule update failures more gracefully from x.py) - #90333 (rustdoc: remove flicker during page load) - #90349 (Fix rare ICE during typeck in rustdoc scrape_examples) - #90398 (Document `doc(keyword)` unstable attribute) - #90441 (Test that promotion follows references when looking for drop) - #90450 (Remove `rustc_hir::hir_id::HirIdVec`) - #90452 (Remove unnecessary `Option` from `promote_candidate` return type) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-10-31Feature gate and make must_not_suspend allow-by-defaultGus Wynn-1/+0
This lint is not yet ready for stable use, primarily due to false positives in edge cases; we want to test it out more before stabilizing.
2021-10-31Lint against RTL unicode codepoints in literals and commentsEsteban Küber-1/+202
Address CVE-2021-42574.
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-65/+6
2021-10-24Rollup merge of #89558 - lcnr:query-stable-lint, r=estebankMatthias Krüger-6/+65
Add rustc lint, warning when iterating over hashmaps r? rust-lang/wg-incr-comp
2021-10-22Rollup merge of #89895 - camsteffen:for-loop-head-span, r=davidtwcoYuki Okushi-2/+1
Don't mark for loop iter expression as desugared We typically don't mark spans of lowered things as desugared. This helps Clippy rightly discern when code is (not) from expansion. This was discovered by ``@flip1995`` at https://github.com/rust-lang/rust-clippy/pull/7789#issuecomment-939289501.
2021-10-21ignore `potential_query_instability` in rustdoclcnr-0/+15
2021-10-18Rollup merge of #89987 - pierwill:fix-85526-docs-hidden-assoc, r=GuillaumeGomezMatthias Krüger-0/+18
Check implementing type for `#[doc(hidden)]` Closes #85526.
2021-10-17Check implementing type for `#[doc(hidden)]`pierwill-0/+18
Closes #85526.
2021-10-17Some "parenthesis" and "parentheses" fixesr00ster91-1/+1
2021-10-15Don't mark for loop head span with desugaringCameron Steffen-2/+1
2021-10-15allow `potential_query_instability` everywherelcnr-2/+6
2021-10-15add a `rustc::query_stability` lintlcnr-4/+44
2021-10-11Add enum_intrinsics_non_enums lintFlying-Toast-0/+109
2021-10-08Rollup merge of #89672 - klensy:unwrap-or-macro, r=jackh726Guillaume Gomez-2/+4
Remove unwrap_or! macro Removes `unwrap_or!` macro and replaces it with `match`. It's kinda cleanup, as rustc_ast not the best place for this macro and this is used only in 2 places anyway.
2021-10-08clippy::complexity fixesMatthias Krüger-2/+1
2021-10-08remove unwrap_or! macroklensy-2/+4
2021-10-06Use get_diagnostic_nameCameron Steffen-38/+38
2021-10-04Rollup merge of #89473 - FabianWolff:issue-89469, r=joshtriplettJubilee-6/+7
Fix extra `non_snake_case` warning for shorthand field bindings Fixes #89469. The problem is the innermost `if` condition here: https://github.com/rust-lang/rust/blob/d14731cb3ced8318d7fc83cbe838f0e7f2fb3b40/compiler/rustc_lint/src/nonstandard_style.rs#L435-L452 This code runs for every `PatKind::Binding`, so if a struct has multiple fields, say A and B, and both are bound in a pattern using shorthands, the call to `self.check_snake_case()` will indeed be skipped in the `check_pat()` call for `A`; but when `check_pat()` is called for `B`, the loop will still iterate over `A`, and `field.ident (= A) != ident (= B)` will be true. I have fixed this by only looking at non-shorthand bindings, and only the binding that `check_pat()` was actually called for.
2021-10-04Rollup merge of #89483 - hkmatsumoto:patch-diagnostics-2, r=estebankJubilee-8/+7
Practice diagnostic message convention Detected by #89455. r? ```@estebank```
2021-10-03Rollup merge of #88481 - bjorn3:remove_feature_gates, r=cjgillotManish Goregaokar-1/+0
Remove some feature gates The first commit removes various feature gates that are unused. The second commit replaces some `Fn` implementations with `Iterator` implementations, which is much cleaner IMO. The third commit replaces an unboxed_closures feature gate with min_specialization. For some reason the unboxed_closures feature gate suppresses the min_specialization feature gate from triggering on an `TrustedStep` impl. The last comment just turns a regular comment into a doc comment as drive by cleanup. I can move it to a separate PR if preferred.
2021-10-03Fix extra `non_snake_case` warning for shorthand field bindingsFabian Wolff-6/+7
2021-10-03Practice diagnostic message conventionHirochika Matsumoto-8/+7
2021-10-03Auto merge of #89479 - camsteffen:diag-naming, r=Manishearthbors-7/+7
Make diangostic item naming consistent Right now there is about a 50/50 split of naming diagnostic items as `vec_type` vs `Vec`. So it is hard to guess a diagnostic item name with confidence. I know it's not great to change these retroactively, but I think it will be much easier to maintain consistency after consistency is established.
2021-10-03Auto merge of #84267 - dtolnay:ptrunit, r=nagisabors-0/+9
Make *const (), *mut () okay for FFI Pointer-to-() is used occasionally in the standard library to mean "pointer to none-of-your-business". Examples: - `RawWakerVTable::new` https://doc.rust-lang.org/1.51.0/std/task/struct.RawWakerVTable.html#method.new - `<*const T>::to_raw_parts` https://doc.rust-lang.org/nightly/std/primitive.pointer.html#method.to_raw_parts I believe it's useful for the same purpose in FFI signatures, even while `()` itself is not FFI safe. The following should be allowed: ```rust extern "C" { fn demo(pc: *const (), pm: *mut ()); } ``` Prior to this PR, those pointers were not considered okay for an extern signature. ```console warning: `extern` block uses type `()`, which is not FFI-safe --> src/main.rs:2:17 | 2 | fn demo(pc: *const (), pm: *mut ()); | ^^^^^^^^^ not FFI-safe | = note: `#[warn(improper_ctypes)]` on by default = help: consider using a struct instead = note: tuples have unspecified layout warning: `extern` block uses type `()`, which is not FFI-safe --> src/main.rs:2:32 | 2 | fn demo(pc: *const (), pm: *mut ()); | ^^^^^^^ not FFI-safe | = help: consider using a struct instead = note: tuples have unspecified layout ```
2021-10-02Make diangostic item names consistentCameron Steffen-7/+7
2021-10-02Remove various unused feature gatesbjorn3-1/+0
2021-09-30Do not pass hir::Crate to lints.Camille GILLOT-7/+5
2021-09-29Avoid more invocations of hir_crate query.Camille GILLOT-2/+8
2021-09-28rustc_session: Remove lint store from `Session`Vadim Petrochenkov-15/+0
2021-09-26Pass real crate-level attributes to `pre_expansion_lint`Samuel Moelius-4/+23
2021-09-22Auto merge of #88865 - guswynn:must_not_suspend, r=oli-obkbors-0/+1
Implement `#[must_not_suspend]` implements #83310 Some notes on the impl: 1. The code that searches for the attribute on the ADT is basically copied from the `must_use` lint. It's not shared, as the logic did diverge 2. The RFC does specify that the attribute can be placed on fn's (and fn-like objects), like `must_use`. I think this is a direct copy from the `must_use` reference definition. This implementation does NOT support this, as I felt that ADT's (+ `impl Trait` + `dyn Trait`) cover the usecase's people actually want on the RFC, and adding an imp for the fn call case would be significantly harder. The `must_use` impl can do a single check at fn call stmt time, but `must_not_suspend` would need to answer the question: "for some value X with type T, find any fn call that COULD have produced this value". That would require significant changes to `generator_interior.rs`, and I would need mentorship on that. `@eholk` and I are discussing it. 3. `@estebank` do you know a way I can make the user-provided `reason` note pop out? right now it seems quite hidden Also, I am not sure if we should run perf on this r? `@nikomatsakis`
2021-09-20Adjust documentation for compatibility with 2021Mark Rousskov-3/+3
This also adjusts the lint docs generation to accept (and ignore) an allow attribute, rather than expecting the documentation to be immediately followed by the lint name.
2021-09-19Auto merge of #88703 - cjgillot:lazymod, r=petrochenkovbors-4/+2
Gather module items after lowering. This avoids having a non-local analysis inside lowering. By implementing `hir_module_items` using a visitor, we make sure that iterations and visitors are consistent.
2021-09-17Rollup merge of #87529 - FabianWolff:issue-87496, r=nikomatsakisYuki Okushi-2/+8
Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparent types Fixes #87496. There is also another function in the same file that looks fishy, but I haven't been able to produce an ICE there, and in any case, it's not related to #87496: https://github.com/rust-lang/rust/blob/fd853c00e255559255885aadff9e93a1760c8728/compiler/rustc_lint/src/types.rs#L720-L734 r? ```@JohnTitor```
2021-09-15Auto merge of #88558 - fee1-dead:const-drop, r=oli-obkbors-0/+5
Const drop The changes are pretty primitive at this point. But at least it works. ^-^ Problems with the current change that I can think of now: - [x] `~const Drop` shouldn't change anything in the non-const world. - [x] types that do not have drop glues shouldn't fail to satisfy `~const Drop` in const contexts. `struct S { a: u8, b: u16 }` This might not fail for `needs_non_const_drop`, but it will fail in `rustc_trait_selection`. - [x] The current change accepts types that have `const Drop` impls but have non-const `Drop` glue. Fixes #88424. Significant Changes: - `~const Drop` is no longer treated as a normal trait bound. In non-const contexts, this bound has no effect, but in const contexts, this restricts the input type and all of its transitive fields to either a) have a `const Drop` impl or b) can be trivially dropped (i.e. no drop glue) - `T: ~const Drop` will not be linted like `T: Drop`. - Instead of recursing and iterating through the type in `rustc_mir::transform::check_consts`, we use the trait system to special case `~const Drop`. See [`rustc_trait_selection::...::candidate_assembly#assemble_const_drop_candidates`](https://github.com/fee1-dead/rust/blob/const-drop/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L817) and others. Changes not related to `const Drop`ping and/or changes that are insignificant: - `Node.constness_for_typeck` no longer returns `hir::Constness::Const` for type aliases in traits. This was previously used to hack how we determine default bound constness for items. But because we now use an explicit opt-in, it is no longer needed. - Removed `is_const_impl_raw` query. We have `impl_constness`, and the only existing use of that query uses `HirId`, which means we can just operate it with hir. - `ty::Destructor` now has a field `constness`, which represents the constness of the destructor. r? `@oli-obk`
2021-09-12Gather module items after lowering.Camille GILLOT-4/+2
2021-09-11must_not_suspend implGus Wynn-0/+1
2021-09-11Rollup merge of #88779 - estebank:unused-delims, r=davidtwcoJubilee-68/+52
Use more accurate spans for "unused delimiter" lint
2021-09-09Use more accurate spans for "unused delimiter" lintEsteban Kuber-68/+52
2021-09-09Make `abi::Abi` `Copy` and remove a *lot* of refsAndreas Liljeqvist-4/+1
fix fix Remove more refs and clones fix more fix
2021-09-09fmtDeadbeef-2/+2
2021-09-09Do not lint for ~const Drop boundsDeadbeef-0/+5
2021-09-05Auto merge of #88435 - cjgillot:no-walk-crate, r=Aaron1011bors-4/+3
Avoid invoking the hir_crate query to traverse the HIR Walking the HIR tree is done using the `hir_crate` query. However, this is unnecessary, since `hir_owner(CRATE_DEF_ID)` provides the same information. Since depending on `hir_crate` forces dependents to always be executed, this leads to unnecessary work. By splitting HIR and attributes visits, we can avoid an edge to `hir_crate` when trying to visit the HIR tree.