Commit Graph

1221 Commits

Author SHA1 Message Date
Philipp Krones
aa3247c891
Merge remote-tracking branch 'upstream/master' into rustup 2023-06-02 10:17:55 +02:00
Centri3
497f37793e Fix attr_search_pat for #[cfg_attr] 2023-06-01 21:26:41 -05:00
Centri3
ab70553a38 foiled again (forgot to run cargo test) 2023-06-01 20:32:08 -05:00
Centri3
0086b6ab0a don't lint allow_attributes on attributes from proc macros 2023-06-01 20:24:41 -05:00
y21
a239c8b52b [unnecessary_lazy_eval]: don't lint on types with deref impl 2023-06-02 00:06:34 +02:00
y21
f74ec6b1b8 new lint: missing_field_in_debug
move some strings into consts, more tests

s/missing_field_in_debug/missing_fields_in_debug

dont trigger in macro expansions

make dogfood tests happy

minor cleanups

replace HashSet with FxHashSet

replace match_def_path with match_type

if_chain -> let chains, fix markdown, allow newtype pattern

fmt

consider string literal in `.field()` calls as used

don't intern defined symbol, remove mentions of 'debug_tuple'

special-case PD, account for field access through `Deref`
2023-05-31 23:52:02 +02:00
lcnr
739530a03c EarlyBinder::new -> EarlyBinder::bind 2023-05-29 13:46:10 +02:00
Nicholas Nethercote
53f1e6b7ef Use Cow in {D,Subd}iagnosticMessage.
Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment:
```
// FIXME(davidtwco): can a `Cow<'static, str>` be used here?
```
This commit answers that question in the affirmative. It's not the most
compelling change ever, but it might be worth merging.

This requires changing the `impl<'a> From<&'a str>` impls to `impl
From<&'static str>`, which involves a bunch of knock-on changes that
require/result in call sites being a little more precise about exactly
what kind of string they use to create errors, and not just `&str`. This
will result in fewer unnecessary allocations, though this will not have
any notable perf effects given that these are error paths.

Note that I was lazy within Clippy, using `to_string` in a few places to
preserve the existing string imprecision. I could have used `impl
Into<{D,Subd}iagnosticMessage>` in various places as is done in the
compiler, but that would have required changes to *many* call sites
(mostly changing `&format("...")` to `format!("...")`) which didn't seem
worthwhile.
2023-05-29 09:23:43 +10:00
Kyle Matsuda
cfcb7fc859 Replace EarlyBinder(x) with EarlyBinder::new(x) 2023-05-28 10:44:50 -06:00
bors
f1fd4673bc Auto merge of #10813 - y21:issue10755, r=xFrednet
[`default_constructed_unit_structs`]: do not lint on type alias paths

Fixes #10755.

Type aliases cannot be used as a constructor, so this lint should not trigger in those cases.
I also changed `clippy_utils::is_ty_alias` to also consider associated types since [they kinda are type aliases too](48ec50ae39/compiler/rustc_resolve/src/late/diagnostics.rs (L1520)).

changelog: [`default_constructed_unit_structs`]: do not lint on type alias paths
2023-05-26 15:20:21 +00:00
bors
a0fd17d3f0 Auto merge of #10779 - Centri3:ptr_cast_constness, r=llogiq
Add new lint `ptr_cast_constness`

This adds a new lint which functions as the opposite side of the coin to `ptr_as_ptr`. Rather than linting only as casts that don't change constness, this lints only constness; suggesting to use `pointer::cast_const` or `pointer::cast_mut` instead.

