Skip to content

Commit

Permalink
auto merge of #13290 : alexcrichton/rust/rollup, r=alexcrichton
Browse files Browse the repository at this point in the history
Closes #13285 (rustc: Stop using LLVMGetSectionName)
Closes #13280 (std: override clone_from for Vec.)
Closes #13277 (serialize: add a few missing pubs to base64)
Closes #13275 (Add and remove some ignore-win32 flags)
Closes #13273 (Removed managed boxes from libarena.)
Closes #13270 (Minor copy-editing for the tutorial)
Closes #13267 (fix Option<~ZeroSizeType>)
Closes #13265 (Update emacs mode to support new `#![inner(attribute)]` syntax.)
Closes #13263 (syntax: Remove AbiSet, use one Abi)
  • Loading branch information
bors committed Apr 4, 2014
2 parents bb31cb8 + 487fa95 commit e7fe207
Show file tree
Hide file tree
Showing 64 changed files with 389 additions and 1,151 deletions.
22 changes: 12 additions & 10 deletions src/compiletest/procsrv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,25 @@ use std::str;
use std::io::process::{ProcessExit, Process, ProcessConfig, ProcessOutput};

#[cfg(target_os = "win32")]
fn target_env(lib_path: &str, prog: &str) -> Vec<(~str,~str)> {

let mut env = os::env();
fn target_env(lib_path: &str, prog: &str) -> Vec<(~str, ~str)> {
let env = os::env();

// Make sure we include the aux directory in the path
assert!(prog.ends_with(".exe"));
let aux_path = prog.slice(0u, prog.len() - 4u).to_owned() + ".libaux";

env = env.map(|pair| {
let (k,v) = (*pair).clone();
if k == ~"PATH" { (~"PATH", v + ";" + lib_path + ";" + aux_path) }
else { (k,v) }
});
let mut new_env: Vec<_> = env.move_iter().map(|(k, v)| {
let new_v = if "PATH" == k {
format!("{};{};{}", v, lib_path, aux_path)
} else {
v
};
(k, new_v)
}).collect();
if prog.ends_with("rustc.exe") {
env.push((~"RUST_THREADS", ~"1"));
new_env.push((~"RUST_THREADS", ~"1"));
}
return env;
return new_env;
}

#[cfg(target_os = "linux")]
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
c
}
} ).collect();
str::from_chars( c )
str::from_chars(c.as_slice())
}

#[cfg(target_os = "win32")]
Expand Down
13 changes: 5 additions & 8 deletions src/doc/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -2107,7 +2107,7 @@ references, or types where the only contained references
have the `'static` lifetime. (For more on named lifetimes and their uses,
see the [references and lifetimes guide][lifetimes].)

> ***Note:*** These two traits were referred to as 'kinds' in earlier
> ***Note:*** These built-in traits were referred to as 'kinds' in earlier
> iterations of the language, and often still are.
Additionally, the `Drop` trait is used to define destructors. This
Expand Down Expand Up @@ -2600,8 +2600,6 @@ As you can see, your module hierarchy is now three modules deep: There is the cr
function, and the module `farm`. The module `farm` also contains two functions and a third module `barn`,
which contains a function `hay`.

(In case you already stumbled over `extern crate`: It isn't directly related to a bare `mod`, we'll get to it later. )

## Paths and visibility

We've now defined a nice module hierarchy. But how do we access the items in it from our `main` function?
Expand Down Expand Up @@ -2843,11 +2841,11 @@ use farm::cow;

The path you give to `use` is per default global, meaning relative to the crate root,
no matter how deep the module hierarchy is, or whether the module body it's written in
is contained in its own file (remember: files are irrelevant).
is contained in its own file. (Remember: files are irrelevant.)

This is different to other languages, where you often only find a single import construct that combines the semantic
This is different from other languages, where you often only find a single import construct that combines the semantic
of `mod foo;` and `use`-statements, and which tend to work relative to the source file or use an absolute file path
- Rubys `require` or C/C++'s `#include` come to mind.
- Ruby's `require` or C/C++'s `#include` come to mind.

