Skip to content

Commit 704dbc7

Browse files
committed
---
yaml --- r: 274719 b: refs/heads/stable c: b5da60d h: refs/heads/master i: 274717: e3aa9da 274715: 82c27d4 274711: 1666a47 274703: 9428a1e 274687: fe0a373
1 parent c448897 commit 704dbc7

File tree

24 files changed

+177
-71
lines changed

24 files changed

+177
-71
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 75acee2bdee0278e0dc9610bfd05eb4367e41c20
32+
refs/heads/stable: b5da60d03a5926adcb770e55bb3ef535583a4d37
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/libcollections/vec_deque.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1968,7 +1968,39 @@ impl<'a, T: 'a> ExactSizeIterator for Drain<'a, T> {}
19681968
#[stable(feature = "rust1", since = "1.0.0")]
19691969
impl<A: PartialEq> PartialEq for VecDeque<A> {
19701970
fn eq(&self, other: &VecDeque<A>) -> bool {
1971-
self.len() == other.len() && self.iter().zip(other).all(|(a, b)| a.eq(b))
1971+
if self.len() != other.len() {
1972+
return false;
1973+
}
1974+
let (sa, sb) = self.as_slices();
1975+
let (oa, ob) = other.as_slices();
1976+
if sa.len() == oa.len() {
1977+
sa == oa && sb == ob
1978+
} else if sa.len() < oa.len() {
1979+
// Always divisible in three sections, for example:
1980+
// self: [a b c|d e f]
1981+
// other: [0 1 2 3|4 5]
1982+
// front = 3, mid = 1,
1983+
// [a b c] == [0 1 2] && [d] == [3] && [e f] == [4 5]
1984+
let front = sa.len();
1985+
let mid = oa.len() - front;
1986+
1987+
let (oa_front, oa_mid) = oa.split_at(front);
1988+
let (sb_mid, sb_back) = sb.split_at(mid);
1989+
debug_assert_eq!(sa.len(), oa_front.len());
1990+
debug_assert_eq!(sb_mid.len(), oa_mid.len());
1991+
debug_assert_eq!(sb_back.len(), ob.len());
1992+
sa == oa_front && sb_mid == oa_mid && sb_back == ob
1993+
} else {
1994+
let front = oa.len();
1995+
let mid = sa.len() - front;
1996+
1997+
let (sa_front, sa_mid) = sa.split_at(front);
1998+
let (ob_mid, ob_back) = ob.split_at(mid);
1999+
debug_assert_eq!(sa_front.len(), oa.len());
2000+
debug_assert_eq!(sa_mid.len(), ob_mid.len());
2001+
debug_assert_eq!(sb.len(), ob_back.len());
2002+
sa_front == oa && sa_mid == ob_mid && sb == ob_back
2003+
}
19722004
}
19732005
}
19742006

branches/stable/src/libcollectionstest/vec_deque.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,33 @@ fn test_hash_after_rotation() {
624624
}
625625
}
626626

