Commit Graph

1146 Commits

Author SHA1 Message Date
Matthias Krüger
c610aeb592
Rollup merge of #106221 - Nilstrieb:rptr-more-like-ref-actually, r=compiler-errors
Rename `Rptr` to `Ref` in AST and HIR

The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already as well.
2022-12-29 13:16:04 +01:00
Nilstrieb
9067e4417e Rename Rptr to Ref in AST and HIR
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already
as well.
2022-12-28 18:52:36 +01:00
fee1-dead
8b3d0c4cf9
Rollup merge of #105484 - nbdd0121:upcast, r=compiler-errors
Implement allow-by-default `multiple_supertrait_upcastable` lint

The lint detects when an object-safe trait has multiple supertraits.

Enabled in libcore and liballoc as they are low-level enough that many embedded programs will use them.

r? `@nikomatsakis`
2022-12-28 15:51:41 +08:00
Michael Goulet
18bf19c3a9
Rollup merge of #106064 - lukas-code:outlives-macro, r=cjgillot
Partially fix `explicit_outlives_requirements` lint in macros

Show the suggestion if and only if the bounds are from the same source context.

fixes https://github.com/rust-lang/rust/issues/106044
fixes https://github.com/rust-lang/rust/issues/106063
2022-12-27 12:33:35 -08:00
Matthias Krüger
b8d71fc41f
Rollup merge of #105515 - estebank:issue-104141, r=oli-obk
Account for macros in const generics

Fix #104141.
2022-12-27 08:57:45 +01:00
Lukas Markeffsky
1eba6c404f address review comments + better tests 2022-12-26 16:35:21 +01:00
Matthias Krüger
d8874f259a fix more clippy::style findings
match_result_ok
obfuscated_if_else
single_char_add
writeln_empty_string
collapsible_match
iter_cloned_collect
unnecessary_mut_passed
2022-12-25 17:32:26 +01:00
Matthias Krüger
d23cb738d2
Rollup merge of #105975 - jeremystucki:rustc-remove-needless-lifetimes, r=eholk
rustc: Remove needless lifetimes
2022-12-24 00:31:41 +01:00
Lukas Markeffsky
94d6245003 Fix explicit_outlives_requirements lint in macros
Show the suggestion if and only if the bounds are from the same source context.
2022-12-22 22:04:40 +01:00
Matthias Krüger
0adf9e046b
Rollup merge of #104741 - bryangarza:bug-104588-async-track-caller, r=compiler-errors
Switch `#[track_caller]` back to a no-op unless feature gate is enabled

This patch fixes a regression, in which `#[track_caller]`, which was previously a no-op, was changed to actually turn on the behavior. This should instead only happen behind the `closure_track_caller` feature gate.

Also, add a warning for the user to understand how their code will compile depending on the feature gate being turned on or not.

Fixes #104588
2022-12-22 11:03:49 +01:00
Yuki Okushi
4c2dd75af3
Rollup merge of #106008 - uweigand:s390x-lintgroup-order, r=Nilstrieb
Sort lint_groups in no_lint_suggestion

The no_lint_suggestion routine passes a vector of lint group names to find_best_match_for_name.  That routine depends on the sort order of its input vector, which matters in case multiple inputs are at the same Levenshtein distance to the target name.

However, no_lint_suggestion currently just passes lint_groups.keys() as input vector - this is sorted in hash value order, which is not guaranteed to be stable, and in fact differs between big- and little-endian host platforms, causing test failures on s390x.

To fix this, always sort the lint groups before using their names as input to find_best_match_for_name.  In doing so, prefer non- deprecated lint group names over deprecated ones, and then use alphabetical order.

Fixes https://github.com/rust-lang/rust/issues/105379
2022-12-22 08:32:12 +09:00
Ulrich Weigand
30fbfd5f05 Sort lint_groups in no_lint_suggestion
The no_lint_suggestion routine passes a vector of lint group names
to find_best_match_for_name.  That routine depends on the sort
order of its input vector, which matters in case multiple inputs
are at the same Levenshtein distance to the target name.

