rustc: Add support for extern crate foo as bar
The compiler will now issue a warning for crates that have syntax of the form `extern crate "foo" as bar`, but it will still continue to accept this syntax. Additionally, the string `foo-bar` will match the crate name `foo_bar` to assist in the transition period as well. This patch will land hopefully in tandem with a Cargo patch that will start translating all crate names to have underscores instead of hyphens. cc #23533
This commit is contained in:
parent
ed81038504
commit
eb2f1d925f
67 changed files with 144 additions and 145 deletions
|
@ -73,22 +73,24 @@ struct CrateInfo {
|
|||
}
|
||||
|
||||
pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
|
||||
let err = |s: &str| {
|
||||
let say = |s: &str, warn: bool| {
|
||||
match (sp, sess) {
|
||||
(_, None) => panic!("{}", s),
|
||||
(Some(sp), Some(sess)) if warn => sess.span_warn(sp, s),
|
||||
(Some(sp), Some(sess)) => sess.span_err(sp, s),
|
||||
(None, Some(sess)) if warn => sess.warn(s),
|
||||
(None, Some(sess)) => sess.err(s),
|
||||
}
|
||||
};
|
||||
if s.len() == 0 {
|
||||
err("crate name must not be empty");
|
||||
} else if s.char_at(0) == '-' {
|
||||
err(&format!("crate name cannot start with a hyphen: {}", s));
|
||||
say("crate name must not be empty", false);
|
||||
} else if s.contains("-") {
|
||||
say(&format!("crate names soon cannot contain hyphens: {}", s), true);
|
||||
}
|
||||
for c in s.chars() {
|
||||
if c.is_alphanumeric() { continue }
|
||||
if c == '_' || c == '-' { continue }
|
||||
err(&format!("invalid character `{}` in crate name: `{}`", c, s));
|
||||
say(&format!("invalid character `{}` in crate name: `{}`", c, s), false);
|
||||
}
|
||||
match sess {
|
||||
Some(sess) => sess.abort_if_errors(),
|
||||
|
@ -153,8 +155,9 @@ impl<'a> CrateReader<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
// Traverses an AST, reading all the information about use'd crates and extern
|
||||
// libraries necessary for later resolving, typechecking, linking, etc.
|
||||
// Traverses an AST, reading all the information about use'd crates and
|
||||
// extern libraries necessary for later resolving, typechecking, linking,
|
||||
// etc.
|
||||
pub fn read_crates(&mut self, krate: &ast::Crate) {
|
||||
self.process_crate(krate);
|
||||
visit::walk_crate(self, krate);
|
||||
|
@ -184,11 +187,10 @@ impl<'a> CrateReader<'a> {
|
|||
debug!("resolving extern crate stmt. ident: {} path_opt: {:?}",
|
||||
ident, path_opt);
|
||||
let name = match *path_opt {
|
||||
Some((ref path_str, _)) => {
|
||||
let name = path_str.to_string();
|
||||
validate_crate_name(Some(self.sess), &name[..],
|
||||
Some(name) => {
|
||||
validate_crate_name(Some(self.sess), name.as_str(),
|
||||
Some(i.span));
|
||||
name
|
||||
name.as_str().to_string()
|
||||
}
|
||||
None => ident.to_string(),
|
||||
};
|
||||
|
@ -304,7 +306,13 @@ impl<'a> CrateReader<'a> {
|
|||
-> Option<ast::CrateNum> {
|
||||
let mut ret = None;
|
||||
self.sess.cstore.iter_crate_data(|cnum, data| {
|
||||
if data.name != name { return }
|
||||
// For now we do a "fuzzy match" on crate names by considering
|
||||
// hyphens equal to underscores. This is purely meant to be a
|
||||
// transitionary feature while we deprecate the quote syntax of
|
||||
// `extern crate` statements.
|
||||
if data.name != name.replace("-", "_") {
|
||||
return
|
||||
}
|
||||
|
||||
match hash {
|
||||
Some(hash) if *hash == data.hash() => { ret = Some(cnum); return }
|
||||
|
|
|
@ -1165,7 +1165,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> {
|
|||
let name = get_ident(item.ident);
|
||||
let name = &name;
|
||||
let location = match *s {
|
||||
Some((ref s, _)) => s.to_string(),
|
||||
Some(s) => s.to_string(),
|
||||
None => name.to_string(),
|
||||
};
|
||||
let alias_span = self.span.span_for_last_ident(item.span);
|
||||
|
|
|
@ -237,7 +237,7 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
ast::ItemExternCrate(ref p) => {
|
||||
let path = match *p {
|
||||
None => None,
|
||||
Some((ref x, _)) => Some(x.to_string()),
|
||||
Some(x) => Some(x.to_string()),
|
||||
};
|
||||
om.extern_crates.push(ExternCrate {
|
||||
name: name,
|
||||
|
|
|
@ -1771,8 +1771,8 @@ pub struct Item {
|
|||
pub enum Item_ {
|
||||
/// An`extern crate` item, with optional original crate name,
|
||||
///
|
||||
/// e.g. `extern crate foo` or `extern crate "foo-bar" as foo`
|
||||
ItemExternCrate(Option<(InternedString, StrStyle)>),
|
||||
/// e.g. `extern crate foo` or `extern crate foo_bar as foo`
|
||||
ItemExternCrate(Option<Name>),
|
||||
/// A `use` or `pub use` item
|
||||
ItemUse(P<ViewPath>),
|
||||
|
||||
|
|
|
@ -1060,7 +1060,7 @@ mod test {
|
|||
let vitem_s = item_to_string(&*vitem);
|
||||
assert_eq!(&vitem_s[..], ex_s);
|
||||
|
||||
let ex_s = "extern crate \"foo\" as bar;";
|
||||
let ex_s = "extern crate foo as bar;";
|
||||
let vitem = string_to_item(ex_s.to_string()).unwrap();
|
||||
let vitem_s = item_to_string(&*vitem);
|
||||
assert_eq!(&vitem_s[..], ex_s);
|
||||
|
|
|
@ -24,6 +24,7 @@ use ptr::P;
|
|||
pub enum ObsoleteSyntax {
|
||||
ClosureKind,
|
||||
EmptyIndex,
|
||||
ExternCrateString,
|
||||
}
|
||||
|
||||
pub trait ParserObsoleteMethods {
|
||||
|
@ -56,6 +57,11 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
|
|||
"write `[..]` instead",
|
||||
false, // warning for now
|
||||
),
|
||||
ObsoleteSyntax::ExternCrateString => (
|
||||
"\"crate-name\"",
|
||||
"use an identifier not in quotes instead",
|
||||
false, // warning for now
|
||||
),
|
||||
};
|
||||
|
||||
self.report(sp, kind, kind_str, desc, error);
|
||||
|
|
|
@ -4986,37 +4986,28 @@ impl<'a> Parser<'a> {
|
|||
attrs: Vec<Attribute>)
|
||||
-> P<Item> {
|
||||
|
||||
let span = self.span;
|
||||
let (maybe_path, ident) = match self.token {
|
||||
token::Ident(..) => {
|
||||
let the_ident = self.parse_ident();
|
||||
let path = if self.eat_keyword_noexpect(keywords::As) {
|
||||
// skip the ident if there is one
|
||||
if self.token.is_ident() { self.bump(); }
|
||||
|
||||
self.span_err(span, "expected `;`, found `as`");
|
||||
self.fileline_help(span,
|
||||
&format!("perhaps you meant to enclose the crate name `{}` in \
|
||||
a string?",
|
||||
the_ident.as_str()));
|
||||
None
|
||||
let crate_name = self.parse_ident();
|
||||
if self.eat_keyword(keywords::As) {
|
||||
(Some(crate_name.name), self.parse_ident())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
self.expect(&token::Semi);
|
||||
(path, the_ident)
|
||||
(None, crate_name)
|
||||
}
|
||||
},
|
||||
token::Literal(token::Str_(..), suf) | token::Literal(token::StrRaw(..), suf) => {
|
||||
token::Literal(token::Str_(..), suf) |
|
||||
token::Literal(token::StrRaw(..), suf) => {
|
||||
let sp = self.span;
|
||||
self.expect_no_suffix(sp, "extern crate name", suf);
|
||||
// forgo the internal suffix check of `parse_str` to
|
||||
// avoid repeats (this unwrap will always succeed due
|
||||
// to the restriction of the `match`)
|
||||
let (s, style, _) = self.parse_optional_str().unwrap();
|
||||
let (s, _, _) = self.parse_optional_str().unwrap();
|
||||
self.expect_keyword(keywords::As);
|
||||
let the_ident = self.parse_ident();
|
||||
self.expect(&token::Semi);
|
||||
(Some((s, style)), the_ident)
|
||||
self.obsolete(sp, ObsoleteSyntax::ExternCrateString);
|
||||
let s = token::intern(&s);
|
||||
(Some(s), the_ident)
|
||||
},
|
||||
_ => {
|
||||
let span = self.span;
|
||||
|
@ -5027,6 +5018,7 @@ impl<'a> Parser<'a> {
|
|||
token_str));
|
||||
}
|
||||
};
|
||||
self.expect(&token::Semi);
|
||||
|
||||
let last_span = self.last_span;
|
||||
self.mk_item(lo,
|
||||
|
|
|
@ -821,8 +821,13 @@ impl<'a> State<'a> {
|
|||
ast::ItemExternCrate(ref optional_path) => {
|
||||
try!(self.head(&visibility_qualified(item.vis,
|
||||
"extern crate")));
|
||||
if let Some((ref p, style)) = *optional_path {
|
||||
try!(self.print_string(p, style));
|
||||
if let Some(p) = *optional_path {
|
||||
let val = token::get_name(p);
|
||||
if val.contains("-") {
|
||||
try!(self.print_string(&val, ast::CookedStr));
|
||||
} else {
|
||||
try!(self.print_name(p));
|
||||
}
|
||||
try!(space(&mut self.s));
|
||||
try!(word(&mut self.s, "as"));
|
||||
try!(space(&mut self.s));
|
||||
|
|
|
@ -54,8 +54,8 @@ impl fold::Folder for StandardLibraryInjector {
|
|||
|
||||
// The name to use in `extern crate "name" as std;`
|
||||
let actual_crate_name = match self.alt_std_name {
|
||||
Some(ref s) => token::intern_and_get_ident(&s[..]),
|
||||
None => token::intern_and_get_ident("std"),
|
||||
Some(ref s) => token::intern(&s),
|
||||
None => token::intern("std"),
|
||||
};
|
||||
|
||||
krate.module.items.insert(0, P(ast::Item {
|
||||
|
@ -64,7 +64,7 @@ impl fold::Folder for StandardLibraryInjector {
|
|||
attrs: vec!(
|
||||
attr::mk_attr_outer(attr::mk_attr_id(), attr::mk_word_item(
|
||||
InternedString::new("macro_use")))),
|
||||
node: ast::ItemExternCrate(Some((actual_crate_name, ast::CookedStr))),
|
||||
node: ast::ItemExternCrate(Some(actual_crate_name)),
|
||||
vis: ast::Inherited,
|
||||
span: DUMMY_SP
|
||||
}));
|
||||
|
|
|
@ -9,5 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
extern crate "" as foo; //~ ERROR: crate name must not be empty
|
||||
//~^ WARNING: obsolete syntax
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -9,5 +9,6 @@
|
|||
// except according to those terms.
|
||||
|
||||
extern crate "#a" as bar; //~ ERROR: invalid character `#` in crate name: `#a`
|
||||
//~^ WARNING: obsolete syntax
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
impl<T> Remote1<T> for isize { }
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
pub struct BigInt;
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
// Test that it's not ok for U to appear uncovered
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::{Remote,Pair};
|
||||
|
||||
pub struct Cover<T>(T);
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::Remote;
|
||||
|
||||
impl<T> Remote for T { }
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
// except according to those terms.
|
||||
|
||||
// ignore-tidy-linelength
|
||||
// aux-build:coherence-orphan-lib.rs
|
||||
// aux-build:coherence_orphan_lib.rs
|
||||
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
extern crate "coherence-orphan-lib" as lib;
|
||||
extern crate coherence_orphan_lib as lib;
|
||||
|
||||
use lib::TheTrait;
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::Remote;
|
||||
|
||||
struct Foo;
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
// Test that the same coverage rules apply even if the local type appears in the
|
||||
// list of type parameters, not the self type.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::{Remote1, Pair};
|
||||
|
||||
pub struct Local<T>(T);
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::{Remote, Pair};
|
||||
|
||||
struct Local<T>(T);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
extern crate core;
|
||||
extern crate rand;
|
||||
extern crate "serialize" as rustc_serialize;
|
||||
extern crate serialize as rustc_serialize;
|
||||
|
||||
#[derive(Rand)] //~ ERROR this trait cannot be derived
|
||||
//~^ WARNING `#[derive(Rand)]` is deprecated
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:issue-11680.rs
|
||||
// aux-build:issue_11680.rs
|
||||
|
||||
extern crate "issue-11680" as other;
|
||||
extern crate issue_11680 as other;
|
||||
|
||||
fn main() {
|
||||
let _b = other::Foo::Bar(1);
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:issue-12612-1.rs
|
||||
// aux-build:issue_12612_1.rs
|
||||
|
||||
extern crate "issue-12612-1" as foo;
|
||||
extern crate issue_12612_1 as foo;
|
||||
|
||||
use foo::bar;
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:issue-16725.rs
|
||||
// aux-build:issue_16725.rs
|
||||
|
||||
extern crate "issue-16725" as foo;
|
||||
extern crate issue_16725 as foo;
|
||||
|
||||
fn main() {
|
||||
unsafe { foo::bar(); }
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:issue-17718-const-privacy.rs
|
||||
// aux-build:issue_17718_const_privacy.rs
|
||||
|
||||
extern crate "issue-17718-const-privacy" as other;
|
||||
extern crate issue_17718_const_privacy as other;
|
||||
|
||||
use a::B; //~ ERROR: const `B` is private
|
||||
use other::{
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:issue-21202.rs
|
||||
// aux-build:issue_21202.rs
|
||||
|
||||
extern crate "issue-21202" as crate1;
|
||||
extern crate issue_21202 as crate1;
|
||||
|
||||
use crate1::A;
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:lint-unused-extern-crate.rs
|
||||
// aux-build:lint_unused_extern_crate.rs
|
||||
|
||||
#![deny(unused_extern_crates)]
|
||||
#![allow(unused_variables)]
|
||||
|
@ -19,12 +19,12 @@
|
|||
|
||||
extern crate libc; //~ ERROR: unused extern crate
|
||||
|
||||
extern crate "collections" as collecs; // no error, it is used
|
||||
extern crate collections as collecs; // no error, it is used
|
||||
|
||||
extern crate rand; // no error, the use marks it as used
|
||||
// even if imported objects aren't used
|
||||
|
||||
extern crate "lint-unused-extern-crate" as other; // no error, the use * marks it as used
|
||||
extern crate lint_unused_extern_crate as other; // no error, the use * marks it as used
|
||||
|
||||
#[allow(unused_imports)]
|
||||
use rand::isaac::IsaacRng;
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:privacy-tuple-struct.rs
|
||||
// aux-build:privacy_tuple_struct.rs
|
||||
|
||||
extern crate "privacy-tuple-struct" as other;
|
||||
extern crate privacy_tuple_struct as other;
|
||||
|
||||
mod a {
|
||||
pub struct A(());
|
||||
|
@ -101,30 +101,30 @@ fn xcrate() {
|
|||
let c = other::C(2, 3); //~ ERROR: cannot invoke tuple struct constructor
|
||||
let d = other::D(4);
|
||||
|
||||
let other::A(()) = a; //~ ERROR: field #1 of struct `privacy-tuple-struct::A` is private
|
||||
let other::A(()) = a; //~ ERROR: field #1 of struct `privacy_tuple_struct::A` is private
|
||||
let other::A(_) = a;
|
||||
match a { other::A(()) => {} }
|
||||
//~^ ERROR: field #1 of struct `privacy-tuple-struct::A` is private
|
||||
//~^ ERROR: field #1 of struct `privacy_tuple_struct::A` is private
|
||||
match a { other::A(_) => {} }
|
||||
|
||||
let other::B(_) = b;
|
||||
let other::B(_b) = b; //~ ERROR: field #1 of struct `privacy-tuple-struct::B` is private
|
||||
let other::B(_b) = b; //~ ERROR: field #1 of struct `privacy_tuple_struct::B` is private
|
||||
match b { other::B(_) => {} }
|
||||
match b { other::B(_b) => {} }
|
||||
//~^ ERROR: field #1 of struct `privacy-tuple-struct::B` is private
|
||||
//~^ ERROR: field #1 of struct `privacy_tuple_struct::B` is private
|
||||
match b { other::B(1) => {} other::B(_) => {} }
|
||||
//~^ ERROR: field #1 of struct `privacy-tuple-struct::B` is private
|
||||
//~^ ERROR: field #1 of struct `privacy_tuple_struct::B` is private
|
||||
|
||||
let other::C(_, _) = c;
|
||||
let other::C(_a, _) = c;
|
||||
let other::C(_, _b) = c; //~ ERROR: field #2 of struct `privacy-tuple-struct::C` is private
|
||||
let other::C(_a, _b) = c; //~ ERROR: field #2 of struct `privacy-tuple-struct::C` is private
|
||||
let other::C(_, _b) = c; //~ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
|
||||
let other::C(_a, _b) = c; //~ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
|
||||
match c { other::C(_, _) => {} }
|
||||
match c { other::C(_a, _) => {} }
|
||||
match c { other::C(_, _b) => {} }
|
||||
//~^ ERROR: field #2 of struct `privacy-tuple-struct::C` is private
|
||||
//~^ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
|
||||
match c { other::C(_a, _b) => {} }
|
||||
//~^ ERROR: field #2 of struct `privacy-tuple-struct::C` is private
|
||||
//~^ ERROR: field #2 of struct `privacy_tuple_struct::C` is private
|
||||
|
||||
let other::D(_) = d;
|
||||
let other::D(_d) = d;
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:regions-bounded-method-type-parameters-cross-crate-lib.rs
|
||||
// aux-build:regions_bounded_method_type_parameters_cross_crate_lib.rs
|
||||
|
||||
// Check explicit region bounds on methods in the cross crate case.
|
||||
|
||||
extern crate "regions-bounded-method-type-parameters-cross-crate-lib" as lib;
|
||||
extern crate regions_bounded_method_type_parameters_cross_crate_lib as lib;
|
||||
|
||||
use lib::Inv;
|
||||
use lib::MaybeOwned;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
// aux-build:pub_static_array.rs
|
||||
|
||||
extern crate "pub_static_array" as array;
|
||||
extern crate pub_static_array as array;
|
||||
|
||||
use array::ARRAY;
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:struct-field-privacy.rs
|
||||
// aux-build:struct_field_privacy.rs
|
||||
|
||||
extern crate "struct-field-privacy" as xc;
|
||||
extern crate struct_field_privacy as xc;
|
||||
|
||||
struct A {
|
||||
a: isize,
|
||||
|
@ -37,11 +37,11 @@ fn test(a: A, b: inner::A, c: inner::B, d: xc::A, e: xc::B) {
|
|||
c.a;
|
||||
c.b; //~ ERROR: field `b` of struct `inner::B` is private
|
||||
|
||||
d.a; //~ ERROR: field `a` of struct `struct-field-privacy::A` is private
|
||||
d.a; //~ ERROR: field `a` of struct `struct_field_privacy::A` is private
|
||||
d.b;
|
||||
|
||||
e.a;
|
||||
e.b; //~ ERROR: field `b` of struct `struct-field-privacy::B` is private
|
||||
e.b; //~ ERROR: field `b` of struct `struct_field_privacy::B` is private
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:struct-field-privacy.rs
|
||||
// aux-build:struct_field_privacy.rs
|
||||
|
||||
extern crate "struct-field-privacy" as xc;
|
||||
extern crate struct_field_privacy as xc;
|
||||
|
||||
use xc::B;
|
||||
|
||||
|
@ -22,9 +22,9 @@ struct A {
|
|||
fn main () {
|
||||
// external crate struct
|
||||
let k = B {
|
||||
aa: 20, //~ ERROR structure `struct-field-privacy::B` has no field named `aa`
|
||||
aa: 20, //~ ERROR structure `struct_field_privacy::B` has no field named `aa`
|
||||
//~^ HELP did you mean `a`?
|
||||
bb: 20, //~ ERROR structure `struct-field-privacy::B` has no field named `bb`
|
||||
bb: 20, //~ ERROR structure `struct_field_privacy::B` has no field named `bb`
|
||||
};
|
||||
// local crate struct
|
||||
let l = A {
|
||||
|
|
|
@ -8,12 +8,12 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:trait-safety-lib.rs
|
||||
// aux-build:trait_safety_lib.rs
|
||||
|
||||
// Check that unsafe traits require unsafe impls and that inherent
|
||||
// impls cannot be unsafe.
|
||||
|
||||
extern crate "trait-safety-lib" as lib;
|
||||
extern crate trait_safety_lib as lib;
|
||||
|
||||
struct Bar;
|
||||
impl lib::Foo for Bar { //~ ERROR requires an `unsafe impl` declaration
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:typeck-default-trait-impl-cross-crate-coherence-lib.rs
|
||||
// aux-build:typeck_default_trait_impl_cross_crate_coherence_lib.rs
|
||||
|
||||
// Test that we do not consider associated types to be sendable without
|
||||
// some applicable trait bound (and we don't ICE).
|
||||
|
||||
#![feature(optin_builtin_traits)]
|
||||
|
||||
extern crate "typeck-default-trait-impl-cross-crate-coherence-lib" as lib;
|
||||
extern crate typeck_default_trait_impl_cross_crate_coherence_lib as lib;
|
||||
|
||||
use lib::DefaultedTrait;
|
||||
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:unreachable-variant.rs
|
||||
// aux-build:unreachable_variant.rs
|
||||
|
||||
extern crate "unreachable-variant" as other;
|
||||
extern crate unreachable_variant as other;
|
||||
|
||||
fn main() {
|
||||
let _x = other::super_sekrit::sooper_sekrit::baz; //~ ERROR is private
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
extern crate
|
||||
"foo"suffix //~ ERROR extern crate name with a suffix is illegal
|
||||
//~^ WARNING: obsolete syntax
|
||||
as foo;
|
||||
|
||||
extern
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Tests that the proper help is displayed in the error message
|
||||
|
||||
extern crate foo as bar;
|
||||
//~^ ERROR expected `;`, found `as`
|
||||
//~^^ HELP perhaps you meant to enclose the crate name `foo` in a string?
|
|
@ -11,4 +11,4 @@
|
|||
// Verifies that the expected token errors for `extern crate` are
|
||||
// raised
|
||||
|
||||
extern crate foo {} //~ERROR expected `;`, found `{`
|
||||
extern crate foo {} //~ERROR expected one of `;` or `as`, found `{`
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#[prelude_import]
|
||||
use std::prelude::v1::*;
|
||||
#[macro_use]
|
||||
extern crate "std" as std;
|
||||
extern crate std as std;
|
||||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
|
|
|
@ -13,6 +13,6 @@
|
|||
#![feature(asm)]
|
||||
|
||||
#[cfg(foo = r#"just parse this"#)]
|
||||
extern crate r##"blah"## as blah;
|
||||
extern crate blah as blah;
|
||||
|
||||
fn main() { unsafe { asm!(r###"blah"###); } }
|
||||
|
|
|
@ -12,4 +12,4 @@ all:
|
|||
| grep "invalid character.*in crate name:"
|
||||
cp foo.rs $(TMPDIR)/-foo.rs
|
||||
$(RUSTC) $(TMPDIR)/-foo.rs 2>&1 \
|
||||
| grep "crate name cannot start with a hyphen:"
|
||||
| grep "soon cannot contain hyphens:"
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
pub struct BigInt;
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
pub struct BigInt;
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
pub trait Local {
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::Remote;
|
||||
|
||||
struct Foo<T>(T);
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
// Test that it's ok for T to appear first in the self-type, as long
|
||||
// as it's covered somewhere.
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::{Remote,Pair};
|
||||
|
||||
pub struct Cover<T>(T);
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
// Test that it's ok for T to appear second in the self-type, as long
|
||||
// as it's covered somewhere.
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::{Remote,Pair};
|
||||
|
||||
pub struct Cover<T>(T);
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
struct Foo<T>(T);
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::Remote1;
|
||||
|
||||
struct Foo<T>(T);
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::Remote;
|
||||
|
||||
struct Local;
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:coherence-lib.rs
|
||||
// aux-build:coherence_lib.rs
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate "coherence-lib" as lib;
|
||||
extern crate coherence_lib as lib;
|
||||
use lib::Remote;
|
||||
|
||||
struct Local<T>(T);
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:issue-12612-1.rs
|
||||
// aux-build:issue-12612-2.rs
|
||||
// aux-build:issue_12612_1.rs
|
||||
// aux-build:issue_12612_2.rs
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate "issue-12612-1" as foo;
|
||||
extern crate "issue-12612-2" as bar;
|
||||
extern crate issue_12612_1 as foo;
|
||||
extern crate issue_12612_2 as bar;
|
||||
|
||||
mod test {
|
||||
use bar::baz;
|
||||
|
|
|
@ -8,13 +8,13 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:trait-safety-lib.rs
|
||||
// aux-build:trait_safety_lib.rs
|
||||
|
||||
// Simple smoke test that unsafe traits can be compiled across crates.
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate "trait-safety-lib" as lib;
|
||||
extern crate trait_safety_lib as lib;
|
||||
|
||||
use lib::Foo;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue