Skip to content

Commit 2afa97a

Browse files
committed
rustc: Handle #[link(name = "")] error
1 parent e86cdaf commit 2afa97a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/librustc/metadata/creader.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,11 @@ fn visit_item(e: &Env, i: @ast::item) {
219219
@"foo"
220220
}
221221
};
222-
cstore::add_used_library(cstore, n.to_owned(), kind);
222+
if n.is_empty() {
223+
e.sess.span_err(m.span, "#[link(name = \"\")] given with empty name");
224+
} else {
225+
cstore::add_used_library(cstore, n.to_owned(), kind);
226+
}
223227
}
224228
None => {}
225229
}

src/test/compile-fail/bad-extern-link-attrs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#[link()] //~ ERROR: specified without `name =
12+
#[link(name = "")] //~ ERROR: with empty name
1213
#[link(name = "foo")]
1314
#[link(name = "foo", kind = "bar")] //~ ERROR: unknown kind
1415
extern {}

0 commit comments

Comments
 (0)