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

Update E0392 to new error format #35671

Merged
merged 1 commit into from
Aug 17, 2016
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
6 changes: 4 additions & 2 deletions src/librustc_typeck/check/wfcheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,10 @@ fn error_380(ccx: &CrateCtxt, span: Span) {

fn error_392<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, span: Span, param_name: ast::Name)
-> DiagnosticBuilder<'tcx> {
struct_span_err!(ccx.tcx.sess, span, E0392,
"parameter `{}` is never used", param_name)
let mut err = struct_span_err!(ccx.tcx.sess, span, E0392,
Copy link
Member

Choose a reason for hiding this comment

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

@jonathandturner: Don't you prefer doing this without declaring variable?

Copy link
Contributor Author

@canova canova Aug 15, 2016

Choose a reason for hiding this comment

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

@GuillaumeGomez Actually I tried it first but code like this turns mutable reference of DiagnosticBuilder because of span_label but return value of function is DiagnosticBuilder(not reference) so I couldn't do like that:

struct_span_err!(ccx.tcx.sess, span, E0392,
                     "parameter `{}` is never used", param_name)
                     .span_label(span, &format!("unused type parameter"))

I don't know another way to do it without declaring variable so I did it like that. If there is a better way, I'm happy to do that.

Copy link
Member

Choose a reason for hiding this comment

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

I thought the .emit() method would have done it. Have you tried it by any chance? Otherwise don't worry, it's just a detail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried it but didn't worked. Returned DiagnosticBuilder variable emitting in another function.

"parameter `{}` is never used", param_name);
err.span_label(span, &format!("unused type parameter"));
err
}

fn error_194(tcx: TyCtxt, span: Span, name: ast::Name) {
Expand Down
1 change: 1 addition & 0 deletions src/test/compile-fail/E0392.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

enum Foo<T> { Bar } //~ ERROR E0392
//~| NOTE unused type parameter

fn main() {
}