Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message for APIT with explicit generic arguments #65614

Merged
merged 1 commit into from
Oct 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
tcx.sess,
span,
E0632,
"cannot provide explicit type parameters when `impl Trait` is \
used in argument position."
"cannot provide explicit generic arguments when `impl Trait` is \
used in argument position"
};

err.emit();
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_typeck/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5048,8 +5048,8 @@ the future, [RFC 2091] prohibits their implementation without a follow-up RFC.
// E0612, // merged into E0609
// E0613, // Removed (merged with E0609)
E0627, // yield statement outside of generator literal
E0632, // cannot provide explicit type parameters when `impl Trait` is used
// in argument position.
E0632, // cannot provide explicit generic arguments when `impl Trait` is
// used in argument position
E0634, // type has conflicting packed representaton hints
E0640, // infer outlives requirements
E0641, // cannot cast to/from a pointer with an unknown kind
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/impl-trait/issues/universal-issue-48703.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ use std::fmt::Debug;
fn foo<T>(x: impl Debug) { }

fn main() {
foo::<String>('a'); //~ ERROR cannot provide explicit type parameters
foo::<String>('a'); //~ ERROR cannot provide explicit generic arguments
}
2 changes: 1 addition & 1 deletion src/test/ui/impl-trait/issues/universal-issue-48703.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0632]: cannot provide explicit type parameters when `impl Trait` is used in argument position.
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
--> $DIR/universal-issue-48703.rs:8:5
|
LL | foo::<String>('a');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ struct TestEvent(i32);
fn main() {
let mut evt = EventHandler {};
evt.handle_event::<TestEvent, fn(TestEvent)>(|_evt| {
//~^ ERROR cannot provide explicit type parameters
//~^ ERROR cannot provide explicit generic arguments
});
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0632]: cannot provide explicit type parameters when `impl Trait` is used in argument position.
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
--> $DIR/universal-turbofish-in-method-issue-50950.rs:14:9
|
LL | evt.handle_event::<TestEvent, fn(TestEvent)>(|_evt| {
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/synthetic-param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ impl<S> Bar<S> {
}

fn main() {
func::<u8>(42); //~ ERROR cannot provide explicit type parameters
func::<u8>(42); //~ ERROR cannot provide explicit generic arguments
func(42); // Ok

Foo::func::<u8>(42); //~ ERROR cannot provide explicit type parameters
Foo::func::<u8>(42); //~ ERROR cannot provide explicit generic arguments
Foo::func(42); // Ok

Bar::<i8>::func::<u8>(42); //~ ERROR cannot provide explicit type parameters
Bar::<i8>::func::<u8>(42); //~ ERROR cannot provide explicit generic arguments
Bar::<i8>::func(42); // Ok
}
6 changes: 3 additions & 3 deletions src/test/ui/synthetic-param.stderr
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
error[E0632]: cannot provide explicit type parameters when `impl Trait` is used in argument position.
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
--> $DIR/synthetic-param.rs:20:5
|
LL | func::<u8>(42);
| ^^^^^^^^^^

error[E0632]: cannot provide explicit type parameters when `impl Trait` is used in argument position.
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
--> $DIR/synthetic-param.rs:23:5
|
LL | Foo::func::<u8>(42);
| ^^^^^^^^^^^^^^^

error[E0632]: cannot provide explicit type parameters when `impl Trait` is used in argument position.
error[E0632]: cannot provide explicit generic arguments when `impl Trait` is used in argument position
--> $DIR/synthetic-param.rs:26:5
|
LL | Bar::<i8>::func::<u8>(42);
Copy link
Member Author

@varkor varkor Oct 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This span is not very good. I'll file a follow up issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #65642.

Expand Down