changelog: new lint [`ptr_cast_constness`]
2023-05-23 21:40:50 +00:00
Yuri Astrakhan
68df61ebd9 remove todo 2023-05-22 20:06:58 -04:00
y21
8c82486ea9 [default_constructed_unit_structs]: do not lint type aliases 2023-05-22 16:13:23 +02:00
Yuri Astrakhan
e926148188 Fix unsafe blocks 2023-05-22 04:07:17 -04:00
Philipp Krones
b76b0aeb63 Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup 2023-05-20 15:39:26 +02:00
Philipp Krones
96b32b1cb8
Merge remote-tracking branch 'upstream/master' into rustup 2023-05-20 15:32:20 +02:00
Jason Newcomb
58132cb3b0 Improve SpanlessEq
* Don't consider expansions of different macros to be the same, even if they expand to the same tokens
* Don't consider `cfg!` expansions to be equal if they check different configs.
2023-05-18 16:42:13 -04:00
Jason Newcomb
5351170744 Slightly refactor constant evaluation and add detection for empty macro expansion and cfged statements. 2023-05-18 15:43:33 -04:00
Jason Newcomb
0b3c2ed811 Search for inactive cfg attributes and empty macro expansion through
the entire block
2023-05-18 15:43:23 -04:00
Centri3
4ff1cd365d add description and rename msrv tests 2023-05-16 11:20:00 -05:00
Centri3
a36d9a7820 move is_ty_alias to clippy_utils 2023-05-14 12:39:08 -05:00
bors
5889ecd14f Auto merge of #111255 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2023-05-05 21:50:14 +00:00
Philipp Krones
7e9abb311d Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup 2023-05-05 17:45:49 +02:00
Philipp Krones
88c7632659
Merge remote-tracking branch 'upstream/master' into rustup 2023-05-05 17:29:35 +02:00
Dylan DPC
a48c7350ab Rollup merge of #108801 - fee1-dead-contrib:c-str, r=compiler-errors
Implement RFC 3348, `c"foo"` literals