627+
#[test]
628+
fn test_eq_after_rotation() {
629+
// test that two deques are equal even if elements are laid out differently
630+
let len = 28;
631+
let mut ring: VecDeque<i32> = (0..len as i32).collect();
632+
let mut shifted = ring.clone();
633+
for _ in 0..10 {
634+
// shift values 1 step to the right by pop, sub one, push
635+
ring.pop_front();
636+
for elt in &mut ring {
637+
*elt -= 1;
638+
}
639+
ring.push_back(len - 1);
640+
}
641+
642+
// try every shift
643+
for _ in 0..shifted.capacity() {
644+
shifted.pop_front();
645+
for elt in &mut shifted {
646+
*elt -= 1;
647+
}
648+
shifted.push_back(len - 1);
649+
assert_eq!(shifted, ring);
650+
assert_eq!(ring, shifted);
651+
}
652+
}
653+
627654
#[test]
628655
fn test_ord() {
629656
let x = VecDeque::new();

branches/stable/src/librustc_back/target/asmjs_unknown_emscripten.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub fn target() -> Target {
2121
no_compiler_rt: true,
2222
linker_is_gnu: true,
2323
allow_asm: false,
24-
archive_format: "gnu".to_string(),
2524
obj_is_bitcode: true,
2625
.. Default::default()
2726
};

branches/stable/src/librustc_back/target/bitrig_base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ pub fn opts() -> TargetOptions {
1919
linker_is_gnu: true,
2020
has_rpath: true,
2121
position_independent_executables: true,
22-
archive_format: "gnu".to_string(),
2322
exe_allocation_crate: "alloc_system".to_string(),
2423

2524
.. Default::default()

branches/stable/src/librustc_back/target/dragonfly_base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub fn opts() -> TargetOptions {
2929
"-Wl,-z,noexecstack".to_string(),
3030
),
3131
position_independent_executables: true,
32-
archive_format: "gnu".to_string(),
3332
exe_allocation_crate: super::maybe_jemalloc(),
3433
.. Default::default()
3534
}

branches/stable/src/librustc_back/target/freebsd_base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub fn opts() -> TargetOptions {
2121
// Always enable NX protection when it is available
2222
"-Wl,-z,noexecstack".to_string(),
2323
],
24-
archive_format: "gnu".to_string(),
2524
exe_allocation_crate: super::maybe_jemalloc(),
2625

2726
.. Default::default()

branches/stable/src/librustc_back/target/le32_unknown_nacl.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ pub fn target() -> Target {
2525
no_compiler_rt: false,
2626
linker_is_gnu: true,
2727
allow_asm: false,
28-
archive_format: "gnu".to_string(),
2928
.. Default::default()
3029
};
3130
Target {

branches/stable/src/librustc_back/target/linux_base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ pub fn opts() -> TargetOptions {
3131
"-Wl,-z,noexecstack".to_string(),
3232
],
3333
position_independent_executables: true,
34-
archive_format: "gnu".to_string(),
3534
exe_allocation_crate: super::maybe_jemalloc(),
3635
has_elf_tls: true,
3736
.. Default::default()

branches/stable/src/librustc_back/target/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl Default for TargetOptions {
249249
pre_link_objects_dll: Vec::new(),
250250
post_link_objects: Vec::new(),
251251
late_link_args: Vec::new(),
252-
archive_format: String::new(),
252+
archive_format: "gnu".to_string(),
253253
custom_unwind_resume: false,
254254
lib_allocation_crate: "alloc_system".to_string(),
255255
exe_allocation_crate: "alloc_system".to_string(),

branches/stable/src/librustc_back/target/netbsd_base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub fn opts() -> TargetOptions {
2929
"-Wl,-z,noexecstack".to_string(),
3030
),
3131
position_independent_executables: true,
32-
archive_format: "gnu".to_string(),
3332
.. Default::default()
3433
}
3534
}

branches/stable/src/librustc_back/target/openbsd_base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ pub fn opts() -> TargetOptions {
2929
"-Wl,-z,noexecstack".to_string(),
3030
),
3131
position_independent_executables: true,
32-
archive_format: "gnu".to_string(),
3332
exe_allocation_crate: "alloc_system".to_string(),
3433
.. Default::default()
3534
}

