Commit graph

9573 commits

Author SHA1 Message Date
Philipp Krones
e7fe1f9c14 Merge commit '0f7558148c22e53cd4608773b56cdfa50dcdeac3' into clippyup 2023-02-10 14:01:19 +01:00
Esteban Küber
821199c885 Modify primary span label for E0308
The previous output was unintuitive to users.
2023-01-30 20:12:19 +00: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
bors
75c8179c25 Auto merge of #107408 - matthiaskrgr:rollup-b5vz2ow, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #104012 (Improve unexpected close and mismatch delimiter hint in TokenTreesReader)
 - #104252 (Stabilize the const_socketaddr feature)
 - #105524 (Replace libc::{type} with crate::ffi::{type})
 - #107096 (Detect references to non-existant messages in Fluent resources)
 - #107355 (Add regression test for #60755)
 - #107384 (Remove `BOOL_TY_FOR_UNIT_TESTING`)
 - #107385 (Use `FallibleTypeFolder` for `ConstInferUnifier` not `TypeRelation`)
 - #107391 (rustdoc: remove inline javascript from copy-path button)
 - #107398 (Remove `ControlFlow::{BREAK, CONTINUE}`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-28 13:12:59 +00:00
Matthias Krüger
a493717718 Rollup merge of #107398 - scottmcm:its-their-funeral, r=dtolnay
Remove `ControlFlow::{BREAK, CONTINUE}`

Libs-API decided to remove these in #102697.

Follow-up to #107023, which removed them from `compiler/`, but a couple new ones showed up since that was merged.

r? libs
2023-01-28 11:11:09 +01:00
bors
3a68217f49 Auto merge of #106916 - lukas-code:overlapping-substs, r=estebank
Remove overlapping parts of multipart suggestions

This PR adds a debug assertion that the parts of a single substitution cannot overlap, fixes a overlapping substitution from the testsuite, and fixes https://github.com/rust-lang/rust/issues/106870.

Note that a single suggestion can still have multiple overlapping substitutions / possible edits, we just don't suggest overlapping replacements in a single edit anymore.

I've also included a fix for an unrelated bug where rustfix for `explicit_outlives_requirements` would produce multiple trailing commas for a where clause.
2023-01-28 10:00:56 +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
06e785548b Auto merge of #101692 - cjgillot:generator-lazy-witness, r=oli-obk
Compute generator saved locals on MIR

Generators are currently type-checked by introducing a `witness` type variable, which is unified with a `GeneratorWitness(captured types)` whose purpose is to ensure that the auto traits correctly migrate from the captured types to the `witness` type.  This requires computing the captured types on HIR during type-checking, only to re-do it on MIR later.

This PR proposes to drop the HIR-based computation, and only keep the MIR one.  This is done in 3 steps.
1. During type-checking, the `witness` type variable is never unified.  This allows to stall all the obligations that depend on it until the end of type-checking.  Then, the stalled obligations are marked as successful, and saved into the typeck results for later verification.
2. At type-checking writeback, `witness` is replaced by `GeneratorWitnessMIR(def_id, substs)`.  From this point on, all trait selection involving `GeneratorWitnessMIR` will fetch the MIR-computed locals, similar to what opaque types do.  There is no lifetime to be preserved here: we consider all the lifetimes appearing in this witness type to be higher-ranked.
3. After borrowck, the stashed obligations are verified against the actually computed types, in the `check_generator_obligations` query.  If any obligation was wrongly marked as fulfilled in step 1, it should be reported here.

There are still many issues:
- ~I am not too happy having to filter out some locals from the checked bounds, I think this is MIR building that introduces raw pointers polluting the analysis;~ solved by a check specific to static variables.
- the diagnostics for captured types don't show where they are used/dropped;
- I do not attempt to support chalk.

