Skip to content

Commit

Permalink
Update E0445 and E0454 to new error format
Browse files Browse the repository at this point in the history
Fixes #35922.
Fixes #35930.
Part of #35233.

r? @GuillaumeGomez
  • Loading branch information
0xmohit authored and Your Name committed Aug 24, 2016
1 parent 308824a commit 11e9b8d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/librustc_metadata/creader.rs
Expand Up @@ -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`");
Expand Down
7 changes: 5 additions & 2 deletions src/librustc_privacy/lib.rs
Expand Up @@ -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,
Expand Down
12 changes: 9 additions & 3 deletions src/test/compile-fail/E0445.rs
Expand Up @@ -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() {}
4 changes: 3 additions & 1 deletion src/test/compile-fail/E0454.rs
Expand Up @@ -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() {
}

0 comments on commit 11e9b8d

Please sign in to comment.