However, no_lint_suggestion currently just passes lint_groups.keys()
as input vector - this is sorted in hash value order, which is not
guaranteed to be stable, and in fact differs between big- and
little-endian host platforms, causing test failures on s390x.

To fix this, always sort the lint groups before using their names
as input to find_best_match_for_name.  In addition, deprecated
lint groups should never be suggested, so filter those out.

Fixes https://github.com/rust-lang/rust/issues/105379
2022-12-21 19:16:41 +01:00
Bryan Garza
9650a4168f Improve code based on feedback.
This patch improves the readability of some of the code by using
if-let-chains. Also, make use of the `add_feature_diagnostics` function.
2022-12-21 03:47:27 +00:00
Bryan Garza
f702e89f9d Add lint doc comment 2022-12-21 03:39:39 +00:00
Bryan Garza
2d060034f0 Update track_caller logic/lint after rebase 2022-12-21 03:39:33 +00:00
Bryan Garza
e28a07a0a1 update wording of lint 2022-12-21 03:30:46 +00:00
Bryan Garza
dc2c4ce578 Update code based on PR comments
This patch does the following:
- Refactor some repeated lines into a single one
- Split the `ungated_async_fn_caller` lint into multiple lines, and make
  one of those lines only print out on nightly
- Use test revisions instead of copying an existing test
2022-12-21 03:30:37 +00:00
Bryan Garza
04926e0534 Switch #[track_caller] back to a no-op unless feature gate is enabled
This patch fixes a regression, in which `#[track_caller]`, which was
previously a no-op, was changed to actually turn on the behavior. This
should instead only happen behind the `closure_track_caller` feature
gate.

Also, add a warning for the user to understand how their code will
compile depending on the feature gate being turned on or not.

Fixes #104588
2022-12-21 03:23:08 +00:00
Jeremy Stucki
3dde32ca97
rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
bors
eb9e5e711d Auto merge of #105880 - Nilstrieb:make-newtypes-less-not-rust, r=oli-obk
Improve syntax of `newtype_index`

This makes it more like proper Rust and also makes the implementation a lot simpler.

Mostly just turns weird flags in the body into proper attributes.

It should probably also be converted to an attribute macro instead of function-like, but that can be done in a future PR.
2022-12-20 07:27:01 +00:00
Matthias Krüger
ebe3563764
Rollup merge of #105873 - matthiaskrgr:clippy_fmt, r=Nilstrieb
use &str / String literals instead of format!()
2022-12-18 23:03:07 +01:00
Matthias Krüger
221e71e7a1
Rollup merge of #105869 - matthiaskrgr:clone_on_copy, r=compiler-errors
don't clone Copy types
2022-12-18 23:03:07 +01:00
Nilstrieb
8bfd6450c7 A few small cleanups for newtype_index
Remove the `..` from the body, only a few invocations used it and it's
inconsistent with rust syntax.

Use `;` instead of `,` between consts. As the Rust syntax gods inteded.
2022-12-18 21:47:28 +01:00
Nilstrieb
88d5f7f4ce Make #[custom_encodable] an attribute for newtype_index
Makes the syntax a little more rusty.
2022-12-18 21:02:14 +01:00
Matthias Krüger
a108d55ce6 don't restuct references just to reborrow 2022-12-18 17:04:32 +01:00
Matthias Krüger
3af7df91fc use &str / String literals instead of format!() 2022-12-18 16:17:46 +01:00
Matthias Krüger
fec9e9ecf1 don't clone Copy types 2022-12-18 14:25:55 +01:00
Matthias Krüger
81c11892a9
Rollup merge of #105768 - fee1-dead-contrib:iat-style, r=eholk
Detect inherent associated types not having CamelCase

