Skip to content

Commit e7fe207

Browse files
committed
auto merge of #13290 : alexcrichton/rust/rollup, r=alexcrichton
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)
2 parents bb31cb8 + 487fa95 commit e7fe207

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+389
-1151
lines changed

src/compiletest/procsrv.rs

+12-10
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,25 @@ use std::str;
1313
use std::io::process::{ProcessExit, Process, ProcessConfig, ProcessOutput};
1414

1515
#[cfg(target_os = "win32")]
16-
fn target_env(lib_path: &str, prog: &str) -> Vec<(~str,~str)> {
17-
18-
let mut env = os::env();
16+
fn target_env(lib_path: &str, prog: &str) -> Vec<(~str, ~str)> {
17+
let env = os::env();
1918

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

24-
env = env.map(|pair| {
25-
let (k,v) = (*pair).clone();
26-
if k == ~"PATH" { (~"PATH", v + ";" + lib_path + ";" + aux_path) }
27-
else { (k,v) }
28-
});
23+
let mut new_env: Vec<_> = env.move_iter().map(|(k, v)| {
24+
let new_v = if "PATH" == k {
25+
format!("{};{};{}", v, lib_path, aux_path)
26+
} else {
27+
v
28+
};
29+
(k, new_v)
30+
}).collect();
2931
if prog.ends_with("rustc.exe") {
30-
env.push((~"RUST_THREADS", ~"1"));
32+
new_env.push((~"RUST_THREADS", ~"1"));
3133
}
32-
return env;
34+
return new_env;
3335
}
3436

3537
#[cfg(target_os = "linux")]

src/compiletest/runtest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
529529
c
530530
}
531531
} ).collect();
532-
str::from_chars( c )
532+
str::from_chars(c.as_slice())
533533
}
534534
535535
#[cfg(target_os = "win32")]

src/doc/tutorial.md

+5-8
Original file line numberDiff line numberDiff line change
@@ -2107,7 +2107,7 @@ references, or types where the only contained references
21072107
have the `'static` lifetime. (For more on named lifetimes and their uses,
21082108
see the [references and lifetimes guide][lifetimes].)
21092109
2110-
> ***Note:*** These two traits were referred to as 'kinds' in earlier
2110+
> ***Note:*** These built-in traits were referred to as 'kinds' in earlier
21112111
> iterations of the language, and often still are.
21122112
21132113
Additionally, the `Drop` trait is used to define destructors. This
@@ -2600,8 +2600,6 @@ As you can see, your module hierarchy is now three modules deep: There is the cr
26002600
function, and the module `farm`. The module `farm` also contains two functions and a third module `barn`,
26012601
which contains a function `hay`.
26022602

2603-
(In case you already stumbled over `extern crate`: It isn't directly related to a bare `mod`, we'll get to it later. )
2604-
26052603
## Paths and visibility
26062604

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

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

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

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

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

30323030
## Using libraries
30333031

@@ -3050,7 +3048,6 @@ fn main() {
30503048
}
30513049
~~~
30523050

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

src/etc/emacs/rust-mode.el

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@
196196
;; Special types
197197
(,(regexp-opt rust-special-types 'words) . font-lock-type-face)
198198

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

203203
;; Syntax extension invocations like `foo!`, highlight including the !

src/libarena/lib.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -23,8 +23,6 @@
2323
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
2424
html_root_url = "http://static.rust-lang.org/doc/master")]
2525
#![allow(missing_doc)]
26-
#![feature(managed_boxes)]
27-
2826
#![allow(visible_private_types)] // NOTE: remove after a stage0 snap
2927

