Skip to content

Commit 1661a0a

Browse files
committed
convert a couple more errors
1 parent 2daaf2b commit 1661a0a

5 files changed

+14
-21
lines changed

src/librustc_lint/builtin.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -469,18 +469,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
469469
return;
470470
}
471471

472-
let desc = match trait_item.kind {
473-
hir::TraitItemKind::Const(..) => "an associated constant",
474-
hir::TraitItemKind::Fn(..) => "a trait method",
475-
hir::TraitItemKind::Type(..) => "an associated type",
476-
};
472+
let def_id = cx.tcx.hir().local_def_id(trait_item.hir_id);
473+
let (article, desc) = cx.tcx.article_and_description(def_id);
477474

478475
self.check_missing_docs_attrs(
479476
cx,
480477
Some(trait_item.hir_id),
481478
&trait_item.attrs,
482479
trait_item.span,
483-
desc,
480+
&format!("{} {}", article, desc),
484481
);
485482
}
486483

@@ -490,18 +487,14 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for MissingDoc {
490487
return;
491488
}
492489

493-
let desc = match impl_item.kind {
494-
hir::ImplItemKind::Const(..) => "an associated constant",
495-
hir::ImplItemKind::Fn(..) => "a method",
496-
hir::ImplItemKind::TyAlias(_) => "an associated type",
497-
hir::ImplItemKind::OpaqueTy(_) => "an associated `impl Trait` type",
498-
};
490+
let def_id = cx.tcx.hir().local_def_id(impl_item.hir_id);
491+
let (article, desc) = cx.tcx.article_and_description(def_id);
499492
self.check_missing_docs_attrs(
500493
cx,
501494
Some(impl_item.hir_id),
502495
&impl_item.attrs,
503496
impl_item.span,
504-
desc,
497+
&format!("{} {}", article, desc),
505498
);
506499
}
507500

src/test/ui/lint/lint-missing-doc.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ trait B {
5050
}
5151

5252
pub trait C { //~ ERROR: missing documentation for a trait
53-
fn foo(&self); //~ ERROR: missing documentation for a trait method
54-
fn foo_with_impl(&self) {} //~ ERROR: missing documentation for a trait method
53+
fn foo(&self); //~ ERROR: missing documentation for an associated function
54+
fn foo_with_impl(&self) {} //~ ERROR: missing documentation for an associated function
5555
}
5656

5757
#[allow(missing_docs)]
@@ -78,7 +78,7 @@ impl Foo {
7878
}
7979

8080
impl PubFoo {
81-
pub fn foo() {} //~ ERROR: missing documentation for a method
81+
pub fn foo() {} //~ ERROR: missing documentation for an associated function
8282
/// dox
8383
pub fn foo1() {}
8484
fn foo2() {}

src/test/ui/lint/lint-missing-doc.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,13 @@ error: missing documentation for a trait
4040
LL | pub trait C {
4141
| ^^^^^^^^^^^
4242

43-
error: missing documentation for a trait method
43+
error: missing documentation for an associated function
4444
--> $DIR/lint-missing-doc.rs:53:5
4545
|
4646
LL | fn foo(&self);
4747
| ^^^^^^^^^^^^^^
4848

49-
error: missing documentation for a trait method
49+
error: missing documentation for an associated function
5050
--> $DIR/lint-missing-doc.rs:54:5
5151
|
5252
LL | fn foo_with_impl(&self) {}
@@ -64,7 +64,7 @@ error: missing documentation for an associated type
6464
LL | type AssociatedTypeDef = Self;
6565
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6666

67-
error: missing documentation for a method
67+
error: missing documentation for an associated function
6868
--> $DIR/lint-missing-doc.rs:81:5
6969
|
7070
LL | pub fn foo() {}

src/test/ui/privacy/private-in-public-non-principal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal> { loo
1010
#[deny(missing_docs)]
1111
fn container() {
1212
impl dyn PubPrincipal {
13-
pub fn check_doc_lint() {} //~ ERROR missing documentation for a method
13+
pub fn check_doc_lint() {} //~ ERROR missing documentation for an associated function
1414
}
1515
impl dyn PubPrincipal + PrivNonPrincipal {
1616
pub fn check_doc_lint() {} // OK, no missing doc lint

src/test/ui/privacy/private-in-public-non-principal.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LL | pub fn leak_dyn_nonprincipal() -> Box<dyn PubPrincipal + PrivNonPrincipal>
88
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
99
= note: for more information, see issue #34537 <https://github.com/rust-lang/rust/issues/34537>
1010

11-
error: missing documentation for a method
11+
error: missing documentation for an associated function
1212
--> $DIR/private-in-public-non-principal.rs:13:9
1313
|
1414
LL | pub fn check_doc_lint() {}

0 commit comments

Comments
 (0)