Respect test style guidelines in tests::traits

This commit is contained in:
Lukas Wirth 2021-04-10 18:03:27 +02:00
parent 4bf32eea21
commit 8113c3a914

View File

@ -270,8 +270,7 @@ fn infer_from_bound_1() {
fn test() {
let s = S(unknown);
foo(s);
}
"#,
}"#,
expect![[r#"
85..86 't': T
91..93 '{}': ()
@ -298,8 +297,7 @@ fn infer_from_bound_2() {
fn test() {
let s = S(unknown);
let x: u32 = foo(s);
}
"#,
}"#,
expect![[r#"
86..87 't': T
97..99 '{}': ()
@ -326,8 +324,7 @@ fn trait_default_method_self_bound_implements_trait() {
fn bar(&self) -> {
let x = self.foo();
}
}
"#,
}"#,
expect![[r#"
26..30 'self': &Self
52..56 'self': &Self
@ -350,8 +347,7 @@ fn trait_default_method_self_bound_implements_super_trait() {
fn bar(&self) -> {
let x = self.foo();
}
}
"#,
}"#,
expect![[r#"
31..35 'self': &Self
85..89 'self': &Self
@ -377,8 +373,7 @@ fn infer_project_associated_type() {
let y: <T as Iterable>::Item = no_matter;
let z: T::Item = no_matter;
let a: <T>::Item = no_matter;
}
"#,
}"#,
expect![[r#"
108..261 '{ ...ter; }': ()
118..119 'x': u32
@ -409,8 +404,7 @@ fn infer_return_associated_type() {
let x = foo1(S);
let y = foo2(S);
let z = foo3(S);
}
"#,
}"#,
expect![[r#"
106..107 't': T
123..125 '{}': ()
@ -444,8 +438,7 @@ fn infer_associated_type_bound() {
}
fn test<T: Iterable<Item=u32>>() {
let y: T::Item = unknown;
}
"#,
}"#,
expect![[r#"
67..100 '{ ...own; }': ()
77..78 'y': u32
@ -459,8 +452,7 @@ fn infer_const_body() {
check_infer(
r#"
const A: u32 = 1 + 1;
static B: u64 = { let x = 1; x };
"#,
static B: u64 = { let x = 1; x };"#,
expect![[r#"
15..16 '1': u32
15..20 '1 + 1': u32
@ -482,8 +474,7 @@ fn tuple_struct_fields() {
let a = S(4, 6);
let b = a.0;
a.1
}
"#,
}"#,
expect![[r#"
37..86 '{ ... a.1 }': u64
47..48 'a': S
@ -509,8 +500,7 @@ fn tuple_struct_with_fn() {
let a = S(|i| 2*i);
let b = a.0(4);
a.0(2)
}
"#,
}"#,
expect![[r#"
43..101 '{ ...0(2) }': u64
53..54 'a': S
@ -968,8 +958,7 @@ fn argument_impl_trait() {
x.foo2();
y.foo2();
z.foo2();
}
"#,
}"#,
expect![[r#"
29..33 'self': &Self
54..58 'self': &Self
@ -1029,8 +1018,7 @@ fn argument_impl_trait_type_args_1() {
foo(S);
foo::<u32>(S);
foo::<u32, i32>(S); // we should ignore the extraneous i32
}
"#,
}"#,
expect![[r#"
155..156 'x': impl Trait
175..186 '{ loop {} }': T
@ -1086,8 +1074,7 @@ fn argument_impl_trait_type_args_2() {
F::<u32>.foo(S);
F::<u32>.foo::<i32>(S);
F::<u32>.foo::<i32, u32>(S); // extraneous argument should be ignored
}
"#,
}"#,
expect![[r#"
87..91 'self': F<T>
93..94 'x': impl Trait
@ -1122,8 +1109,7 @@ fn argument_impl_trait_to_fn_pointer() {
fn test() {
let f: fn(S) -> () = foo;
}
"#,
}"#,
expect![[r#"
22..23 'x': impl Trait
37..48 '{ loop {} }': ()
@ -1156,8 +1142,7 @@ fn impl_trait() {
x.foo2();
y.foo2();
z.foo2();
}
"#,
}"#,
expect![[r#"
29..33 'self': &Self
54..58 'self': &Self
@ -1199,8 +1184,7 @@ fn simple_return_pos_impl_trait() {
fn test() {
let a = bar();
a.foo();
}
"#,
}"#,
expect![[r#"
29..33 'self': &Self
71..82 '{ loop {} }': !
@ -1237,8 +1221,7 @@ fn more_return_pos_impl_trait() {
let (c, d) = baz(1u128);
c.next().foo();
d.foo();
}
"#,
}"#,
expect![[r#"
49..53 'self': &mut Self
101..105 'self': &Self
@ -1295,8 +1278,7 @@ fn dyn_trait() {
x.foo2();
y.foo2();
z.foo2();
}
"#,
}"#,
expect![[r#"
29..33 'self': &Self
54..58 'self': &Self
@ -1343,8 +1325,7 @@ fn dyn_trait_in_impl() {
fn test(s: S<u32, i32>) {
s.bar().baz();
}
"#,
}"#,
expect![[r#"
32..36 'self': &Self
102..106 'self': &S<T, U>
@ -1377,8 +1358,7 @@ fn dyn_trait_bare() {
x.foo();
y.foo();
z.foo();
}
"#,
}"#,
expect![[r#"
26..30 'self': &Self
60..62 '{}': ()
@ -1405,16 +1385,23 @@ fn weird_bounds() {
check_infer(
r#"
trait Trait {}
fn test(a: impl Trait + 'lifetime, b: impl 'lifetime, c: impl (Trait), d: impl ('lifetime), e: impl ?Sized, f: impl Trait + ?Sized) {}
fn test(
a: impl Trait + 'lifetime,
b: impl 'lifetime,
c: impl (Trait),
d: impl ('lifetime),
e: impl ?Sized,
f: impl Trait + ?Sized
) {}
"#,
expect![[r#"
23..24 'a': impl Trait
50..51 'b': impl
69..70 'c': impl Trait
86..87 'd': impl
107..108 'e': impl
123..124 'f': impl Trait
147..149 '{}': ()
28..29 'a': impl Trait
59..60 'b': impl
82..83 'c': impl Trait
103..104 'd': impl
128..129 'e': impl
148..149 'f': impl Trait
173..175 '{}': ()
"#]],
);
}
@ -1458,8 +1445,7 @@ fn assoc_type_bindings() {
get(set(S));
get2(set(S));
get2(S::<str>);
}
"#,
}"#,
expect![[r#"
49..50 't': T
77..79 '{}': ()
@ -1556,8 +1542,7 @@ fn projection_eq_within_chalk() {
fn test<T: Trait1<Type = u32>>(x: T) {
x.foo();
}
"#,
}"#,
expect![[r#"
61..65 'self': Self
163..164 'x': T
@ -1600,8 +1585,7 @@ fn super_trait_method_resolution() {
fn test<T: Trait1, U: Trait2>(x: T, y: U) {
x.foo();
y.foo();
}
"#,
}"#,
expect![[r#"
49..53 'self': &Self
62..64 '{}': ()
@ -1629,8 +1613,7 @@ fn super_trait_impl_trait_method_resolution() {
fn test(x: &impl Trait1) {
x.foo();
}
"#,
}"#,
expect![[r#"
49..53 'self': &Self
62..64 '{}': ()
@ -1679,8 +1662,7 @@ fn super_trait_assoc_type_bounds() {
fn test() {
get2(set(S));
}
"#,
}"#,
expect![[r#"
102..103 't': T
113..115 '{}': ()
@ -1709,8 +1691,7 @@ fn fn_trait() {
fn test<F: FnOnce(u32, u64) -> u128>(f: F) {
f.call_once((1, 2));
}
"#,
}"#,
expect![[r#"
56..60 'self': Self
62..66 'args': Args
@ -1758,8 +1739,7 @@ fn fn_ptr_and_item() {
let opt: Opt<u8>;
let f: fn(u8) -> u32;
opt.map(f);
}
"#,
}"#,
expect![[r#"
74..78 'self': Self
80..84 'args': Args
@ -1828,8 +1808,7 @@ fn fn_trait_deref_with_ty_default() {
let make_foo_fn_ptr: fn() -> Foo = make_foo_fn;
let lazy2: Lazy<Foo, _> = Lazy::new(make_foo_fn_ptr);
let r2 = lazy2.foo();
}
"#,
}"#,
expect![[r#"
64..68 'self': &Self
165..169 'self': Self
@ -1880,8 +1859,7 @@ fn closure_1() {
x.map(|v| v + 1);
x.map(|_v| 1u64);
let y: Option<i64> = x.map(|_v| 1);
}
"#,
}"#,
expect![[r#"
147..151 'self': Option<T>
153..154 'f': F
@ -1944,8 +1922,7 @@ fn closure_2() {
let g = |v| v + 1;
g(1u64);
let h = |v| 1u128 + v;
}
"#,
}"#,
expect![[r#"
72..76 'self': Self
78..81 'rhs': Rhs
@ -2006,8 +1983,7 @@ fn closure_as_argument_inference_order() {
let x2 = foo2(|s| s.method(), S);
let x3 = S.foo1(S, |s| s.method());
let x4 = S.foo2(|s| s.method(), S);
}
"#,
}"#,
expect![[r#"
94..95 'x': T
100..101 'f': F
@ -2155,8 +2131,7 @@ fn unselected_projection_on_impl_self() {
impl Trait for S2 {
type Item = i32;
fn f(&self, x: <Self>::Item) { let y = x; }
}
"#,
}"#,
expect![[r#"
40..44 'self': &Self
46..47 'x': Trait::Item<Self>
@ -2442,8 +2417,7 @@ fn proc_macro_server_types() {
let group: Self::Group = make();
make()
}
}
"#,
}"#,
expect![[r#"
1061..1072 '{ loop {} }': T
1063..1070 'loop {}': !
@ -2477,8 +2451,7 @@ fn unify_impl_trait() {
foo(s1);
let x: i32 = bar(S(default()));
S(default())
}
"#,
}"#,
expect![[r#"
26..27 'x': impl Trait<u32>
46..57 '{ loop {} }': ()
@ -2541,8 +2514,7 @@ fn assoc_types_from_bounds() {
fn main() {
f::<(), _>(|z| { z; });
}
"#,
}"#,
expect![[r#"
133..135 '_v': F
178..181 '{ }': ()
@ -2696,8 +2668,7 @@ fn iterator_chain() {
Vec::<i32>::new().into_iter()
.filter_map(|x| if x > 0 { Some(x as u32) } else { None })
.for_each(|y| { y; });
}
"#,
}"#,
expect![[r#"
226..230 'self': Self
232..233 'f': F
@ -2785,8 +2756,7 @@ fn trait_object_no_coercion() {
fn test(x: &dyn Foo) {
foo(x);
}
"#,
}"#,
expect![[r#"
21..22 'x': &dyn Foo
34..36 '{}': ()
@ -2818,8 +2788,7 @@ fn builtin_copy() {
NotCopy.test();
(IsCopy, IsCopy).test();
(IsCopy, NotCopy).test();
}
"#,
}"#,
expect![[r#"
110..114 'self': &Self
166..267 '{ ...t(); }': ()
@ -2859,8 +2828,7 @@ fn builtin_fn_def_copy() {
bar.test();
Struct.test();
Enum::Variant.test();
}
"#,
}"#,
expect![[r#"
41..43 '{}': ()
60..61 'T': {unknown}
@ -2894,8 +2862,7 @@ fn builtin_fn_ptr_copy() {
f1.test();
f2.test();
f3.test();
}
"#,
}"#,
expect![[r#"
54..58 'self': &Self
108..110 'f1': fn()
@ -2927,8 +2894,7 @@ fn builtin_sized() {
(*"foo").test(); // not Sized
(1u8, 1u8).test();
(1u8, *"foo").test(); // not Sized
}
"#,
}"#,
expect![[r#"
56..60 'self': &Self
113..228 '{ ...ized }': ()
@ -3009,8 +2975,7 @@ fn infer_closure_arg() {
let s = Option::None;
let f = |x: Option<i32>| {};
(&f)(s)
}
"#,
}"#,
expect![[r#"
52..126 '{ ...)(s) }': ()
62..63 's': Option<i32>
@ -3117,8 +3082,7 @@ fn infer_box_fn_arg() {
let s = Option::None;
let f: Box<dyn FnOnce(&Option<i32>)> = box (|ps| {});
f(&s);
}
"#,
}"#,
expect![[r#"
100..104 'self': Self
106..110 'args': Args
@ -3284,8 +3248,7 @@ fn f() {
().method();
//^^^^^^^^^^^ u8
}
}
"#,
}"#,
expect![[r#"
46..50 'self': &Self
58..63 '{ 0 }': u8
@ -3339,8 +3302,7 @@ fn f() {
fn inner() -> S {
let s = inner();
}
}
"#,
}"#,
expect![[r#"
17..73 '{ ... } }': ()
39..71 '{ ... }': ()
@ -3375,8 +3337,7 @@ fn test() {
let x = A;
let y = A;
let r = x.do_op(y);
}
"#,
}"#,
expect![[r#"
63..67 'self': Self
69..72 'rhs': RHS
@ -3425,9 +3386,7 @@ impl foo::Bar for F {
fn foo() {
use foo::Bar;
let x = <F as Bar>::boo();
}
"#,
}"#,
expect![[r#"
132..163 '{ ... }': Bar::Output<Self>
146..153 'loop {}': !
@ -3465,8 +3424,7 @@ fn foo() {
pub trait Deserialize {
fn deserialize() -> u8;
}
"#,
}"#,
);
}