Skip to content

When a help message is associated with a warning message, the two message you should be printed together and the source code printed only once. #21938

New issue

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

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

Already on GitHub? # to your account

Closed
dzamlo opened this issue Feb 4, 2015 · 5 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints

Comments

@dzamlo
Copy link
Contributor

dzamlo commented Feb 4, 2015

For exemple, for the following code:

extern crate libc;

fn main() {
}

The output of rustc is:

bar.rs:1:1: 1:19 warning: use of unstable library feature 'libc'
bar.rs:1 extern crate libc;
         ^~~~~~~~~~~~~~~~~~
bar.rs:1:1: 1:19 help: add #![feature(libc)] to the crate attributes to silence this warning
bar.rs:1 extern crate libc;
         ^~~~~~~~~~~~~~~~~~

It should be:

bar.rs:1:1: 1:19 warning: use of unstable library feature 'libc'
bar.rs:1:1: 1:19 help: add #![feature(libc)] to the crate attributes to silence this warning
bar.rs:1 extern crate libc;
         ^~~~~~~~~~~~~~~~~~

I don't know if there is any help message associated with an error message, but if this the case, the same issue apply.

@steveklabnik steveklabnik added the A-diagnostics Area: Messages for errors, warnings, and lints label Feb 6, 2015
@pnkfelix pnkfelix added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Feb 21, 2015
steveklabnik added a commit to steveklabnik/rust that referenced this issue Feb 26, 2015
When warnings and errors occur, the associated help message should not print the same code snippet.
rust-lang#21938
Manishearth added a commit to Manishearth/rust that referenced this issue Mar 4, 2015
 When warnings and errors occur, the associated help message should not print the same code snippet.
rust-lang#21938
Manishearth added a commit to Manishearth/rust that referenced this issue Mar 5, 2015
 When warnings and errors occur, the associated help message should not print the same code snippet.
rust-lang#21938
@caipre
Copy link
Contributor

caipre commented May 9, 2015

Looks like the referenced merge addresses error + help combos (albeit not in the order described above):

$ echo 'mod foo;' > test.rs
$ rustc ./test.rs
test.rs:1:5: 1:8 error: file not found for module `foo`
test.rs:1 mod foo;
              ^~~
test.rs:1:5: 1:8 help: name the file either foo.rs or foo/mod.rs inside the directory ""

But this still happens for error + warning combos:

use std::vec::Drain;

fn main () {
}
$ rustc ./test.rs
./test.rs:1:5: 1:20 error: use of unstable library feature 'collections': recently added as part of collections reform 2
./test.rs:1 use std::vec::Drain;
                ^~~~~~~~~~~~~~~
./test.rs:1:5: 1:20 warning: unused import, #[warn(unused_imports)] on by default
./test.rs:1 use std::vec::Drain;
                ^~~~~~~~~~~~~~~
error: aborting due to previous error

Though this may be deliberate since the error and warning are about different issues.

@carols10cents
Copy link
Member

(albeit not in the order described above):

So since helps look like they're a subdiagnostic of errors, and errors get output before their subdiagnostics, the ordering looks intentional.

With the error+warning case, I think those are actually two separate diagnostics, that is, the warning is not the subdiagnostic of the error, so they shouldn't be combined.

Sooo I think this issue might be done? If I'm understanding the intentionality of the current error display?

@brson brson removed the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Jun 27, 2016
@brson
Copy link
Contributor

brson commented Jun 27, 2016

Warnings have undergone a lot of churn lately, and some of them have been grouped together in logical ways. @jonathandturner @nikomatsakis @nrc @pnkfelix is this issue still relevant?

@pnkfelix
Copy link
Member

pnkfelix commented Jul 4, 2016

I think we can close this. The main redundancy has been addressed, and I think the current handling of help messages works at least for the case described

@nikomatsakis
Copy link
Contributor

Agreed.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints
Projects
None yet
Development

No branches or pull requests

7 participants