Fixes #105341.
2022-12-17 00:45:52 +01:00
Deadbeef
08a0e71ec9 Detect inherent associated types not having CamelCase
Fixes #105341.
2022-12-16 14:45:04 +00:00
Oli Scherer
a5cd3bde95 Ensure no one constructs AliasTys themselves 2022-12-14 15:36:39 +00:00
Oli Scherer
1bf80249ae Remove many more cases of mk_substs_trait that can now use the iterator scheme` 2022-12-14 15:36:39 +00:00
Michael Goulet
61adaf8187 Combine projection and opaque into alias 2022-12-13 17:48:55 +00:00
Michael Goulet
c13bd83528 squash OpaqueTy and ProjectionTy into AliasTy 2022-12-13 17:40:27 +00:00
Michael Goulet
5c6afb850c ProjectionTy.item_def_id -> ProjectionTy.def_id 2022-12-13 17:34:44 +00:00
Michael Goulet
7f3af72606 Use ty::OpaqueTy everywhere 2022-12-13 17:29:26 +00:00
Nicholas Nethercote
4ff5a3655f Speed up the "builtin lints only" case.
This commit partly undoes #104863, which combined the builtin lints pass
with other lints. This caused a slowdown, because often there are no
other lints, and it's faster to do a pass with a single lint directly
than it is to do a combined pass with a `passes` vector containing a
single lint.
2022-12-12 08:59:27 +11:00
Nicholas Nethercote
3c53781800 Reinstate {Early,Late}LintPassObjects.
I removed these in #105291, and subsequently learned they are necessary
for performance.

This commit reinstates them with the new and more descriptive names
`RuntimeCombined{Early,Late}LintPass`, similar to the existing passes
like `BuiltinCombinedEarlyLintPass`. It also adds some comments,
particularly emphasising how we have ways to combine passes at both
compile-time and runtime. And it moves some comments around.
2022-12-12 08:59:27 +11:00
Nicholas Nethercote
2b05f84115 Rename run_early_passes as lint_callback.
This matches the name used in `late.rs`.
2022-12-12 08:59:27 +11:00
Matthias Krüger
2daa3bcbc2
Rollup merge of #105537 - kadiwa4:remove_some_imports, r=fee1-dead
compiler: remove unnecessary imports and qualified paths

Some of these imports were necessary before Edition 2021, others were already in the prelude.

I hope it's fine that this PR is so spread-out across files :/
2022-12-11 09:51:57 +01:00
bors
c6fcdb6906 Auto merge of #105416 - nnethercote:more-linting-tweaks, r=cjgillot
More linting tweaks

Squeeze a little more blood from this stone.

r? `@cjgillot`
2022-12-10 19:49:51 +00:00
KaDiWa
9bc69925cb
compiler: remove unnecessary imports and qualified paths 2022-12-10 18:45:34 +01:00
Matthias Krüger
9e87dd907e
Rollup merge of #105505 - WaffleLapkin:yeet_unused_parens_lint, r=fee1-dead
Don't warn about unused parens when they are used by yeet expr

Don't even get me started on how I've found this.
2022-12-10 09:24:44 +01:00
Esteban Küber
fb3e4b349a Account for macros in const generics 2022-12-09 15:21:12 -08:00
Matthias Krüger
4fae5891d0
Rollup merge of #102406 - mejrs:missing_copy, r=wesleywiser
Make `missing_copy_implementations` more cautious

- Fixes https://github.com/rust-lang/rust/issues/98348
- Also makes the lint not fire on large types and types containing raw pointers. Thoughts?
2022-12-09 22:31:54 +01:00
Maybe Waffle
84a46352ac Don't warn about unused parens when they are used by yeet expr 2022-12-09 18:32:06 +00:00
Gary Guo
5e44a65517 Implement allow-by-default multiple_supertrait_upcastable lint 2022-12-09 02:29:51 +00:00
Matthias Krüger
3bcfa4c459
Rollup merge of #105267 - compiler-errors:issue-104613, r=oli-obk
Don't ICE in ExprUseVisitor on FRU for non-existent struct

Fixes #104613
Fixes #105202
2022-12-07 15:39:06 +01:00
Nicholas Nethercote
d049be30cf Split EarlyContextAndPasses::check_id in two. 2022-12-07 19:29:31 +11:00
Nicholas Nethercote
b08fd6e8ef Inline some hot lint pass functions.
These each have a single call site, due to being called from a
"combined" lint pass.
2022-12-07 19:29:31 +11:00
Nicholas Nethercote
ec117c0ebd Rename $passes as $pass in several macros.
Because it makes more sense that way.
2022-12-07 19:29:31 +11:00