Skip to content

Commit 64156a3

Browse files
committed
auto merge of #485 : alexcrichton/cargo/fix-for-rustc-master, r=alexcrichton
Extending #479 to use a `'static` shell instead of a `'a` shell.
2 parents 1ab5eb0 + afed575 commit 64156a3

File tree

12 files changed

+90
-87
lines changed

12 files changed

+90
-87
lines changed

Cargo.lock

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cargo/core/manifest.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::hash;
2-
use std::result;
32
use std::fmt::{mod, Show, Formatter};
43
use semver::Version;
54
use serialize::{Encoder,Encodable};
@@ -85,7 +84,7 @@ impl LibKind {
8584
}
8685

8786
pub fn from_strs<S: Str>(strings: Vec<S>) -> CargoResult<Vec<LibKind>> {
88-
result::collect(strings.iter().map(|s| LibKind::from_str(s.as_slice())))
87+
strings.iter().map(|s| LibKind::from_str(s.as_slice())).collect()
8988
}
9089

9190
pub fn crate_type(&self) -> &'static str {

src/cargo/core/registry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl Registry for Vec<Summary> {
1616
}
1717

1818
pub struct PackageRegistry<'a> {
19-
sources: SourceMap,
19+
sources: SourceMap<'a>,
2020
overrides: Vec<SourceId>,
2121
config: &'a mut Config<'a>
2222
}
@@ -53,7 +53,7 @@ impl<'a> PackageRegistry<'a> {
5353
Ok(ret)
5454
}
5555

56-
pub fn move_sources(self) -> SourceMap {
56+
pub fn move_sources(self) -> SourceMap<'a> {
5757
self.sources
5858
}
5959

src/cargo/core/resolver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ impl fmt::Show for Resolve {
216216
}
217217
}
218218

