Commit Graph

16255 Commits

Author SHA1 Message Date
Samuel Moelius
90ba82bd39 Two small documentation improvements 2023-02-28 09:52:01 -05:00
bors
8b65632b6e Auto merge of #10419 - deining:fix/typos, r=Jarcho
Fixing typos

changelog: none
2023-02-27 20:51:12 +00:00
Andreas Deininger
03a3f74365 Fixing typos 2023-02-27 21:45:26 +01:00
bors
2742ac0748 Auto merge of #10399 - samueltardieu:issue-10396, r=Manishearth
Do not suggest to derive `Default` on generics with implicit arguments

Fixes #10396

changelog: FP: [`derivable_impls`]: do not suggest to derive `Default` on generics with implicit arguments
2023-02-27 17:12:43 +00:00
bors
ba7fd68e87 Auto merge of #10408 - cdown:cdown/2023-02-26/exit_lint_sp, r=Alexendoo
exit lint: potentualy -> potentially

changelog: none
2023-02-26 20:51:54 +00:00
Chris Down
5f3df6cfce exit lint: potentualy -> potentially 2023-02-26 17:43:24 +00:00
Samuel Tardieu
c82ff00539 Do not suggest to derive Default on generics with implicit arguments 2023-02-26 15:44:04 +01:00
bors
3d193fa17a Auto merge of #10400 - calebcartwright:rustfmt-cleanup, r=Jarcho
chore: remove unneeded rustfmt skip

---

The associated rustfmt bug that originally necessitated these skips was resolved a while back, so these are no longer necessary

changelog: none
2023-02-26 03:03:01 +00:00
bors
e1ac1332b6 Auto merge of #10375 - samueltardieu:issue-10371, r=Manishearth
Do not suggest using Self in const generic parameters

Fixes #10371

changelog: FP: [`use_self`]: do not suggest using `Self` in const generic parameters
2023-02-26 00:52:55 +00:00
bors
149392b0ba Auto merge of #10402 - Jarcho:rustup, r=Jarcho
Rustup

Looks like `@flip1995`  is busy.

r? `@ghost`

changelog: None
2023-02-25 23:34:06 +00:00
Jason Newcomb
69c4ff6df8 Emit unnecessary_def_path in source order. 2023-02-25 18:09:24 -05:00
Jason Newcomb
e825adf637 Fix normalization of custom_ice_message test. 2023-02-25 18:08:51 -05:00
bors
51551193d8 Auto merge of #10401 - samueltardieu:issue-10148, r=Alexendoo
Do not panic when analyzing the malformed origin of a format string

Fixes #10148. This will trigger only when generating format strings while accepting weird things in a procedural macro and setting the span to something which is not a string.

changelog: none
2023-02-25 23:05:23 +00:00
Samuel Tardieu
64775f30c2 Do not panic when analyzing the malformed origin of a format string 2023-02-25 23:48:17 +01:00
Jason Newcomb
5552f4a6b5 Bump nightly version -> 2023-02-25 2023-02-25 17:44:05 -05:00
Jason Newcomb
bc184e9c7d Merge branch 'master' into rustup 2023-02-25 17:43:19 -05:00
Caleb Cartwright
730fa93634 chore: remove unneeded rustfmt skip 2023-02-25 12:34:05 -06:00
bors
b528cc90bc Auto merge of #10391 - ldm0:ldm0_fix_unwrap_in_tests, r=xFrednet
Fix test function checker in `unwrap_used`, `expect_used`

After #9686 , `unwrap` and `expect` in integration tests and raw test functions won't be allowed.

fixes #10011
fixes #10238
fixes #10264

---

