Skip to content

Commit 30d8eff

Browse files
committed
test the substs ppaux code both with and without -Z verbose
1 parent 832b707 commit 30d8eff

File tree

3 files changed

+65
-48
lines changed

3 files changed

+65
-48
lines changed

src/librustc/traits/error_reporting.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,8 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
436436
// If we can't show anything useful, try to find
437437
// similar impls.
438438

439-
let impl_candidates = find_similar_impl_candidates(infcx, trait_ref);
439+
let impl_candidates =
440+
find_similar_impl_candidates(infcx, trait_ref);
440441
if impl_candidates.len() > 0 {
441442
report_similar_impl_candidates(obligation.cause.span,
442443
&mut err, &impl_candidates);

src/test/compile-fail/substs-ppaux.rs

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
//
11+
// revisions: verbose normal
12+
//
13+
//[verbose] compile-flags: -Z verbose
14+
//
15+
// TODO nikomatsakis: test with both verbose and without
16+
17+
trait Foo<'b, 'c, S=u32> {
18+
fn bar<'a, T>() where T: 'a {}
19+
fn baz() {}
20+
}
21+
22+
impl<'a,'b,T,S> Foo<'a, 'b, S> for T {}
23+
24+
fn main() {}
25+
26+
fn foo<'z>() where &'z (): Sized {
27+
let x: () = <i8 as Foo<'static, 'static, u8>>::bar::<'static, char>;
28+
//[verbose]~^ ERROR mismatched types
29+
//[verbose]~| expected `()`
30+
//[verbose]~| found `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::bar::<ReStatic, char>}`
31+
//[normal]~^^^^ ERROR mismatched types
32+
//[normal]~| expected `()`
33+
//[normal]~| found `fn() {<i8 as Foo<'static, 'static, u8>>::bar::<'static, char>}`
34+
35+
36+
let x: () = <i8 as Foo<'static, 'static, u32>>::bar::<'static, char>;
37+
//[verbose]~^ ERROR mismatched types
38+
//[verbose]~| expected `()`
39+
//[verbose]~| found `fn() {<i8 as Foo<ReStatic, ReStatic, u32>>::bar::<ReStatic, char>}`
40+
//[normal]~^^^^ ERROR mismatched types
41+
//[normal]~| expected `()`
42+
//[normal]~| found `fn() {<i8 as Foo<'static, 'static>>::bar::<'static, char>}`
43+
44+
let x: () = <i8 as Foo<'static, 'static, u8>>::baz;
45+
//[verbose]~^ ERROR mismatched types
46+
//[verbose]~| expected `()`
47+
//[verbose]~| found `fn() {<i8 as Foo<ReStatic, ReStatic, u8>>::baz}`
48+
//[normal]~^^^^ ERROR mismatched types
49+
//[normal]~| expected `()`
50+
//[normal]~| found `fn() {<i8 as Foo<'static, 'static, u8>>::baz}`
51+
52+
let x: () = foo::<'static>;
53+
//[verbose]~^ ERROR mismatched types
54+
//[verbose]~| expected `()`
55+
//[verbose]~| found `fn() {foo::<ReStatic>}`
56+
//[normal]~^^^^ ERROR mismatched types
57+
//[normal]~| expected `()`
58+
//[normal]~| found `fn() {foo::<'static>}`
59+
60+
<str as Foo<u8>>::bar;
61+
//[verbose]~^ ERROR `str: std::marker::Sized` is not satisfied
62+
//[normal]~^^ ERROR `str: std::marker::Sized` is not satisfied
63+
}

src/test/compile-fail/substs-verbose.rs

-47
This file was deleted.

0 commit comments

Comments
 (0)