Skip to content

Commit 0925704

Browse files
committed
Auto merge of #140695 - Zalathar:rollup-i32gzbo, r=Zalathar
Rollup of 12 pull requests Successful merges: - #139550 (Fix `-Zremap-path-scope` rmeta handling) - #139764 (Consistent trait bounds for ExtractIf Debug impls) - #139773 (Implement `Iterator::last` for `vec::IntoIter`) - #140035 (Implement RFC 3503: frontmatters) - #140251 (coverage-dump: Resolve global file IDs to filenames) - #140393 (std: get rid of `sys_common::process`) - #140532 (Fix RustAnalyzer discovery of rustc's `stable_mir` crate) - #140598 (Steer docs to `utf8_chunks` and `Iterator::take`) - #140634 (Use more accurate ELF flags on MIPS) - #140673 (Clean rustdoc tests folder) - #140678 (Be a bit more relaxed about not yet constrained infer vars in closure upvar analysis) - #140687 (Update mdbook to 0.4.49) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2603903 + 249d333 commit 0925704

File tree

5 files changed

+46
-7
lines changed

5 files changed

+46
-7
lines changed

tests/ui/double_ended_iterator_last.fixed

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ fn issue_14139() {
8484
}
8585

8686
fn drop_order() {
87+
struct DropDeIterator(std::vec::IntoIter<S>);
88+
impl Iterator for DropDeIterator {
89+
type Item = S;
90+
fn next(&mut self) -> Option<Self::Item> {
91+
self.0.next()
92+
}
93+
}
94+
impl DoubleEndedIterator for DropDeIterator {
95+
fn next_back(&mut self) -> Option<Self::Item> {
96+
self.0.next_back()
97+
}
98+
}
99+
87100
struct S(&'static str);
88101
impl std::ops::Drop for S {
89102
fn drop(&mut self) {
@@ -92,7 +105,7 @@ fn drop_order() {
92105
}
93106

94107
let v = vec![S("one"), S("two"), S("three")];
95-
let mut v = v.into_iter();
108+
let mut v = DropDeIterator(v.into_iter());
96109
println!("Last element is {}", v.next_back().unwrap().0);
97110
//~^ ERROR: called `Iterator::last` on a `DoubleEndedIterator`
98111
println!("Done");

tests/ui/double_ended_iterator_last.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ fn issue_14139() {
8484
}
8585

8686
fn drop_order() {
87+
struct DropDeIterator(std::vec::IntoIter<S>);
88+
impl Iterator for DropDeIterator {
89+
type Item = S;
90+
fn next(&mut self) -> Option<Self::Item> {
91+
self.0.next()
92+
}
93+
}
94+
impl DoubleEndedIterator for DropDeIterator {
95+
fn next_back(&mut self) -> Option<Self::Item> {
96+
self.0.next_back()
97+
}
98+
}
99+
87100
struct S(&'static str);
88101
impl std::ops::Drop for S {
89102
fn drop(&mut self) {
@@ -92,7 +105,7 @@ fn drop_order() {
92105
}
93106

94107
let v = vec![S("one"), S("two"), S("three")];
95-
let v = v.into_iter();
108+
let v = DropDeIterator(v.into_iter());
96109
println!("Last element is {}", v.last().unwrap().0);
97110
//~^ ERROR: called `Iterator::last` on a `DoubleEndedIterator`
98111
println!("Done");

tests/ui/double_ended_iterator_last.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ LL | let _ = DeIterator.last();
1818
| help: try: `next_back()`
1919

2020
error: called `Iterator::last` on a `DoubleEndedIterator`; this will needlessly iterate the entire iterator
21-
--> tests/ui/double_ended_iterator_last.rs:96:36
21+
--> tests/ui/double_ended_iterator_last.rs:109:36
2222
|
2323
LL | println!("Last element is {}", v.last().unwrap().0);
2424
| ^^^^^^^^
2525
|
2626
= note: this change will alter drop order which may be undesirable
2727
help: try
2828
|
29-
LL ~ let mut v = v.into_iter();
29+
LL ~ let mut v = DropDeIterator(v.into_iter());
3030
LL ~ println!("Last element is {}", v.next_back().unwrap().0);
3131
|
3232

tests/ui/double_ended_iterator_last_unfixable.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,19 @@ fn main() {
1111
}
1212

1313
fn drop_order() {
14+
struct DropDeIterator(std::vec::IntoIter<S>);
15+
impl Iterator for DropDeIterator {
16+
type Item = S;
17+
fn next(&mut self) -> Option<Self::Item> {
18+
self.0.next()
19+
}
20+
}
21+
impl DoubleEndedIterator for DropDeIterator {
22+
fn next_back(&mut self) -> Option<Self::Item> {
23+
self.0.next_back()
24+
}
25+
}
26+
1427
struct S(&'static str);
1528
impl std::ops::Drop for S {
1629
fn drop(&mut self) {
@@ -19,7 +32,7 @@ fn drop_order() {
1932
}
2033

2134
let v = vec![S("one"), S("two"), S("three")];
22-
let v = (v.into_iter(), 42);
35+
let v = (DropDeIterator(v.into_iter()), 42);
2336
println!("Last element is {}", v.0.last().unwrap().0);
2437
//~^ ERROR: called `Iterator::last` on a `DoubleEndedIterator`
2538
println!("Done");

tests/ui/double_ended_iterator_last_unfixable.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: called `Iterator::last` on a `DoubleEndedIterator`; this will needlessly iterate the entire iterator
2-
--> tests/ui/double_ended_iterator_last_unfixable.rs:23:36
2+
--> tests/ui/double_ended_iterator_last_unfixable.rs:36:36
33
|
44
LL | println!("Last element is {}", v.0.last().unwrap().0);
55
| ^^^^------
@@ -8,7 +8,7 @@ LL | println!("Last element is {}", v.0.last().unwrap().0);
88
|
99
= note: this change will alter drop order which may be undesirable
1010
note: this must be made mutable to use `.next_back()`
11-
--> tests/ui/double_ended_iterator_last_unfixable.rs:23:36
11+
--> tests/ui/double_ended_iterator_last_unfixable.rs:36:36
1212
|
1313
LL | println!("Last element is {}", v.0.last().unwrap().0);
1414
| ^^^

0 commit comments

Comments
 (0)