Commit Graph

140 Commits

Author SHA1 Message Date
Yuki Okushi
61115cd753
Rollup merge of #111150 - mj10021:issue-111025-fix, r=petrochenkov
added TraitAlias to check_item() for missing_docs

As in issue #111025 the `missing_docs` was not being triggered for trait aliases.  I added `TraitAlias` to the pattern match for check_item(), and the lint seems to be behaving appropriately
2023-05-07 14:12:15 +09:00
Ben Kimock
ff855547f4 Rename InstCombine to InstSimplify 2023-05-06 23:22:32 -04:00
James Dietz
fd005b06bb delete whitelist and add checks to check_item() for missing_docs
add test and bless
2023-05-06 18:31:50 -04:00
clubby789
9027d208f2 Check arguments length in trivial diagnostic lint 2023-05-06 14:42:35 +01:00
Dylan DPC
40c4ed4994
Rollup merge of #110955 - fee1-dead-contrib:sus-operation, r=compiler-errors
uplift `clippy::clone_double_ref` as `suspicious_double_ref_op`

Split from #109842.

r? ``@compiler-errors``
2023-05-02 11:44:52 +05:30
Matthias Krüger
1b262b8b56
Rollup merge of #110823 - compiler-errors:tweak-await-span, r=b-naber
Tweak await span to not contain dot

Fixes a discrepancy between method calls and await expressions where the latter are desugared to have a span that *contains* the dot (i.e. `.await`) but method call identifiers don't contain the dot. This leads to weird suggestions suggestions in borrowck -- see linked issue.

Fixes #110761

This mostly touches a bunch of tests to tighten their `await` span.
2023-05-01 01:09:47 +02:00
Matthias Krüger
791d33c5eb
Rollup merge of #110973 - bindsdev:packed-struct-ref-diagnostic-note, r=compiler-errors
improve error notes for packed struct reference diagnostic

Addresses #110199
2023-04-30 01:14:58 +02:00
bindsdev
107d480892 improve error notes for packed struct reference diagnostic 2023-04-28 20:28:56 -05:00
Lukas Markeffsky
69c71dacda fix false negative for unused_mut 2023-04-28 19:35:40 +02:00
Deadbeef
5c99175a9e uplift clippy::clone_double_ref as suspicious_double_ref_op 2023-04-28 17:24:48 +00:00
Michael Goulet
f0fc4f9acf Tweak await span 2023-04-27 17:18:11 +00:00
Michael Goulet
12a2f24b15 Remove a bunch of orphaned test files 2023-04-27 17:17:38 +00:00
bors
3462f79e94 Auto merge of #108118 - oli-obk:lazy_typeck, r=cjgillot
Run various queries from other queries instead of explicitly in phases

These are just legacy leftovers from when rustc didn't have a query system. While there are more cleanups of this sort that can be done here, I want to land them in smaller steps.

This phased order of query invocations was already a lie, as any query that looks at types (e.g. the wf checks run before) can invoke e.g. const eval which invokes borrowck, which invokes typeck, ...
2023-04-23 13:34:31 +00:00
Oli Scherer
334423263a Run check_match and check_liveness when MIR is built instead of having an explicit phase for them 2023-04-21 22:32:38 +00:00
DrMeepster
a642563d49 major test improvements 2023-04-21 02:45:48 -07:00
DrMeepster
f92294f76b bless 2023-04-21 02:14:03 -07:00
DrMeepster
2bcb018253 fmt 2023-04-21 02:14:03 -07:00
DrMeepster
b92c2f792c fix incorrect param env in dead code lint 2023-04-21 02:14:03 -07:00
bors
8d09b8e206 Auto merge of #110370 - c410-f3r:dqewdas, r=petrochenkov
Move test files

r? `@petrochenkov`
2023-04-21 01:26:57 +00:00
Caio
4adc5f9281 Move test files 2023-04-20 15:06:17 -03:00
Ezra Shaw
8cad917e68
reimpl make non_upper_case_globals lint not report trait impls 2023-04-20 16:28:49 +12:00
Ezra Shaw
625619551d
make non_upper_case_globals lint not report trait impls 2023-04-19 12:47:35 +12:00
Matthias Krüger
06d12f668e
Rollup merge of #110257 - 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-17 18:13:33 +02:00
Eric Huss
d7ed5a52ff Unignore closure-bang.
This test was ignored long ago in
https://github.com/rust-lang/rust/pull/20578/ when the syntax for
closures was changed.

