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

rustc: Fix bugs in renamed and removed lints and re-add raw_pointer_derive #30878

Merged
merged 1 commit into from Jan 16, 2016

Conversation

Projects
None yet
4 participants
@brson
Copy link
Contributor

brson commented Jan 13, 2016

This adds back the raw_pointer_derive lint as a 'removed' lint, so that its removal does not cause errors (#30346) but warnings.

In the process I discovered regressions in the code for renamed and removed lints, which didn't appear to have any tests. The addition of a second lint pass (ast vs. hir) meant that attributes were being inspected twice, renamed and removed warnings printed twice. I restructured the code so these tests are only done once and added tests. Unfortunately it makes the patch more complicated for the needed beta backport.

r? @nikomatsakis

@brson brson force-pushed the brson:raw-pointer-derive branch from e86f816 to a13b094 Jan 13, 2016

@brson brson force-pushed the brson:raw-pointer-derive branch from a13b094 to d46117b Jan 13, 2016

Level::Forbid => "-F",
},
lint_name);
sess.note_without_error(&msg);

This comment has been minimized.

@nagisa

nagisa Jan 13, 2016

Contributor

Use a structural error (you probably would want to return one from check_lint_name in some form?)

This comment has been minimized.

@nikomatsakis

nikomatsakis Jan 13, 2016

Contributor

Ah, yes, this is true. It'd be better to return the error and attach the note to it -- that would also mean that the caller is always the one that ultimately reports all warnings/errors, which seems good.

// The raw_pointer_derived lint only warns about its own removal
// cc #30346

#[deny(raw_pointer_derive)] //~ WARN raw_pointer_derive has been removed

This comment has been minimized.

@nagisa

nagisa Jan 13, 2016

Contributor

I wonder whether the diagnostic for #[deny(raw_pointer_deriving)] would only report about it being renamed, or also that it has been removed? I suspect its former and I think we might want the behaviour resembling the later.

This comment has been minimized.

@brson

brson Jan 14, 2016

Author Contributor

You are probably right, but I don't think it's worth the effort to change. What will happen is they will get the renamed warning, change the name, then get the removed warning. It is a minor hassle for a scenario that is never going to come up in practice with this particular lint, and may never happen again.

/// passed on the command line. Since it emits non-fatal warnings and
/// there are *two* lint passes that inspect attributes, this is only
/// run from the late pass to avoid printing duplicate warnings.
fn check_lint_name(sess: &Session,

This comment has been minimized.

@nagisa

nagisa Jan 13, 2016

Contributor

To me it seems strange that we report some warnings in this function and have callers to handle reporting warnings/errors for another cases.

This comment has been minimized.

@nikomatsakis

nikomatsakis Jan 13, 2016

Contributor

@nagisa do you mean the case where no matching name is found?

This comment has been minimized.

@nikomatsakis

nikomatsakis Jan 13, 2016

Contributor

If so, I presume @brson structured it this way because some callers want warnings, and some want errors. Seems ok to me (though it wouldn't hurt to put the reasoning into a comment).

This comment has been minimized.

@nagisa

nagisa Jan 13, 2016

Contributor

Yes.

This comment has been minimized.

@brson

brson Jan 14, 2016

Author Contributor

The logic is just awkward. It's called in two scenarios and some of the errors/warnings are shared, some different. Doing the warning reporting in the caller would introduce duplication.

Ok,
// Lint doesn't exist
NoLint,
// The lint is either ranamed or removed and a warning was printed

This comment has been minimized.

@nikomatsakis

nikomatsakis Jan 13, 2016

Contributor

Nit: s/ranamed/renamed/

@@ -152,8 +152,11 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
store.register_late_pass(sess, false, box lint::GatherNodeLevels);

// Insert temporary renamings for a one-time deprecation
store.register_renamed("raw_pointer_deriving", "raw_pointer_derive");

This comment has been minimized.

@nikomatsakis

nikomatsakis Jan 13, 2016

Contributor

Maybe make this register_removed, since it was ultimately removed?

This comment has been minimized.

@brson

brson Jan 14, 2016

Author Contributor

Good idea cc @nagisa this will solve the problem you forsaw.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Jan 13, 2016

This looks good to me, though I think that restructuring to return a DiagnosticBuilder (so you can attach the note to it and then call emit()) would be nicer.

@brson brson force-pushed the brson:raw-pointer-derive branch from d46117b to a9efbeb Jan 14, 2016

@brson

This comment has been minimized.

Copy link
Contributor Author

brson commented Jan 14, 2016

r? @nikomatsakis I've addressed all points.

@brson brson added the beta-accepted label Jan 14, 2016

@brson

This comment has been minimized.

Copy link
Contributor Author

brson commented Jan 14, 2016

@rust-lang/compiler I tagged this beta-accepted, assuming you would be cool with it. @nikomatsakis and I at least have discussed it a lot.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Jan 14, 2016

r=me modulo nits, and I think backporting makes sense. Looks pretty non-invasive.

@brson brson force-pushed the brson:raw-pointer-derive branch from a9efbeb to ca81d3d Jan 14, 2016

@brson

This comment has been minimized.

Copy link
Contributor Author

brson commented Jan 14, 2016

r=nikomatsakis

@brson

This comment has been minimized.

Copy link
Contributor Author

brson commented Jan 15, 2016

@bors r+ p=1

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 15, 2016

📌 Commit ca81d3d has been approved by brson

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jan 15, 2016

⌛️ Testing commit ca81d3d with merge cee9463...

bors added a commit that referenced this pull request Jan 15, 2016

Auto merge of #30878 - brson:raw-pointer-derive, r=brson
This adds back the raw_pointer_derive lint as a 'removed' lint, so that its removal does not cause errors (#30346) but warnings.

In the process I discovered regressions in the code for renamed and removed lints, which didn't appear to have any tests. The addition of a second lint pass (ast vs. hir) meant that attributes were being inspected twice, renamed and removed warnings printed twice. I restructured the code so these tests are only done once and added tests. Unfortunately it makes the patch more complicated for the needed beta backport.

r? @nikomatsakis

@bors bors merged commit ca81d3d into rust-lang:master Jan 16, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details

@brson brson referenced this pull request Jan 16, 2016

Merged

Beta next #30950

@brson brson removed the beta-nominated label Jan 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.