Skip to content

Commit 1f3fb8d

Browse files
committed
---
yaml --- r: 85707 b: refs/heads/dist-snap c: 9e1e152 h: refs/heads/master i: 85705: 7b348c1 85703: 1cfece6 v: v3
1 parent 71769db commit 1f3fb8d

Some content is hidden

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

54 files changed

+2000
-711
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 0983ebe5310d4eb6d289f636f7ed0536c08bbc0e
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/dist-snap: 651f38258d72742c5961d646f865316f8ea1823c
9+
refs/heads/dist-snap: 9e1e15209129dad9d3bba90450a43ffb2505df14
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/doc/rust.md

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,38 @@ In this example, the module `quux` re-exports all of the public names defined in
851851

852852
Also note that the paths contained in `use` items are relative to the crate root.
853853
So, in the previous example, the `use` refers to `quux::foo::*`, and not simply to `foo::*`.
854+
This also means that top-level module declarations should be at the crate root if direct usage
855+
of the declared modules within `use` items is desired. It is also possible to use `self` and `super`
856+
at the beginning of a `use` item to refer to the current and direct parent modules respectively.
857+
All rules regarding accessing declared modules in `use` declarations applies to both module declarations
858+
and `extern mod` declarations.
859+
860+
An example of what will and will not work for `use` items:
861+
~~~~
862+
# #[allow(unused_imports)];
863+
use foo::extra; // good: foo is at the root of the crate
864+
use foo::baz::foobaz; // good: foo is at the root of the crate
865+
866+
mod foo {
867+
extern mod extra;
868+
869+
use foo::extra::list; // good: foo is at crate root
870+
// use extra::*; // bad: extra is not at the crate root
871+
use self::baz::foobaz; // good: self refers to module 'foo'
872+
use foo::bar::foobar; // good: foo is at crate root
873+
874+
pub mod bar {
875+
pub fn foobar() { }
876+
}
877+
878+
pub mod baz {
879+
use super::bar::foobar; // good: super refers to module 'foo'
880+
pub fn foobaz() { }
881+
}
882+
}
883+
884+
fn main() {}
885+
~~~~
854886

855887
### Functions
856888

@@ -1006,20 +1038,25 @@ code_. They are defined in the same way as any other Rust function,
10061038
except that they have the `extern` modifier.
10071039

10081040
~~~
1041+
// Declares an extern fn, the ABI defaults to "C"
10091042
extern fn new_vec() -> ~[int] { ~[] }
1043+
1044+
// Declares an extern fn with "stdcall" ABI
1045+
extern "stdcall" fn new_vec_stdcall() -> ~[int] { ~[] }
10101046
~~~
10111047

1012-
Extern functions may not be called from Rust code,
1013-
but Rust code may take their value as a raw `u8` pointer.
1048+
Unlike normal functions, extern fns have an `extern "ABI" fn()`.
1049+
This is the same type as the functions declared in an extern
1050+
block.
10141051

10151052
~~~
10161053
# extern fn new_vec() -> ~[int] { ~[] }
1017-
let fptr: *u8 = new_vec;
1054+
let fptr: extern "C" fn() -> ~[int] = new_vec;
10181055
~~~
10191056

1020-
The primary motivation for extern functions is
1021-
to create callbacks for foreign functions that expect to receive function
1022-
pointers.
1057+
Extern functions may be called from Rust code, but
1058+
caution must be taken with respect to the size of the stack
1059+
segment, just as when calling an extern function normally.
10231060

10241061
### Type definitions
10251062

