mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 15:14:29 +00:00
docs
This commit is contained in:
parent
92f13d8231
commit
9341427b0a
1 changed files with 5 additions and 4 deletions
|
@ -6,13 +6,13 @@ use syntax::ast::*;
|
|||
use rustc::lint::{Context, LintPass, LintArray, Lint, Level};
|
||||
use syntax::codemap::Span;
|
||||
|
||||
|
||||
/// Handles all the linting of funky types
|
||||
pub struct TypePass;
|
||||
|
||||
declare_lint!(CLIPPY_BOX_VEC, Warn,
|
||||
"Warn on usage of Box<Vec<T>>")
|
||||
|
||||
|
||||
/// Matches a type with a provided string, and returns its type parameters if successful
|
||||
pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]> {
|
||||
match ty.node {
|
||||
TyPath(Path {segments: ref seg, ..}, _, _) => {
|
||||
|
@ -35,13 +35,14 @@ pub fn match_ty_unwrap<'a>(ty: &'a Ty, segments: &[&str]) -> Option<&'a [P<Ty>]>
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fn span_note_and_lint(cx: &Context, lint: &'static Lint, span: Span, msg: &str, note: &str) {
|
||||
/// Lets me span a note only if the lint is shown
|
||||
pub fn span_note_and_lint(cx: &Context, lint: &'static Lint, span: Span, msg: &str, note: &str) {
|
||||
cx.span_lint(lint, span, msg);
|
||||
if cx.current_level(lint) != Level::Allow {
|
||||
cx.sess().span_note(span, note);
|
||||
}
|
||||
}
|
||||
|
||||
impl LintPass for TypePass {
|
||||
fn get_lints(&self) -> LintArray {
|
||||
lint_array!(CLIPPY_BOX_VEC)
|
||||
|
|
Loading…
Reference in a new issue