3028
extern crate collections;
@@ -301,7 +299,7 @@ fn test_arena_destructors() {
301299
for i in range(0u, 10) {
302300
// Arena allocate something with drop glue to make sure it
303301
// doesn't leak.
304-
arena.alloc(|| @i);
302+
arena.alloc(|| Rc::new(i));
305303
// Allocate something with funny size and alignment, to keep
306304
// things interesting.
307305
arena.alloc(|| [0u8, 1u8, 2u8]);
@@ -316,13 +314,13 @@ fn test_arena_destructors_fail() {
316314
for i in range(0u, 10) {
317315
// Arena allocate something with drop glue to make sure it
318316
// doesn't leak.
319-
arena.alloc(|| { @i });
317+
arena.alloc(|| { Rc::new(i) });
320318
// Allocate something with funny size and alignment, to keep
321319
// things interesting.
322320
arena.alloc(|| { [0u8, 1u8, 2u8] });
323321
}
324322
// Now, fail while allocating
325-
arena.alloc::<@int>(|| {
323+
arena.alloc::<Rc<int>>(|| {
326324
// Now fail.
327325
fail!();
328326
});

src/librustc/front/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn fold_foreign_mod(cx: &mut Context, nm: &ast::ForeignMod) -> ast::ForeignMod {
9090
filter_view_item(cx, a).map(|x| cx.fold_view_item(x))
9191
}).collect();
9292
ast::ForeignMod {
93-
abis: nm.abis,
93+
abi: nm.abi,
9494
view_items: filtered_view_items,
9595
items: filtered_items
9696
}

src/librustc/lib/llvm.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1438,8 +1438,6 @@ pub mod llvm {
14381438
-> Bool;
14391439
/** Moves the section iterator to point to the next section. */
14401440
pub fn LLVMMoveToNextSection(SI: SectionIteratorRef);
1441-
/** Returns the current section name. */
1442-
pub fn LLVMGetSectionName(SI: SectionIteratorRef) -> *c_char;
14431441
/** Returns the current section size. */
14441442
pub fn LLVMGetSectionSize(SI: SectionIteratorRef) -> c_ulonglong;
14451443
/** Returns the current section contents as a string buffer. */
@@ -1784,6 +1782,9 @@ pub mod llvm {
17841782

17851783
pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
17861784
pub fn LLVMVersionMinor() -> c_int;
1785+
1786+
pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
1787+
data: *mut *c_char) -> c_int;
17871788
}
17881789
}
17891790

src/librustc/metadata/creader.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ fn extract_crate_info(e: &Env, i: &ast::ViewItem) -> Option<CrateInfo> {
187187
fn visit_item(e: &Env, i: &ast::Item) {
188188
match i.node {
189189
ast::ItemForeignMod(ref fm) => {
190-
if fm.abis.is_rust() || fm.abis.is_intrinsic() {
190+
if fm.abi == abi::Rust || fm.abi == abi::RustIntrinsic {
191191
return;
192192
}
193193

src/librustc/metadata/encoder.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use std::hash::Hash;
3333
use std::io::MemWriter;
3434
use std::str;
3535
use collections::HashMap;
36-
use syntax::abi::AbiSet;
36+
use syntax::abi;
3737
use syntax::ast::*;
3838
use syntax::ast;
3939
use syntax::ast_map::{PathElem, PathElems};
@@ -1217,7 +1217,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
12171217
nitem: &ForeignItem,
12181218
index: @RefCell<Vec<entry<i64>> >,
12191219
path: PathElems,
1220-
abi: AbiSet) {
1220+
abi: abi::Abi) {
12211221
index.borrow_mut().push(entry {
12221222
val: nitem.id as i64,
12231223
pos: ebml_w.writer.tell().unwrap(),
@@ -1231,7 +1231,7 @@ fn encode_info_for_foreign_item(ecx: &EncodeContext,
12311231
encode_bounds_and_type(ebml_w, ecx,
12321232
&lookup_item_type(ecx.tcx,local_def(nitem.id)));
12331233
encode_name(ebml_w, nitem.ident.name);
1234-
if abi.is_intrinsic() {
1234+
if abi == abi::RustIntrinsic {
12351235
(ecx.encode_inlined_item)(ecx, ebml_w, IIForeignRef(nitem));
12361236
} else {
12371237
encode_symbol(ecx, ebml_w, nitem.id);
@@ -1279,11 +1279,11 @@ fn my_visit_foreign_item(ni: &ForeignItem,
12791279
let mut ebml_w = unsafe {
12801280
ebml_w.unsafe_clone()
12811281
};
1282-
let abis = ecx.tcx.map.get_foreign_abis(ni.id);
1282+
let abi = ecx.tcx.map.get_foreign_abi(ni.id);
12831283
ecx.tcx.map.with_path(ni.id, |path| {
12841284
encode_info_for_foreign_item(ecx, &mut ebml_w,
12851285
ni, index,
1286-
path, abis);
1286+
path, abi);
12871287
});
12881288
}
12891289

src/librustc/metadata/loader.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ use std::cast;
2929
use std::cmp;
3030
use std::io;
3131
use std::os::consts::{macos, freebsd, linux, android, win32};
32+
use std::ptr;
3233
use std::rc::Rc;
33-
use std::str;
3434
use std::slice;
35+
use std::str;
3536

3637
use collections::{HashMap, HashSet};
3738
use flate;
@@ -439,8 +440,9 @@ fn get_metadata_section_imp(os: Os, filename: &Path) -> Result<MetadataBlob, ~st
439440
};
440441
let si = mk_section_iter(of.llof);
441442
while llvm::LLVMIsSectionIteratorAtEnd(of.llof, si.llsi) == False {
442-
let name_buf = llvm::LLVMGetSectionName(si.llsi);
443-
let name = str::raw::from_c_str(name_buf);
443+
let mut name_buf = ptr::null();
444+
let name_len = llvm::LLVMRustGetSectionName(si.llsi, &mut name_buf);
445+
let name = str::raw::from_buf_len(name_buf as *u8, name_len as uint);
444446
debug!("get_metadata_section: name {}", name);
445447
if read_meta_section_name(os) == name {
446448
let cbuf = llvm::LLVMGetSectionContents(si.llsi);

src/librustc/metadata/tydecode.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use middle::ty;
2020

2121
use std::str;
2222
use std::uint;
23-
use syntax::abi::AbiSet;
2423
use syntax::abi;
2524
use syntax::ast;
2625
use syntax::ast::*;
@@ -460,18 +459,12 @@ fn parse_purity(c: char) -> Purity {
460459
}
461460
}
462461

463-
fn parse_abi_set(st: &mut PState) -> AbiSet {
462+
fn parse_abi_set(st: &mut PState) -> abi::Abi {
464463
assert_eq!(next(st), '[');
465-
let mut abis = AbiSet::empty();
466-
while peek(st) != ']' {
467-
scan(st, |c| c == ',', |bytes| {
468-
let abi_str = str::from_utf8(bytes).unwrap().to_owned();
469-
let abi = abi::lookup(abi_str).expect(abi_str);
470-
abis.add(abi);
471-
});
472-
}
473-
assert_eq!(next(st), ']');
474-
return abis;
464+
scan(st, |c| c == ']', |bytes| {
465+
let abi_str = str::from_utf8(bytes).unwrap().to_owned();
466+
abi::lookup(abi_str).expect(abi_str)
467+
})
475468
}
476469

477470
fn parse_onceness(c: char) -> ast::Onceness {
@@ -505,7 +498,7 @@ fn parse_bare_fn_ty(st: &mut PState, conv: conv_did) -> ty::BareFnTy {
505498
let sig = parse_sig(st, |x,y| conv(x,y));
506499
ty::BareFnTy {
507500
purity: purity,
508-
abis: abi,
501+
abi: abi,
509502
sig: sig
510503
}
511504
}

src/librustc/metadata/tyencode.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::fmt;
2323
use middle::ty::param_ty;
2424
use middle::ty;
2525

26-
use syntax::abi::AbiSet;
26+
use syntax::abi::Abi;
2727
use syntax::ast;
2828
use syntax::ast::*;
2929
use syntax::diagnostic::SpanHandler;
@@ -341,12 +341,9 @@ fn enc_purity(w: &mut MemWriter, p: Purity) {
341341
}
342342
}
343343

344-
fn enc_abi_set(w: &mut MemWriter, abis: AbiSet) {
344+
fn enc_abi(w: &mut MemWriter, abi: Abi) {
345345
mywrite!(w, "[");
346-
abis.each(|abi| {
347-
mywrite!(w, "{},", abi.name());
348-
true
349-
});
346+
mywrite!(w, "{}", abi.name());
350347
mywrite!(w, "]")
351348
}
352349

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

360357
pub fn enc_bare_fn_ty(w: &mut MemWriter, cx: &ctxt, ft: &ty::BareFnTy) {
361358
enc_purity(w, ft.purity);
362-
enc_abi_set(w, ft.abis);
359+
enc_abi(w, ft.abi);
363360
enc_fn_sig(w, cx, &ft.sig);
364361
}
365362

src/librustc/middle/lint.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ use std::u32;
5959
use std::u64;
6060
use std::u8;
6161
use collections::SmallIntMap;
62+
use syntax::abi;
6263
use syntax::ast_map;
6364
use syntax::ast_util::IdVisitingOperation;
6465
use syntax::attr::{AttrMetaMethods, AttributeMethods};
@@ -892,7 +893,7 @@ fn check_item_ctypes(cx: &Context, it: &ast::Item) {
892893
}
893894

894895
match it.node {
895-
ast::ItemForeignMod(ref nmod) if !nmod.abis.is_intrinsic() => {
896+
ast::ItemForeignMod(ref nmod) if nmod.abi != abi::RustIntrinsic => {
896897
for ni in nmod.items.iter() {
897898
match ni.node {
898899
ast::ForeignItemFn(decl, _) => check_foreign_fn(cx, decl),

src/librustc/middle/trans/base.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -855,8 +855,8 @@ pub fn trans_external_path(ccx: &CrateContext, did: ast::DefId, t: ty::t) -> Val
855855
let name = csearch::get_symbol(&ccx.sess().cstore, did);
856856
match ty::get(t).sty {
857857
ty::ty_bare_fn(ref fn_ty) => {
858-
match fn_ty.abis.for_target(ccx.sess().targ_cfg.os,
859-
ccx.sess().targ_cfg.arch) {
858+
match fn_ty.abi.for_target(ccx.sess().targ_cfg.os,
859+
ccx.sess().targ_cfg.arch) {
860860
Some(Rust) | Some(RustIntrinsic) => {
861861
get_extern_rust_fn(ccx,
862862
fn_ty.sig.inputs.as_slice(),
@@ -865,7 +865,7 @@ pub fn trans_external_path(ccx: &CrateContext, did: ast::DefId, t: ty::t) -> Val
865865
did)
866866
}
867867
Some(..) | None => {
868-
let c = foreign::llvm_calling_convention(ccx, fn_ty.abis);
868+
let c = foreign::llvm_calling_convention(ccx, fn_ty.abi);
869869
let cconv = c.unwrap_or(lib::llvm::CCallConv);
870870
let llty = type_of_fn_from_ty(ccx, t);
871871
get_extern_fn(&mut *ccx.externs.borrow_mut(), ccx.llmod,
@@ -1601,7 +1601,7 @@ impl<'a> Visitor<()> for TransItemVisitor<'a> {
16011601
pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
16021602
let _icx = push_ctxt("trans_item");
16031603
match item.node {
1604-
ast::ItemFn(decl, purity, _abis, ref generics, body) => {
1604+
ast::ItemFn(decl, purity, _abi, ref generics, body) => {
16051605
if purity == ast::ExternFn {
16061606
let llfndecl = get_item_val(ccx, item.id);
16071607
foreign::trans_rust_fn_with_foreign_abi(
@@ -1721,7 +1721,7 @@ fn register_fn(ccx: &CrateContext,
17211721
-> ValueRef {
17221722
let f = match ty::get(node_type).sty {
17231723
ty::ty_bare_fn(ref f) => {
1724-
assert!(f.abis.is_rust() || f.abis.is_intrinsic());
1724+
assert!(f.abi == Rust || f.abi == RustIntrinsic);
17251725
f
17261726
}
17271727
_ => fail!("expected bare rust fn or an intrinsic")
@@ -1997,8 +1997,8 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
19971997

19981998
match ni.node {
19991999
ast::ForeignItemFn(..) => {
2000-
let abis = ccx.tcx.map.get_foreign_abis(id);
2001-
foreign::register_foreign_item_fn(ccx, abis, ni)
2000+
let abi = ccx.tcx.map.get_foreign_abi(id);
2001+
foreign::register_foreign_item_fn(ccx, abi, ni)
20022002
}
20032003
ast::ForeignItemStatic(..) => {
20042004
foreign::register_static(ccx, ni)

0 commit comments

Comments
 (0)