cc `@eholk` `@jyn514` for the drop-tracking work
r? `@oli-obk` as you warned me of potential unsoundness
2023-01-28 01:05:29 +00: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
Camille GILLOT
ba6d3e7e9d Introduce GeneratorWitnessMIR. 2023-01-27 18:58:44 +00: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
Kyle Matsuda
afb586fa1f change fn_sig query to use EarlyBinder; remove bound_fn_sig query; add EarlyBinder to fn_sig in metadata 2023-01-26 20:28:25 -07:00
Kyle Matsuda
38899d0c29 replace usages of fn_sig query with bound_fn_sig 2023-01-26 20:15:36 -07:00
bors
a64940f948 Auto merge of #106745 - m-ou-se:format-args-ast, r=oli-obk
Move format_args!() into AST (and expand it during AST lowering)

Implements https://github.com/rust-lang/compiler-team/issues/541

This moves FormatArgs from rustc_builtin_macros to rustc_ast_lowering. For now, the end result is the same. But this allows for future changes to do smarter things with format_args!(). It also allows Clippy to directly access the ast::FormatArgs, making things a lot easier.

This change turns the format args types into lang items. The builtin macro used to refer to them by their path. After this change, the path is no longer relevant, making it easier to make changes in `core`.

This updates clippy to use the new language items, but this doesn't yet make clippy use the ast::FormatArgs structure that's now available. That should be done after this is merged.
2023-01-26 12:44:47 +00:00
Bryan Garza
520814b713 Update Clippy for ConstEvalCounter 2023-01-23 23:56:22 +00:00
Vincenzo Palazzo
2d8ede2335 fix: use LocalDefId instead of HirId in trait res
use LocalDefId instead of HirId in trait resolution to simplify
the obligation clause resolution

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
2023-01-23 11:42:18 +00:00
bors
298a78277e Auto merge of #106977 - michaelwoerister:unord_id_collections, r=oli-obk
Use UnordMap and UnordSet for id collections (DefIdMap, LocalDefIdMap, etc)

This PR changes the `rustc_data_structures::define_id_collections!` macro to use `UnordMap` and `UnordSet` instead of `FxHashMap` and `FxHashSet`. This should account for a large portion of hash-maps being used in places where they can cause trouble.

The changes required are moderate but non-zero:
- In some places the collections are extracted into sorted vecs.
- There are a few instances where for-loops have been changed to extends.

~~Let's see what the performance impact is. With a bit more refactoring, we might be able to get rid of some of the additional sorting -- but the change set is already big enough. Unless there's a performance impact, I'd like to do further changes in subsequent PRs.~~