RFC: https://github.com/rust-lang/rfcs/pull/3348
Tracking issue: #105723
2023-05-05 18:40:33 +05:30
Samuel Moelius
7e24ff33e4
Update macros.rs 2023-05-02 19:02:06 -04:00
Nicholas Nethercote
431cce1540 Restrict From<S> for {D,Subd}iagnosticMessage.
Currently a `{D,Subd}iagnosticMessage` can be created from any type that
impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static,
str>`, which are reasonable. It also includes `&String`, which is pretty
weird, and results in many places making unnecessary allocations for
patterns like this:
```
self.fatal(&format!(...))
```
This creates a string with `format!`, takes a reference, passes the
reference to `fatal`, which does an `into()`, which clones the
reference, doing a second allocation. Two allocations for a single
string, bleh.

This commit changes the `From` impls so that you can only create a
`{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static,
str>`. This requires changing all the places that currently create one
from a `&String`. Most of these are of the `&format!(...)` form
described above; each one removes an unnecessary static `&`, plus an
allocation when executed. There are also a few places where the existing
use of `&String` was more reasonable; these now just use `clone()` at
the call site.

As well as making the code nicer and more efficient, this is a step
towards possibly using `Cow<'static, str>` in
`{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing
the `From<&'a str>` impls to `From<&'static str>`, which is doable, but
I'm not yet sure if it's worthwhile.
2023-05-03 08:44:39 +10:00
Deadbeef
37127b8d70 initial step towards implementing C string literals 2023-05-02 10:30:09 +00:00
yukang
d4baabe902 clean up Colon from clippy 2023-05-01 16:15:17 +08:00
y21
1d08325293 move lint to loops, emit proper suggestion, more tests 2023-04-29 18:59:07 +02:00
y21
bb58083ce5 new lint: while_pop_unwrap 2023-04-29 18:59:06 +02:00
Michael Goulet
83504fa763 Make clippy happy 2023-04-27 17:18:12 +00:00
Boxy
0339d4e982 rename needs_infer to has_infer 2023-04-27 08:35:19 +01:00
Albert Larsan
9a61550e78 Make {Arc,Rc,Weak}::ptr_eq ignore pointer metadata 2023-04-26 15:27:32 +00:00
Matthias Krüger
331c5471d7 Rollup merge of #110556 - kylematsuda:earlybinder-explicit-item-bounds, r=compiler-errors
Switch to `EarlyBinder` for `explicit_item_bounds`

Part of the work to finish https://github.com/rust-lang/rust/issues/105779.

This PR adds `EarlyBinder` to the return type of the `explicit_item_bounds` query and removes `bound_explicit_item_bounds`.

r? `@compiler-errors` (hope it's okay to request you, since you reviewed #110299 and #110498 😃)
2023-04-25 21:06:32 +02:00
bors
96f8471d81 Auto merge of #10649 - jsoref:spelling, r=Jarcho
Spelling

This PR corrects misspellings identified by the [check-spelling action](https://github.com/marketplace/actions/check-spelling).

The misspellings have been reported at https://github.com/jsoref/rust-clippy/actions/runs/4710771873#summary-12776860721

The action reports that the changes in this PR would make it happy: https://github.com/jsoref/rust-clippy/actions/runs/4710771874#summary-12776860722

changelog: none
2023-04-23 22:30:06 +00:00
Josh Soref
6f7801f810 Rewrite search_same description 2023-04-23 10:53:06 -04:00
Josh Soref
d2061faf9e Spelling
* applying
* binding
* complex
* constituent
* demonstrate
* desugaring
* exact
* expression
* for
* functionalities
* github
* implementation
* infers
* multiple conflicting traits
* mutable
* necessarily
* nightly
* nonexistent
* optional
* parameter
* reassignments
* resources
* substitution
* suggestion
* that
* that array is
* using the

Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-04-23 10:52:27 -04:00
bors
496c11005c Auto merge of #10679 - y21:better-const-ctx-check, r=Jarcho
use `is_inside_const_context` for `in_constant` util fn

Fixes #10452.

This PR improves the `in_constant` util function to detect more cases of const contexts. Previously this function would not detect cases like expressions in array length position or expression in an inline const block `const { .. }`.

changelog: [`bool_to_int_with_if`]: recognize array length operand as being in a const context and don't suggest `usize::from` there
2023-04-23 13:33:51 +00:00
Philipp Krones
0add5bb0f1
Bump Clippy version -> 0.1.71 2023-04-23 03:39:19 -07:00
Philipp Krones
583c97e9bb
Merge remote-tracking branch 'upstream/master' into rustup 2023-04-23 03:39:03 -07:00
bors
86d8f1268a Auto merge of #106934 - DrMeepster:offset_of, r=WaffleLapkin
Add offset_of! macro (RFC 3308)

Implements https://github.com/rust-lang/rfcs/pull/3308 (tracking issue #106655) by adding the built in macro `core::mem::offset_of`. Two of the future possibilities are also implemented:

* Nested field accesses (without array indexing)
* DST support (for `Sized` fields)

I wrote this a few months ago, before the RFC merged. Now that it's merged, I decided to rebase and finish it.

cc `@thomcc` (RFC author)
2023-04-22 00:10:44 +00:00
DrMeepster
68c4776b46 offset_of 2023-04-21 02:14:02 -07:00
y21
654d12ff89 use is_inside_const_context query for in_constant 2023-04-20 22:43:59 +02:00
Kyle Matsuda
55d8146334 add subst_identity_iter and subst_identity_iter_copied methods on EarlyBinder; use this to simplify some EarlyBinder noise around explicit_item_bounds calls 2023-04-20 12:36:50 -06:00
Kyle Matsuda
097309c10f add EarlyBinder to output of explicit_item_bounds; replace bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query 2023-04-20 12:36:50 -06:00
Kyle Matsuda
afa28e6304 change usages of explicit_item_bounds to bound_explicit_item_bounds 2023-04-20 12:36:50 -06:00
Camille GILLOT
8ead58c67b Remove WithOptconstParam. 2023-04-20 17:48:32 +00:00
Maybe Waffle
2ebfbc5753 Remove very useless as_substs usage from clippy 2023-04-18 17:39:08 +00:00
Philipp Krones
6b95029f17 Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyup 2023-04-11 15:31:08 +02:00
bors
d048c1130f Auto merge of #110031 - compiler-errors:generic-elaboration, r=b-naber
Make elaboration generic over input

Combines all the `elaborate_*` family of functions into just one, which is an iterator over the same type that you pass in (e.g. elaborating `Predicate` gives `Predicate`s, elaborating `Obligation`s gives `Obligation`s, etc.)
2023-04-09 00:18:10 +00:00
Michael Goulet
0963a66ab3 Make elaborator generic 2023-04-06 23:30:22 +00:00
Philipp Krones
04c387efe7
Merge remote-tracking branch 'upstream/master' into rustup 2023-04-06 12:32:32 +02:00
Gary Guo
293c1a1a6a Fix tools 2023-04-06 09:34:16 +01:00
Gary Guo
f5ac844296 Refactor unwind from Option to a new enum 2023-04-06 09:34:16 +01:00
Oli Scherer
e9c7fb10b9 Rename ast::Static to ast::StaticItem to match ast::ConstItem 2023-04-04 15:34:40 +00:00
Oli Scherer
e610ddfa5e box a bunch of large types 2023-04-04 13:58:50 +00:00
Oli Scherer
ff7636db6a Split out ast::ItemKind::Const into its own struct 2023-04-04 09:44:50 +00:00
Oli Scherer
929696d754 rust-analyzer guided tuple field to named field 2023-04-04 09:44:50 +00:00
Oli Scherer
a6beddcc5a rust-analyzer guided enum variant structification 2023-04-04 09:44:45 +00:00
bors
6a6a262f7b Auto merge of #109010 - compiler-errors:rtn, r=eholk
Initial support for return type notation (RTN)

See: https://smallcultfollowing.com/babysteps/blog/2023/02/13/return-type-notation-send-bounds-part-2/

1. Only supports `T: Trait<method(): Send>` style bounds, not `<T as Trait>::method(): Send`. Checking validity and injecting an implicit binder for all of the late-bound method generics is harder to do for the latter.
    * I'd add this in a follow-up.
3. ~Doesn't support RTN in general type position, i.e. no `let x: <T as Trait>::method() = ...`~
    * I don't think we actually want this.
5. Doesn't add syntax for "eliding" the function args -- i.e. for now, we write `method(): Send` instead of `method(..): Send`.
    * May be a hazard if we try to add it in the future. I'll probably add it in a follow-up later, with a structured suggestion to change `method()` to `method(..)` once we add it.
7. ~I'm not in love with the feature gate name 😺~
    * I renamed it to `return_type_notation` ✔️

Follow-up PRs will probably add support for `where T::method(): Send` bounds. I'm not sure if we ever want to support return-type-notation in arbitrary type positions. I may also make the bounds require `..` in the args list later.

r? `@ghost`
2023-03-31 18:04:12 +00:00
Samuel "Sam" Tardieu
6601d85c22 Flag bufreader.lines().filter_map(Result::ok) as suspicious 2023-03-31 14:43:30 +02:00
Trevor Gross
4cf5bdc60c Stabilize a portion of 'once_cell'
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-29 18:04:44 -04:00
bors
c5011e9d42 Auto merge of #10553 - Nilstrieb:better-uninit, r=Alexendoo
In uninit checking, add fallback for polymorphic types

After #10520, we always assumed that polymorphic types do not allow to be left uninitialized. But we can do better, by peeking into polymorphic types and adding a few special cases for going through tuples, arrays (because the length may be polymorphic) and blanket allowing all unions (like MaybeUninit).

fixes #10551

changelog: [uninit_vec]: fix false positive for polymorphic types
changelog: [uninit_assumed_init]: fix false positive for polymorphic types
2023-03-29 18:26:35 +00:00
Nilstrieb
51b4d2a1e8 In uninit checking, add fallback for polymorphic types 2023-03-29 19:46:44 +02:00
Alex Macleod
6589d79492 Replace remaining usage of FormatArgsExpn 2023-03-28 21:28:57 +00:00
Alex Macleod
3259b48568 Migrate format_args.rs to rustc_ast::FormatArgs
No longer lints empty precisions `{:.}` as the spans aren't available
2023-03-28 12:22:22 +00:00
Michael Goulet
fc6262fa0c Add (..) syntax for RTN 2023-03-28 01:14:28 +00:00
Guillaume Gomez
538e8bdcc8 Rollup merge of #109354 - Swatinem:rm-closureid, r=compiler-errors
Remove the `NodeId` of `ast::ExprKind::Async`

This is a followup to https://github.com/rust-lang/rust/pull/104833#pullrequestreview-1314537416.

In my original attempt, I was using `LoweringContext::expr`, which was not correct as it creates a fresh `DefId`.
It now uses the correct `DefId` for the wrapping `Expr`, and also makes forwarding `#[track_caller]` attributes more explicit.
2023-03-27 18:56:19 +02:00
Michael Goulet
db4e4afce8 Don't elaborate non-obligations into obligations 2023-03-26 20:33:54 +00:00
bluthej
2493be2196 Improve is_range_full implementation
Make this function work with signed integer types by extracting the
underlying type and finding the min and max values.

Change the signature to make it more consistent:
- The range is now given as an `Expr` in order to extract the type
- The container's path is now passed, and only as an `Option` so that
  the function can be called in the general case without a container
2023-03-26 19:12:36 +02:00
bluthej
1d168b31c3
Merge branch 'rust-lang:master' into clear-with-drain 2023-03-26 19:11:38 +02:00
Philipp Krones
8df896c076 Merge commit 'd5e2a7aca55ed49fc943b7a07a8eba05ab5a0079' into clippyup 2023-03-24 14:26:19 +01:00
Philipp Krones
62cba5d971
Merge remote-tracking branch 'upstream/master' into rustup 2023-03-24 13:36:09 +01:00
bors
58eb9964cc Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obk
Add `CastKind::Transmute` to MIR

~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~

Includes lowering `transmute` calls to it, so it's used.

Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
2023-03-23 18:43:04 +00:00
bors
f34590478b Auto merge of #109517 - matthiaskrgr:rollup-m3orqzd, r=matthiaskrgr
Rollup of 7 pull requests

Successful merges:

 - #108541 (Suppress `opaque_hidden_inferred_bound` for nested RPITs)
 - #109137 (resolve: Querify most cstore access methods (subset 2))
 - #109380 (add `known-bug` test for unsoundness issue)
 - #109462 (Make alias-eq have a relation direction (and rename it to alias-relate))
 - #109475 (Simpler checked shifts in MIR building)
 - #109504 (Stabilize `arc_into_inner` and `rc_into_inner`.)
 - #109506 (make param bound vars visibly bound vars with -Zverbose)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-03-23 12:35:05 +00:00
Michael Goulet
b506eb5338 Rename AliasEq -> AliasRelate 2023-03-23 05:56:40 +00:00
Scott McMurray
8bdd54e8c6 Add CastKind::Transmute to MIR
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic.

Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
2023-03-22 15:15:41 -07:00
bluthej
85d428101d Pull is_full_range method from iter_with_drain
Rename method to `is_range_full` because the type is actually
`RangeFull`.

Method moved to `clippy_utils` for reuse in `clear_with_drain`.
2023-03-22 11:01:51 +01:00
Vadim Petrochenkov
cae7b87711 rustc: Remove unused Session argument from some attribute functions 2023-03-22 13:55:55 +04:00
Nilstrieb
84b6049eb9 Use uninit checking from rustc
rustc has proper heuristics for actually checking whether a type allows
being left uninitialized (by asking CTFE). We can now use this for our
helper instead of rolling our own bad version with false positives.
2023-03-21 18:28:06 +01:00
Arpad Borsos
1e17a443b3 Remove the NodeId of ast::ExprKind::Async 2023-03-19 19:01:31 +01:00
Matthias Krüger
60fe49c54c Rollup merge of #108958 - clubby789:unbox-the-hir, r=compiler-errors
Remove box expressions from HIR

After #108516, `#[rustc_box]` is used at HIR->THIR lowering and this is no longer emitted, so it can be removed.

This is based on top of #108471 to help with conflicts, so 43490488ccacd1a822e9c621f5ed6fca99959a0b is the only relevant commit (sorry for all the duplicated pings!)

````@rustbot```` label +S-blocked
2023-03-17 08:42:37 +01:00
Samuel "Sam" Tardieu
ffabdab8cf New lint to detect &std::path::MAIN_SEPARATOR.to_string() 2023-03-16 21:42:04 +01:00
Mara Bos
d1b28f3a5f Fix clippy. 2023-03-16 12:08:07 +01:00
clubby789
f2eddc5924 Remove box expressions from HIR 2023-03-14 17:18:26 +00:00
bors
491f63214a Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errors
Remove `identity_future` indirection

This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm.

Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation.

Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-14 10:12:58 +00:00
J-ZhengLi
f4ccb06d69 extract is_interior_mutable_type from [mut_key] to clippy_utils::ty;
fix configuration of [`ifs_same_cond`];

add some style improvement for [`ifs_same_cond`];
2023-03-13 20:17:30 +08:00
clubby789
15f24234c8 Remove box_syntax from AST and use in tools 2023-03-12 13:19:46 +00:00
bors
f19db28361 Auto merge of #10434 - Jarcho:snip_context, r=dswij
Remove `snippet_with_macro_callsite`

`snippet_with_context` is used instead to support nested macro calls.

changelog: None
2023-03-11 12:45:20 +00:00
bors
15d7278df8 Auto merge of #108974 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`

cc `@m-ou-se` This sync also includes https://github.com/rust-lang/rust-clippy/pull/10275
2023-03-10 20:08:26 +00:00
Philipp Krones
cf8a67d9ad Merge commit '3c06e0b1ce003912f8fe0536d3a7fe22558e38cf' into clippyup 2023-03-10 10:53:50 +01:00
bors
3c06e0b1ce Auto merge of #10275 - Alexendoo:format-args-ast, r=flip1995
Migrate `write.rs` to `rustc_ast::FormatArgs`

changelog: none

Part 1 of #10233

The additions to `clippy_utils` are the main novelty of this PR, there's no removals yet since other parts still rely on `FormatArgsExpn`

The changes to `write.rs` itself are relatively straightforward this time around, as there's no lints in it that rely on type checking format params

r? `@flip1995`
2023-03-10 09:38:18 +00:00
Philipp Krones
ec9029d12c
Bump Clippy version -> 0.1.70 2023-03-10 10:22:27 +01:00
Philipp Krones
baa997caf6
Merge remote-tracking branch 'upstream/master' into rustup 2023-03-10 10:22:18 +01:00
Camille GILLOT
27910cbcbd Introduce a no-op PlaceMention statement for let _ =. 2023-03-09 17:45:13 +00:00
Matthias Krüger
d9fdac52b2 Rollup merge of #108856 - Zeegomo:remove-drop-and-rep, r=tmiasko
Remove DropAndReplace terminator

#107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-03-08 21:26:51 +01:00
Arpad Borsos
90afb207eb Remove identity_future indirection
This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm.

Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]` annotation.
2023-03-08 15:37:14 +01:00
unexge
682d52cf7c Update assertion macro parsing logic for Rust 1.52 changes
Co-authored-by: Weihang Lo <me@weihanglo.tw>
2023-03-08 08:51:52 +00:00
unexge
b4b2b1235a Revert "Dogfood missing_assert_message on Clippy"
This reverts commit ec653570ad50d11ecc3b5649dd28e29ed96199d3.
2023-03-08 08:51:50 +00:00
Burak Varlı
8f3ac65227 Dogfood missing_assert_message on Clippy
Co-authored-by: Weihang Lo <me@weihanglo.tw>
2023-03-08 08:51:24 +00:00
Giacomo Pasini
5619fd5940 Remove DropAndReplace terminator
PR 107844 made DropAndReplace unused, let's remove it completely
from the codebase.
2023-03-07 14:25:22 +01:00
Alex Macleod
dc23e42fb6 Add format_args_collector internal lint 2023-03-06 21:38:32 +00:00
Alex Macleod
a2906a1598 Migrate write.rs to rustc_ast::FormatArgs 2023-03-06 21:38:32 +00:00
Vadim Petrochenkov
79359cbbcf rustc_middle: Remove trait DefIdTree
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-03-02 23:46:44 +04:00
Matthias Krüger
5cf9c3422c Rollup merge of #108516 - clubby789:rustc-box-restrict, r=compiler-errors
Restrict `#[rustc_box]` to `Box::new` calls

Currently, `#[rustc_box]` can be applied to any call expression with a single argument. This PR only allows it to be applied to calls to `Box::new`
2023-03-02 07:24:00 +01:00
Jason Newcomb
1a81a3e5cf Remove snippet_with_macro_callsite 2023-03-02 00:51:04 -05:00
clubby789
702a83b1a1 Restrict #[rustc_box] to Box::new calls 2023-03-02 02:42:19 +00:00
Andreas Deininger
03a3f74365 Fixing typos 2023-02-27 21:45:26 +01:00
bors
0966f59c78 Auto merge of #108474 - Jarcho:clippyup, r=Manishearth
Update Clippy

Seems like `@flip1995` so this is a couple days late.

r? `@Manishearth`
2023-02-26 18:45:47 +00:00
Jason Newcomb
0413fb35ba Merge commit '149392b0baa4730c68f3c3eadf5c6ed7b16b85a4' into clippyup 2023-02-25 19:28:50 -05: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
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
bc184e9c7d Merge branch 'master' into rustup 2023-02-25 17:43:19 -05:00
Michael Goulet
9fd0a415bb Make clippy happy 2023-02-25 19:46:36 +00:00
Nicholas Nethercote
e5df17aae5 Use List::empty() instead of mk_substs(&[]). 2023-02-24 07:33:02 +11:00
Nicholas Nethercote
783b55ec82 Rename many interner functions.
(This is a large commit. The changes to
`compiler/rustc_middle/src/ty/context.rs` are the most important ones.)

