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

Omit 'obsolete' note for a warning with -Awarning #23782

Closed
wants to merge 1 commit into from

Conversation

mvdnes
Copy link
Contributor

@mvdnes mvdnes commented Mar 27, 2015

When emmitting a note, previously it was not known if the note was for an error or a
warning. If it was for a warning, then with -Awarnings it should not have been print.
The emit_for function allows someone to specify which level should determine its visibility.

An example:

extern crate "std" as std2;
fn main() {}

When compiling with -Awarnings, this would previously emit note: use an identifier not in quotes instead (and nothing else).
With this patch, it will be completely silent as expected.

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @kmcallister (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see CONTRIBUTING.md for more information.

@@ -207,6 +207,14 @@ impl Handler {
if lvl == Warning && !self.can_emit_warnings { return }
self.emit.borrow_mut().emit(cmsp, msg, Some(code), lvl);
}
pub fn emit_for(&self,
Copy link
Member

Choose a reason for hiding this comment

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

Can we have some documentation explaining the arguments and when to use this?

@kmcallister kmcallister removed their assignment Apr 9, 2015
@huonw
Copy link
Member

huonw commented Apr 15, 2015

r? @alexcrichton (randomish assignment to fill the void)

@alexcrichton
Copy link
Member

This function is currently only used in one location, and has a bit of a mouthful of a signature, so could it just manually check for can_emit_warnings in the relevant location?

@mvdnes
Copy link
Contributor Author

mvdnes commented Apr 16, 2015

The field is public, so that is a possibility aswell.
Something like if error || self.sess.span_diagnostic.handler().can_emit_warnings { ... }.
I can commit such a thing if you want.

@alexcrichton
Copy link
Member

Sounds good to me!

@mvdnes
Copy link
Contributor Author

mvdnes commented Apr 16, 2015

I have pushed the alternative solution.
Although I did notice that there are currently no use cases for it. The extern crate "..." part does not parse anymore, and the other case is an error.

@mvdnes mvdnes changed the title Add emit_for function in diagnostic Omit 'obsolete' note for a warning with -Awarning Apr 16, 2015
@alexcrichton
Copy link
Member

@bors: r+ 6de33c2 rollup

Thanks!

steveklabnik added a commit to steveklabnik/rust that referenced this pull request Apr 16, 2015
When emmitting a note, previously it was not known if the note was for an error or a
warning. If it was for a warning, then with `-Awarnings` it should not have been print.
The `emit_for` function allows someone to specify which level should determine its visibility.

An example:
```rust
extern crate "std" as std2;
fn main() {}
```

When compiling with `-Awarnings`, this would previously emit `note: use an identifier not in quotes instead` (and nothing else).
With this patch, it will be completely silent as expected.
bors added a commit that referenced this pull request Apr 16, 2015
bors added a commit that referenced this pull request Apr 17, 2015
bors added a commit that referenced this pull request Apr 17, 2015
Manishearth added a commit to Manishearth/rust that referenced this pull request Apr 17, 2015
 When emmitting a note, previously it was not known if the note was for an error or a
warning. If it was for a warning, then with `-Awarnings` it should not have been print.
The `emit_for` function allows someone to specify which level should determine its visibility.

An example:
```rust
extern crate \"std\" as std2;
fn main() {}
```

When compiling with `-Awarnings`, this would previously emit `note: use an identifier not in quotes instead` (and nothing else).
With this patch, it will be completely silent as expected.
Manishearth added a commit to Manishearth/rust that referenced this pull request Apr 17, 2015
 When emmitting a note, previously it was not known if the note was for an error or a
warning. If it was for a warning, then with `-Awarnings` it should not have been print.
The `emit_for` function allows someone to specify which level should determine its visibility.

An example:
```rust
extern crate \"std\" as std2;
fn main() {}
```

When compiling with `-Awarnings`, this would previously emit `note: use an identifier not in quotes instead` (and nothing else).
With this patch, it will be completely silent as expected.
@steveklabnik
Copy link
Member

This was merged in #24512 , sorry, I rebased and forgot that'd screw it up :(

@mvdnes mvdnes deleted the obsolete_note branch April 18, 2015 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants