Skip to content

Commit 8714563

Browse files
committed
---
yaml --- r: 85718 b: refs/heads/dist-snap c: 7bee050 h: refs/heads/master v: v3
1 parent 53882f3 commit 8714563

File tree

12 files changed

+252
-188
lines changed

12 files changed

+252
-188
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: ae63a3e400970a895d03ec1ef359ba86217c854b
9+
refs/heads/dist-snap: 7bee0501caba36ae9ee2f96aac0f0bf01bd5fddb
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1212
refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0

branches/dist-snap/doc/tutorial-container.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ assert_eq!(sum, 57);
160160
161161
## For loops
162162
163+
The function `range` (or `range_inclusive`) allows to simply iterate through a given range:
164+
165+
~~~
166+
for i in range(0, 5) {
167+
printf!("%d ", i) // prints "0 1 2 3 4"
168+
}
169+
170+
for i in std::iterator::range_inclusive(0, 5) { // needs explicit import
171+
printf!("%d ", i) // prints "0 1 2 3 4 5"
172+
}
173+
~~~
174+
163175
The `for` keyword can be used as sugar for iterating through any iterator:
164176
165177
~~~

branches/dist-snap/doc/tutorial-ffi.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,8 @@ prefer using raw pointers (`*`) if that's needed because the compiler can't make
445445
about them.
446446

447447
Vectors and strings share the same basic memory layout, and utilities are available in the `vec` and
448-
`str` modules for working with C APIs. Strings are terminated with `\0` for interoperability with C,
449-
but it should not be assumed because a slice will not always be nul-terminated. Instead, the
450-
`str::as_c_str` function should be used.
448+
`str` modules for working with C APIs. However, strings are not terminated with `\0`. If you need a
449+
NUL-terminated string for interoperability with C, you should use the `c_str::to_c_str` function.
451450

452451
The standard library includes type aliases and function definitions for the C standard library in
453452
the `libc` module, and Rust links against `libc` and `libm` by default.

branches/dist-snap/mk/llvm.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ ifeq ($(CFG_LLVM_ROOT),)
2626

2727
$$(LLVM_CONFIG_$(1)): $$(LLVM_DEPS)
2828
@$$(call E, make: llvm)
29-
$$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1)) $$(CFG_LLVM_BUILD_ENV)
29+
$$(Q)$$(MAKE) -C $$(CFG_LLVM_BUILD_DIR_$(1))
3030
$$(Q)touch $$(LLVM_CONFIG_$(1))
3131
endif
3232

branches/dist-snap/mk/platform.mk

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,7 @@ endef
2626
$(foreach t,$(CFG_TARGET_TRIPLES),$(eval $(call DEF_OSTYPE_VAR,$(t))))
2727
$(foreach t,$(CFG_TARGET_TRIPLES),$(info cfg: os for $(t) is $(OSTYPE_$(t))))
2828

29-
# FIXME: no-omit-frame-pointer is just so that task_start_wrapper
30-
# has a frame pointer and the stack walker can understand it. Turning off
31-
# frame pointers everywhere is overkill
32-
CFG_GCCISH_CFLAGS += -fno-omit-frame-pointer -DUSE_UTF8
29+
CFG_GCCISH_CFLAGS += -DUSE_UTF8
3330

