Skip to content

Rollup of 6 pull requests #31421

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mk/rt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ COMPRT_AR_$(1) := $$(AR_$(1))
# We chomp -Werror here because GCC warns about the type signature of
# builtins not matching its own and the build fails. It's a bit hacky,
# but what can we do, we're building libclang-rt using GCC ......
COMPRT_CFLAGS_$(1) := $$(subst -Werror,,$$(CFG_GCCISH_CFLAGS_$(1))) -std=c99
COMPRT_CFLAGS_$(1) := $$(filter-out -Werror -Werror=*,$$(CFG_GCCISH_CFLAGS_$(1))) -std=c99

# FreeBSD Clang's packaging is problematic; it doesn't copy unwind.h to
# the standard include directory. This should really be in our changes to
Expand Down
3 changes: 2 additions & 1 deletion mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,8 @@ $(3)/test/run-make/%-$(1)-T-$(2)-H-$(3).ok: \
$$(S) \
$(3) \
"$$(LLVM_LIBDIR_RUSTFLAGS_$(3))" \
"$$(LLVM_ALL_COMPONENTS_$(3))"
"$$(LLVM_ALL_COMPONENTS_$(3))" \
"$$(LLVM_CXXFLAGS_$(3))"
@touch -r [email protected]_time $$@ && rm [email protected]_time
else
# FIXME #11094 - The above rule doesn't work right for multiple targets
Expand Down
1 change: 1 addition & 0 deletions src/etc/maketest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def convert_path_spec(name, value):
putenv('S', os.path.abspath(sys.argv[13]))
putenv('RUSTFLAGS', sys.argv[15])
putenv('LLVM_COMPONENTS', sys.argv[16])
putenv('LLVM_CXXFLAGS', sys.argv[17])
putenv('PYTHON', sys.executable)
os.putenv('TARGET', target_triple)

