1
Fork 0

Fix error spans for arguments to tuple enum constructors

This commit is contained in:
Nathan Fenner 2023-02-28 14:58:14 -08:00
parent 2566b4105d
commit f0212e6532
3 changed files with 371 additions and 11 deletions

View file

@ -24,6 +24,31 @@ impl<'a, A: T1> T1 for &'a A {}
fn want<V: T1>(_x: V) {}
enum ExampleTuple<T> {
ExampleTupleVariant(T),
}
use ExampleDifferentTupleVariantName as ExampleYetAnotherTupleVariantName;
use ExampleTuple as ExampleOtherTuple;
use ExampleTuple::ExampleTupleVariant as ExampleDifferentTupleVariantName;
use ExampleTuple::*;
impl<A> T1 for ExampleTuple<A> where A: T3 {}
enum ExampleStruct<T> {
ExampleStructVariant { field: T },
}
use ExampleDifferentStructVariantName as ExampleYetAnotherStructVariantName;
use ExampleStruct as ExampleOtherStruct;
use ExampleStruct::ExampleStructVariant as ExampleDifferentStructVariantName;
use ExampleStruct::*;
impl<A> T1 for ExampleStruct<A> where A: T3 {}
struct ExampleActuallyTupleStruct<T>(T, i32);
use ExampleActuallyTupleStruct as ExampleActuallyTupleStructOther;
impl<A> T1 for ExampleActuallyTupleStruct<A> where A: T3 {}
fn example<Q>(q: Q) {
want(Wrapper { value: Burrito { filling: q } });
//~^ ERROR the trait bound `Q: T3` is not satisfied [E0277]
@ -36,6 +61,42 @@ fn example<Q>(q: Q) {
want(&Some(q));
//~^ ERROR `Q` is not an iterator [E0277]
want(&ExampleTuple::ExampleTupleVariant(q));
//~^ ERROR `Q: T3` is not satisfied [E0277]
want(&ExampleTupleVariant(q));
//~^ ERROR `Q: T3` is not satisfied [E0277]
want(&ExampleOtherTuple::ExampleTupleVariant(q));
//~^ ERROR `Q: T3` is not satisfied [E0277]
want(&ExampleDifferentTupleVariantName(q));
//~^ ERROR `Q: T3` is not satisfied [E0277]
want(&ExampleYetAnotherTupleVariantName(q));
//~^ ERROR `Q: T3` is not satisfied [E0277]
want(&ExampleStruct::ExampleStructVariant { field: q });
//~^ ERROR `Q: T3` is not satisfied [E0277]
want(&ExampleStructVariant { field: q });
//~^ ERROR `Q: T3` is not satisfied [E0277]
want(&ExampleOtherStruct::ExampleStructVariant { field: q });
//~^ ERROR `Q: T3` is not satisfied [E0277]
want(&ExampleDifferentStructVariantName { field: q });
//~^ ERROR `Q: T3` is not satisfied [E0277]
want(&ExampleYetAnotherStructVariantName { field: q });
//~^ ERROR `Q: T3` is not satisfied [E0277]
want(&ExampleActuallyTupleStruct(q, 0));
//~^ ERROR `Q: T3` is not satisfied [E0277]
want(&ExampleActuallyTupleStructOther(q, 0));
//~^ ERROR `Q: T3` is not satisfied [E0277]
}
fn main() {}