Update E0445 and E0454 to new error format

Fixes #35922.
Fixes #35930.
Part of #35233.

r? @GuillaumeGomez
This commit is contained in:
Mohit Agarwal 2016-08-24 17:43:51 +05:30 committed by Your Name
parent 308824acec
commit 11e9b8de7d
4 changed files with 21 additions and 8 deletions

View File

@ -101,8 +101,10 @@ fn register_native_lib(sess: &Session,
if name.is_empty() {
match span {
Some(span) => {
span_err!(sess, span, E0454,
"#[link(name = \"\")] given with empty name");
struct_span_err!(sess, span, E0454,
"#[link(name = \"\")] given with empty name")
.span_label(span, &format!("empty name given"))
.emit();
}
None => {
sess.err("empty library name given via `-l`");

View File

@ -964,8 +964,11 @@ impl<'a, 'tcx: 'a, 'v> Visitor<'v> for SearchInterfaceForPrivateItemsVisitor<'a,
if !vis.is_at_least(self.required_visibility, &self.tcx.map) {
if self.tcx.sess.features.borrow().pub_restricted ||
self.old_error_set.contains(&trait_ref.ref_id) {
span_err!(self.tcx.sess, trait_ref.path.span, E0445,
"private trait in public interface");
struct_span_err!(self.tcx.sess, trait_ref.path.span, E0445,
"private trait in public interface")
.span_label(trait_ref.path.span, &format!(
"private trait can't be public"))
.emit();
} else {
self.tcx.sess.add_lint(lint::builtin::PRIVATE_IN_PUBLIC,
node_id,

View File

@ -12,8 +12,14 @@ trait Foo {
fn dummy(&self) { }
}
pub trait Bar : Foo {} //~ ERROR E0445
pub struct Bar2<T: Foo>(pub T); //~ ERROR E0445
pub fn foo<T: Foo> (t: T) {} //~ ERROR E0445
pub trait Bar : Foo {}
//~^ ERROR private trait in public interface [E0445]
//~| NOTE private trait can't be public
pub struct Bar2<T: Foo>(pub T);
//~^ ERROR private trait in public interface [E0445]
//~| NOTE private trait can't be public
pub fn foo<T: Foo> (t: T) {}
//~^ ERROR private trait in public interface [E0445]
//~| NOTE private trait can't be public
fn main() {}

View File

@ -8,7 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[link(name = "")] extern {} //~ ERROR E0454
#[link(name = "")] extern {}
//~^ ERROR E0454
//~| NOTE empty name given
fn main() {
}