_ => return
};
- let msg = match stability {
- Some(attr::Stability { text: Some(ref s), .. }) => {
- format!("use of {} item: {}", label, *s)
+ output(cx, span, stability, lint, label);
+ if cross_crate && stability::is_staged_api(cx.tcx, id) {
+ if lint.name == UNSTABLE.name {
+ output(cx, span, stability, STAGED_UNSTABLE, label);
+ } else if lint.name == EXPERIMENTAL.name {
+ output(cx, span, stability, STAGED_EXPERIMENTAL, label);
}
- _ => format!("use of {} item", label)
- };
+ }
- cx.span_lint(lint, span, &msg[]);
+ fn output(cx: &Context, span: Span, stability: &Option<attr::Stability>,
+ lint: &'static Lint, label: &'static str) {
+ let msg = match *stability {
+ Some(attr::Stability { text: Some(ref s), .. }) => {
+ format!("use of {} item: {}", label, *s)
+ }
+ _ => format!("use of {} item", label)
+ };
+
- cx.span_lint(lint, span, msg.index(&FullRange));
++ cx.span_lint(lint, span, &msg[]);
+ }
}
+
fn is_internal(&self, cx: &Context, span: Span) -> bool {
cx.tcx.sess.codemap().span_is_internal(span)
}
pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
use syntax::parse::token::intern_and_get_ident as intern;
- let end = sess.target.target.target_endian.index(&FullRange);
- let arch = sess.target.target.arch.index(&FullRange);
- let wordsz = sess.target.target.target_pointer_width.index(&FullRange);
- let os = sess.target.target.target_os.index(&FullRange);
+ let end = &sess.target.target.target_endian[];
+ let arch = &sess.target.target.arch[];
- let wordsz = &sess.target.target.target_word_size[];
++ let wordsz = &sess.target.target.target_pointer_width[];
+ let os = &sess.target.target.target_os[];
let fam = match sess.target.target.options.is_like_windows {
true => InternedString::new("windows"),
}
};
- let (int_type, uint_type) = match target.target_pointer_width.index(&FullRange) {
- let (int_type, uint_type) = match &target.target_word_size[] {
++ let (int_type, uint_type) = match &target.target_pointer_width[] {
"32" => (ast::TyI32, ast::TyU32),
"64" => (ast::TyI64, ast::TyU64),
- w => sp.handler().fatal((format!("target specification was invalid: unrecognized \
- target-word-size {}", w)).index(&FullRange))
+ w => sp.handler().fatal(&format!("target specification was invalid: unrecognized \
+ target-word-size {}", w)[])
};
Config {
pub fn call_memcpy(cx: Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) {
let _icx = push_ctxt("call_memcpy");
let ccx = cx.ccx();
- let key = match ccx.sess().target.target.target_pointer_width.index(&FullRange) {
- let key = match &ccx.sess().target.target.target_word_size[] {
++ let key = match &ccx.sess().target.target.target_pointer_width[] {
"32" => "llvm.memcpy.p0i8.p0i8.i32",
"64" => "llvm.memcpy.p0i8.p0i8.i64",
tws => panic!("Unsupported target word size for memcpy: {}", tws),
let llty = type_of::type_of(ccx, ty);
- let intrinsic_key = match ccx.sess().target.target.target_pointer_width.index(&FullRange) {
- let intrinsic_key = match &ccx.sess().target.target.target_word_size[] {
++ let intrinsic_key = match &ccx.sess().target.target.target_pointer_width[] {
"32" => "llvm.memset.p0i8.i32",
"64" => "llvm.memset.p0i8.i64",
tws => panic!("Unsupported target word size for memset: {}", tws),
/// currently conservatively bounded to 1 << 47 as that is enough to cover the current usable
/// address space on 64-bit ARMv8 and x86_64.
pub fn obj_size_bound(&self) -> u64 {
- match self.sess().target.target.target_pointer_width.index(&FullRange) {
- match &self.sess().target.target.target_word_size[] {
++ match &self.sess().target.target.target_pointer_width[] {
"32" => 1 << 31,
"64" => 1 << 47,
_ => unreachable!() // error handled by config::build_target_config
hash_id.hash(&mut state);
mono_ty.hash(&mut state);
- hash = format!("h{}", state.result());
+ hash = format!("h{}", state.finish());
ccx.tcx().map.with_path(fn_id.node, |path| {
- exported_name(path, hash.index(&FullRange))
+ exported_name(path, &hash[])
})
};
}
pub fn int(ccx: &CrateContext) -> Type {
- match ccx.tcx().sess.target.target.target_pointer_width.index(&FullRange) {
- match &ccx.tcx().sess.target.target.target_word_size[] {
++ match &ccx.tcx().sess.target.target.target_pointer_width[] {
"32" => Type::i32(ccx),
"64" => Type::i64(ccx),
tws => panic!("Unsupported target word size for int: {}", tws),
attr::mark_used(&no_std_attr);
krate.attrs.push(no_std_attr);
- if !no_prelude(krate.attrs.index(&FullRange)) {
+ // only add `use std::prelude::*;` if there wasn't a
+ // `#![no_implicit_prelude]` at the crate level.
+ // fold_mod() will insert glob path.
+ if !no_prelude(&krate.attrs[]) {
+ // only add `use std::prelude::*;` if there wasn't a
+ // `#![no_implicit_prelude]` at the crate level.
+ // fold_mod() will insert glob path.
+ let globs_attr = attr::mk_attr_inner(attr::mk_attr_id(),
+ attr::mk_list_item(
+ InternedString::new("feature"),
+ vec!(
+ attr::mk_word_item(InternedString::new("globs")),
+ )));
+ // std_inject runs after feature checking so manually mark this attr
+ attr::mark_used(&globs_attr);
+ krate.attrs.push(globs_attr);
+
krate.module = self.fold_mod(krate.module);
}
krate