Commit Graph

751 Commits

Author SHA1 Message Date
Matthias Krüger
d26e07b91a
Rollup merge of #106747 - yanchen4791:issue-105507-fix, r=estebank
Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB

Fix for issue #105507

The problem:
When generic associated types (GATs) are from higher-ranked trait bounds (HRTB), they are implied 'static requirement (see
[Implied 'static requirement from higher-ranked trait bounds](https://blog.rust-lang.org/2022/10/28/gats-stabilization.html#implied-static-requirement-from-higher-ranked-trait-bounds) for more details). If the user did not explicitly specify the `'static` lifetime when using the GAT, the current error message will only point out the type `does not live long enough` where the type is used, but not where the GAT is specified and how to fix the problem.

The solution:
Add notes at the span where the problematic GATs are specified and suggestions of how to fix the problem by adding `'static` lifetime at the right spans.
2023-01-18 06:59:20 +01:00
yanchen4791
aadd58ef7a Add 'static lifetime suggestion when GAT implied 'static requirement from HRTB 2023-01-17 11:52:45 -08:00
Matthias Krüger
68f12338af
Rollup merge of #104505 - WaffleLapkin:no-double-spaces-in-comments, r=jackh726
Remove double spaces after dots in comments

Most of the comments do not have double spaces, so I assume these are typos.
2023-01-17 20:21:25 +01:00
Maybe Waffle
6a28fb42a8 Remove double spaces after dots in comments 2023-01-17 08:09:33 +00:00
Matthias Krüger
6b49435480
Rollup merge of #106829 - compiler-errors:more-alias-combine, r=spastorino
Unify `Opaque`/`Projection` handling in region outlives code

They share basically identical paths in most places which are even easier to unify now that they're both `ty::Alias`

r? types
2023-01-17 05:25:22 +01:00
Matthias Krüger
d2a8a9fb36
Rollup merge of #106940 - oli-obk:tait_error, r=compiler-errors
Improve a TAIT error and add an error code plus documentation

cc https://github.com/rust-lang/rust/issues/106858
2023-01-16 20:29:39 +01:00
Oli Scherer
6b69b5e460 Improve a TAIT error and add an error code plus documentation 2023-01-16 16:54:14 +00:00
Michael Goulet
90df86f474 Remove bound_{explicit,}_item_bounds 2023-01-15 15:36:06 +00:00
Michael Goulet
9b28edb6d7 Make InstantiatedPredicates impl IntoIterator 2023-01-15 15:36:06 +00:00
André Vennberg
0e65003c9e Fix some missed double spaces. 2023-01-14 18:23:40 +01:00
André Vennberg
da3623abab Removed various double spaces in compiler source comments. 2023-01-14 17:34:59 +01:00
Michael Goulet
1ea6862db3 Unify Opaque/Projection handling in region outlives code 2023-01-13 23:53:28 +00:00
Matthias Krüger
57b371ab14
Rollup merge of #106641 - chenyukang:yukang/fix-105761-segguest-this, r=estebank
Provide help on closures capturing self causing borrow checker errors

Fixes #105761

r? ````@estebank````
2023-01-13 19:16:43 +01:00
Esteban Küber
06a2d2d001 Fix ICE formatting 2023-01-12 23:46:58 +00:00
yukang
eafbca9166 take care when there is no args in method call 2023-01-12 20:17:28 +08:00
yukang
c82545955e Provide help on closures capturing self causing borrow checker errors 2023-01-12 20:17:25 +08:00
Albert Larsan
40ba0e84d5
Change src/test to tests in source files, fix tidy and tests 2023-01-11 09:32:13 +00:00
Yuki Okushi
e5e116dca9
Rollup merge of #106204 - compiler-errors:no-take-opaques-in-compare, r=oli-obk
No need to take opaques in `check_type_bounds`

`InferCtxt` already has its defining use anchor set to err

r? ``@oli-obk``
2023-01-10 08:05:34 +09:00
bors
3020239de9 Auto merge of #106637 - fee1-dead-contrib:rollup-ticvmsd, r=fee1-dead
Rollup of 10 pull requests

Successful merges:

 - #105292 (Change a commit_if_ok call to probe)
 - #105655 (Remove invalid case for mutable borrow suggestion)
 - #106047 (Fix ui constant tests for big-endian platforms)
 - #106061 (Enable Shadow Call Stack for Fuchsia on AArch64)
 - #106164 (Move `check_region_obligations_and_report_errors` to `TypeErrCtxt`)
 - #106291 (Fix incorrect suggestion for extra `&` in pattern)
 - #106389 (Simplify some canonical type alias names)
 - #106468 (Use FxIndexSet when updating obligation causes in `adjust_fulfillment_errors_for_expr_obligation`)
 - #106549 (Use fmt named parameters in rustc_borrowck)
 - #106614 (error-code docs improvements (No. 2))

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
2023-01-09 18:20:00 +00:00
Michael Goulet
f769d34291 Assert defining anchor is set in take_opaque_types 2023-01-09 18:14:28 +00:00
fee1-dead
99529b0cd2
Rollup merge of #106549 - wcampbell0x2a:use-fmt-named-parameters-borrowck, r=estebank
Use fmt named parameters in rustc_borrowck
2023-01-09 23:35:31 +08:00
bors
af58fc8699 Auto merge of #101947 - aliemjay:astconv-normalize, r=lcnr
Don't normalize in AstConv

See individual commits.

Fixes #101350
Fixes #54940
2023-01-09 15:29:59 +00:00
Yuki Okushi
fe075319e6
Rollup merge of #106410 - clubby789:borrow-mut-self-mut-self-diag, r=compiler-errors
Suggest `mut self: &mut Self` for `?Sized` impls

Closes #106325
Closes #93078

The suggestion is _probably_ not what the user wants (hence `MaybeIncorrect`) but at least makes the problem in the above issues clearer. It might be better to add a note explaining why this is the case, but I'm not sure how best to word that so this is a start.

``@rustbot`` label +A-diagnostics
2023-01-08 17:01:46 +09:00
Matthias Krüger
1e6710da59
Rollup merge of #106509 - estebank:closure-in-block, r=davidtwco
Detect closures assigned to binding in block

Fix #58497.
2023-01-07 20:43:22 +01:00
Ali MJ Al-Nasrawy
c6a17bf8bc make ascribe_user_type a TypeOp
Projection types in user annotations may contain inference variables.
This makes the normalization depend on the unification with the actual
type and thus requires a separate TypeOp to track the obligations.
Otherwise simply calling `TypeChecker::normalize` would ICE with
"unexpected ambiguity"
2023-01-07 13:41:41 +03:00
wcampbell
d0cf7e3bf5 Use fmt named parameters in rustc_borrowck 2023-01-06 19:34:45 -05:00
yanchen4791
523fe7a121 Suggests adding named lifetime when the return contains value borrowed from more than one lifetimes of the function's inputs 2023-01-05 21:09:27 -08:00
Esteban Küber
ce6b7179af Detect closures assigned to binding in block
Fix #58497.
2023-01-05 21:29:36 +00:00
clubby789
23c3a30730 Explain error with &mut self for unsized trait impls 2023-01-05 16:51:30 +00:00
Michael Goulet
5ce6311f34
Rollup merge of #106403 - compiler-errors:rename-hir-methods, r=cjgillot
Rename `hir::Map::{get_,find_}parent_node` to `hir::Map::{,opt_}parent_id`, and add `hir::Map::{get,find}_parent`

The `hir::Map::get_parent_node` function doesn't return a `Node`, and I think that's quite confusing. Let's rename it to something that sounds more like something that gets the parent hir id => `hir::Map::parent_id`. Same with `find_parent_node` => `opt_parent_id`.

Also, combine `hir.get(hir.parent_id(hir_id))` and similar `hir.find(hir.parent_id(hir_id))` function into new functions that actually retrieve the parent node in one call. This last commit is the only one that might need to be looked at closely.
2023-01-04 20:36:28 -08:00
Giacomo Pasini
ac4426c093
Merge borrowck permission checks
Merge `check_access_permission` and
`check_if_reassignment_to_immutable_state`.
The goal of this commit is twofold:
First, we simplify the codebase by removing duplicate logic.
Second, we avoid duplicate reporting of illegal reassignment
errors by reusing the exiting de-duplicating logic of
access_place.
2023-01-04 15:25:45 +01:00
Michael Goulet
2baee88bdb Address comments 2023-01-04 00:51:50 +00:00
Michael Goulet
7690fe3bc6 Simplify some iterator combinators 2023-01-04 00:48:07 +00:00
Michael Goulet
a313ef05a7 rename get_parent_node to parent_id 2023-01-04 00:43:13 +00:00
Esteban Küber
545406528a Verbose suggestions 2023-01-01 21:33:23 -08:00
Esteban Küber
5bfcfeee2a Merge multiple mutable borrows of immutable binding errors
Fix #53466.
2023-01-01 10:09:26 -08:00
bors
96c1f338bb Auto merge of #106245 - estebank:mutability-suggestions, r=jyn514
Use verbose suggestions for mutability errors
2022-12-31 08:43:24 +00:00
Esteban Küber
b9439ebf12 Use verbose suggestions for mutability errors 2022-12-28 22:06:25 -08:00
Nilstrieb
9067e4417e Rename Rptr to Ref in AST and HIR
The name makes a lot more sense, and `ty::TyKind` calls it `Ref` already
as well.
2022-12-28 18:52:36 +01:00
bors
0ca50032ce Auto merge of #106095 - estebank:pin-mut-reborrow, r=compiler-errors
Suggest `Pin::as_mut` when encountering borrow error

Fix #65409 for `Pin<&mut T>`.
2022-12-27 07:31:42 +00:00
Esteban Küber
8a13a7c148 review comments 2022-12-26 13:35:35 -08:00
Esteban Küber
bd890f9cd1 Remove redundant clone suggestion 2022-12-25 17:16:54 -08:00
Esteban Küber
2d6a2ff76e Create new inference context 2022-12-25 16:51:11 -08:00
Matthias Krüger
d8874f259a fix more clippy::style findings
match_result_ok
obfuscated_if_else
single_char_add
writeln_empty_string
collapsible_match
iter_cloned_collect
unnecessary_mut_passed
2022-12-25 17:32:26 +01:00
Esteban Küber
ea7de0d485 Do not use hir_ty_to_ty 2022-12-23 16:45:16 -08:00
Matthias Krüger
d23cb738d2
Rollup merge of #105975 - jeremystucki:rustc-remove-needless-lifetimes, r=eholk
rustc: Remove needless lifetimes
2022-12-24 00:31:41 +01:00
Esteban Küber
12fd9011b8 Verify receiver is of self: Pin<&mut Self> 2022-12-23 15:13:04 -08:00
Esteban Küber
a929316aed Suggest .clone() on method call move errors 2022-12-23 12:49:20 -08:00
Esteban Küber
c79db9c5e5 Suggest Pin::as_mut when encountering borrow error 2022-12-23 09:59:39 -08:00
Jeremy Stucki
3dde32ca97
rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00