Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
55b6f649024b372af901b3412a6d36c4284ccf3d
rust/tests/ui/borrowck/issue-82462.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 lines
386 B
Rust
Raw Normal View History

rustc: use more correct span data in for loop desugaring Before: help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped | LL | for x in DroppingSlice(&*v).iter(); { | + After: help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped | LL | }; | + This seems like a reasonable fix: since the desugared "expr_drop_temps_mut" contains the entire desugared loop construct, its span should contain the entire loop construct as well.
2021-08-21 12:51:34 -07:00
struct DroppingSlice<'a>(&'a [i32]);
impl Drop for DroppingSlice<'_> {
fn drop(&mut self) {
println!("hi from slice");
}
}
impl DroppingSlice<'_> {
fn iter(&self) -> std::slice::Iter<'_, i32> {
self.0.iter()
}
}
fn main() {
let mut v = vec![1, 2, 3, 4];
for x in DroppingSlice(&*v).iter() {
v.push(*x); //~ERROR
break;
}
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 1249ms Template: 20ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API