From 83c5b4ec40ceadfbcf3c558f06e04c48f01c1e52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 13 Dec 2019 11:37:31 -0800 Subject: [PATCH] Avoid output dependency on std spans --- src/test/ui/issues/issue-21950.rs | 15 ++++-- src/test/ui/issues/issue-21950.stderr | 27 +++++------ src/test/ui/issues/issue-22560.rs | 19 +++++--- src/test/ui/issues/issue-22560.stderr | 66 +++++++++++---------------- 4 files changed, 60 insertions(+), 67 deletions(-) diff --git a/src/test/ui/issues/issue-21950.rs b/src/test/ui/issues/issue-21950.rs index 0bc87824cce..72a98bd8ddd 100644 --- a/src/test/ui/issues/issue-21950.rs +++ b/src/test/ui/issues/issue-21950.rs @@ -1,8 +1,13 @@ -use std::ops::Add; +trait Add { + type Output; +} + +impl Add for i32 { + type Output = i32; +} fn main() { - let x = &10 as - &dyn Add; - //~^ ERROR E0393 - //~| ERROR E0191 + let x = &10 as &dyn Add; + //~^ ERROR E0393 + //~| ERROR E0191 } diff --git a/src/test/ui/issues/issue-21950.stderr b/src/test/ui/issues/issue-21950.stderr index c904236b31b..93c2444f884 100644 --- a/src/test/ui/issues/issue-21950.stderr +++ b/src/test/ui/issues/issue-21950.stderr @@ -1,27 +1,24 @@ error[E0393]: the type parameter `Rhs` must be explicitly specified - --> $DIR/issue-21950.rs:5:18 + --> $DIR/issue-21950.rs:10:25 | -LL | &dyn Add; - | ^^^ help: set the type parameter to the desired type: `Add` - | - ::: $SRC_DIR/libcore/ops/arith.rs:LL:COL - | -LL | / pub trait Add { -LL | | /// The resulting type after applying the `+` operator. -LL | | #[stable(feature = "rust1", since = "1.0.0")] +LL | / trait Add { LL | | type Output; -... | -LL | | fn add(self, rhs: Rhs) -> Self::Output; LL | | } | |_- type parameter `Rhs` must be specified for this +... +LL | let x = &10 as &dyn Add; + | ^^^ help: set the type parameter to the desired type: `Add` | = note: because of the default `Self` reference, type parameters must be specified on object types -error[E0191]: the value of the associated type `Output` (from trait `std::ops::Add`) must be specified - --> $DIR/issue-21950.rs:5:18 +error[E0191]: the value of the associated type `Output` (from trait `Add`) must be specified + --> $DIR/issue-21950.rs:10:25 | -LL | &dyn Add; - | ^^^ help: specify the associated type: `Add` +LL | type Output; + | ------------ `Output` defined here +... +LL | let x = &10 as &dyn Add; + | ^^^ help: specify the associated type: `Add` error: aborting due to 2 previous errors diff --git a/src/test/ui/issues/issue-22560.rs b/src/test/ui/issues/issue-22560.rs index acee99dbedc..44be8817b08 100644 --- a/src/test/ui/issues/issue-22560.rs +++ b/src/test/ui/issues/issue-22560.rs @@ -1,10 +1,15 @@ -use std::ops::{Add, Sub}; +trait Add { + type Output; +} -type Test = dyn Add + - //~^ ERROR E0393 - //~| ERROR E0191 - Sub; - //~^ ERROR E0393 - //~| ERROR E0225 +trait Sub { + type Output; +} + +type Test = dyn Add + Sub; +//~^ ERROR E0393 +//~| ERROR E0191 +//~| ERROR E0393 +//~| ERROR E0225 fn main() { } diff --git a/src/test/ui/issues/issue-22560.stderr b/src/test/ui/issues/issue-22560.stderr index bce49aaf16d..4466a40f0da 100644 --- a/src/test/ui/issues/issue-22560.stderr +++ b/src/test/ui/issues/issue-22560.stderr @@ -1,65 +1,51 @@ error[E0393]: the type parameter `Rhs` must be explicitly specified - --> $DIR/issue-22560.rs:6:13 + --> $DIR/issue-22560.rs:9:23 | -LL | Sub; - | ^^^ help: set the type parameter to the desired type: `Sub` - | - ::: $SRC_DIR/libcore/ops/arith.rs:LL:COL - | -LL | / pub trait Sub { -LL | | /// The resulting type after applying the `-` operator. -LL | | #[stable(feature = "rust1", since = "1.0.0")] +LL | / trait Sub { LL | | type Output; -... | -LL | | fn sub(self, rhs: Rhs) -> Self::Output; LL | | } | |_- type parameter `Rhs` must be specified for this +LL | +LL | type Test = dyn Add + Sub; + | ^^^ help: set the type parameter to the desired type: `Sub` | = note: because of the default `Self` reference, type parameters must be specified on object types error[E0393]: the type parameter `Rhs` must be explicitly specified - --> $DIR/issue-22560.rs:3:17 + --> $DIR/issue-22560.rs:9:17 | -LL | type Test = dyn Add + - | ^^^ help: set the type parameter to the desired type: `Add` - | - ::: $SRC_DIR/libcore/ops/arith.rs:LL:COL - | -LL | / pub trait Add { -LL | | /// The resulting type after applying the `+` operator. -LL | | #[stable(feature = "rust1", since = "1.0.0")] +LL | / trait Add { LL | | type Output; -... | -LL | | fn add(self, rhs: Rhs) -> Self::Output; LL | | } | |_- type parameter `Rhs` must be specified for this +... +LL | type Test = dyn Add + Sub; + | ^^^ help: set the type parameter to the desired type: `Add` | = note: because of the default `Self` reference, type parameters must be specified on object types error[E0225]: only auto traits can be used as additional traits in a trait object - --> $DIR/issue-22560.rs:6:13 + --> $DIR/issue-22560.rs:9:23 | -LL | type Test = dyn Add + - | --- - | | +LL | type Test = dyn Add + Sub; + | --- ^^^ + | | | + | | additional non-auto trait + | | trait alias used in trait object type (additional use) | first non-auto trait | trait alias used in trait object type (first use) -... -LL | Sub; - | ^^^ - | | - | additional non-auto trait - | trait alias used in trait object type (additional use) -error[E0191]: the value of the associated types `Output` (from trait `std::ops::Add`), `Output` (from trait `std::ops::Sub`) must be specified - --> $DIR/issue-22560.rs:3:13 +error[E0191]: the value of the associated types `Output` (from trait `Add`), `Output` (from trait `Sub`) must be specified + --> $DIR/issue-22560.rs:9:13 | -LL | type Test = dyn Add + - | _____________^ -LL | | -LL | | -LL | | Sub; - | |_______________^ associated types `Output`, `Output` must be specified +LL | type Output; + | ------------ `Output` defined here +... +LL | type Output; + | ------------ `Output` defined here +... +LL | type Test = dyn Add + Sub; + | ^^^^^^^^^^^^^ associated types `Output`, `Output` must be specified error: aborting due to 4 previous errors