Commit Graph

285 Commits

Author SHA1 Message Date
Jack Huey
319575ae8c Introduce EarlyBinder 2022-05-10 22:47:18 -04:00
bors
eead58e75b Auto merge of #96736 - oli-obk:tait_missing_wf_check, r=davidtwco
Check hidden types for well formedness at the definition site instead of only at the opaque type itself

work towards #90409 . We'll need to look into closure and generator bodies of closures and generators nested inside the hidden type in order to fix that. In hindsight this PR is not necessary for that, but it may be a bit easier with it and we'll get better diagnostics from it on its own.
2022-05-10 13:39:43 +00:00
Oli Scherer
f667e952f8 Check hidden types for well formedness at the definition site instead of only at the opaque type itself 2022-05-10 07:20:00 +00:00
bors
574830f573 Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errors
Begin fixing all the broken doctests in `compiler/`

Begins to fix #95994.
All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are.
There are also a few that I marked `ignore` that could maybe be made to work but seem less important.
Each `ignore` has a rough "reason" for ignoring after it parentheses, with

- `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax"
- `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy.
- `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR.
- `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup.

Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful.

I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-07 06:30:29 +00:00
Guillaume Gomez
c3ddd59f5b
Rollup merge of #96733 - SparrowLii:place_to_string, r=davidtwco
turn `append_place_to_string` from recursion into iteration

This PR fixes the FIXME in the impl of `append_place_to_string` which turns `append_place_to_string` from recursion into iteration, meanwhile simplifying the code relatively.
2022-05-06 20:05:40 +02:00
bors
9a251644fa Auto merge of #96268 - jackh726:remove-mutable_borrow_reservation_conflict-lint, r=nikomatsakis
Remove mutable_borrow_reservation_conflict lint and allow the code pattern

This was the only breaking issue with the NLL stabilization PR. Lang team decided to go ahead and allow this.

r? `@nikomatsakis`
Closes #59159
Closes #56254
2022-05-06 12:32:44 +00:00
SparrowLii
8ff01894a0 turn append_place_to_string from recursion into iteration 2022-05-06 12:11:42 +08:00
Josh Triplett
0fc5c524f5 Stabilize bool::then_some 2022-05-04 13:22:08 +02:00
Elliot Roberts
7907385999 fix most compiler/ doctests 2022-05-02 17:40:30 -07:00
Vadim Petrochenkov
5b5964f569 rustc: Panic by default in DefIdTree::parent
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root.
So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root.

Same applies to `local_parent`/`opt_local_parent`.
2022-05-02 01:56:50 +03:00
bors
a707f40107 Auto merge of #95819 - oli-obk:mir_can't_hold_all_these_lifetimes, r=estebank
Enforce Copy bounds for repeat elements while considering lifetimes

fixes https://github.com/rust-lang/rust/issues/95477

this is a breaking change in order to fix a soundness bug.

Before this PR we only checked whether the repeat element type had an `impl Copy`, but not whether that impl also had the appropriate lifetimes. E.g. if the impl was for `YourType<'static>` and not a general `'a`, then copying any type other than a `'static` one should have been rejected, but wasn't.

r? `@lcnr`
2022-04-29 20:00:47 +00:00
David Wood
73fa217bc1 errors: span_suggestion takes impl ToString
Change `span_suggestion` (and variants) to take `impl ToString` rather
than `String` for the suggested code, as this simplifies the
requirements on the diagnostic derive.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-29 02:05:20 +01:00
Oli Scherer
4e6e68e27a Check that repeat expression elements are Copy (ignoring lifetimes) in typeck and that they are Copy (with proper lifetime checks) in borrowck 2022-04-28 09:19:42 +00:00
marmeladema
2c94218238 Recover suggestions to introduce named lifetime under NLL 2022-04-27 22:36:40 +02:00
Dylan DPC
dc1f98c655
Rollup merge of #96385 - marmeladema:nll-fix-trait-lifetime-bound-suggestions, r=jackh726
Recover most `impl Trait` and `dyn Trait` lifetime bound suggestions under NLL

This is done by replacing the duplicated (and very partial) implementation from borrowck with one inspsired from `NiceRegionError::try_report_static_impl_trait` and by re-using `suggest_new_region_bound`.

Fixes #96277

