about summary refs log tree commit diff
path: root/compiler/rustc_borrowck
AgeCommit message (Collapse)AuthorLines
2022-06-02Rollup merge of #97023 - cjgillot:uniform-anon, r=estebankDylan DPC-4/+6
Diagnose anonymous lifetimes errors more uniformly between async and regular fns Async fns and regular fns are desugared differently. For the former, we create a generic parameter at HIR level. For the latter, we just create an anonymous region for typeck. I plan to migrate regular fns to the async fn desugaring. Before that, this PR attempts to merge the diagnostics for both cases. r? ```@estebank```
2022-06-01rename PointerAddress → PointerExposeAddressRalf Jung-1/+1
2022-05-31Add a pointer to address cast kindTomasz Miąsko-3/+17
A pointer to address cast are often special-cased. Introduce a dedicated cast kind to make them easy distinguishable.
2022-05-29Handle anonymous lifetimes properly in diagnostics.Camille GILLOT-4/+6
2022-05-28Fix TyKind lint, make consts no longer fn, etcMichael Goulet-3/+5
2022-05-28Initial fixes on top of type interner commitMichael Goulet-2/+4
2022-05-28Auto merge of #97284 - b-naber:constraint-dyn-impl-suggestion, r=estebankbors-64/+263
Add suggestion for relaxing static lifetime bounds on dyn trait impls in NLL This PR introduces suggestions for relaxing static lifetime bounds on impls of dyn trait items for NLL similar to what is already available in lexical region diagnostics. Fixes https://github.com/rust-lang/rust/issues/95701 r? `@estebank`
2022-05-26clippy::complexity fixesMatthias Krüger-3/+3
clone_on_copy useless_format bind_instead_of_map filter_map_identity useless_conversion map_flatten unnecessary_unwrap
2022-05-26rebase, use Ty in CallArgument and re-insert static_assert_size on ↵b-naber-21/+16
ConstraintCategory
2022-05-25suggest constraining dyn trait in impl in NLLb-naber-28/+197
2022-05-25add def_id and substs to ConstraintCategory::CallArgumentb-naber-36/+71
2022-05-23Refactor call terminator to always hold a destination placeJakob Degen-25/+24
2022-05-22Lifetime variance fixes for rustcMichael Goulet-14/+18
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-199/+217
2022-05-17Change `Successors` to `impl Iterator<Item = BasicBlock>`SparrowLii-6/+6
2022-05-16Some tracing cleanupsOli Scherer-1/+1
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