summary refs log tree commit diff
path: root/compiler/rustc_borrowck/src
AgeCommit message (Collapse)AuthorLines
2022-05-14Auto merge of #96883 - jackh726:early-binder-2, r=oli-obkbors-4/+9
Add EarlyBinder Chalk has no concept of `Param` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L579) or `ReEarlyBound` (https://github.com/rust-lang/chalk/blob/e0ade19d139bc784384acc6736cd960c91dd55a1/chalk-ir/src/lib.rs#L1308). Everything is just "bound" - the equivalent of rustc's late-bound. It's not completely clear yet whether to move everything to the same time of binder in rustc or add `Param` and `ReEarlyBound` in Chalk. Either way, tracking when we have or haven't already substituted out these in rustc can be helpful. As a first step, I'm just adding a `EarlyBinder` newtype that is required to call `subst`. I also add a couple "transparent" `bound_*` wrappers around a couple query that are often immediately substituted. r? `@nikomatsakis`
2022-05-13Add bound_type_ofJack Huey-4/+5
2022-05-13For non-defining opaque type usage errors, don't try to also prove all trait ↵Oli Scherer-106/+1
bounds
2022-05-10Introduce EarlyBinderJack Huey-5/+9
2022-05-10Auto merge of #96736 - oli-obk:tait_missing_wf_check, r=davidtwcobors-0/+1
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-10Check hidden types for well formedness at the definition site instead of ↵Oli Scherer-0/+1
only at the opaque type itself
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-33/+36
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-06Rollup merge of #96733 - SparrowLii:place_to_string, r=davidtwcoGuillaume Gomez-132/+78
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-06Auto merge of #96268 - ↵bors-69/+8
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-06turn `append_place_to_string` from recursion into iterationSparrowLii-132/+78
2022-05-04Stabilize `bool::then_some`Josh Triplett-1/+0
2022-05-02fix most compiler/ doctestsElliot Roberts-33/+36
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-1/+1
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-04-29Auto merge of #95819 - oli-obk:mir_can't_hold_all_these_lifetimes, r=estebankbors-41/+12
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-29errors: `span_suggestion` takes `impl ToString`David Wood-1/+1
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-28Check that repeat expression elements are Copy (ignoring lifetimes) in ↵Oli Scherer-41/+12
typeck and that they are Copy (with proper lifetime checks) in borrowck
2022-04-27Recover suggestions to introduce named lifetime under NLLmarmeladema-1/+34
2022-04-27Rollup merge of #96385 - ↵Dylan DPC-77/+42
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-25simplify `describe_field` func in borrowck's diagnostics partSparrowLii-19/+10
2022-04-25Recover most `impl Trait` and `dyn Trait` lifetime bound suggestions under NLLmarmeladema-77/+42
2022-04-24Rollup merge of #96352 - marmeladema:fix-nll-lifetime-bound-suggestions, ↵Matthias Krüger-1/+5
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-24make `classify_drop_access_kind` iterateSparrowLii-35/+38
2022-04-24Recover missing suggestion part under NLLmarmeladema-1/+4
2022-04-24Improve span for `consider adding an explicit lifetime bound` suggestions ↵marmeladema-0/+1
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-22Rollup merge of #96315 - SparrowLii:graph_lt, r=petrochenkovMatthias Krüger-6/+3
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-22Make the lifetime accurate which is used in the region constraints partSparrowLii-6/+3
2022-04-21Rollup merge of #96248 - TaKO8Ki:remove-unnecessary-format-args, ↵Dylan DPC-1/+1
r=compiler-errors Stop using a string literal as a format argument
2022-04-20Remove mutable_borrow_reservation_conflict lintJack Huey-69/+8
2022-04-20remove an unnecessary format argTakayuki Maeda-1/+1
2022-04-19Add an explicit `Span` field to `OutlivesConstraint`Aaron Hill-6/+28
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-17Lint elided lifetimes in path on the AST.Camille GILLOT-1/+1
2022-04-11Add new `MutatatingUseContext`s for deinit and `SetDiscriminant`Jakob Degen-0/+4
2022-04-11Add new `Deinit` statement kindJakob Degen-28/+10
2022-04-10Auto merge of #95889 - Dylan-DPC:rollup-1cmywu4, r=Dylan-DPCbors-9/+31
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-10Rollup merge of #95807 - TaKO8Ki:suggest-local-var-for-vector, r=fee1-deadDylan DPC-9/+31
Suggest adding a local for vector to fix borrowck errors closes #95574
2022-04-10Store LocalDefId in is_late_bound_map.Camille GILLOT-5/+3
This allows to avoid looking at HIR from borrowck.
2022-04-10Avoid accessing HIR from MIR queries.Camille GILLOT-14/+15
2022-04-09use `format-args-capture` and remove unnecessary nested blocksTakayuki Maeda-133/+116
2022-04-08suggest adding a local for vector to fix borrowck errorsTakayuki Maeda-9/+31
2022-04-07Deduplicate the error printing code for hidden type mismatchesOli Scherer-10/+3
2022-04-07Report opaque type mismatches directly during borrowck of the function ↵Oli Scherer-13/+25
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-06Check that all hidden types are the same and then deduplicate them.Oli Scherer-62/+80
2022-04-05Rollup merge of #95670 - TaKO8Ki:remove-unused-function-parameters, r=davidtwcoDylan DPC-12/+3
Refactor: remove unused function parameters
2022-04-05remove unused function parametersTakayuki Maeda-12/+3
2022-04-05Rollup merge of #95607 - compiler-errors:issue-95272, r=Aaron1011Dylan DPC-4/+15
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-05errors: implement fallback diagnostic translationDavid Wood-1/+1
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-05span: move `MultiSpan`David Wood-4/+4
`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-04Format invariance notes with backticksMichael Goulet-4/+4
2022-04-04Handle reporting invariance of fn pointerMichael Goulet-0/+11
2022-03-31update commentlcnr-2/+4