However, it's also possible to import things relative to the module of the `use`-statement:
Adding a `super::` in front of the path will start in the parent module,
Expand Down Expand Up @@ -3027,7 +3025,7 @@ The nested `barn` module is private, but the `pub use` allows users
of the module `farm` to access a function from `barn` without needing
to know that `barn` exists.

In other words, you can use them to decouple an public api from their internal implementation.
In other words, you can use it to decouple a public api from its internal implementation.

## Using libraries

Expand All @@ -3050,7 +3048,6 @@ fn main() {
}
~~~

Despite its name, `extern crate` is a distinct construct from regular `mod` declarations:
A statement of the form `extern crate foo;` will cause `rustc` to search for the crate `foo`,
and if it finds a matching binary it lets you use it from inside your crate.

Expand Down
4 changes: 2 additions & 2 deletions src/etc/emacs/rust-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@
;; Special types
(,(regexp-opt rust-special-types 'words) . font-lock-type-face)

;; Attributes like `#[bar(baz)]`
(,(rust-re-grab (concat "#\\[" rust-re-ident "[^]]*\\]"))
;; Attributes like `#[bar(baz)]` or `#![bar(baz)]`
(,(rust-re-grab (concat "#\\!?[" rust-re-ident "[^]]*\\]"))
1 font-lock-preprocessor-face)

;; Syntax extension invocations like `foo!`, highlight including the !
Expand Down
10 changes: 4 additions & 6 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -23,8 +23,6 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://static.rust-lang.org/doc/master")]
#![allow(missing_doc)]
#![feature(managed_boxes)]

#![allow(visible_private_types)] // NOTE: remove after a stage0 snap

extern crate collections;
Expand Down Expand Up @@ -301,7 +299,7 @@ fn test_arena_destructors() {
for i in range(0u, 10) {
// Arena allocate something with drop glue to make sure it
// doesn't leak.
arena.alloc(|| @i);
arena.alloc(|| Rc::new(i));
// Allocate something with funny size and alignment, to keep
// things interesting.
arena.alloc(|| [0u8, 1u8, 2u8]);
Expand All @@ -316,13 +314,13 @@ fn test_arena_destructors_fail() {
for i in range(0u, 10) {
// Arena allocate something with drop glue to make sure it
// doesn't leak.
arena.alloc(|| { @i });
arena.alloc(|| { Rc::new(i) });
// Allocate something with funny size and alignment, to keep
// things interesting.
arena.alloc(|| { [0u8, 1u8, 2u8] });
}
// Now, fail while allocating
arena.alloc::<@int>(|| {
arena.alloc::<Rc<int>>(|| {
// Now fail.
fail!();
});
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/front/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn fold_foreign_mod(cx: &mut Context, nm: &ast::ForeignMod) -> ast::ForeignMod {
filter_view_item(cx, a).map(|x| cx.fold_view_item(x))
}).collect();
ast::ForeignMod {
abis: nm.abis,
abi: nm.abi,
view_items: filtered_view_items,
items: filtered_items
}
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1438,8 +1438,6 @@ pub mod llvm {
-> Bool;
/** Moves the section iterator to point to the next section. */
pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
/** Returns the current section name. */
pub fn LLVMGetSectionName(SI: SectionIteratorRef) -> *c_char;
/** Returns the current section size. */
pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
/** Returns the current section contents as a string buffer. */
Expand Down Expand Up @@ -1784,6 +1782,9 @@ pub mod llvm {

pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
pub fn LLVMVersionMinor() -> c_int;

pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
data: *mut *c_char) -> c_int;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ fn extract_crate_info(e: &Env, i: &ast::ViewItem) -> Option<CrateInfo> {
fn visit_item(e: &Env, i: &ast::Item) {
match i.node {
ast::ItemForeignMod(ref fm) => {
if fm.abis.is_rust() || fm.abis.is_intrinsic() {
if fm.abi == abi::Rust || fm.abi == abi::RustIntrinsic {
return;
}

Expand Down
10 changes: 5 additions & 5 deletions src/librustc/metadata/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use std::hash::Hash;
use std::io::MemWriter;
use std::str;
use collections::HashMap;
use syntax::abi::AbiSet;
use syntax::abi;
use syntax::ast::*;
use syntax::ast;
use syntax::ast_map::{PathElem, PathElems};
Expand Down Expand Up @@ -1217,7 +1217,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
nitem: &ForeignItem,
index: @RefCell<Vec<entry<i64>> >,
path: PathElems,
abi: AbiSet) {
abi: abi::Abi) {
index.borrow_mut().push(entry {
val: nitem.id as i64,
pos: ebml_w.writer.tell().unwrap(),
Expand All @@ -1231,7 +1231,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
encode_bounds_and_type(ebml_w, ecx,
&lookup_item_type(ecx.tcx,local_def(nitem.id)));
encode_name(ebml_w, nitem.ident.name);
if abi.is_intrinsic() {
if abi == abi::RustIntrinsic {
(ecx.encode_inlined_item)(ecx, ebml_w, IIForeignRef(nitem));
} else {
encode_symbol(ecx, ebml_w, nitem.id);
Expand Down Expand Up @@ -1279,11 +1279,11 @@ fn my_visit_foreign_item(ni: &ForeignItem,
let mut ebml_w = unsafe {
ebml_w.unsafe_clone()
};
let abis = ecx.tcx.map.get_foreign_abis(ni.id);
let abi = ecx.tcx.map.get_foreign_abi(ni.id);
ecx.tcx.map.with_path(ni.id, |path| {
encode_info_for_foreign_item(ecx, &mut ebml_w,
ni, index,
path, abis);
path, abi);
});
}

Expand Down
8 changes: 5 additions & 3 deletions src/librustc/metadata/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ use std::cast;
use std::cmp;
use std::io;
use std::os::consts::{macos, freebsd, linux, android, win32};
use std::ptr;
use std::rc::Rc;
use std::str;
use std::slice;
use std::str;

use collections::{HashMap, HashSet};
use flate;
Expand Down Expand Up @@ -439,8 +440,9 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, ~st
};
let si = mk_section_iter(of.llof);
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
let name_buf = llvm::LLVMGetSectionName(si.llsi);
let name = str::raw::from_c_str(name_buf);
let mut name_buf = ptr::null();
let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf);
let name = str::raw::from_buf_len(name_buf as *u8, name_len as uint);
debug!("get_metadata_section: name {}", name);
if read_meta_section_name(os) == name {
let cbuf = llvm::LLVMGetSectionContents(si.llsi);
Expand Down
19 changes: 6 additions & 13 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use middle::ty;

use std::str;
use std::uint;
use syntax::abi::AbiSet;
use syntax::abi;
use syntax::ast;
use syntax::ast::*;
Expand Down Expand Up @@ -460,18 +459,12 @@ fn parse_purity(c: char) -> Purity {
}
}

fn parse_abi_set(st: &mut PState) -> AbiSet {
fn parse_abi_set(st: &mut PState) -> abi::Abi {
assert_eq!(next(st), '[');
let mut abis = AbiSet::empty();
while peek(st) != ']' {
scan(st, |c| c == ',', |bytes| {
let abi_str = str::from_utf8(bytes).unwrap().to_owned();
let abi = abi::lookup(abi_str).expect(abi_str);
abis.add(abi);
});
}
assert_eq!(next(st), ']');
return abis;
scan(st, |c| c == ']', |bytes| {
let abi_str = str::from_utf8(bytes).unwrap().to_owned();
abi::lookup(abi_str).expect(abi_str)
})
}

fn parse_onceness(c: char) -> ast::Onceness {
Expand Down Expand Up @@ -505,7 +498,7 @@ fn parse_bare_fn_ty(st: &mut PState, conv: conv_did) -> ty::BareFnTy {
let sig = parse_sig(st, |x,y| conv(x,y));
ty::BareFnTy {
purity: purity,
abis: abi,
abi: abi,
sig: sig
}
}
Expand Down
11 changes: 4 additions & 7 deletions src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use std::fmt;
use middle::ty::param_ty;
use middle::ty;

use syntax::abi::AbiSet;
use syntax::abi::Abi;
use syntax::ast;
use syntax::ast::*;
use syntax::diagnostic::SpanHandler;
Expand Down Expand Up @@ -341,12 +341,9 @@ fn enc_purity(w: &mut MemWriter, p: Purity) {
}
}

fn enc_abi_set(w: &mut MemWriter, abis: AbiSet) {
fn enc_abi(w: &mut MemWriter, abi: Abi) {
mywrite!(w, "[");
abis.each(|abi| {
mywrite!(w, "{},", abi.name());
true
});
mywrite!(w, "{}", abi.name());
mywrite!(w, "]")
}

Expand All @@ -359,7 +356,7 @@ fn enc_onceness(w: &mut MemWriter, o: Onceness) {

pub fn enc_bare_fn_ty(w: &mut MemWriter, cx: &ctxt, ft: &ty::BareFnTy) {
enc_purity(w, ft.purity);
enc_abi_set(w, ft.abis);
enc_abi(w, ft.abi);
enc_fn_sig(w, cx, &ft.sig);
}

Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ use std::u32;
use std::u64;
use std::u8;
use collections::SmallIntMap;
use syntax::abi;
use syntax::ast_map;
use syntax::ast_util::IdVisitingOperation;
use syntax::attr::{AttrMetaMethods, AttributeMethods};
Expand Down Expand Up @@ -892,7 +893,7 @@ fn check_item_ctypes(cx: &Context, it: &ast::Item) {
}

match it.node {
ast::ItemForeignMod(ref nmod) if !nmod.abis.is_intrinsic() => {
ast::ItemForeignMod(ref nmod) if nmod.abi != abi::RustIntrinsic => {
for ni in nmod.items.iter() {
match ni.node {
ast::ForeignItemFn(decl, _) => check_foreign_fn(cx, decl),
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,8 +855,8 @@ pub fn trans_external_path(ccx: &CrateContext, did: ast::DefId, t: ty::t) -> Val
let name = csearch::get_symbol(&ccx.sess().cstore, did);
match ty::get(t).sty {
ty::ty_bare_fn(ref fn_ty) => {
match fn_ty.abis.for_target(ccx.sess().targ_cfg.os,
ccx.sess().targ_cfg.arch) {
match fn_ty.abi.for_target(ccx.sess().targ_cfg.os,
ccx.sess().targ_cfg.arch) {
Some(Rust) | Some(RustIntrinsic) => {
get_extern_rust_fn(ccx,
fn_ty.sig.inputs.as_slice(),
Expand All @@ -865,7 +865,7 @@ pub fn trans_external_path(ccx: &CrateContext, did: ast::DefId, t: ty::t) -> Val
did)
}
Some(..) | None => {
let c = foreign::llvm_calling_convention(ccx, fn_ty.abis);
let c = foreign::llvm_calling_convention(ccx, fn_ty.abi);
let cconv = c.unwrap_or(lib::llvm::CCallConv);
let llty = type_of_fn_from_ty(ccx, t);
get_extern_fn(&mut *ccx.externs.borrow_mut(), ccx.llmod,
Expand Down Expand Up @@ -1601,7 +1601,7 @@ impl<'a> Visitor<()> for TransItemVisitor<'a> {
pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
let _icx = push_ctxt("trans_item");
match item.node {
ast::ItemFn(decl, purity, _abis, ref generics, body) => {
ast::ItemFn(decl, purity, _abi, ref generics, body) => {
if purity == ast::ExternFn {
let llfndecl = get_item_val(ccx, item.id);
foreign::trans_rust_fn_with_foreign_abi(
Expand Down Expand Up @@ -1721,7 +1721,7 @@ fn register_fn(ccx: &CrateContext,
-> ValueRef {
let f = match ty::get(node_type).sty {
ty::ty_bare_fn(ref f) => {
assert!(f.abis.is_rust() || f.abis.is_intrinsic());
assert!(f.abi == Rust || f.abi == RustIntrinsic);
f
}
_ => fail!("expected bare rust fn or an intrinsic")
Expand Down Expand Up @@ -1997,8 +1997,8 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {

match ni.node {
ast::ForeignItemFn(..) => {
let abis = ccx.tcx.map.get_foreign_abis(id);
foreign::register_foreign_item_fn(ccx, abis, ni)
let abi = ccx.tcx.map.get_foreign_abi(id);
foreign::register_foreign_item_fn(ccx, abi, ni)
}
ast::ForeignItemStatic(..) => {
foreign::register_static(ccx, ni)
Expand Down
Loading

0 comments on commit e7fe207

Please sign in to comment.