Skip to content

Commit 607f607

Browse files
committed
Keep track of the whole error chain
1 parent 8818693 commit 607f607

20 files changed

+66
-48
lines changed

src/librustc/middle/traits/select.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1928,6 +1928,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19281928
}
19291929
}
19301930

1931+
#[allow(unused_comparisons)]
19311932
fn derived_cause(&self,
19321933
obligation: &TraitObligation<'tcx>,
19331934
variant: fn(Rc<ty::Binder<ty::TraitRef<'tcx>>>,
@@ -1945,7 +1946,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
19451946
* reporting.
19461947
*/
19471948

1948-
if obligation.recursion_depth == 0 {
1949+
// NOTE(flaper87): As of now, it keeps track of the whole error
1950+
// chain. Ideally, we should have a way to configure this either
1951+
// by using -Z verbose or just a CLI argument.
1952+
if obligation.recursion_depth >= 0 {
19491953
ObligationCause::new(obligation.cause.span,
19501954
obligation.trait_ref.def_id().node,
19511955
variant(obligation.trait_ref.clone(),

src/libsyntax/ext/deriving/bounds.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ pub fn expand_deriving_bound<F>(cx: &mut ExtCtxt,
2626
MetaWord(ref tname) => {
2727
match tname.get() {
2828
"Copy" => "Copy",
29-
"Send" => "Send",
30-
"Sync" => "Sync",
29+
"Send" | "Sync" => {
30+
return cx.span_err(span,
31+
format!("{} is an unsafe trait and it \
32+
should be implemented explicitly", *tname)[])
33+
}
3134
ref tname => {
3235
cx.span_bug(span,
3336
format!("expected built-in trait name but \

src/test/compile-fail/deriving-bounds.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#[deriving(Sync(Bad),Send,Copy)]
11+
#[deriving(Copy(Bad))]
1212
//~^ ERROR unexpected value in deriving, expected a trait
1313
struct Test;
1414

15+
#[deriving(Sync)]
16+
//~^ ERROR Sync is an unsafe trait and it should be implemented explicitly
17+
struct Test1;
18+
1519
pub fn main() {}

src/test/compile-fail/issue-17718-static-sync.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ struct Foo { marker: marker::NoSync }
1414

1515
static FOO: uint = 3;
1616
static BAR: Foo = Foo { marker: marker::NoSync };
17-
//~^ ERROR: shared static items must have a type which implements Sync
17+
//~^ ERROR: the trait `core::kinds::Sync` is not implemented
1818

1919
fn main() {}

src/test/compile-fail/issue-7013.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ struct A {
3333
fn main() {
3434
let a = A {v: box B{v: None} as Box<Foo+Send>};
3535
//~^ ERROR the trait `core::kinds::Send` is not implemented
36+
//~^^ ERROR the trait `core::kinds::Send` is not implemented
3637
}

src/test/compile-fail/issue-7364.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use std::cell::RefCell;
1414
// Regresion test for issue 7364
1515
static boxed: Box<RefCell<int>> = box RefCell::new(0);
1616
//~^ ERROR statics are not allowed to have custom pointers
17-
//~^^ ERROR: shared static items must have a type which implements Sync
17+
//~^^ ERROR: the trait `core::kinds::Sync` is not implemented for the type
18+
//~^^^ ERROR: the trait `core::kinds::Sync` is not implemented for the type
19+
//~^^^^ ERROR: the trait `core::kinds::Sync` is not implemented for the type
1820

1921
fn main() { }

src/test/compile-fail/kindck-destructor-owned.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,6 @@
99
// except according to those terms.
1010

1111

12-
use std::rc::Rc;
13-
14-
struct Foo {
15-
f: Rc<int>,
16-
}
17-
18-
impl Drop for Foo {
19-
//~^ ERROR the trait `core::kinds::Send` is not implemented
20-
//~^^ NOTE cannot implement a destructor on a structure or enumeration that does not satisfy Send
21-
fn drop(&mut self) {
22-
}
23-
}
24-
2512
struct Bar<'a> {
2613
f: &'a int,
2714
}

src/test/compile-fail/kindck-nonsendable-1.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ fn bar<F:FnOnce() + Send>(_: F) { }
1717

1818
fn main() {
1919
let x = Rc::new(3u);
20-
bar(move|| foo(x)); //~ ERROR `core::kinds::Send` is not implemented
20+
bar(move|| foo(x));
21+
//~^ ERROR `core::kinds::Send` is not implemented
22+
//~^^ ERROR `core::kinds::Send` is not implemented
2123
}
2224

src/test/compile-fail/kindck-send-unsafe.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
extern crate core;
12+
1113
fn assert_send<T:Send>() { }
1214

13-
// unsafe ptrs are ok unless they point at unsendable things
14-
fn test70() {
15-
assert_send::<*mut int>();
16-
}
1715
fn test71<'a>() {
18-
assert_send::<*mut &'a int>(); //~ ERROR declared lifetime bound not satisfied
16+
assert_send::<*mut &'a int>();
17+
//~^ ERROR the trait `core::kinds::Send` is not implemented for the type
1918
}
2019

2120
fn main() {

src/test/compile-fail/mut-not-freeze.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,8 @@ fn f<T: Sync>(_: T) {}
1414

1515
fn main() {
1616
let x = RefCell::new(0i);
17-
f(x); //~ ERROR `core::kinds::Sync` is not implemented
17+
f(x);
18+
//~^ ERROR `core::kinds::Sync` is not implemented
19+
//~^^ ERROR `core::kinds::Sync` is not implemented
20+
//~^^^ ERROR `core::kinds::Sync` is not implemented
1821
}

0 commit comments

Comments
 (0)