Auto merge of #72433 - RalfJung:rollup-srft8nx, r=RalfJung

Rollup of 7 pull requests

Successful merges:

 - #72055 (Intern predicates)
 - #72149 (Don't `type_of` on trait assoc ty without default)
 - #72347 (Make intra-link resolve links for both trait and impl items)
 - #72350 (Improve documentation of `slice::from_raw_parts`)
 - #72382 (Show default values for debug-assertions & debug-assertions-std)
 - #72421 (Fix anchor display when hovering impl)
 - #72425 (fix discriminant_value sign extension)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-05-21 22:14:26 +00:00
commit d9417b3851
72 changed files with 942 additions and 683 deletions

View file

@ -0,0 +1,6 @@
trait X {
type S;
fn f() -> Self::S {} //~ ERROR mismatched types
}
fn main() {}

View file

@ -0,0 +1,14 @@
error[E0308]: mismatched types
--> $DIR/issue-72076.rs:3:23
|
LL | fn f() -> Self::S {}
| ^^ expected associated type, found `()`
|
= note: expected associated type `<Self as X>::S`
found unit type `()`
= help: consider constraining the associated type `<Self as X>::S` to `()` or calling a method that returns `<Self as X>::S`
= note: for more information, visit https://doc.rust-lang.org/book/ch19-03-advanced-traits.html
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.

View file

@ -7,6 +7,7 @@ trait Trait<T = Self> {
fn func(&self) -> Self::A;
fn funk(&self, _: Self::A);
fn funq(&self) -> Self::A {} //~ ERROR mismatched types
}
fn foo(_: impl Trait, x: impl Trait) {

View file

@ -1,5 +1,19 @@
error[E0308]: mismatched types
--> $DIR/trait-with-missing-associated-type-restriction.rs:13:9
--> $DIR/trait-with-missing-associated-type-restriction.rs:10:31
|
LL | fn funq(&self) -> Self::A {}
| ^^ expected associated type, found `()`
|
= note: expected associated type `<Self as Trait<T>>::A`
found unit type `()`
help: a method is available that returns `<Self as Trait<T>>::A`
--> $DIR/trait-with-missing-associated-type-restriction.rs:8:5
|
LL | fn func(&self) -> Self::A;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ consider calling `Trait::func`
error[E0308]: mismatched types
--> $DIR/trait-with-missing-associated-type-restriction.rs:14:9
|
LL | qux(x.func())
| ^^^^^^^^ expected `usize`, found associated type
@ -12,7 +26,7 @@ LL | fn foo(_: impl Trait, x: impl Trait<A = usize>) {
| ^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/trait-with-missing-associated-type-restriction.rs:17:9
--> $DIR/trait-with-missing-associated-type-restriction.rs:18:9
|
LL | qux(x.func())
| ^^^^^^^^ expected `usize`, found associated type
@ -25,7 +39,7 @@ LL | fn bar<T: Trait<A = usize>>(x: T) {
| ^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/trait-with-missing-associated-type-restriction.rs:21:9
--> $DIR/trait-with-missing-associated-type-restriction.rs:22:9
|
LL | qux(x.func())
| ^^^^^^^^ expected `usize`, found associated type
@ -38,25 +52,28 @@ LL | fn foo2(x: impl Trait<i32, A = usize>) {
| ^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/trait-with-missing-associated-type-restriction.rs:25:12
--> $DIR/trait-with-missing-associated-type-restriction.rs:26:12
|
LL | x.funk(3);
| ^ expected associated type, found integer
|
= note: expected associated type `<T as Trait<i32>>::A`
found type `{integer}`
help: a method is available that returns `<T as Trait<i32>>::A`
help: some methods are available that return `<T as Trait<i32>>::A`
--> $DIR/trait-with-missing-associated-type-restriction.rs:8:5
|
LL | fn func(&self) -> Self::A;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ consider calling `Trait::func`
LL | fn funk(&self, _: Self::A);
LL | fn funq(&self) -> Self::A {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^ consider calling `Trait::funq`
help: consider constraining the associated type `<T as Trait<i32>>::A` to `{integer}`
|
LL | fn bar2<T: Trait<i32, A = {integer}>>(x: T) {
| ^^^^^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/trait-with-missing-associated-type-restriction.rs:26:9
--> $DIR/trait-with-missing-associated-type-restriction.rs:27:9
|
LL | qux(x.func())
| ^^^^^^^^ expected `usize`, found associated type
@ -69,7 +86,7 @@ LL | fn bar2<T: Trait<i32, A = usize>>(x: T) {
| ^^^^^^^^^^^
error[E0308]: mismatched types
--> $DIR/trait-with-missing-associated-type-restriction.rs:30:9
--> $DIR/trait-with-missing-associated-type-restriction.rs:31:9
|
LL | fn baz<D: std::fmt::Debug, T: Trait<A = D>>(x: T) {
| - this type parameter
@ -80,13 +97,13 @@ LL | qux(x.func())
found type parameter `D`
error[E0308]: mismatched types
--> $DIR/trait-with-missing-associated-type-restriction.rs:34:9
--> $DIR/trait-with-missing-associated-type-restriction.rs:35:9
|
LL | qux(x.func())
| ^^^^^^^^ expected `usize`, found `()`
error[E0308]: mismatched types
--> $DIR/trait-with-missing-associated-type-restriction.rs:38:9
--> $DIR/trait-with-missing-associated-type-restriction.rs:39:9
|
LL | qux(x.func())
| ^^^^^^^^ expected `usize`, found associated type
@ -98,6 +115,6 @@ help: consider constraining the associated type `<T as Trait>::A` to `usize`
LL | fn ban<T>(x: T) where T: Trait<A = usize> {
| ^^^^^^^^^^^
error: aborting due to 8 previous errors
error: aborting due to 9 previous errors
For more information about this error, try `rustc --explain E0308`.