branches/stable/src/librustc_back/target/solaris_base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub fn opts() -> TargetOptions {
1818
executables: true,
1919
has_rpath: true,
2020
is_like_solaris: true,
21-
archive_format: "gnu".to_string(),
2221
exe_allocation_crate: super::maybe_jemalloc(),
2322

2423
.. Default::default()

branches/stable/src/librustc_back/target/windows_base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ pub fn opts() -> TargetOptions {
2525
staticlib_suffix: ".lib".to_string(),
2626
no_default_libraries: true,
2727
is_like_windows: true,
28-
archive_format: "gnu".to_string(),
2928
pre_link_args: vec!(
3029
// And here, we see obscure linker flags #45. On windows, it has been
3130
// found to be necessary to have this flag to compile liblibc.

branches/stable/src/librustc_back/target/windows_msvc_base.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ pub fn opts() -> TargetOptions {
5959
"/NOLOGO".to_string(),
6060
"/NXCOMPAT".to_string(),
6161
],
62-
archive_format: "gnu".to_string(),
6362
exe_allocation_crate: "alloc_system".to_string(),
6463

6564
.. Default::default()

branches/stable/src/librustc_driver/lib.rs

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ pub fn run_compiler<'a>(args: &[String],
164164

165165
let descriptions = diagnostics_registry();
166166

167-
do_or_return!(callbacks.early_callback(&matches, &descriptions, sopts.error_format), None);
167+
do_or_return!(callbacks.early_callback(&matches,
168+
&sopts,
169+
&descriptions,
170+
sopts.error_format),
171+
None);
168172

169173
let (odir, ofile) = make_output(&matches);
170174
let (input, input_file_path) = match make_input(&matches.free) {
@@ -251,6 +255,7 @@ pub trait CompilerCalls<'a> {
251255
// else (e.g., selecting input and output).
252256
fn early_callback(&mut self,
253257
_: &getopts::Matches,
258+
_: &config::Options,
254259
_: &diagnostics::registry::Registry,
255260
_: ErrorOutputType)
256261
-> Compilation {
@@ -324,34 +329,68 @@ pub trait CompilerCalls<'a> {
324329
#[derive(Copy, Clone)]
325330
pub struct RustcDefaultCalls;
326331

332+
fn handle_explain(code: &str,
333+
descriptions: &diagnostics::registry::Registry,
334+
output: ErrorOutputType) {
335+
let normalised = if !code.starts_with("E") {
336+
format!("E{0:0>4}", code)
337+
} else {
338+
code.to_string()
339+
};
340+
match descriptions.find_description(&normalised) {
341+
Some(ref description) => {
342+
// Slice off the leading newline and print.
343+
print!("{}", &description[1..]);
344+
}
345+
None => {
346+
early_error(output, &format!("no extended information for {}", code));
347+
}
348+
}
349+
}
350+
351+
fn check_cfg(sopts: &config::Options,
352+
output: ErrorOutputType) {
353+
let mut emitter: Box<Emitter> = match output {
354+
config::ErrorOutputType::HumanReadable(color_config) => {
355+
Box::new(errors::emitter::BasicEmitter::stderr(color_config))
356+
}
357+
config::ErrorOutputType::Json => Box::new(errors::json::JsonEmitter::basic()),
358+
};
359+
360+
let mut saw_invalid_predicate = false;
361+
for item in sopts.cfg.iter() {
362+
match item.node {
363+
ast::MetaList(ref pred, _) => {
364+
saw_invalid_predicate = true;
365+
emitter.emit(None,
366+
&format!("invalid predicate in --cfg command line argument: `{}`",
367+
pred),
368+
None,
369+
errors::Level::Fatal);
370+
}
371+
_ => {},
372+
}
373+
}
374+
375+
if saw_invalid_predicate {
376+
panic!(errors::FatalError);
377+
}
378+
}
379+
327380
impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
328381
fn early_callback(&mut self,
329382
matches: &getopts::Matches,
383+
sopts: &config::Options,
330384
descriptions: &diagnostics::registry::Registry,
331385
output: ErrorOutputType)
332386
-> Compilation {
333-
match matches.opt_str("explain") {
334-
Some(ref code) => {
335-
let normalised = if !code.starts_with("E") {
336-
format!("E{0:0>4}", code)
337-
} else {
338-
code.to_string()
339-
};
340-
match descriptions.find_description(&normalised) {
341-
Some(ref description) => {
342-
// Slice off the leading newline and print.
343-
print!("{}", &description[1..]);
344-
}
345-
None => {
346-
early_error(output, &format!("no extended information for {}", code));
347-
}
348-
}
349-
return Compilation::Stop;
350-
}
351-
None => (),
387+
if let Some(ref code) = matches.opt_str("explain") {
388+
handle_explain(code, descriptions, output);
389+
return Compilation::Stop;
352390
}
353391

354-
return Compilation::Continue;
392+
check_cfg(sopts, output);
393+
Compilation::Continue
355394
}
356395

357396
fn no_input(&mut self,

branches/stable/src/librustc_mir/build/scope.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl<'a,'tcx> Builder<'a,'tcx> {
236236
self.diverge_cleanup();
237237
let scope = self.scopes.pop().unwrap();
238238
assert_eq!(scope.extent, extent);
239-
build_scope_drops(block, &scope, &self.scopes[..], &mut self.cfg)
239+
build_scope_drops(&mut self.cfg, &scope, &self.scopes[..], block)
240240
}
241241

242242

@@ -254,8 +254,18 @@ impl<'a,'tcx> Builder<'a,'tcx> {
254254
self.hir.span_bug(span, &format!("extent {:?} does not enclose", extent))
255255
});
256256

257+
let tmp = self.get_unit_temp();
257258
for (idx, ref scope) in self.scopes.iter().enumerate().rev().take(scope_count) {
258-
unpack!(block = build_scope_drops(block, scope, &self.scopes[..idx], &mut self.cfg));
259+
unpack!(block = build_scope_drops(&mut self.cfg,
260+
scope,
261+
&self.scopes[..idx],
262+
block));
263+
if let Some(ref free_data) = scope.free {
264+
let next = self.cfg.start_new_block();
265+
let free = build_free(self.hir.tcx(), tmp.clone(), free_data, next);
266+
self.cfg.terminate(block, free);
267+
block = next;
268+
}
259269
}
260270
self.cfg.terminate(block, Terminator::Goto { target: target });
261271
}
@@ -508,10 +518,10 @@ impl<'a,'tcx> Builder<'a,'tcx> {
508518
}
509519

510520
/// Builds drops for pop_scope and exit_scope.
511-
fn build_scope_drops<'tcx>(mut block: BasicBlock,
521+
fn build_scope_drops<'tcx>(cfg: &mut CFG<'tcx>,
512522
scope: &Scope<'tcx>,
513523
earlier_scopes: &[Scope<'tcx>],
514-
cfg: &mut CFG<'tcx>)
524+
mut block: BasicBlock)
515525
-> BlockAnd<()> {
516526
let mut iter = scope.drops.iter().rev().peekable();
517527
while let Some(drop_data) = iter.next() {
@@ -586,9 +596,10 @@ fn build_diverge_scope<'tcx>(tcx: &ty::ctxt<'tcx>,
586596
target = if let Some(cached_block) = free_data.cached_block {
587597
cached_block
588598
} else {
589-
let t = build_free(tcx, cfg, unit_temp, free_data, target);
590-
free_data.cached_block = Some(t);
591-
t
599+
let into = cfg.start_new_cleanup_block();
600+
cfg.terminate(into, build_free(tcx, unit_temp, free_data, target));
601+
free_data.cached_block = Some(into);
602+
into
592603
}
593604
};
594605

@@ -608,19 +619,16 @@ fn build_diverge_scope<'tcx>(tcx: &ty::ctxt<'tcx>,
608619
}
609620

610621
fn build_free<'tcx>(tcx: &ty::ctxt<'tcx>,
611-
cfg: &mut CFG<'tcx>,
612622
unit_temp: Lvalue<'tcx>,
613623
data: &FreeData<'tcx>,
614-
target: BasicBlock)
615-
-> BasicBlock {
624+
target: BasicBlock) -> Terminator<'tcx> {
616625
let free_func = tcx.lang_items.box_free_fn()
617626
.expect("box_free language item is missing");
618627
let substs = tcx.mk_substs(Substs::new(
619628
VecPerParamSpace::new(vec![], vec![], vec![data.item_ty]),
620629
VecPerParamSpace::new(vec![], vec![], vec![])
621630
));
622-
let block = cfg.start_new_cleanup_block();
623-
cfg.terminate(block, Terminator::Call {
631+
Terminator::Call {
624632
func: Operand::Constant(Constant {
625633
span: data.span,
626634
ty: tcx.lookup_item_type(free_func).ty.subst(tcx, substs),
@@ -633,6 +641,5 @@ fn build_free<'tcx>(tcx: &ty::ctxt<'tcx>,
633641
args: vec![Operand::Consume(data.value.clone())],
634642
destination: Some((unit_temp, target)),
635643
cleanup: None
636-
});
637-
block
644+
}
638645
}

0 commit comments

Comments
 (0)