3431
# On Darwin, we need to run dsymutil so the debugging information ends
3532
# up in the right place. On other platforms, it automatically gets
@@ -153,7 +150,6 @@ CFG_GCCISH_POST_LIB_FLAGS_x86_64-unknown-linux-gnu := -Wl,-no-whole-archive
153150
CFG_DEF_SUFFIX_x86_64-unknown-linux-gnu := .linux.def
154151
CFG_INSTALL_NAME_x86_64-unknown-linux-gnu =
155152
CFG_LIBUV_LINK_FLAGS_x86_64-unknown-linux-gnu =
156-
CFG_LLVM_BUILD_ENV_x86_64-unknown-linux-gnu="CXXFLAGS=-fno-omit-frame-pointer"
157153
CFG_EXE_SUFFIX_x86_64-unknown-linux-gnu =
158154
CFG_WINDOWSY_x86_64-unknown-linux-gnu :=
159155
CFG_UNIXY_x86_64-unknown-linux-gnu := 1
@@ -179,7 +175,6 @@ CFG_GCCISH_POST_LIB_FLAGS_i686-unknown-linux-gnu := -Wl,-no-whole-archive
179175
CFG_DEF_SUFFIX_i686-unknown-linux-gnu := .linux.def
180176
CFG_INSTALL_NAME_i686-unknown-linux-gnu =
181177
CFG_LIBUV_LINK_FLAGS_i686-unknown-linux-gnu =
182-
CFG_LLVM_BUILD_ENV_i686-unknown-linux-gnu="CXXFLAGS=-fno-omit-frame-pointer"
183178
CFG_EXE_SUFFIX_i686-unknown-linux-gnu =
184179
CFG_WINDOWSY_i686-unknown-linux-gnu :=
185180
CFG_UNIXY_i686-unknown-linux-gnu := 1

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,6 @@ pub enum FailType {
501501
pub mod groups {
502502
use getopts::{HasArg, Long, Maybe, Multi, No, Occur, Opt, Optional, Req};
503503
use getopts::{Short, Yes};
504-
use std::str;
505504

506505
/** one group of options, e.g., both -h and --help, along with
507506
* their shared description and properties
@@ -692,7 +691,7 @@ pub mod groups {
692691

693692
// FIXME: #5516
694693
// here we just need to indent the start of the description
695-
let rowlen = str::count_chars(row, 0, row.len());
694+
let rowlen = row.len();
696695
if rowlen < 24 {
697696
do (24 - rowlen).times {
698697
row.push_char(' ')
@@ -799,7 +798,7 @@ pub mod groups {
799798
cont
800799
};
801800

802-
ss.char_offset_iter().advance(|x| machine(x));
801+
ss.iter().enumerate().advance(|x| machine(x));
803802

804803
// Let the automaton 'run out' by supplying trailing whitespace
805804
while cont && match state { B | C => true, A => false } {

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

Lines changed: 57 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ fn fcx_has_nonzero_span(fcx: &FunctionContext) -> bool {
137137
}
138138
}
139139

140+
fn span_is_empty(opt_span: &Option<span>) -> bool {
141+
match *opt_span {
142+
None => true,
143+
Some(span) => *span.lo == 0 && *span.hi == 0
144+
}
145+
}
146+
140147
struct StatRecorder<'self> {
141148
ccx: @mut CrateContext,
142149
name: &'self str,
@@ -1624,6 +1631,13 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
16241631
}
16251632
};
16261633
let uses_outptr = type_of::return_uses_outptr(ccx.tcx, substd_output_type);
1634+
1635+
let debug_context = if id != -1 && ccx.sess.opts.debuginfo && !span_is_empty(&sp) {
1636+
Some(debuginfo::create_function_debug_context(ccx, id, param_substs, llfndecl))
1637+
} else {
1638+
None
1639+
};
1640+
16271641
let fcx = @mut FunctionContext {
16281642
llfn: llfndecl,
16291643
llenv: unsafe {
@@ -1644,7 +1658,7 @@ pub fn new_fn_ctxt_w_id(ccx: @mut CrateContext,
16441658
span: sp,
16451659
path: path,
16461660
ccx: ccx,
1647-
debug_context: None,
1661+
debug_context: debug_context,
16481662
};
16491663
fcx.llenv = unsafe {
16501664
llvm::LLVMGetParam(llfndecl, fcx.env_arg_pos() as c_uint)
@@ -1696,7 +1710,8 @@ pub fn new_fn_ctxt(ccx: @mut CrateContext,
16961710
// field of the fn_ctxt with
16971711
pub fn create_llargs_for_fn_args(cx: @mut FunctionContext,
16981712
self_arg: self_arg,
1699-
args: &[ast::arg])
1713+
args: &[ast::arg],
1714+
arg_tys: &[ty::t])
17001715
-> ~[ValueRef] {
17011716
let _icx = push_ctxt("create_llargs_for_fn_args");
17021717

@@ -1713,26 +1728,31 @@ pub fn create_llargs_for_fn_args(cx: @mut FunctionContext,
17131728

17141729
// Return an array containing the ValueRefs that we get from
17151730
// llvm::LLVMGetParam for each argument.
1716-
vec::from_fn(args.len(), |i| {
1717-
unsafe {
1718-
let arg_n = cx.arg_pos(i);
1719-
let arg = &args[i];
1720-
let llarg = llvm::LLVMGetParam(cx.llfn, arg_n as c_uint);
1721-
1722-
// FIXME #7260: aliasing should be determined by monomorphized ty::t
1723-
match arg.ty.node {
1724-
// `~` pointers never alias other parameters, because ownership was transferred
1725-
ast::ty_uniq(_) => {
1726-
llvm::LLVMAddAttribute(llarg, lib::llvm::NoAliasAttribute as c_uint);
1731+
do vec::from_fn(args.len()) |i| {
1732+
let arg_n = cx.arg_pos(i);
1733+
let arg_ty = arg_tys[i];
1734+
let llarg = unsafe {llvm::LLVMGetParam(cx.llfn, arg_n as c_uint) };
1735+
1736+
match ty::get(arg_ty).sty {
1737+
// `~` pointers never alias other parameters, because
1738+
// ownership was transferred
1739+
ty::ty_uniq(*) |
1740+
ty::ty_evec(_, ty::vstore_uniq) |
1741+
ty::ty_closure(ty::ClosureTy {sigil: ast::OwnedSigil, _}) => {
1742+
unsafe {
1743+
llvm::LLVMAddAttribute(
1744+
llarg, lib::llvm::NoAliasAttribute as c_uint);
17271745
}
1728-
// FIXME: #6785: `&mut` can only alias `&const` and `@mut`, we should check for
1729-
// those in the other parameters and then mark it as `noalias` if there aren't any
1730-
_ => {}
17311746
}
1732-
1733-
llarg
1747+
// FIXME: #6785: `&mut` can only alias `&const` and
1748+
// `@mut`, we should check for those in the other
1749+
// parameters and then mark it as `noalias` if there
1750+
// aren't any
1751+
_ => {}
17341752
}
1735-
})
1753+
1754+
llarg
1755+
}
17361756
}
17371757

17381758
pub fn copy_args_to_allocas(fcx: @mut FunctionContext,
@@ -1867,7 +1887,6 @@ pub fn trans_closure(ccx: @mut CrateContext,
18671887
debug!("trans_closure(..., param_substs=%s)",
18681888
param_substs.repr(ccx.tcx));
18691889

1870-
// Set up arguments to the function.
18711890
let fcx = new_fn_ctxt_w_id(ccx,
18721891
path,
18731892
llfndecl,
@@ -1877,29 +1896,33 @@ pub fn trans_closure(ccx: @mut CrateContext,
18771896
param_substs,
18781897
body.info(),
18791898
Some(body.span));
1880-
let raw_llargs = create_llargs_for_fn_args(fcx, self_arg, decl.inputs);
1881-
1882-
// Set the fixed stack segment flag if necessary.
1883-
if attr::contains_name(attributes, "fixed_stack_segment") {
1884-
set_no_inline(fcx.llfn);
1885-
set_fixed_stack_segment(fcx.llfn);
1886-
}
1887-
1888-
if ccx.sess.opts.debuginfo && fcx_has_nonzero_span(fcx) {
1889-
debuginfo::create_function_metadata(fcx);
1890-
}
18911899

18921900
// Create the first basic block in the function and keep a handle on it to
18931901
// pass to finish_fn later.
18941902
let bcx_top = fcx.entry_bcx.unwrap();
18951903
let mut bcx = bcx_top;
18961904
let block_ty = node_id_type(bcx, body.id);
18971905

1906+
// Set up arguments to the function.
18981907
let arg_tys = ty::ty_fn_args(node_id_type(bcx, id));
1908+
let raw_llargs = create_llargs_for_fn_args(fcx, self_arg,
1909+
decl.inputs, arg_tys);
1910+
1911+
// Set the fixed stack segment flag if necessary.
1912+
if attr::contains_name(attributes, "fixed_stack_segment") {
1913+
set_no_inline(fcx.llfn);
1914+
set_fixed_stack_segment(fcx.llfn);
1915+
}
1916+
18991917
bcx = copy_args_to_allocas(fcx, bcx, decl.inputs, raw_llargs, arg_tys);
19001918

19011919
maybe_load_env(fcx);
19021920

1921+
// Up until here, IR instructions for this function have explicitly not been annotated with
1922+
// source code location, so we don't step into call setup code. From here on, source location
1923+
// emitting should be enabled.
1924+
debuginfo::start_emitting_source_locations(fcx);
1925+
19031926
// This call to trans_block is the place where we bridge between
19041927
// translation calls that don't have a return value (trans_crate,
19051928
// trans_mod, trans_item, et cetera) and those that do
@@ -2092,10 +2115,11 @@ pub fn trans_enum_variant_or_tuple_like_struct<A:IdAndTy>(
20922115
None,
20932116
None);
20942117

2095-
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args);
2118+
let arg_tys = ty::ty_fn_args(ctor_ty);
2119+
2120+
let raw_llargs = create_llargs_for_fn_args(fcx, no_self, fn_args, arg_tys);
20962121

20972122
let bcx = fcx.entry_bcx.unwrap();
2098-
let arg_tys = ty::ty_fn_args(ctor_ty);
20992123

21002124
insert_synthetic_type_entries(bcx, fn_args, arg_tys);
21012125
let bcx = copy_args_to_allocas(fcx, bcx, fn_args, raw_llargs, arg_tys);

0 commit comments

Comments
 (0)