The current status is that a closure with an explicit `!` return type
will trigger the `unreachable_code` lint which appears to be the
original intent of the test
(https://github.com/rust-lang/rust/pull/16836). A closure without a
return type won't trigger the lint since the `!` type isn't inferred
(AFAIK). This restores the test to its original form.
2023-04-15 14:43:20 -07:00
Lukas Markeffsky
0d0949d87f emit unused_parens for break if it is not immediately followed by a block 2023-04-13 18:09:47 +02:00
Lukas Markeffsky
8df1f41b9c fix false positives for unused_parens around unary and binary operations 2023-04-13 18:08:52 +02:00
Ezra Shaw
39e23ef532
impl reviewer feedback
- remove unused (pun intentional) `continue`
- improve wording with assoc items in general
2023-04-13 23:39:14 +12:00
Ezra Shaw
c41dcac8e8
dead-code-lint: de-dup multiple unused assoc fns 2023-04-13 22:42:47 +12:00
Ezra Shaw
03cf0e949f
refactor: emit "unused assoc fn" in lexical order
with repect to other dead code lints
2023-04-13 20:53:32 +12:00
bors
4087deaccd Auto merge of #110249 - matthiaskrgr:rollup-7iig04q, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #110153 (Fix typos in compiler)
 - #110165 (rustdoc: use CSS `overscroll-behavior` instead of JavaScript)
 - #110175 (Symbol cleanups)
 - #110203 (Remove `..` from return type notation)
 - #110205 (rustdoc: make settings radio and checks thicker, less contrast)
 - #110222 (Improve the error message when forwarding a matched fragment to another macro)
 - #110237 (Split out a separate feature gate for impl trait in associated types)
 - #110241 (tidy: Issue an error when UI test limits are too high)

Failed merges:

 - #110218 (Remove `ToRegionVid`)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-04-12 20:01:36 +00:00
Oli Scherer
f263f88bea Split out a separate feature gate for impl trait in associated types 2023-04-12 16:17:31 +00:00
Matthias Krüger
49769260a3
Rollup merge of #110209 - JohnTitor:issue-59003, r=compiler-errors
Add regression test for #59003

Closes #59003
r? compiler-errors
2023-04-12 17:04:33 +02:00
Yuki Okushi
06ec5faccb
Add regression test for #59003
Signed-off-by: Yuki Okushi <jtitor@2k36.org>
2023-04-12 06:24:49 +09:00
Michael Goulet
4560b61cd1 Broken tests 2023-04-11 17:45:42 +00:00
Camille GILLOT
8528ac6e35 Do not suppress temporary_cstring_as_ptr in macros. 2023-04-04 18:55:02 +00:00
bors
35d06f9c74 Auto merge of #109599 - notriddle:notriddle/use-redundant-glob, r=petrochenkov
diagnostics: account for glob shadowing when linting redundant imports

Fixes #92904
2023-04-04 06:41:27 +00:00
Michael Howell
000e94e67d diagnostics: account for glob shadowing when linting redundant imports
Co-Authored-By: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2023-04-01 11:11:21 -07:00
Mu42
dde26b31b6 add run-rustfix 2023-03-29 09:56:28 +08:00
Michael Howell
2005e300c0 tests: make directory for use redundant lint 2023-03-25 09:23:05 -07:00
Mu001999
910a5ad2df Emits suggestions for expressions with parentheses or not separately 2023-03-25 01:00:49 +08:00
Mu42
6034b2fcb8 Use independent suggestions 2023-03-24 20:09:02 +08:00
Mu42
8e56c2c5f1 Suggest ..= when someone tries to create an overflowing range 2023-03-24 14:24:25 +08:00
Guillaume Gomez
e03b13ccb7 Update anonymous-reexport UI test 2023-03-22 16:05:20 +01:00
DaniPopes
8ca0f61fe3
fix ClashingExternDeclarations lint ICE 2023-03-20 00:50:03 +01:00
Dylan DPC
462e7e7a10
Rollup merge of #109003 - GuillaumeGomez:useless-anonymous-reexport-lint, r=cjgillot
Add `useless_anonymous_reexport` lint

This is a follow-up of https://github.com/rust-lang/rust/pull/108936. We once again show all anonymous re-exports in rustdoc, however we also wanted to add a lint to let users know that it very likely doesn't have the effect they think it has.
2023-03-19 15:33:57 +05:30
Matthias Krüger
36b82373e0
Rollup merge of #109158 - Ezrashaw:expand-sugg-for-unused-lint, r=Nilstrieb
error-msg: expand suggestion for `unused_def` lint

Fixes #108885

Expands `let _ = ..` suggestion into more positions.
2023-03-16 08:57:07 +01:00
Ezra Shaw
35103fe8ab
error-msg: expand suggestion for unused lint 2023-03-15 23:30:12 +13:00
yukang
b3af5e2f8b Fix #109152, fix the scenario that we may can not get span of func 2023-03-15 14:07:39 +08:00
Guillaume Gomez
7b0fa085b0 Update failing ui tests 2023-03-12 16:38:54 +01:00
Guillaume Gomez
ac4ea52980 Add test for useless_anonymous_reexport lint 2023-03-12 16:33:37 +01:00
Matthias Krüger
fbc121fdfd
Rollup merge of #104363 - WaffleLapkin:bonk_box_new, r=Nilstrieb
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 🤷

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-11 15:43:11 +01:00
Albert Larsan
33d7fad7e5
Add regression test for 98444 2023-03-06 13:41:07 +00:00
Maybe Waffle
a90abd64fb Remove feature(box_syntax) from unused allocation list test 2023-03-03 19:02:35 +00:00
Maybe Waffle
ff5f784140 Add a test for unused_allocation lint
(how come we didn't have one already??)
2023-03-03 17:47:40 +00:00
Matthias Krüger
371904bba6
Rollup merge of #108297 - chenyukang:yukang/delim-error-exit, r=petrochenkov
Exit when there are unmatched delims to avoid noisy diagnostics

From https://github.com/rust-lang/rust/pull/104012#issuecomment-1311764832
r? ``@petrochenkov``
2023-03-01 01:20:22 +01:00
yukang
65ad5f8de7 remove duplicated diagnostic for unclosed delimiter 2023-02-28 07:57:17 +00:00
yukang
f01d0c02e7 Exit when there are unmatched delims to avoid noisy diagnostics 2023-02-28 07:55:19 +00:00
Obei Sideg
99344a8b32 Add ui test for E0271 error 2023-02-23 13:57:13 +03:00
Obei Sideg
b93d54556f Add ui test for map_unit_fn lint in closure case 2023-02-23 13:57:13 +03:00
Obei Sideg
ddd7d10879 Add ui test for map_unit_fn lint 2023-02-23 13:57:13 +03:00
bors
0978711950 Auto merge of #108324 - notriddle:notriddle/assoc-fn-method, r=compiler-errors,davidtwco,estebank,oli-obk
diagnostics: if AssocFn has self argument, describe as method

Discussed in https://rust-lang.zulipchat.com/#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/.22associated.20function.22.20vs.20.22method.22/near/329265515

This commit also changes the tooltips on rustdoc intra-doc links targeting methods.

For anyone not sure why this is being done, see the Reference definitions of these terms in <https://doc.rust-lang.org/1.67.1/reference/items/associated-items.html#methods>

> Associated functions whose first parameter is named `self` are called methods and may be invoked using the [method call operator](https://doc.rust-lang.org/1.67.1/reference/expressions/method-call-expr.html), for example, `x.foo()`, as well as the usual function call notation.

In particular, while this means it's technically correct for rustc to refer to a method as an associated function (and there are a few cases where it'll still do so), rustc *must never* use the term "method" to refer to an associated function that does not have a `self` parameter.
2023-02-23 00:19:12 +00:00
Michael Howell
3f374128ee diagnostics: update test cases to refer to assoc fn with self as method 2023-02-22 08:40:47 -07:00
clubby789
c7a4f387fd Lint dead code in closures 2023-02-22 15:27:19 +00:00
Dylan DPC
4dea3a295f
Rollup merge of #108000 - y21:no-zero-init-for-uninhabited, r=jackh726
lint: don't suggest MaybeUninit::assume_init for uninhabited types

Creating a zeroed uninhabited type such as `!` or an empty enum with `mem::zeroed()` (or transmuting `()` to `!`) currently triggers this lint:
```rs
warning: the type `!` does not permit zero-initialization
 --> test.rs:5:23
  |
5 |         let _val: ! = mem::zeroed();
  |                       ^^^^^^^^^^^^^
  |                       |
  |                       this code causes undefined behavior when executed
  |                       help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done
  |
  = note: the `!` type has no valid value
```
The `MaybeUninit` suggestion in the help message seems confusing/useless for uninhabited types, as such a type cannot be fully initialized in the first place (as the note implies).
This PR limits this help message to inhabited types which can be initialized
2023-02-21 14:19:58 +05:30
bors
21e5b941e0 Auto merge of #108128 - clubby789:builtin-derived-attr, r=jackh726
Properly check for builtin derived code

Fixes #108122
2023-02-19 21:18:07 +00:00
y21
0610df9314 lint: don't suggest assume_init for uninhabited types 2023-02-18 19:05:44 +01:00
clubby789
eebd31c187 Don't eagerly convert principal to string 2023-02-17 14:44:58 +00:00
clubby789
90f642bb3d Properly check for builtin derives 2023-02-16 19:44:03 +00:00
Michael Goulet
087a0136d0 Don't ICE in might_permit_raw_init if reference is polymorphic 2023-02-14 01:03:06 +00:00
Matthias Krüger
8fc9ed51f0
Rollup merge of #107043 - Nilstrieb:true-and-false-is-false, r=wesleywiser
Support `true` and `false` as boolean flag params

Implements [MCP 577](https://github.com/rust-lang/compiler-team/issues/577).
2023-02-10 06:09:56 +01:00
bors
044a28a409 Auto merge of #103761 - chenyukang:yukang/fix-103320-must-use, r=compiler-errors
Add explanatory message for [#must_use] in ops

Fixes #103320
2023-02-06 12:57:37 +00:00
Dylan DPC
d9db35785d
Rollup merge of #107539 - PossiblyAShrub:unused-parens-in-index, r=lcnr
Emit warnings on unused parens in index expressions

Fixes: #96606.

I am not sure what the best term for "index expression" is. Is there a better term we could use?
2023-02-03 23:04:51 +05:30
yukang
cb55d10eb2 Fix #103320, add explanatory message for [#must_use] 2023-02-04 00:27:03 +08:00
Aidan Olsen
c3a71ede7c Emit warnings on unused parens/braces in index expressions 2023-02-02 12:46:31 -07:00
Ralf Jung
dfc4a7b2d0 make unaligned_reference a hard error 2023-01-31 20:28:11 +01:00
Esteban Küber
62ba3e70a1 Modify primary span label for E0308
The previous output was unintuitive to users.
2023-01-30 20:12:19 +00:00
Camille GILLOT
0e52a671d4 Bless tests. 2023-01-27 20:10:17 +00:00
Camille GILLOT
9259da51ed Test the 3 generator handling versions for generator/async tests. 2023-01-27 18:58:13 +00:00
Aaron Hill
dc8876196b
Add SEMICOLON_IN_EXPRESSIONS_FROM_MACROS to future-incompat report 2023-01-21 14:38:25 -06:00
--global
734f375019 Change bindings_with_variant_name to deny-by-default 2023-01-20 02:26:12 -05:00
Nilstrieb
a6fda3ee7f Support true and false as boolean flag params
Implements MCP 577.
2023-01-18 20:46:36 +01:00
Dylan DPC
f91f369949
Rollup merge of #106148 - chenyukang:yukang/fix-105061-unused, r=lcnr
Fix unused_parens issue for higher ranked function pointers

fixes #105061

r? `@lcnr`
2023-01-17 20:33:03 +05:30
yukang
9d74bb832f comments feedback 2023-01-16 20:44:14 +08:00
clubby789
295f5483fe Fix regression in unused_braces with macros 2023-01-15 05:08:30 +00:00
yukang
644ee8d250 add test case for issue 105601 2023-01-14 17:11:05 +08:00
yukang
7d99866bfc fix #105061, Fix unused_parens issue for higher ranked function pointers 2023-01-14 17:11:04 +08:00
Matthias Krüger
c6e3a47843
Rollup merge of #106585 - estebank:issue-46585, r=compiler-errors
When suggesting writing a fully qualified path probe for appropriate types

Address the more common part of #46585.
2023-01-13 19:16:42 +01:00
Arthur Carcano
797f247997 Mark ZST as FFI-safe if all its fields are PhantomData
Modify the linting behavior and add the corresponding
regression test
2023-01-12 12:21:35 +01:00
Esteban Küber
12ddf77811 When suggesting writing a fully qualified path probe for appropriate types
Fix #46585.
2023-01-11 21:30:10 +00:00
Albert Larsan
cf2dff2b1e
Move /src/test to /tests 2023-01-11 09:32:08 +00:00