-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.37.0 stable #63498
Merged
Merged
1.37.0 stable #63498
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
33 changes: 33 additions & 0 deletions
33
src/test/ui/borrowck/return-local-binding-from-desugaring.rs
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// To avoid leaking the names of local bindings from expressions like for loops, #60984 | ||
// explicitly ignored them, but an assertion that `LocalKind::Var` *must* have a name would | ||
// trigger an ICE. Before this change, this file's output would be: | ||
// ``` | ||
// error[E0515]: cannot return value referencing local variable `__next` | ||
// --> return-local-binding-from-desugaring.rs:LL:CC | ||
// | | ||
// LL | for ref x in xs { | ||
// | ----- `__next` is borrowed here | ||
// ... | ||
// LL | result | ||
// | ^^^^^^ returns a value referencing data owned by the current function | ||
// ``` | ||
// FIXME: ideally `LocalKind` would carry more information to more accurately explain the problem. | ||
|
||
use std::collections::HashMap; | ||
use std::hash::Hash; | ||
|
||
fn group_by<I, F, T>(xs: &mut I, f: F) -> HashMap<T, Vec<&I::Item>> | ||
where | ||
I: Iterator, | ||
F: Fn(&I::Item) -> T, | ||
T: Eq + Hash, | ||
{ | ||
let mut result = HashMap::new(); | ||
for ref x in xs { | ||
let key = f(x); | ||
result.entry(key).or_insert(Vec::new()).push(x); | ||
} | ||
result //~ ERROR cannot return value referencing local binding | ||
} | ||
|
||
fn main() {} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/borrowck/return-local-binding-from-desugaring.stderr
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0515]: cannot return value referencing local binding | ||
--> $DIR/return-local-binding-from-desugaring.rs:30:5 | ||
| | ||
LL | for ref x in xs { | ||
| -- local binding introduced here | ||
... | ||
LL | result | ||
| ^^^^^^ returns a value referencing data owned by the current function | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0515`. |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// compile-pass | ||
|
||
struct Foo { | ||
foo: Option<&'static Foo> | ||
} | ||
|
||
static FOO: Foo = Foo { | ||
foo: Some(&FOO), | ||
}; | ||
|
||
fn main() {} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure this won't trigger:
continueOnError
tells Azure Pipelines to ignore this task failing, butcondition: succeeded()
is still implied. You should also addcondition: true
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fix is #63511.