@@ -1384,14 +1421,13 @@ between the Rust ABI and the foreign ABI.
13841421
A number of [attributes](#attributes) control the behavior of external
13851422
blocks.
13861423

1387-
By default external blocks assume
1388-
that the library they are calling uses the standard C "cdecl" ABI.
1389-
Other ABIs may be specified using the `abi` attribute as in
1424+
By default external blocks assume that the library they are calling
1425+
uses the standard C "cdecl" ABI. Other ABIs may be specified using
1426+
an `abi` string, as shown here:
13901427

13911428
~~~{.xfail-test}
13921429
// Interface to the Windows API
1393-
#[abi = "stdcall"]
1394-
extern { }
1430+
extern "stdcall" { }
13951431
~~~
13961432

13971433
The `link_name` attribute allows the name of the library to be specified.
@@ -1407,6 +1443,12 @@ This is particularly useful for creating external blocks for libc,
14071443
which tends to not follow standard library naming conventions
14081444
and is linked to all Rust programs anyway.
14091445

1446+
The type of a function
1447+
declared in an extern block
1448+
is `extern "abi" fn(A1, ..., An) -> R`,
1449+
where `A1...An` are the declared types of its arguments
1450+
and `R` is the decalred return type.
1451+
14101452
## Attributes
14111453

14121454
~~~~~~~~{.ebnf .gram}

branches/dist-snap/mk/tests.mk

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,9 @@ CFG_ADB_TEST_DIR=/data/tmp
144144

145145
$(info check: android device test dir $(CFG_ADB_TEST_DIR) ready \
146146
$(shell adb remount 1>/dev/null) \
147-
$(shell adb shell mkdir $(CFG_ADB_TEST_DIR) 1>/dev/null) \
148-
$(shell adb shell rm -rf $(CFG_ADB_TEST_DIR)/* 1>/dev/null) \
147+
$(shell adb shell rm -r $(CFG_ADB_TEST_DIR) >/dev/null) \
148+
$(shell adb shell mkdir $(CFG_ADB_TEST_DIR)) \
149+
$(shell adb shell mkdir $(CFG_ADB_TEST_DIR)/tmp) \
149150
$(shell adb push $(S)src/etc/adb_run_wrapper.sh $(CFG_ADB_TEST_DIR) 1>/dev/null) \
150151
$(shell adb push $(CFG_ANDROID_CROSS_PATH)/arm-linux-androideabi/lib/armv7-a/libgnustl_shared.so \
151152
$(CFG_ADB_TEST_DIR) 1>/dev/null) \
@@ -239,6 +240,8 @@ tidy:
239240
@$(call E, check: formatting)
240241
$(Q)find $(S)src -name '*.r[sc]' \
241242
| grep '^$(S)src/test' -v \
243+
| grep '^$(S)src/libuv' -v \
244+
| grep '^$(S)src/llvm' -v \
242245
| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
243246
$(Q)find $(S)src/etc -name '*.py' \
244247
| xargs -n 10 $(CFG_PYTHON) $(S)src/etc/tidy.py
@@ -409,14 +412,16 @@ $$(call TEST_OK_FILE,$(1),$(2),$(3),$(4)): \
409412
$(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2))
410413
@$$(call E, run: $$< via adb)
411414
@$(CFG_ADB) push $$< $(CFG_ADB_TEST_DIR)
412-
@$(CFG_ADB) shell LD_LIBRARY_PATH=$(CFG_ADB_TEST_DIR) \
413-
$(CFG_ADB_TEST_DIR)/`echo $$< | sed 's/.*\///'` \
414-
--logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log > \
415-
tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
415+
@$(CFG_ADB) shell '(cd $(CFG_ADB_TEST_DIR); LD_LIBRARY_PATH=. \
416+
./$$(notdir $$<) \
417+
--logfile $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log \
418+
$$(call CRATE_TEST_BENCH_ARGS,$(1),$(2),$(3),$(4)))' \
419+
> tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
416420
@cat tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp
417421
@touch tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
418422
@$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log tmp/
419423
@$(CFG_ADB) shell rm $(CFG_ADB_TEST_DIR)/check-stage$(1)-T-$(2)-H-$(3)-$(4).log
424+
@$(CFG_ADB) pull $(CFG_ADB_TEST_DIR)/$$(call TEST_RATCHET_FILE,$(1),$(2),$(3),$(4)) tmp/
420425
@if grep -q "result: ok" tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \
421426
then \
422427
rm tmp/check-stage$(1)-T-$(2)-H-$(3)-$(4).tmp; \

branches/dist-snap/src/libextra/rl.rs

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,31 @@ use std::libc::{c_char, c_int};
1616
use std::local_data;
1717
use std::str;
1818

19+
#[cfg(stage0)]
1920
pub mod rustrt {
2021
use std::libc::{c_char, c_int};
2122

22-
#[cfg(stage0)]
23-
mod macro_hack {
24-
#[macro_escape];
25-
macro_rules! externfn(
26-
(fn $name:ident ($($arg_name:ident : $arg_ty:ty),*) $(-> $ret_ty:ty),*) => (
27-
extern {
28-
fn $name($($arg_name : $arg_ty),*) $(-> $ret_ty),*;
29-
}
30-
)
31-
)
23+
extern {
24+
fn linenoise(prompt: *c_char) -> *c_char;
25+
fn linenoiseHistoryAdd(line: *c_char) -> c_int;
26+
fn linenoiseHistorySetMaxLen(len: c_int) -> c_int;
27+
fn linenoiseHistorySave(file: *c_char) -> c_int;
28+
fn linenoiseHistoryLoad(file: *c_char) -> c_int;
29+
fn linenoiseSetCompletionCallback(callback: *u8);
30+
fn linenoiseAddCompletion(completions: *(), line: *c_char);
3231
}
32+
}
33+
34+
#[cfg(not(stage0))]
35+
pub mod rustrt {
36+
use std::libc::{c_char, c_int};
3337

3438
externfn!(fn linenoise(prompt: *c_char) -> *c_char)
3539
externfn!(fn linenoiseHistoryAdd(line: *c_char) -> c_int)
3640
externfn!(fn linenoiseHistorySetMaxLen(len: c_int) -> c_int)
3741
externfn!(fn linenoiseHistorySave(file: *c_char) -> c_int)
3842
externfn!(fn linenoiseHistoryLoad(file: *c_char) -> c_int)
39-
externfn!(fn linenoiseSetCompletionCallback(callback: *u8))
43+
externfn!(fn linenoiseSetCompletionCallback(callback: extern "C" fn(*i8, *())))
4044
externfn!(fn linenoiseAddCompletion(completions: *(), line: *c_char))
4145
}
4246

branches/dist-snap/src/libextra/url.rs

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ impl Url {
6161
}
6262

6363
impl UserInfo {
64+
#[inline]
6465
pub fn new(user: ~str, pass: Option<~str>) -> UserInfo {
6566
UserInfo { user: user, pass: pass }
6667
}
@@ -460,11 +461,14 @@ fn get_authority(rawurl: &str) ->
460461
}
461462
InHost => {
462463
pos = i;
463-
// can't be sure whether this is an ipv6 address or a port
464464
if input == Unreserved {
465-
return Err(~"Illegal characters in authority.");
465+
// must be port
466+
host = rawurl.slice(begin, i).to_owned();
467+
st = InPort;
468+
} else {
469+
// can't be sure whether this is an ipv6 address or a port
470+
st = Ip6Port;
466471
}
467-
st = Ip6Port;
468472
}
469473
Ip6Port => {
470474
if input == Unreserved {
@@ -514,25 +518,12 @@ fn get_authority(rawurl: &str) ->
514518
}
515519
_ => ()
516520
}
517-
end = i;
518521
}
519522

520-
let end = end; // make end immutable so it can be captured
521-
522-
let host_is_end_plus_one: &fn() -> bool = || {
523-
let xs = ['?', '#', '/'];
524-
end+1 == len
525-
&& !xs.iter().any(|x| *x == (rawurl[end] as char))
526-
};
527-
528523
// finish up
529524
match st {
530525
Start => {
531-
if host_is_end_plus_one() {
532-
host = rawurl.slice(begin, end+1).to_owned();
533-
} else {
534-
host = rawurl.slice(begin, end).to_owned();
535-
}
526+
host = rawurl.slice(begin, end).to_owned();
536527
}
537528
PassHostPort | Ip6Port => {
538529
if input != Digit {
@@ -552,8 +543,7 @@ fn get_authority(rawurl: &str) ->
552543
}
553544
}
554545

555-
let rest = if host_is_end_plus_one() { ~"" }
556-
else { rawurl.slice(end, len).to_owned() };
546+
let rest = rawurl.slice(end, len).to_owned();
557547
return Ok((userinfo, host, port, rest));
558548
}
559549

@@ -806,18 +796,17 @@ mod tests {
806796
807797
#[test]
808798
fn test_url_parse() {
809-
let url = ~"http://user:[email protected]/doc?s=v#something";
799+
let url = ~"http://user:[email protected]:8080/doc?s=v#something";
810800

811801
let up = from_str(url);
812802
let u = up.unwrap();
813-
assert!(u.scheme == ~"http");
814-
let userinfo = u.user.get_ref();
815-
assert!(userinfo.user == ~"user");
816-
assert!(userinfo.pass.get_ref() == &~"pass");
817-
assert!(u.host == ~"rust-lang.org");
818-
assert!(u.path == ~"/doc");
819-
assert!(u.query == ~[(~"s", ~"v")]);
820-
assert!(u.fragment.get_ref() == &~"something");
803+
assert_eq!(&u.scheme, &~"http");
804+
assert_eq!(&u.user, &Some(UserInfo::new(~"user", Some(~"pass"))));
805+
assert_eq!(&u.host, &~"rust-lang.org");
806+
assert_eq!(&u.port, &Some(~"8080"));
807+
assert_eq!(&u.path, &~"/doc");
808+
assert_eq!(&u.query, &~[(~"s", ~"v")]);
809+
assert_eq!(&u.fragment, &Some(~"something"));
821810
}
822811
823812
#[test]
@@ -828,6 +817,22 @@ mod tests {
828817
assert!(url.path == ~"/");
829818
}
830819
820+
#[test]
821+
fn test_url_host_with_port() {
822+
let urlstr = ~"scheme://host:1234";
823+
let url = from_str(urlstr).unwrap();
824+
assert_eq!(&url.scheme, &~"scheme");
825+
assert_eq!(&url.host, &~"host");
826+
assert_eq!(&url.port, &Some(~"1234"));
827+
assert_eq!(&url.path, &~""); // is empty path really correct? Other tests think so
828+
let urlstr = ~"scheme://host:1234/";
829+
let url = from_str(urlstr).unwrap();
830+
assert_eq!(&url.scheme, &~"scheme");
831+
assert_eq!(&url.host, &~"host");
832+
assert_eq!(&url.port, &Some(~"1234"));
833+
assert_eq!(&url.path, &~"/");
834+
}
835+
831836
#[test]
832837
fn test_url_with_underscores() {
833838
let urlstr = ~"http://dotcom.com/file_name.html";

branches/dist-snap/src/librustc/middle/liveness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ impl Liveness {
16171617

16181618
pub fn should_warn(&self, var: Variable) -> Option<@str> {
16191619
let name = self.ir.variable_name(var);
1620-
if name[0] == ('_' as u8) { None } else { Some(name) }
1620+
if name.len() == 0 || name[0] == ('_' as u8) { None } else { Some(name) }
16211621
}
16221622

16231623
pub fn warn_about_unused_args(&self, decl: &fn_decl, entry_ln: LiveNode) {

branches/dist-snap/src/librustc/middle/trans/base.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ use middle::trans::expr;
5252
use middle::trans::foreign;
5353
use middle::trans::glue;
5454
use middle::trans::inline;
55+
use middle::trans::llrepr::LlvmRepr;
5556
use middle::trans::machine;
5657
use middle::trans::machine::{llalign_of_min, llsize_of};
5758
use middle::trans::meth;
@@ -1739,6 +1740,10 @@ pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
17391740
args: &[ast::arg],
17401741
raw_llargs: &[ValueRef],
17411742
arg_tys: &[ty::t]) -> @mut Block {
1743+
debug!("copy_args_to_allocas: raw_llargs=%s arg_tys=%s",
1744+
raw_llargs.llrepr(fcx.ccx),
1745+
arg_tys.repr(fcx.ccx.tcx));
1746+
17421747
let _icx = push_ctxt("copy_args_to_allocas");
17431748
let mut bcx = bcx;
17441749

branches/dist-snap/src/librustc/middle/trans/builder.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use std::hashmap::HashMap;
2222
use std::libc::{c_uint, c_ulonglong, c_char};
2323
use std::vec;
2424
use syntax::codemap::span;
25+
use std::ptr::is_not_null;
2526

2627
pub struct Builder {
2728
llbuilder: BuilderRef,
@@ -483,6 +484,7 @@ impl Builder {
483484
debug!("Store %s -> %s",
484485
self.ccx.tn.val_to_str(val),
485486
self.ccx.tn.val_to_str(ptr));
487+
assert!(is_not_null(self.llbuilder));
486488
self.count_insn("store");
487489
unsafe {
488490
llvm::LLVMBuildStore(self.llbuilder, val, ptr);

0 commit comments

Comments
 (0)