r? ```@jackh726```
2022-04-27 02:47:11 +02:00
SparrowLii
74853eedfe simplify describe_field func in borrowck's diagnostics part 2022-04-25 16:09:36 +08:00
marmeladema
e1b074a2a8 Recover most impl Trait and dyn Trait lifetime bound suggestions under NLL 2022-04-25 09:14:44 +02:00
Matthias Krüger
aef9eb50cd
Rollup merge of #96352 - marmeladema:fix-nll-lifetime-bound-suggestions, r=jackh726
Improve span for `consider adding an explicit lifetime bound` suggestions under NLL

Because NLL borrowck is run after typeck, `in_progress_typeck_results` was always `None` which was preventing the retrieval of the span to which the suggestion is suppose to add the lifetime bound.
We now manually pass the `LocalDefId` owner to `construct_generic_bound_failure` so that under NLL, we give the owner id of the current body.

This helps with #96332
2022-04-24 18:00:27 +02:00
SparrowLii
a34e1b58cb make classify_drop_access_kind iterate 2022-04-24 17:27:05 +08:00
marmeladema
53120b59ae Recover missing suggestion part under NLL 2022-04-24 09:36:23 +02:00
marmeladema
7b0db3e7c8 Improve span for consider adding an explicit lifetime bound suggestions under NLL
Because NLL borrowck is run after typeck, `in_progress_typeck_results`
was always `None` which was preventing the retrieval of the span to which
the suggestion is suppose to add the lifetime bound.

We now manually pass the `LocalDefId` owner to `construct_generic_bound_failure`
so that under NLL, we give the owner id of the current body.
2022-04-24 09:34:50 +02:00
Matthias Krüger
eeed267215
Rollup merge of #96315 - SparrowLii:graph_lt, r=petrochenkov
Make the lifetime accurate which is used in the region constraints part

This PR fixes the FIXME about lifetime using in the region constraints part.
We cannot write `<'graph, 'tcx, D>` because the definition of `Successors<'0, '1, D>` requires `'1 : '0`.
We cannot add bound to `'graph` either because `'graph` is required to be an arbitrary value in the definition of `WithSuccessors`
So the most accurate way is to use `<'s, 'tcx, D>`.
cc `@Aaron1011` who added this FIXME in #85343
2022-04-22 18:56:26 +02:00
SparrowLii
343523cbf1 Make the lifetime accurate which is used in the region constraints part 2022-04-22 20:05:39 +08:00
Dylan DPC
18b6ad327f
Rollup merge of #96248 - TaKO8Ki:remove-unnecessary-format-args, r=compiler-errors
Stop using a string literal as a format argument
2022-04-21 20:55:19 +02:00
Jack Huey
2300401fb0 Remove mutable_borrow_reservation_conflict lint 2022-04-20 22:10:46 -04:00
Takayuki Maeda
5078b053b5 remove an unnecessary format arg 2022-04-20 21:16:56 +09:00
Aaron Hill
611a06a375
Add an explicit Span field to OutlivesConstraint
Previously, we would retrieve the span from the `Body` using
the `locations` field. However, we may end up changing the
`locations` field when moving a constraint from a promoted
to a different body.

We now store the original `Span` in a dedication field, so that
changes to the `locations` do not affect the quality of our
diagnostics.
2022-04-19 23:42:20 -04:00
Camille GILLOT
a9e13fa553 Lint elided lifetimes in path on the AST. 2022-04-17 11:03:34 +02:00
Jakob Degen
48b01a0d0e Add new MutatatingUseContexts for deinit and SetDiscriminant 2022-04-11 09:26:26 -04:00
Jakob Degen
9b6b1a625b Add new Deinit statement kind 2022-04-11 08:55:03 -04:00
bors
1f7fb6413d Auto merge of #95889 - Dylan-DPC:rollup-1cmywu4, r=Dylan-DPC
Rollup of 7 pull requests

Successful merges:

 - #95566 (Avoid duplication of doc comments in `std::char` constants and functions)
 - #95784 (Suggest replacing `typeof(...)` with an actual type)
 - #95807 (Suggest adding a local for vector to fix borrowck errors)
 - #95849 (Check for git submodules in non-git source tree.)
 - #95852 (Fix missing space in lossy provenance cast lint)
 - #95857 (Allow multiple derefs to be splitted in deref_separator)
 - #95868 (rustdoc: Reduce allocations in a `html::markdown` function)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2022-04-10 21:01:13 +00:00
Dylan DPC
c172544848
Rollup merge of #95807 - TaKO8Ki:suggest-local-var-for-vector, r=fee1-dead
Suggest adding a local for vector to fix borrowck errors

