Skip to content

Commit f483032

Browse files
committed
review comment
1 parent 005fc6e commit f483032

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/librustc_ast_passes/ast_validation.rs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -820,40 +820,35 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
820820
ref self_ty,
821821
items: _,
822822
} => {
823-
let error = |annotation_span, annotation, note, code| {
823+
let error = |annotation_span, annotation| {
824824
let mut err = self.err_handler().struct_span_err(
825825
self_ty.span,
826826
&format!("inherent impls cannot be {}", annotation),
827827
);
828828
err.span_label(annotation_span, &format!("{} because of this", annotation));
829829
err.span_label(self_ty.span, "inherent impl for this type");
830-
if note {
831-
err.note(&format!(
832-
"only trait implementations may be annotated with {}",
833-
annotation
834-
));
835-
}
836-
if code {
837-
err.code(error_code!(E0197));
838-
}
839-
err.emit();
830+
err
840831
};
841832

842833
self.invalid_visibility(
843834
&item.vis,
844835
Some("place qualifiers on individual impl items instead"),
845836
);
846837
if let Unsafe::Yes(span) = unsafety {
847-
error(span, "unsafe", false, true)
838+
error(span, "unsafe").code(error_code!(E0197)).emit();
848839
}
849840
if let ImplPolarity::Negative(span) = polarity {
850-
error(span, "negative", false, false);
841+
error(span, "negative").emit();
851842
}
852843
if let Defaultness::Default(def_span) = defaultness {
853-
error(def_span, "`default`", true, false);
844+
error(def_span, "`default`")
845+
.note("only trait implementations may be annotated with `default`")
846+
.emit();
854847
}
855848
if let Const::Yes(span) = constness {
856-
error(span, "`const`", true, false);
849+
error(span, "`const`")
850+
.note("only trait implementations may be annotated with `const`")
851+
.emit();
857852
}
858853
}
859854
ItemKind::Fn(def, ref sig, ref generics, ref body) => {

0 commit comments

Comments
 (0)