forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#56113 - spastorino:erroneous-loop-diagnostic-…
…in-nll, r=pnkfelix Erroneous loop diagnostic in nll Closes rust-lang#53773 r? @nikomatsakis
- Loading branch information
Showing
14 changed files
with
361 additions
and
194 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
451 changes: 278 additions & 173 deletions
451
src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#![feature(nll)] | ||
|
||
struct Archive; | ||
struct ArchiveIterator<'a> { | ||
x: &'a Archive, | ||
} | ||
struct ArchiveChild<'a> { | ||
x: &'a Archive, | ||
} | ||
|
||
struct A { | ||
raw: &'static mut Archive, | ||
} | ||
struct Iter<'a> { | ||
raw: &'a mut ArchiveIterator<'a>, | ||
} | ||
struct C<'a> { | ||
raw: &'a mut ArchiveChild<'a>, | ||
} | ||
|
||
impl A { | ||
pub fn iter(&self) -> Iter<'_> { | ||
panic!() | ||
} | ||
} | ||
impl Drop for A { | ||
fn drop(&mut self) {} | ||
} | ||
impl<'a> Drop for C<'a> { | ||
fn drop(&mut self) {} | ||
} | ||
|
||
impl<'a> Iterator for Iter<'a> { | ||
type Item = C<'a>; | ||
fn next(&mut self) -> Option<C<'a>> { | ||
panic!() | ||
} | ||
} | ||
|
||
fn error(archive: &A) { | ||
let mut members: Vec<&mut ArchiveChild<'_>> = vec![]; | ||
for child in archive.iter() { | ||
members.push(child.raw); | ||
//~^ ERROR borrow may still be in use when destructor runs [E0713] | ||
} | ||
members.len(); | ||
} | ||
|
||
fn main() {} |
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,16 @@ | ||
error[E0713]: borrow may still be in use when destructor runs | ||
--> $DIR/issue-53773.rs:43:22 | ||
| | ||
LL | members.push(child.raw); | ||
| ^^^^^^^^^ | ||
LL | //~^ ERROR borrow may still be in use when destructor runs [E0713] | ||
LL | } | ||
| - here, drop of `child` needs exclusive access to `*child.raw`, because the type `C<'_>` implements the `Drop` trait | ||
LL | members.len(); | ||
| ------- borrow later used here | ||
| | ||
= note: consider using a `let` binding to create a longer lived value | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0713`. |
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