Performance does not seem to be negatively affected ([perf-run here](https://github.com/rust-lang/rust/pull/106977#issuecomment-1396776699)).

Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).

r? `@ghost`
2023-01-21 14:18:17 +00:00
bors
ce460dcd14 Auto merge of #105102 - compiler-errors:copy-impl-considering-regions, r=lcnr
Check ADT fields for copy implementations considering regions

Fixes #88901
r? `@ghost`
2023-01-20 21:29:52 +00:00
Lukas Markeffsky
10c868686d fix overlapping spans for clippy::uninlined_format_args 2023-01-20 20:16:37 +01:00
Alex Macleod
11611b0440 Move unchecked_duration_subtraction to pedantic 2023-01-19 11:18:47 +01:00
Michael Woerister
c1b358945a Allow for more efficient sorting when exporting Unord collections. 2023-01-19 10:40:54 +01:00
Michael Woerister
465ed5bd46 Use UnordMap instead of FxHashMap in define_id_collections!(). 2023-01-19 10:40:47 +01:00
Michael Woerister
31a053059e Use UnordSet instead of FxHashSet in define_id_collections!(). 2023-01-19 10:19:07 +01:00
Kyle Matsuda
2bfba8685d fix missing subst in clippy utils 2023-01-17 08:55:28 -07:00
Kyle Matsuda
a084d7908c change item_bounds query to return EarlyBinder; remove bound_item_bounds query 2023-01-17 08:55:28 -07:00
Kyle Matsuda
5dac27503f change usages of item_bounds query to bound_item_bounds 2023-01-17 08:55:27 -07:00
Kyle Matsuda
b92d90211e change impl_trait_ref query to return EarlyBinder; remove bound_impl_trait_ref query; add EarlyBinder to impl_trait_ref in metadata 2023-01-14 00:29:56 -07:00
Kyle Matsuda
a160ce3a48 change usages of impl_trait_ref to bound_impl_trait_ref 2023-01-14 00:23:32 -07:00
Michael Goulet
93d0f47064 Check ADT fields for copy implementations considering regions 2023-01-13 23:06:29 +00:00
bors
efb631a09c Auto merge of #106776 - oli-obk:om_nom_nom_nom_nom, r=cjgillot
Feed a bunch of queries instead of tracking fields on TyCtxt

r? `@cjgillot`

pulled out of https://github.com/rust-lang/rust/pull/105462
2023-01-13 13:57:21 +00:00
bors
ac95db69fd Auto merge of #106801 - JohnTitor:rollup-xqkraw0, r=JohnTitor
Rollup of 6 pull requests

Successful merges:

 - #106608 (Render missing generics suggestion verbosely)
 - #106716 ([RFC 2397] Deny incorrect locations)
 - #106754 (Rename `Ty::is_ty_infer` -> `Ty::is_ty_or_numeric_infer`)
 - #106782 (Ignore tests move in git blame)
 - #106785 (Make blame spans better for impl wfcheck)
 - #106791 (Fix ICE formatting)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-13 10:56:53 +00:00
Yuki Okushi
71b99c48ee Rollup merge of #106608 - compiler-errors:missing-generics-verbose, r=estebank
Render missing generics suggestion verbosely

It's a bit easier to read like this, especially ones that are appending new generics onto an existing list, like ": `, T`" which render somewhat poorly inline.

Also don't suggest `dyn` as a type parameter to add, even if technically that's valid in edition 2015.
2023-01-13 16:54:22 +09:00
bors
83dba6e8bb Auto merge of #106092 - asquared31415:start_lang_item_checks, r=davidtwco
Add checks for the signature of the `start` lang item

Closes #105963
2023-01-13 07:45:34 +00:00
Michael Goulet
2253646395 Don't suggest dyn as parameter to add 2023-01-12 22:04:30 +00:00
Philipp Krones
d21616737b Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup 2023-01-12 19:48:13 +01:00
Oli Scherer
0c48b5a223 Feed the features_query instead of grabbing it from the session lazily 2023-01-12 17:14:17 +00:00
Mara Bos
2bcd697e2d Update clippy for new format_args!() lang items. 2023-01-12 00:25:46 +01:00
Mara Bos
dd168838b9 Make clippy compile. 2023-01-12 00:25:46 +01:00
asquared31415
c319440311 add checks for the signature of the lang item 2023-01-11 14:35:08 -08:00
Albert Larsan
5f8686ec3b Change src/test to tests in source files, fix tidy and tests 2023-01-11 09:32:13 +00:00
Michael Goulet
70f6c478f6 get_parent and find_parent 2023-01-04 00:43:13 +00:00
Michael Goulet
bd1d8971cf rename find_parent_node to opt_parent_id 2023-01-04 00:43:13 +00:00
Michael Goulet
73d293fb6d rename get_parent_node to parent_id 2023-01-04 00:43:13 +00:00
bors
cd579d69ec Auto merge of #106266 - matthiaskrgr:rollup-cxrdbzy, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #104531 (Provide a better error and a suggestion for `Fn` traits with lifetime params)
 - #105899 (`./x doc library --open` opens `std`)
 - #106190 (Account for multiple multiline spans with empty padding)
 - #106202 (Trim more paths in obligation types)
 - #106234 (rustdoc: simplify settings, help, and copy button CSS by not reusing)
 - #106236 (docs/test: add docs and a UI test for `E0514` and `E0519`)
 - #106259 (Update Clippy)
 - #106260 (Fix index out of bounds issues in rustdoc)
 - #106263 (Formatter should not try to format non-Rust files)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-12-29 19:40:06 +00:00
Matthias Krüger
d8365f9864 Rollup merge of #106259 - flip1995:clippyup, r=matthiaskrgr
Update Clippy

r? `@Manishearth`

I think this was the very first sync with no conflicts whatsoever. I love this time of the year :D
2022-12-29 18:24:32 +01:00