closes #95574
2022-04-10 21:03:35 +02:00
Camille GILLOT
69d8183337 Store LocalDefId in is_late_bound_map.
This allows to avoid looking at HIR from borrowck.
2022-04-10 13:36:06 +02:00
Camille GILLOT
db03a2deb0 Avoid accessing HIR from MIR queries. 2022-04-10 13:08:36 +02:00
Takayuki Maeda
470b4fca0e use format-args-capture and remove unnecessary nested blocks 2022-04-09 00:01:40 +09:00
Takayuki Maeda
71fea61bc9 suggest adding a local for vector to fix borrowck errors 2022-04-08 23:17:57 +09:00
Oli Scherer
7d2cad68d2 Deduplicate the error printing code for hidden type mismatches 2022-04-07 13:52:59 +00:00
Oli Scherer
25876b3541 Report opaque type mismatches directly during borrowck of the function instead of within the type_of query.
This allows us to only store a single hidden type per opaque type instead of having to store one per set of substitutions.
2022-04-07 13:39:52 +00:00
Oli Scherer
27dc503556 Check that all hidden types are the same and then deduplicate them. 2022-04-06 15:02:37 +00:00
Dylan DPC
68329648ac
Rollup merge of #95670 - TaKO8Ki:remove-unused-function-parameters, r=davidtwco
Refactor: remove unused function parameters
2022-04-05 15:56:51 +02:00
Takayuki Maeda
975980427b remove unused function parameters 2022-04-05 19:33:22 +09:00
Dylan DPC
2a7e7bd0e0
Rollup merge of #95607 - compiler-errors:issue-95272, r=Aaron1011
Note invariance reason for FnDef types

Fixes #95272. Is it worthwhile even printing a variance explanation here? Or should I try to track down which function parameter is responsible for the invariance?

r? ``@Aaron1011`` since you wrote #89336
2022-04-05 09:33:23 +02:00
David Wood
7f91697b50 errors: implement fallback diagnostic translation
This commit updates the signatures of all diagnostic functions to accept
types that can be converted into a `DiagnosticMessage`. This enables
existing diagnostic calls to continue to work as before and Fluent
identifiers to be provided. The `SessionDiagnostic` derive just
generates normal diagnostic calls, so these APIs had to be modified to
accept Fluent identifiers.

In addition, loading of the "fallback" Fluent bundle, which contains the
built-in English messages, has been implemented.

Each diagnostic now has "arguments" which correspond to variables in the
Fluent messages (necessary to render a Fluent message) but no API for
adding arguments has been added yet. Therefore, diagnostics (that do not
require interpolation) can be converted to use Fluent identifiers and
will be output as before.
2022-04-05 07:01:02 +01:00
David Wood
c45f29595d span: move MultiSpan
`MultiSpan` contains labels, which are more complicated with the
introduction of diagnostic translation and will use types from
`rustc_errors` - however, `rustc_errors` depends on `rustc_span` so
`rustc_span` cannot use types like `DiagnosticMessage` without
dependency cycles. Introduce a new `rustc_error_messages` crate that can
contain `DiagnosticMessage` and `MultiSpan`.

Signed-off-by: David Wood <david.wood@huawei.com>
2022-04-05 07:01:00 +01:00
Michael Goulet
2a129d4fa5 Format invariance notes with backticks 2022-04-04 20:26:31 -07:00
Michael Goulet
a8877cf738 Handle reporting invariance of fn pointer 2022-04-04 19:37:14 -07:00
lcnr
89c66eb42d update comment 2022-03-31 15:41:52 +02:00
lcnr
d7cada1767 obligation cause: RepeatVec -> RepeatValueCopy 2022-03-31 12:51:46 +02:00
Dylan DPC
1b7d6dbd30
Rollup merge of #95497 - nyurik:compiler-spell-comments, r=compiler-errors
Spellchecking compiler comments

This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-31 04:57:28 +02:00
bors
a40c595695 Auto merge of #95436 - cjgillot:static-mut, r=oli-obk
Remember mutability in `DefKind::Static`.

This allows to compute the `BodyOwnerKind` from `DefKind` only, and
removes a direct dependency of some MIR queries onto HIR.

As a side effect, it also simplifies metadata, since we don't need 4
flavours of `EntryKind::*Static` any more.
2022-03-30 22:09:56 +00:00