changelog: Fix: [`expect_used`], [`unwrap_used`], [`dbg_macro`], [`print_stdout`], [`print_stderr`]: No longer lint in test functions, if the related configuration is set
[#10391](https://github.com/rust-lang/rust-clippy/pull/10391)
<!-- changelog_checked -->
2023-02-24 09:24:41 +00:00
Liu Dingming
84ceca852e run cargo collect-metadata 2023-02-24 05:53:58 +08:00
bors
659112ca95 Auto merge of #10369 - nindalf:no_mangle_lint, r=llogiq
Add new lint no_mangle_with_rust_abi

Fixes issue #10347

This PR adds a new lint `no_mangle_with_rust_abi` that suggests converting a function to the C ABI to if the function has the `#[no_mangle]` attribute and `Abi == Abi::Rust`. It will not run for any of the other variants defined in [rustc_target::spec::abi::Abi](https://doc.rust-lang.org/beta/nightly-rustc/rustc_target/spec/abi/enum.Abi.html), nor suggest any conversion other than conversion to the C ABI.

Functions that explicitly opt into the Rust ABI with `extern "Rust"` are ignored by this lint.

---

changelog: [`no_mangle_with_rust_abi`]: add lint that converts Rust ABI functions with the `#[no_mangle]` attribute to C ABI
2023-02-23 19:41:03 +00:00
Krishna Sundarram
00c294ad05 Add new lint no_mangle_with_rust_abi 2023-02-23 17:35:06 +00:00
bors
f9adb83e0a Auto merge of #10392 - mkrasnitski:false-positives, r=Jarcho
Fix more false positives for `extra_unused_type_parameters`

Builds on #10321. All empty functions are no longer linted, instead of just those that have trait bounds on them. Also, if a trait bound contains a non-public trait (un-exported, but still potentially reachable), then the corresponding type parameter isn't linted.

Finally, added support for the `avoid_breaking_exported_api` config option.

r? `@flip1995`
changelog: none
2023-02-23 15:53:39 +00:00
Michael Krasnitski
528bb639d4 Fix more false positives for extra_unused_type_parameters 2023-02-23 10:12:02 -05:00
bors
daa94d2583 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
bors
95cd5284d4 Auto merge of #108340 - eggyal:remove_traversal_trait_aliases, r=oli-obk
Remove type-traversal trait aliases

#107924 moved the type traversal (folding and visiting) traits into the type library, but created trait aliases in `rustc_middle` to minimise both the API churn for trait consumers and the arising boilerplate.  As mentioned in that PR, an alternative approach of defining subtraits with blanket implementations of the respective supertraits was also considered at that time but was ruled out as not adding much value.

Unfortunately, it has since emerged that rust-analyzer has difficulty with these trait aliases at present, resulting in a degraded contributor experience (see the recent [r-a has become useless](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/r-a.20has.20become.20useless) topic on the #t-compiler/help Zulip stream).

This PR removes the trait aliases, and accordingly the underlying type library traits are now used directly; they are parameterised by `TyCtxt<'tcx>` rather than just the `'tcx` lifetime, and imports have been updated to reflect the fact that the trait aliases' explicitly named traits are no longer automatically brought into scope.  These changes also roll-back the (no-longer required) workarounds to #107747 that were made in b409329c62.

Since this PR is just a find+replace together with the changes necessary for compilation & tidy to pass, it's currently just one mega-commit.  Let me know if you'd like it broken up.

r? `@oli-obk`
2023-02-22 18:26:51 +00:00
Alan Egerton
430c4ab7ff Remove type-traversal trait aliases 2023-02-22 17:04:58 +00:00
Michael Howell
d254516be1 clippy: update clippy to use new TyCtxt::def_descr 2023-02-22 08:40:47 -07:00
Liu Dingming
79a90248c3 bless 2023-02-22 21:49:26 +08:00
Liu Dingming
a5acb926c1 fix fmt 2023-02-22 21:44:56 +08:00
Liu Dingming
1a474d9179 Recover tests 2023-02-22 21:36:30 +08:00
Liu Dingming
b9c617a1b7 correct comments 2023-02-22 21:36:16 +08:00
Liu Dingming
72e773f6a8 Fix test function checker in [unwrap_used], [expect_used] 2023-02-22 21:31:21 +08:00
bors
8d08917d3a Auto merge of #10385 - Jarcho:readme_restriction, r=xFrednet
Update readme description of `restriction` lints to dissuade casual use.

Adds some stronger wording about not enabling `restriction` lints. I've seen it come up a few times where people are confused about what the `restriction` category is for and end up casually enabling lints from it (or the whole category).

changelog: None
2023-02-22 09:51:01 +00:00
David Wood
ab69a2a57b various: translation resources from cg backend
Extend `CodegenBackend` trait with a function returning the translation
resources from the codegen backend, which can be added to the complete
list of resources provided to the emitter.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22 09:15:54 +00:00
David Wood
aa0e543ba0 errors: generate typed identifiers in each crate
Instead of loading the Fluent resources for every crate in
`rustc_error_messages`, each crate generates typed identifiers for its
own diagnostics and creates a static which are pulled together in the
`rustc_driver` crate and provided to the diagnostic emitter.

Signed-off-by: David Wood <david.wood@huawei.com>
2023-02-22 09:15:53 +00:00
Jason Newcomb
bf7c209620 Update readme description of restriction lints to dissuade casual use. 2023-02-21 22:05:38 -05:00
bors
51668820f4 Auto merge of #10386 - Jarcho:issue_10384, r=Manishearth
Normalize projections types when checking `explicit_auto_deref`

fixes #10384

changelog: [`explicit_auto_deref`]: Better consider projection types when checking if auto deref is applicable
2023-02-21 21:27:41 +00:00
Jason Newcomb
0aad34e43f Normalize projections types when checking explicit_auto_deref 2023-02-21 15:59:06 -05:00
bors
803ce88477 Auto merge of #10380 - Alexendoo:needless-lifetime-macro-expansion, r=xFrednet
Ignore lifetimes from differing contexts in `needless_lifetimes`

Fixes #10379

changelog: [`needless_lifetimes`]: Don't lint signatures in macros if the lifetime is a metavariable
2023-02-21 20:47:30 +00:00
bors
5ef3cc8ca1 Auto merge of #10197 - blyxyas:impl_trait_param, r=Jarcho
Add `impl_trait_in_params` lint

As this is a lint about style, and using `impl Trait` is purely cosmetical (even with downsides), a lot of unrelated files needed to allow this lint.

---

Resolves #10030

changelog: New lint: [`impl_trait_in_params`]
[10197](https://github.com/rust-lang/rust-clippy/pull/10197)
<!-- changelog_checked -->
2023-02-21 03:02:48 +00:00
Nicholas Nethercote
71b8646854 Use ThinVec in various AST types.
This commit changes the sequence parsers to produce `ThinVec`, which
triggers numerous conversions.
2023-02-21 11:51:56 +11:00
bors
b1cf1e7b6a Auto merge of #10303 - pvdrz:pub_crate_missing_docs, r=giraffate
Add configuration to lint missing docs of `pub(crate)` items

Fixes this: https://github.com/rust-lang/rust-clippy/issues/5736#issuecomment-1412442404

TODO:
- [x] Needs docs
- [x] Needs better names
- [x] Should `pub` items be checked to when this new option is enabled? I'm saying no because `missing_docs` already exists

`@flip1995` I'd like to get some input from you :)

---

changelog: Enhancement: [`missing_docs_in_private_items`]: Added new configuration `missing-docs-in-crate-items` to lint on items visible within the current crate. For example, `pub(crate)` items.
[#10303](https://github.com/rust-lang/rust-clippy/pull/10303)
<!-- changelog_checked -->
2023-02-20 23:59:07 +00:00
Christian Poveda
790f28b153
Update documentation 2023-02-20 09:34:49 -05:00
bors
574c8aeeb5 Auto merge of #10382 - samueltardieu:issue-10381, r=llogiq
Box::default(): do not omit the type of the removed trait object

Within a larger expression, when the type of `Box::new(T::default())` is `Box<dyn Trait>`, the concrete type `T` cannot be omitted in the proposed replacement `Box::<T>::default()`.

Fixes #10381

changelog: [`box_default`]: in case of a trait object do not omit the concrete type name
2023-02-20 13:14:23 +00:00
Samuel Tardieu
92c403c9b0 Box::default(): do not omit the type of the removed trait object
Within a larger expression, when the type of `Box::new(T::default())` is
`Box<dyn Trait>`, the concrete type `T` cannot be omitted in the
proposed replacement `Box::<T>::default()`.
2023-02-20 11:58:27 +01:00
Alex Macleod
09058388de Ignore lifetimes from differing contexts in needless_lifetimes 2023-02-20 09:54:53 +00:00
Samuel Tardieu
f531abcef5 Do not suggest using Self in const generic parameters 2023-02-19 11:59:02 +01:00
blyxyas
89fde4abf2
Add placeholders, remove name suggesting 2023-02-18 20:05:30 +01:00
bors
85d4b5ac48 Auto merge of #10368 - c410-f3r:lock-1, r=xFrednet
[significant_drop_tightening] Evaluate the return expression of a block

For whatever reason, the return expression of a block is not contained inside the slice of statements and because of that the lint wasn't evaluating things that could potentially block the release of a lock.

```rust
pub fn example() -> i32 {
    let mutex = Mutex::new(1);
    let lock = mutex.lock().unwrap();
    let _ = *lock;
    let _ = *lock;
   do_heavy_computation_that_takes_time_and_returns_i32()
}
```

---

changelog: none
<!-- changelog_checked -->
2023-02-18 13:23:35 +00:00
Caio
7518969501 Evaluate the return expression of a block 2023-02-18 09:14:41 -03:00