forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#52244 - glandium:issue52097, r=estebank
Don't display default generic parameters in diagnostics that compare types In errors like: ``` expected type: `RawVec<foo, Global>` found type: `foo` ``` `RawVec` being defined as `RawVec<T, A: Alloc = Global>`, the error is better written as ``` expected type: `RawVec<foo>` found type: `foo` ``` In fact, that is already what happens when `foo` is not an ADT, because in that case, the diagnostic handler doesn't try to highlight something, and just uses the `Display` trait instead of its own logic. e.g. ``` expected type: `RawVec<usize>` found type: `usize` ```
- Loading branch information
Showing
3 changed files
with
581 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
trait Qux {} | ||
struct A; | ||
struct B; | ||
impl Qux for A {} | ||
impl Qux for B {} | ||
|
||
struct Foo<T, U: Qux = A, V: Qux = B>(T, U, V); | ||
|
||
struct foo; | ||
struct bar; | ||
|
||
fn want<T>(t: T) {} | ||
|
||
fn have_usize(f: usize) { | ||
want::<foo>(f); //~ ERROR mismatched types | ||
want::<bar>(f); //~ ERROR mismatched types | ||
want::<Foo<usize>>(f); //~ ERROR mismatched types | ||
want::<Foo<usize, B>>(f); //~ ERROR mismatched types | ||
want::<Foo<foo>>(f); //~ ERROR mismatched types | ||
want::<Foo<foo, B>>(f); //~ ERROR mismatched types | ||
want::<Foo<bar>>(f); //~ ERROR mismatched types | ||
want::<Foo<bar, B>>(f); //~ ERROR mismatched types | ||
} | ||
|
||
fn have_foo(f: foo) { | ||
want::<usize>(f); //~ ERROR mismatched types | ||
want::<bar>(f); //~ ERROR mismatched types | ||
want::<Foo<usize>>(f); //~ ERROR mismatched types | ||
want::<Foo<usize, B>>(f); //~ ERROR mismatched types | ||
want::<Foo<foo>>(f); //~ ERROR mismatched types | ||
want::<Foo<foo, B>>(f); //~ ERROR mismatched types | ||
want::<Foo<bar>>(f); //~ ERROR mismatched types | ||
want::<Foo<bar, B>>(f); //~ ERROR mismatched types | ||
} | ||
|
||
fn have_foo_foo(f: Foo<foo>) { | ||
want::<usize>(f); //~ ERROR mismatched types | ||
want::<foo>(f); //~ ERROR mismatched types | ||
want::<bar>(f); //~ ERROR mismatched types | ||
want::<Foo<usize>>(f); //~ ERROR mismatched types | ||
want::<Foo<usize, B>>(f); //~ ERROR mismatched types | ||
want::<Foo<foo, B>>(f); //~ ERROR mismatched types | ||
want::<Foo<bar>>(f); //~ ERROR mismatched types | ||
want::<Foo<bar, B>>(f); //~ ERROR mismatched types | ||
want::<&Foo<foo>>(f); //~ ERROR mismatched types | ||
want::<&Foo<foo, B>>(f); //~ ERROR mismatched types | ||
} | ||
|
||
fn have_foo_foo_b(f: Foo<foo, B>) { | ||
want::<usize>(f); //~ ERROR mismatched types | ||
want::<foo>(f); //~ ERROR mismatched types | ||
want::<bar>(f); //~ ERROR mismatched types | ||
want::<Foo<usize>>(f); //~ ERROR mismatched types | ||
want::<Foo<usize, B>>(f); //~ ERROR mismatched types | ||
want::<Foo<foo>>(f); //~ ERROR mismatched types | ||
want::<Foo<bar>>(f); //~ ERROR mismatched types | ||
want::<Foo<bar, B>>(f); //~ ERROR mismatched types | ||
want::<&Foo<foo>>(f); //~ ERROR mismatched types | ||
want::<&Foo<foo, B>>(f); //~ ERROR mismatched types | ||
} | ||
|
||
fn have_foo_foo_b_a(f: Foo<foo, B, A>) { | ||
want::<usize>(f); //~ ERROR mismatched types | ||
want::<foo>(f); //~ ERROR mismatched types | ||
want::<bar>(f); //~ ERROR mismatched types | ||
want::<Foo<usize>>(f); //~ ERROR mismatched types | ||
want::<Foo<usize, B>>(f); //~ ERROR mismatched types | ||
want::<Foo<foo>>(f); //~ ERROR mismatched types | ||
want::<Foo<foo, B>>(f); //~ ERROR mismatched types | ||
want::<Foo<bar>>(f); //~ ERROR mismatched types | ||
want::<Foo<bar, B>>(f); //~ ERROR mismatched types | ||
want::<&Foo<foo>>(f); //~ ERROR mismatched types | ||
want::<&Foo<foo, B>>(f); //~ ERROR mismatched types | ||
} | ||
|
||
fn main() {} |
Oops, something went wrong.