The current naming scheme is a mess, with a mix of `_intern_`, `intern_`
and `mk_` prefixes, with little consistency. In particular, in many
cases it's easy to use an iterator interner when a (preferable) slice
interner is available.

The guiding principles of the new naming system:
- No `_intern_` prefixes.
- The `intern_` prefix is for internal operations.
- The `mk_` prefix is for external operations.
- For cases where there is a slice interner and an iterator interner,
  the former is `mk_foo` and the latter is `mk_foo_from_iter`.

Also, `slice_interners!` and `direct_interners!` can now be `pub` or
non-`pub`, which helps enforce the internal/external operations
division.

It's not perfect, but I think it's a clear improvement.

The following lists show everything that was renamed.

slice_interners
- const_list
  - mk_const_list -> mk_const_list_from_iter
  - intern_const_list -> mk_const_list
- substs
  - mk_substs -> mk_substs_from_iter
  - intern_substs -> mk_substs
  - check_substs -> check_and_mk_substs (this is a weird one)
- canonical_var_infos
  - intern_canonical_var_infos -> mk_canonical_var_infos
- poly_existential_predicates
  - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter
  - intern_poly_existential_predicates -> mk_poly_existential_predicates
  - _intern_poly_existential_predicates -> intern_poly_existential_predicates
