-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #92467 - Aaron1011:extern-local-region, r=oli-obk
Ensure that early-bound function lifetimes are always 'local' During borrowchecking, we treat any free (early-bound) regions on the 'defining type' as `RegionClassification::External`. According to the doc comments, we should only have 'external' regions when checking a closure/generator. However, a plain function can also have some if its regions be considered 'early bound' - this occurs when the region is constrained by an argument, appears in a `where` clause, or in an opaque type. This was causing us to incorrectly mark these regions as 'external', which caused some diagnostic code to act as if we were referring to a 'parent' region from inside a closure. This PR marks all instantiated region variables as 'local' when we're borrow-checking something other than a closure/generator/inline-const.
- Loading branch information
Showing
38 changed files
with
98 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,13 @@ | ||
error[E0521]: borrowed data escapes outside of associated function | ||
error: lifetime may not live long enough | ||
--> $DIR/issue-16683.rs:4:9 | ||
| | ||
LL | trait T<'a> { | ||
| -- lifetime `'a` defined here | ||
LL | fn a(&'a self) -> &'a bool; | ||
LL | fn b(&self) { | ||
| ----- | ||
| | | ||
| `self` is a reference that is only valid in the associated function body | ||
| let's call the lifetime of this reference `'1` | ||
| - let's call the lifetime of this reference `'1` | ||
LL | self.a(); | ||
| ^^^^^^^^ | ||
| | | ||
| `self` escapes the associated function body here | ||
| argument requires that `'1` must outlive `'a` | ||
| ^^^^^^^^ argument requires that `'1` must outlive `'a` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0521`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,13 @@ | ||
error[E0521]: borrowed data escapes outside of associated function | ||
error: lifetime may not live long enough | ||
--> $DIR/issue-17758.rs:7:9 | ||
| | ||
LL | trait Foo<'a> { | ||
| -- lifetime `'a` defined here | ||
LL | fn foo(&'a self); | ||
LL | fn bar(&self) { | ||
| ----- | ||
| | | ||
| `self` is a reference that is only valid in the associated function body | ||
| let's call the lifetime of this reference `'1` | ||
| - let's call the lifetime of this reference `'1` | ||
LL | self.foo(); | ||
| ^^^^^^^^^^ | ||
| | | ||
| `self` escapes the associated function body here | ||
| argument requires that `'1` must outlive `'a` | ||
| ^^^^^^^^^^ argument requires that `'1` must outlive `'a` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0521`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
error[E0521]: borrowed data escapes outside of associated function | ||
error: lifetime may not live long enough | ||
--> $DIR/issue-67007-escaping-data.rs:17:21 | ||
| | ||
LL | impl<'tcx> Consumer<'tcx> { | ||
| ---- lifetime `'tcx` defined here | ||
LL | fn bad_method<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) { | ||
| -- ----- --- `fcx` is a reference that is only valid in the associated function body | ||
| | | | ||
| | `self` declared here, outside of the associated function body | ||
| lifetime `'a` defined here | ||
| -- lifetime `'a` defined here | ||
LL | let other = self.use_fcx(fcx); | ||
| ^^^^^^^^^^^^^^^^^ | ||
| | | ||
| `fcx` escapes the associated function body here | ||
| argument requires that `'a` must outlive `'tcx` | ||
| ^^^^^^^^^^^^^^^^^ argument requires that `'a` must outlive `'tcx` | ||
| | ||
= help: consider adding the following bound: `'a: 'tcx` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0521`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.