convert a couple more errors

This commit is contained in:
mark 2020-03-21 19:47:23 -05:00
parent 2daaf2b252
commit 1661a0a99b
5 changed files with 14 additions and 21 deletions

View File

@ -469,18 +469,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
return;
}
let desc = match trait_item.kind {
hir::TraitItemKind::Const(..) => "an associated constant",
hir::TraitItemKind::Fn(..) => "a trait method",
hir::TraitItemKind::Type(..) => "an associated type",
};
let def_id = cx.tcx.hir().local_def_id(trait_item.hir_id);
let (article, desc) = cx.tcx.article_and_description(def_id);
self.check_missing_docs_attrs(
cx,
Some(trait_item.hir_id),
&trait_item.attrs,
trait_item.span,
desc,
&format!("{} {}", article, desc),
);
}
@ -490,18 +487,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
return;
}
let desc = match impl_item.kind {
hir::ImplItemKind::Const(..) => "an associated constant",
hir::ImplItemKind::Fn(..) => "a method",
hir::ImplItemKind::TyAlias(_) => "an associated type",
hir::ImplItemKind::OpaqueTy(_) => "an associated `impl Trait` type",
};
let def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
let (article, desc) = cx.tcx.article_and_description(def_id);
self.check_missing_docs_attrs(
cx,
Some(impl_item.hir_id),
&impl_item.attrs,
impl_item.span,
desc,
&format!("{} {}", article, desc),
);
}

View File

@ -50,8 +50,8 @@ trait B {
}
pub trait C { //~ ERROR: missing documentation for a trait
fn foo(&self); //~ ERROR: missing documentation for a trait method
fn foo_with_impl(&self) {} //~ ERROR: missing documentation for a trait method
fn foo(&self); //~ ERROR: missing documentation for an associated function
fn foo_with_impl(&self) {} //~ ERROR: missing documentation for an associated function
}
#[allow(missing_docs)]
@ -78,7 +78,7 @@ impl Foo {
}
impl PubFoo {
pub fn foo() {} //~ ERROR: missing documentation for a method
pub fn foo() {} //~ ERROR: missing documentation for an associated function
/// dox
pub fn foo1() {}
fn foo2() {}

View File

@ -40,13 +40,13 @@ error: missing documentation for a trait
LL | pub trait C {
| ^^^^^^^^^^^
error: missing documentation for a trait method
error: missing documentation for an associated function
--> $DIR/lint-missing-doc.rs:53:5
|
LL | fn foo(&self);
| ^^^^^^^^^^^^^^
error: missing documentation for a trait method
error: missing documentation for an associated function
--> $DIR/lint-missing-doc.rs:54:5
|
LL | fn foo_with_impl(&self) {}
@ -64,7 +64,7 @@ error: missing documentation for an associated type
LL | type AssociatedTypeDef = Self;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: missing documentation for a method
error: missing documentation for an associated function
--> $DIR/lint-missing-doc.rs:81:5
|
LL | pub fn foo() {}

View File

@ -10,7 +10,7 @@ pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loo
#[deny(missing_docs)]
fn container() {
impl dyn PubPrincipal {
pub fn check_doc_lint() {} //~ ERROR missing documentation for a method
pub fn check_doc_lint() {} //~ ERROR missing documentation for an associated function
}
impl dyn PubPrincipal + PrivNonPrincipal {
pub fn check_doc_lint() {} // OK, no missing doc lint

View File

@ -8,7 +8,7 @@ LL | pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal>
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
error: missing documentation for a method
error: missing documentation for an associated function
--> $DIR/private-in-public-non-principal.rs:13:9
|
LL | pub fn check_doc_lint() {}