Skip to content

Commit c807445

Browse files
committed
Auto merge of #5509 - Eh2406:use_the_new, r=alexcrichton
Use the new stable The new rust release has stabilized `Box::leak` and `impl Iterator` lets use them!
2 parents 7067bc8 + 19cb91f commit c807445

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

src/cargo/core/interning.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,14 @@ use serde::{Serialize, Serializer};
33
use std::fmt;
44
use std::sync::RwLock;
55
use std::collections::HashSet;
6-
use std::slice;
76
use std::str;
8-
use std::mem;
97
use std::ptr;
108
use std::cmp::Ordering;
119
use std::ops::Deref;
1210
use std::hash::{Hash, Hasher};
1311

1412
pub fn leak(s: String) -> &'static str {
15-
let boxed = s.into_boxed_str();
16-
let ptr = boxed.as_ptr();
17-
let len = boxed.len();
18-
mem::forget(boxed);
19-
unsafe {
20-
let slice = slice::from_raw_parts(ptr, len);
21-
str::from_utf8_unchecked(slice)
22-
}
13+
Box::leak(s.into_boxed_str())
2314
}
2415

2516
lazy_static! {

src/cargo/core/resolver/types.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,13 +206,10 @@ impl DepsFrame {
206206
.unwrap_or(0)
207207
}
208208

209-
pub fn flatten<'s>(&'s self) -> Box<Iterator<Item = (&PackageId, Dependency)> + 's> {
210-
// TODO: with impl Trait the Box can be removed
211-
Box::new(
212-
self.remaining_siblings
213-
.clone()
214-
.map(move |(_, (d, _, _))| (self.parent.package_id(), d)),
215-
)
209+
pub fn flatten<'s>(&'s self) -> impl Iterator<Item=(&PackageId, Dependency)> + 's {
210+
self.remaining_siblings
211+
.clone()
212+
.map(move |(_, (d, _, _))| (self.parent.package_id(), d))
216213
}
217214
}
218215

0 commit comments

Comments
 (0)