- predicates
  - mk_predicates -> mk_predicates_from_iter
  - intern_predicates -> mk_predicates
  - _intern_predicates -> intern_predicates
- projs
  - intern_projs -> mk_projs
- place_elems
  - mk_place_elems -> mk_place_elems_from_iter
  - intern_place_elems -> mk_place_elems
- bound_variable_kinds
  - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter
  - intern_bound_variable_kinds -> mk_bound_variable_kinds

direct_interners
- region
  - intern_region (unchanged)
- const
  - mk_const_internal -> intern_const
- const_allocation
  - intern_const_alloc -> mk_const_alloc
- layout
  - intern_layout -> mk_layout
- adt_def
  - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid)
  - alloc_adt_def(!) -> mk_adt_def
- external_constraints
  - intern_external_constraints -> mk_external_constraints

Other
- type_list
  - mk_type_list -> mk_type_list_from_iter
  - intern_type_list -> mk_type_list
- tup
  - mk_tup -> mk_tup_from_iter
  - intern_tup -> mk_tup
2023-02-24 07:32:24 +11:00
Alan Egerton
430c4ab7ff Remove type-traversal trait aliases 2023-02-22 17:04:58 +00:00
Jason Newcomb
0aad34e43f Normalize projections types when checking explicit_auto_deref 2023-02-21 15:59:06 -05: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
Boxy
8a66a6816b Add Clause::ConstArgHasType variant 2023-02-17 09:30:33 +00:00
Kyle Matsuda
98c4a49db8 remove bound_type_of query; make type_of return EarlyBinder; change type_of in metadata 2023-02-16 17:05:56 -07:00
Kyle Matsuda
f0565c939e change usages of type_of to bound_type_of 2023-02-16 17:01:52 -07:00
Jirka Vebr
0b1ae20365
Fix dogfood tests by adding type annotations 2023-02-16 13:29:38 +01:00
Matthias Krüger
dd6534ae87 Rollup merge of #108047 - oli-obk:machine->🞋, r=RalfJung
Use `target` instead of `machine` for mir interpreter integer handling.