Expand Down
14 changes: 14 additions & 0 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,20 @@ impl<'a> From<&'a str> for Vec<u8> {
// Clone-on-write
////////////////////////////////////////////////////////////////////////////////

#[stable(feature = "cow_from_vec", since = "1.7.0")]
impl<'a, T: Clone> From<&'a [T]> for Cow<'a, [T]> {
fn from(s: &'a [T]) -> Cow<'a, [T]> {
Cow::Borrowed(s)
}
}

#[stable(feature = "cow_from_vec", since = "1.7.0")]
impl<'a, T: Clone> From<Vec<T>> for Cow<'a, [T]> {
fn from(v: Vec<T>) -> Cow<'a, [T]> {
Cow::Owned(v)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone {
fn from_iter<I: IntoIterator<Item = T>>(it: I) -> Cow<'a, [T]> {
Expand Down
11 changes: 11 additions & 0 deletions src/libcollectionstest/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::borrow::Cow;
use std::cmp::Ordering::{Equal, Greater, Less};
use std::str::from_utf8;

Expand Down Expand Up @@ -1267,6 +1268,16 @@ fn test_box_slice_clone() {
assert_eq!(data, data2);
}

#[test]
fn test_cow_from() {
let borrowed = "borrowed";
let owned = String::from("owned");
match (Cow::from(owned.clone()), Cow::from(borrowed)) {
(Cow::Owned(o), Cow::Borrowed(b)) => assert!(o == owned && b == borrowed),
_ => panic!("invalid `Cow::from`"),
}
}

mod pattern {
use std::str::pattern::Pattern;
use std::str::pattern::{Searcher, ReverseSearcher};
Expand Down
11 changes: 11 additions & 0 deletions src/libcollectionstest/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::borrow::Cow;
use std::iter::{FromIterator, repeat};
use std::mem::size_of;

Expand Down Expand Up @@ -466,6 +467,16 @@ fn test_into_iter_count() {
assert_eq!(vec![1, 2, 3].into_iter().count(), 3);
}

#[test]
fn test_cow_from() {
let borrowed: &[_] = &["borrowed", "(slice)"];
let owned = vec!["owned", "(vec)"];
match (Cow::from(owned.clone()), Cow::from(borrowed)) {
(Cow::Owned(o), Cow::Borrowed(b)) => assert!(o == owned && b == borrowed),
_ => panic!("invalid `Cow::from`"),
}
}

#[bench]
fn bench_new(b: &mut Bencher) {
b.iter(|| {
Expand Down
37 changes: 24 additions & 13 deletions src/librustc_trans/trans/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ pub enum UnwindKind {
pub struct CachedEarlyExit {
label: EarlyExitLabel,
cleanup_block: BasicBlockRef,
last_cleanup: usize,
}

pub trait Cleanup<'tcx> {
Expand Down Expand Up @@ -560,7 +561,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
for scope in self.scopes.borrow_mut().iter_mut().rev() {
if scope.kind.is_ast_with_id(cleanup_scope) {
scope.cleanups.push(cleanup);
scope.clear_cached_exits();
scope.cached_landing_pad = None;
return;
} else {
// will be adding a cleanup to some enclosing scope
Expand All @@ -585,7 +586,7 @@ impl<'blk, 'tcx> CleanupMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx> {
let mut scopes = self.scopes.borrow_mut();
let scope = &mut (*scopes)[custom_scope.index];
scope.cleanups.push(cleanup);
scope.clear_cached_exits();
scope.cached_landing_pad = None;
}

/// Returns true if there are pending cleanups that should execute on panic.
Expand Down Expand Up @@ -723,6 +724,7 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
let orig_scopes_len = self.scopes_len();
let mut prev_llbb;
let mut popped_scopes = vec!();
let mut skip = 0;

// First we pop off all the cleanup stacks that are
// traversed until the exit is reached, pushing them
Expand Down Expand Up @@ -769,20 +771,25 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
}
}

// Pop off the scope, since we may be generating
// unwinding code for it.
let top_scope = self.pop_scope();
let cached_exit = top_scope.cached_early_exit(label);
popped_scopes.push(top_scope);

// Check if we have already cached the unwinding of this
// scope for this label. If so, we can stop popping scopes
// and branch to the cached label, since it contains the
// cleanups for any subsequent scopes.
if let Some(exit) = self.top_scope(|s| s.cached_early_exit(label)) {
if let Some((exit, last_cleanup)) = cached_exit {
prev_llbb = exit;
skip = last_cleanup;
break;
}

// Pop off the scope, since we will be generating
// unwinding code for it. If we are searching for a loop exit,
// If we are searching for a loop exit,
// and this scope is that loop, then stop popping and set
// `prev_llbb` to the appropriate exit block from the loop.
popped_scopes.push(self.pop_scope());
let scope = popped_scopes.last().unwrap();
match label {
UnwindExit(..) | ReturnExit => { }
Expand Down Expand Up @@ -826,13 +833,15 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx
let bcx_in = self.new_block(&name[..], None);
let exit_label = label.start(bcx_in);
let mut bcx_out = bcx_in;
for cleanup in scope.cleanups.iter().rev() {
let len = scope.cleanups.len();
for cleanup in scope.cleanups.iter().rev().take(len - skip) {
bcx_out = cleanup.trans(bcx_out, scope.debug_loc);
}
skip = 0;
exit_label.branch(bcx_out, prev_llbb);
prev_llbb = bcx_in.llbb;

scope.add_cached_early_exit(exit_label, prev_llbb);
scope.add_cached_early_exit(exit_label, prev_llbb, len);
}
self.push_scope(scope);
}
Expand Down Expand Up @@ -938,18 +947,20 @@ impl<'blk, 'tcx> CleanupScope<'blk, 'tcx> {

fn cached_early_exit(&self,
label: EarlyExitLabel)
-> Option<BasicBlockRef> {
self.cached_early_exits.iter().
-> Option<(BasicBlockRef, usize)> {
self.cached_early_exits.iter().rev().
find(|e| e.label == label).
map(|e| e.cleanup_block)
map(|e| (e.cleanup_block, e.last_cleanup))
}

fn add_cached_early_exit(&mut self,
label: EarlyExitLabel,
blk: BasicBlockRef) {
blk: BasicBlockRef,
last_cleanup: usize) {
self.cached_early_exits.push(
CachedEarlyExit { label: label,
cleanup_block: blk });
cleanup_block: blk,
last_cleanup: last_cleanup});
}

/// True if this scope has cleanups that need unwinding
Expand Down
20 changes: 10 additions & 10 deletions src/libsyntax/errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ impl EmitterWriter {
chars.next();
}
}
if (col - col_ptr) > 1 {
if (col - col_ptr) > 0 {
// One extra squiggly is replaced by a "^"
s.pop();
}
Expand Down Expand Up @@ -962,7 +962,7 @@ mod test {
_____\n\
ddd__eee_\n\
elided\n\
_ff_gg";
__f_gg";
let file = cm.new_filemap_and_lines("dummy.txt", inp);

let span = |lo, hi, (off_lo, off_hi)| {
Expand All @@ -976,7 +976,7 @@ mod test {
let sp1 = span(0, 6, (0, 5));
let sp2 = span(8, 8, (0, 3));
let sp3 = span(8, 8, (5, 8));
let sp4 = span(10, 10, (1, 3));
let sp4 = span(10, 10, (2, 3));
let sp5 = span(10, 10, (4, 6));

let expect0 = "dummy.txt: 5 ccccc\n\
Expand All @@ -986,8 +986,8 @@ mod test {
dummy.txt: 9 ddd__eee_\n\
\x20 ^~~ ^~~\n\
\x20 ...\n\
dummy.txt:11 _ff_gg\n\
\x20 ^~ ^~\n";
dummy.txt:11 __f_gg\n\
\x20 ^ ^~\n";

let expect = "dummy.txt: 1 aaaaa\n\
dummy.txt: 2 aaaaa\n\
Expand All @@ -1008,8 +1008,8 @@ mod test {
let expect2 = "dummy.txt: 9 ddd__eee_\n\
\x20 ^~~ ^~~\n\
\x20 ...\n\
dummy.txt:11 _ff_gg\n\
\x20 ^~ ^~\n";
dummy.txt:11 __f_gg\n\
\x20 ^ ^~\n";


let expect_end = "dummy.txt: 1 aaaaa\n\
Expand All @@ -1020,7 +1020,7 @@ mod test {
dummy.txt: 9 ddd__eee_\n\
\x20 ^ ^\n\
\x20 ...\n\
dummy.txt:11 _ff_gg\n\
dummy.txt:11 __f_gg\n\
\x20 ^ ^\n";

let expect0_end = "dummy.txt: 5 ccccc\n\
Expand All @@ -1031,7 +1031,7 @@ mod test {
dummy.txt: 9 ddd__eee_\n\
\x20 ^ ^\n\
\x20 ...\n\
dummy.txt:11 _ff_gg\n\
dummy.txt:11 __f_gg\n\
\x20 ^ ^\n";

let expect_end_g1 = "dummy.txt:1 aaaaa\n\
Expand All @@ -1042,7 +1042,7 @@ mod test {
let expect2_end = "dummy.txt: 9 ddd__eee_\n\
\x20 ^ ^\n\
\x20 ...\n\
dummy.txt:11 _ff_gg\n\
dummy.txt:11 __f_gg\n\
\x20 ^ ^\n";

let expect_groups = [expect2, expect_g1];
Expand Down
3 changes: 0 additions & 3 deletions src/libsyntax_ext/deriving/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ pub mod decodable;
pub mod hash;
pub mod debug;
pub mod default;
pub mod primitive;

#[path="cmp/partial_eq.rs"]
pub mod partial_eq;
Expand Down Expand Up @@ -178,8 +177,6 @@ derive_traits! {

"Default" => default::expand_deriving_default,

"FromPrimitive" => primitive::expand_deriving_from_primitive,

"Send" => bounds::expand_deriving_unsafe_bound,
"Sync" => bounds::expand_deriving_unsafe_bound,
"Copy" => bounds::expand_deriving_copy,
Expand Down
Loading