Skip to content

Commit

Permalink
Only trigger missing documentation warnings to public functions and f…
Browse files Browse the repository at this point in the history
…ields.
  • Loading branch information
Xazax-hun committed May 24, 2013
1 parent c658132 commit 3d61931
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -972,16 +972,23 @@ fn lint_unnecessary_allocations(cx: @mut Context) -> visit::vt<()> {
fn lint_missing_struct_doc(cx: @mut Context) -> visit::vt<()> {
visit::mk_simple_visitor(@visit::SimpleVisitor {
visit_struct_field: |field| {
let mut has_doc = false;
for field.node.attrs.each |attr| {
if attr.node.is_sugared_doc {
has_doc = true;
break;
let relevant = match field.node.kind {
ast::named_field(_, vis) => vis != ast::private,
ast::unnamed_field => false,
};

if relevant {
let mut has_doc = false;
for field.node.attrs.each |attr| {
if attr.node.is_sugared_doc {
has_doc = true;
break;
}
}
if !has_doc {
cx.span_lint(missing_struct_doc, field.span, "missing documentation \
for a field.");
}
}
if !has_doc {
cx.span_lint(missing_struct_doc, field.span, "missing documentation \
for a field.");
}
},
.. *visit::default_simple_visitor()
Expand All @@ -1003,18 +1010,22 @@ fn lint_missing_trait_doc(cx: @mut Context) -> visit::vt<()> {
m.span
},
ast::provided(m) => {
for m.attrs.each |attr| {
if attr.node.is_sugared_doc {
has_doc = true;
break;
if m.vis == ast::private {
has_doc = true;
} else {
for m.attrs.each |attr| {
if attr.node.is_sugared_doc {
has_doc = true;
break;
}
}
}
m.span
}
};
if !has_doc {
cx.span_lint(missing_trait_doc, span, "missing documentation \
for a method.");
for a method.");
}
},
.. *visit::default_simple_visitor()
Expand Down

5 comments on commit 3d61931

@bors
Copy link
Contributor

@bors bors commented on 3d61931 May 27, 2013

Choose a reason for hiding this comment

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

saw approval from graydon
at Xazax-hun@3d61931

@bors
Copy link
Contributor

@bors bors commented on 3d61931 May 27, 2013

Choose a reason for hiding this comment

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

merging Xazax-hun/rust/incoming = 3d61931 into auto

@bors
Copy link
Contributor

@bors bors commented on 3d61931 May 27, 2013

Choose a reason for hiding this comment

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

Xazax-hun/rust/incoming = 3d61931 merged ok, testing candidate = 5d04ee8

@bors
Copy link
Contributor

@bors bors commented on 3d61931 May 27, 2013

Choose a reason for hiding this comment

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

@bors
Copy link
Contributor

@bors bors commented on 3d61931 May 27, 2013

Choose a reason for hiding this comment

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

fast-forwarding incoming to auto = 5d04ee8

Please sign in to comment.