219-
struct Context<'a, R> {
219+
struct Context<'a, R:'a> {
220220
registry: &'a mut R,
221221
resolve: Resolve,
222222

src/cargo/core/shell.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ pub struct ShellConfig {
1111
}
1212

1313
enum AdequateTerminal {
14-
NoColor(Box<Writer>),
15-
Color(Box<Terminal<Box<Writer>>>)
14+
NoColor(Box<Writer+'static>),
15+
Color(Box<Terminal<Box<Writer+'static>>+'static>)
1616
}
1717

1818
pub struct Shell {
@@ -75,14 +75,14 @@ impl MultiShell {
7575
pub type ShellCallback<'a> = |&mut Shell|:'a -> IoResult<()>;
7676

7777
impl Shell {
78-
pub fn create(out: Box<Writer>, config: ShellConfig) -> Shell {
78+
pub fn create(out: Box<Writer+'static>, config: ShellConfig) -> Shell {
7979
if config.tty && config.color {
80-
let term: Option<term::TerminfoTerminal<Box<Writer>>> = Terminal::new(out);
80+
let term: Option<term::TerminfoTerminal<Box<Writer+'static>>> = Terminal::new(out);
8181
term.map(|t| Shell {
82-
terminal: Color(box t as Box<Terminal<Box<Writer>>>),
82+
terminal: Color(box t as Box<Terminal<Box<Writer+'static>>>),
8383
config: config
8484
}).unwrap_or_else(|| {
85-
Shell { terminal: NoColor(box stderr() as Box<Writer>), config: config }
85+
Shell { terminal: NoColor(box stderr() as Box<Writer+'static>), config: config }
8686
})
8787
} else {
8888
Shell { terminal: NoColor(out), config: config }
@@ -121,8 +121,8 @@ impl Shell {
121121
}
122122
}
123123

124-
impl Terminal<Box<Writer>> for Shell {
125-
fn new(out: Box<Writer>) -> Option<Shell> {
124+
impl Terminal<Box<Writer+'static>> for Shell {
125+
fn new(out: Box<Writer+'static>) -> Option<Shell> {
126126
Some(Shell {
127127
terminal: NoColor(out),
128128
config: ShellConfig {
@@ -168,18 +168,18 @@ impl Terminal<Box<Writer>> for Shell {
168168
}
169169
}
170170

171-
fn unwrap(self) -> Box<Writer> {
171+
fn unwrap(self) -> Box<Writer+'static> {
172172
fail!("Can't unwrap a Shell");
173173
}
174174

175-
fn get_ref<'a>(&'a self) -> &'a Box<Writer> {
175+
fn get_ref<'b>(&'b self) -> &'b Box<Writer+'static> {
176176
match self.terminal {
177177
Color(ref c) => c.get_ref(),
178178
NoColor(ref w) => w
179179
}
180180
}
181181

182-
fn get_mut<'a>(&'a mut self) -> &'a mut Box<Writer> {
182+
fn get_mut<'b>(&'b mut self) -> &'b mut Box<Writer+'static> {
183183
match self.terminal {
184184
Color(ref mut c) => c.get_mut(),
185185
NoColor(ref mut w) => w

src/cargo/core/source.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,18 @@ impl SourceId {
244244
}
245245
}
246246

247-
pub fn load(&self, config: &mut Config) -> Box<Source> {
247+
pub fn load<'a>(&self, config: &'a mut Config) -> Box<Source+'a> {
248248
log!(5, "loading SourceId; {}", self);
249249
match self.kind {
250-
GitKind(..) => box GitSource::new(self, config) as Box<Source>,
250+
GitKind(..) => box GitSource::new(self, config) as Box<Source+'a>,
251251
PathKind => {
252252
let path = match self.url.to_file_path() {
253253
Ok(p) => p,
254254
Err(()) => fail!("path sources cannot be remote"),
255255
};
256256
box PathSource::new(&path, self) as Box<Source>
257257
},
258-
RegistryKind => box DummyRegistrySource::new(self) as Box<Source>,
258+
RegistryKind => box DummyRegistrySource::new(self) as Box<Source+'a>,
259259
}
260260
}
261261

@@ -267,17 +267,17 @@ impl SourceId {
267267
}
268268
}
269269

270-
pub struct SourceMap {
271-
map: HashMap<SourceId, Box<Source>>
270+
pub struct SourceMap<'a> {
271+
map: HashMap<SourceId, Box<Source+'a>>
272272
}
273273

274-
pub type Sources<'a> = Values<'a, SourceId, Box<Source>>;
275-
pub type SourcesMut<'a> = iter::Map<'static, (&'a SourceId, &'a mut Box<Source>),
276-
&'a mut Source,
277-
MutEntries<'a, SourceId, Box<Source>>>;
274+
pub type Sources<'a> = Values<'a, SourceId, Box<Source+'a>>;
275+
pub type SourcesMut<'a> = iter::Map<'static, (&'a SourceId, &'a mut Box<Source+'a>),
276+
&'a mut Source+'a,
277+
MutEntries<'a, SourceId, Box<Source+'a>>>;
278278

279-
impl SourceMap {
280-
pub fn new() -> SourceMap {
279+
impl<'a> SourceMap<'a> {
280+
pub fn new() -> SourceMap<'a> {
281281
SourceMap {
282282
map: HashMap::new()
283283
}
@@ -287,54 +287,54 @@ impl SourceMap {
287287
self.map.contains_key(id)
288288
}
289289

290-
pub fn get(&self, id: &SourceId) -> Option<&Source> {
290+
pub fn get(&self, id: &SourceId) -> Option<&Source+'a> {
291291
let source = self.map.find(id);
292292

293293
source.map(|s| {
294-
let s: &Source = *s;
294+
let s: &Source+'a = *s;
295295
s
296296
})
297297
}
298298

299-
pub fn get_mut(&mut self, id: &SourceId) -> Option<&mut Source> {
299+
pub fn get_mut(&mut self, id: &SourceId) -> Option<&mut Source+'a> {
300300
self.map.find_mut(id).map(|s| {
301-
let s: &mut Source = *s;
301+
let s: &mut Source+'a = *s;
302302
s
303303
})
304304
}
305305

306-
pub fn get_by_package_id(&self, pkg_id: &PackageId) -> Option<&Source> {
306+
pub fn get_by_package_id(&self, pkg_id: &PackageId) -> Option<&Source+'a> {
307307
self.get(pkg_id.get_source_id())
308308
}
309309

310-
pub fn insert(&mut self, id: &SourceId, source: Box<Source>) {
310+
pub fn insert(&mut self, id: &SourceId, source: Box<Source+'a>) {
311311
self.map.insert(id.clone(), source);
312312
}
313313

314314
pub fn len(&self) -> uint {
315315
self.map.len()
316316
}
317317

318-
pub fn sources(&self) -> Sources {
318+
pub fn sources(&'a self) -> Sources<'a> {
319319
self.map.values()
320320
}
321321

322-
pub fn sources_mut(&mut self) -> SourcesMut {
323-
self.map.mut_iter().map(|(_, v)| { let s: &mut Source = *v; s })
322+
pub fn sources_mut(&'a mut self) -> SourcesMut<'a> {
323+
self.map.mut_iter().map(|(_, v)| { let s: &mut Source+'a = *v; s })
324324
}
325325
}
326326

327-
pub struct SourceSet {
328-
sources: Vec<Box<Source>>
327+
pub struct SourceSet<'a> {
328+
sources: Vec<Box<Source+'a>>
329329
}
330330

331-
impl SourceSet {
332-
pub fn new(sources: Vec<Box<Source>>) -> SourceSet {
331+
impl<'a> SourceSet<'a> {
332+
pub fn new(sources: Vec<Box<Source+'a>>) -> SourceSet<'a> {
333333
SourceSet { sources: sources }
334334
}
335335
}
336336

337-
impl Registry for SourceSet {
337+
impl<'a> Registry for SourceSet<'a> {
338338
fn query(&mut self, name: &Dependency) -> CargoResult<Vec<Summary>> {
339339
let mut ret = Vec::new();
340340

@@ -346,7 +346,7 @@ impl Registry for SourceSet {
346346
}
347347
}
348348

349-
impl Source for SourceSet {
349+
impl<'a> Source for SourceSet<'a> {
350350
fn update(&mut self) -> CargoResult<()> {
351351
for source in self.sources.mut_iter() {
352352
try!(source.update());

src/cargo/ops/cargo_compile.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
2525
use std::os;
2626
use std::collections::{HashMap, HashSet};
27-
use std::result;
2827

2928
use core::registry::PackageRegistry;
3029
use core::{MultiShell, Source, SourceId, PackageSet, Target, PackageId};
@@ -147,9 +146,9 @@ fn source_ids_from_config(configs: &HashMap<String, config::ConfigValue>,
147146

148147
// Make sure we don't override the local package, even if it's in the list
149148
// of override paths
150-
result::collect(paths.iter().filter(|p| {
149+
paths.iter().filter(|p| {
151150
cur_path != os::make_absolute(&Path::new(p.as_slice()))
152-
}).map(|p| SourceId::for_path(&Path::new(p.as_slice()))))
151+
}).map(|p| SourceId::for_path(&Path::new(p.as_slice()))).collect()
153152
}
154153

155154
fn scrape_target_config(config: &mut Config,

src/cargo/ops/cargo_rustc/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct Context<'a, 'b> {
1919
pub rustc_version: String,
2020
pub config: &'b mut Config<'b>,
2121
pub resolve: &'a Resolve,
22-
pub sources: &'a SourceMap,
22+
pub sources: &'a SourceMap<'b>,
2323
pub compilation: Compilation,
2424

2525
env: &'a str,

src/cargo/sources/git/source.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use sources::git::utils::{GitReference, GitRemote, Master, Other, GitRevision};
1212

1313
/* TODO: Refactor GitSource to delegate to a PathSource
1414
*/
15-
pub struct GitSource<'a, 'b> {
15+
pub struct GitSource<'a, 'b:'a> {
1616
remote: GitRemote,
1717
reference: GitReference,
1818
db_path: Path,
@@ -195,7 +195,7 @@ impl<'a, 'b> Source for GitSource<'a, 'b> {
195195
}
196196

197197
fn fingerprint(&self, _pkg: &Package) -> CargoResult<String> {
198-
Ok(self.rev.get_ref().to_string())
198+
Ok(self.rev.as_ref().unwrap().to_string())
199199
}
200200
}
201201

src/cargo/util/toml.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,10 @@ impl TomlManifest {
396396
None => inferred_test_targets(layout),
397397
};
398398

399-
let benches = if self.bench.is_none() || self.bench.get_ref().is_empty() {
399+
let benches = if self.bench.is_none() || self.bench.as_ref().unwrap().is_empty() {
400400
inferred_bench_targets(layout)
401401
} else {
402-
self.bench.get_ref().iter().map(|t| t.clone()).collect()
402+
self.bench.as_ref().unwrap().iter().map(|t| t.clone()).collect()
403403
};
404404

405405
// Get targets

0 commit comments

Comments
 (0)