Skip to content

Implement lint plugins #15024

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

Merged
merged 20 commits into from
Jun 24, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
75bfeda
Move lint.rs out of middle
kmcallister Jun 1, 2014
3144614
Move lint infrastructure and individual lints into separate files
kmcallister Jun 1, 2014
5d4c96a
Rename lint::Lint to lint::LintId
kmcallister Jun 1, 2014
69b6bc5
Convert lints to a trait-based infrastructure
kmcallister Jun 2, 2014
442fbc4
Replace enum LintId with an extensible alternative
kmcallister Jun 4, 2014
819f76c
Store the registered lints in the Session
kmcallister Jun 10, 2014
c7af606
Clean up and document the public lint API
kmcallister Jun 6, 2014
c1898b9
Stop using Default for initializing builtin lints
kmcallister Jun 13, 2014
609552e
Run lint passes using the Option dance instead of RefCells
kmcallister Jun 13, 2014
21e7b93
Use names in Lint structs in an ASCII-case-insensitive way
kmcallister Jun 13, 2014
b5542f7
Convert builtin lints to uppercase names for style consistency
kmcallister Jun 13, 2014
a813a37
Rework lint attr parsing and use it in middle::dead
kmcallister Jun 13, 2014
6fede93
Make the crate and its exported items available in the lint context
kmcallister Jun 17, 2014
ba1c0c4
Drop the ExportedItems argument from LintPass::check_crate
kmcallister Jun 18, 2014
c747626
Reindent function call continuations, and other style fixes
kmcallister Jun 18, 2014
e67e6e6
List builtin lints one per line for better diffs
kmcallister Jun 18, 2014
51d438e
Incorporate upstream changes to old lint code
kmcallister Jun 18, 2014
2f274d1
Implement lint plugins
kmcallister Jun 19, 2014
7dc724b
Test lint plugins
kmcallister Jun 18, 2014
7e694e7
More upstream lint changes
kmcallister Jun 24, 2014
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
Prev Previous commit
More upstream lint changes
  • Loading branch information
Keegan McAllister committed Jun 24, 2014
commit 7e694e71153ebc8d3f2be9c20783bb283e38a59e
32 changes: 6 additions & 26 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1358,7 +1358,8 @@ impl LintPass for MissingDoc {
declare_lint!(DEPRECATED, Warn,
"detects use of #[deprecated] items")

declare_lint!(EXPERIMENTAL, Warn,
// FIXME #6875: Change to Warn after std library stabilization is complete
declare_lint!(EXPERIMENTAL, Allow,
"detects use of #[experimental] items")

declare_lint!(UNSTABLE, Allow,
Expand Down Expand Up @@ -1411,32 +1412,11 @@ impl LintPass for Stability {
_ => return
};

let stability = if ast_util::is_local(id) {
// this crate
let s = cx.tcx.map.with_attrs(id.node, |attrs| {
attrs.map(|a| attr::find_stability(a.as_slice()))
});
match s {
Some(s) => s,
// stability attributes are promises made across crates; do not
// check anything for crate-local usage.
if ast_util::is_local(id) { return }

// no possibility of having attributes
// (e.g. it's a local variable), so just
// ignore it.
None => return
}
} else {
// cross-crate

let mut s = None;
// run through all the attributes and take the first
// stability one.
csearch::get_item_attrs(&cx.sess().cstore, id, |attrs| {
if s.is_none() {
s = attr::find_stability(attrs.as_slice())
}
});
s
};
let stability = cx.tcx.stability.borrow_mut().lookup(&cx.tcx.sess.cstore, id);

let (lint, label) = match stability {
// no stability attributes == Unstable
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ impl<'a> Context<'a> {
impl<'a> AstConv for Context<'a>{
fn tcx<'a>(&'a self) -> &'a ty::ctxt { self.tcx }

fn get_item_ty(&self, id: ast::DefId) -> ty::ty_param_bounds_and_ty {
fn get_item_ty(&self, id: ast::DefId) -> ty::Polytype {
ty::lookup_item_type(self.tcx, id)
}

Expand Down