The naming of `machine` only makes sense from a mir interpreter internals perspective, but outside users talk about the `target` platform. As per https://github.com/rust-lang/rust/pull/108029#issuecomment-1429791015

r? `@RalfJung`
2023-02-15 21:30:57 +01:00
bors
30f38d69ab Auto merge of #108006 - cjgillot:def-impl, r=oli-obk
Avoid accessing HIR when it can be avoided

Experiment to see if it helps some incremental cases.

Will be rebased once https://github.com/rust-lang/rust/pull/107942 gets merged.

r? `@ghost`
2023-02-15 16:14:10 +00:00
Oli Scherer
cecc45cedc Use target instead of machine for mir interpreter integer handling.
The naming of `machine` only makes sense from a mir interpreter internals perspective, but outside users talk about the `target` platform
2023-02-15 08:56:18 +00:00
bors
5a8b288712 Auto merge of #108056 - matthiaskrgr:rollup-oa6bxvh, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #107573 (Update the minimum external LLVM to 14)
 - #107626 (Fix `x fix` on the standard library itself)
 - #107673 (update ICU4X to 1.1.0)
 - #107733 (Store metrics from `metrics.json` to CI PGO timer)
 - #108007 (Use `is_str` instead of string kind comparison)
 - #108033 (add an unstable `#[rustc_coinductive]` attribute)
 - #108039 (Refactor refcounted structural_impls via functors)
 - #108040 (Use derive attributes for uninteresting traversals)
 - #108044 (interpret: rename Pointer::from_addr → from_addr_invalid)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-02-14 21:07:04 +00:00
Camille GILLOT
e41c37316d Add of_trait to DefKind::Impl. 2023-02-14 19:55:44 +00:00
Matthias Krüger
b8c36429e4 Rollup merge of #108007 - compiler-errors:str-less-kind, r=Nilstrieb
Use `is_str` instead of string kind comparison

Split out from #107939
2023-02-14 18:24:42 +01:00
Oli Scherer
e3a739a115 s/eval_usize/eval_target_usize/ for clarity 2023-02-14 08:51:19 +00:00
Michael Goulet
4b8f112d09 Use is_str instead of string kind comparison 2023-02-13 19:06:22 +00:00
Alan Egerton
340d9e818a Make visiting traits generic over the Interner 2023-02-13 10:24:49 +00:00
Alan Egerton
e8e9c32af9 Alias folding/visiting traits instead of re-export 2023-02-13 10:24:46 +00:00
bors
863e96d626 Auto merge of #107507 - BoxyUwU:deferred_projection_equality, r=lcnr
Implement `deferred_projection_equality` for erica solver

Somewhat of a revival of #96912. When relating projections now emit an `AliasEq` obligation instead of attempting to determine equality of projections that may not be as normalized as possible (i.e. because of lazy norm, or just containing inference variables that prevent us from resolving an impl). Only do this when the new solver is enabled
2023-02-11 05:46:24 +00:00
Mara Bos
145e6a94d6 Add suspicious_command_arg_space lint. 2023-02-10 19:02:39 +01:00
Boxy
cd3bcbb8e5 add AliasEq to PredicateKind 2023-02-10 13:44:46 +00:00
Philipp Krones
e7fe1f9c14 Merge commit '0f7558148c22e53cd4608773b56cdfa50dcdeac3' into clippyup 2023-02-10 14:01:19 +01:00
Philipp Krones
7c61b4ed89
Merge remote-tracking branch 'upstream/master' into rustup 2023-02-10 11:33:45 +01:00
bors
17369f324c Auto merge of #106227 - bryangarza:ctfe-limit, r=oli-obk
Use stable metric for const eval limit instead of current terminator-based logic

This patch adds a `MirPass` that inserts a new MIR instruction `ConstEvalCounter` to any loops and function calls in the CFG. This instruction is used during Const Eval to count against the `const_eval_limit`, and emit the `StepLimitReached` error, replacing the current logic which uses Terminators only.

The new method of counting loops and function calls should be more stable across compiler versions (i.e., not cause crates that compiled successfully before, to no longer compile when changes to the MIR generation/optimization are made).

Also see: #103877
2023-01-29 04:11:27 +00:00
bors
79475f56ec Auto merge of #107206 - cjgillot:no-h2l-map, r=WaffleLapkin
Remove HirId -> LocalDefId map from HIR.

Having this map in HIR prevents the creating of new definitions after HIR has been built.
Thankfully, we do not need it.

Based on https://github.com/rust-lang/rust/pull/103902
2023-01-28 16:11:33 +00:00
Camille GILLOT
3e32533cc2 Remove HirId -> LocalDefId map from HIR. 2023-01-28 09:55:26 +00:00
Camille GILLOT
92c4f1e2d9 Take a LocalDefId in hir::Visitor::visit_fn. 2023-01-28 09:51:50 +00:00
Scott McMurray
e65a7ff0b3 Remove from librustdoc and clippy too 2023-01-27 20:44:19 -08:00
bors
997fe0d57e Auto merge of #107386 - flip1995:clippyup, r=Manishearth
Update Clippy

r? `@Manishearth`
2023-01-27 21:20:39 +00:00
Philipp Krones
5c7a65251a Merge commit '1480cea393d0cee195e59949eabdfbcf1230f7f9' into clippyup 2023-01-27 21:09:08 +01:00
Philipp Krones
6f9c70a201
Bump Clippy version -> 0.1.69 2023-01-27 20:27:00 +01:00
Philipp Krones
2bc2431fd1
Merge remote-tracking branch 'upstream/master' into rustup 2023-01-27 20:26:35 +01:00
bors
bcb90528c0 Auto merge of #107372 - JohnTitor:rollup-zkl2ges, r=JohnTitor
Rollup of 9 pull requests

Successful merges:

 - #106806 (Replace format flags u32 by enums and bools.)
 - #107194 (Remove dependency on slice_internals feature in rustc_ast)
 - #107234 (Revisit fix_is_ci_llvm_available logic)
 - #107316 (Update snap from `1.0.1` to `1.1.0`)
 - #107321 (solver comments + remove `TyCtxt::evaluate_goal`)
 - #107332 (Fix wording from `rustbuild` to `bootstrap`)
 - #107347 (reduce rightward-drift)
 - #107352 (compiler: Fix E0587 explanation)
 - #107357 (Fix infinite loop in rustdoc get_all_import_attributes function)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-27 17:49:56 +00:00
Mara Bos
b64a20930c Update clippy for restructured format flags fields. 2023-01-27 08:53:41 +01:00