Skip to content

Rollup of 14 pull requests #24260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 101 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
dc8a8e9
Check uses of `Self` in impls in the compiler rather than during expa…
nrc Apr 3, 2015
05b8a10
Encode more precise scoping rules for function params.
pnkfelix Apr 3, 2015
c4216a5
Test cases for Issue 23338.
pnkfelix Apr 3, 2015
19e9828
Fix printing of extended errors.
michaelsproul Apr 4, 2015
8842760
Make `AdditiveIterator` and `MultiplicativeIterator` extensible
tbu- Mar 11, 2015
ab32154
Provide context for macro expansions which result in unparsed tokens.
whipsch Apr 4, 2015
63b36ea
Work with assoc types in a super trait.
nrc Apr 7, 2015
da7529a
Split check_cast to a separate file
sanxiyn Apr 7, 2015
f4c2228
Check casts from float
sanxiyn Apr 7, 2015
d18b405
Check casts from fat pointer
sanxiyn Apr 7, 2015
039a553
Add more extended error messages for match exprs.
michaelsproul Apr 7, 2015
4cf5930
Remove incorrect example from docs
hauleth Apr 7, 2015
df95719
Add Clone impls for extern "C" and unsafe fns
lilyball Apr 7, 2015
4695bf0
Remove another invalid example
hauleth Apr 7, 2015
3344221
Fix a typo
omo Apr 7, 2015
9a51c63
rustup: let RUSTUP_PREFIX env override default prefix.
rillian Apr 7, 2015
97f24a8
Make `sum` and `product` inherent methods on `Iterator`
tbu- Apr 6, 2015
dddcbcf
Fix range performance regression
aturon Apr 6, 2015
f354c8a
New TOC
steveklabnik Apr 7, 2015
5c3aa01
disabling a test that is failing on bitrig.
Apr 7, 2015
dd6c4a8
Auto merge of #23293 - tbu-:pr_additive_multiplicative, r=alexcrichton
bors Apr 8, 2015
0027253
Import real content.
steveklabnik Apr 8, 2015
c9454b1
Update "`let` is used to introduce variables" paragraph
bombless Apr 8, 2015
ce97c19
Auto merge of #24078 - whipsch:extra-token-msg, r=huonw
bors Apr 8, 2015
a329a61
alloc: impl fmt::Pointer for Rc, Arc and Box
richo Apr 7, 2015
e2ff188
Address review comments
sanxiyn Apr 8, 2015
3a66c7f
Auto merge of #24120 - aturon:range-perf, r=alexcrichton
bors Apr 8, 2015
926f38e
Auto merge of #23998 - nrc:impl-self, r=nikomatsakis
bors Apr 8, 2015
86c5faf
Address review nit by making `map_id` take an `FnMut`.
pnkfelix Apr 8, 2015
9266d59
Auto merge of #24021 - pnkfelix:fn-params-outlive-body, r=nikomatsakis
bors Apr 8, 2015
59e62de
Add tests for #22289, #22370 and #22384
lgrz Apr 8, 2015
1e79870
Modify the ExprUseVisitor to walk each part of an AutoRef, and in
nikomatsakis Apr 8, 2015
ac3cc6c
Rollup merge of #24143 - michaelsproul:extended-errors, r=pnkfelix
steveklabnik Apr 8, 2015
4cef7f2
Rollup merge of #24149 - bombless:update-faq, r=steveklabnik
steveklabnik Apr 8, 2015
91798a8
Rollup merge of #24167 - hauleth:remove-incorrect-example-from-mpsc, …
steveklabnik Apr 8, 2015
12e9d7c
Rollup merge of #24178 - steveklabnik:new_toc, r=nikomatsakis
steveklabnik Apr 8, 2015
30e7e6e
Auto merge of #24195 - steveklabnik:rollup, r=steveklabnik
bors Apr 8, 2015
45aa6c8
Implement reentrant mutexes and make stdio use them
nagisa Apr 3, 2015
ff80477
Auto merge of #24029 - nagisa:print-locking, r=alexcrichton
bors Apr 8, 2015
45eb54c
configure: Remove obsolete --nightly flag
brson Apr 8, 2015
bc9f16c
configure: Remove obsolete --disable-verify option
brson Apr 8, 2015
ed8eebd
configure: Rename --enable-debug to --enable-debug-assertions
brson Apr 8, 2015
59e332b
configure: Disable debug assertions by default
brson Apr 8, 2015
2cdfd37
configure: Clarify help message for --enable-debug-assertions
brson Apr 8, 2015
8545d2c
configure: Disable LLVM asserts by default
brson Apr 8, 2015
1b34f0a
configure: Clarify --enable-debug-assertions status message
brson Apr 8, 2015
7cbf823
configure: Add --enable-debuginfo
brson Apr 8, 2015
0cb9379
Allow plugins to register LLVM passes
kmcallister Apr 8, 2015
1002155
Add --enable-debug to control multiple perf options
brson Apr 8, 2015
6436e34
Auto merge of #24144 - richo:ptr-formatter, r=alexcrichton
bors Apr 8, 2015
6d17c35
configure: Add --enable-debug-jemalloc
brson Apr 8, 2015
2a9e101
Remove `ignore-tidy-linelength` from tests that no longer need it
lgrz Apr 8, 2015
65e3f03
std: Destabilize the internals of panic!
alexcrichton Apr 8, 2015
6b32072
std: Stabilize Clone::clone_from
alexcrichton Apr 8, 2015
561fdec
std: Stabilize io::Error::from_raw_os_error
alexcrichton Apr 8, 2015
ec7c800
Remove pretty-expanded from failing tests
alexcrichton Apr 8, 2015
287a544
Auto merge of #24158 - sanxiyn:cast, r=nrc
bors Apr 9, 2015
a725426
Don't deoptimize llvm when --enable-debug
brson Apr 9, 2015
0a380a9
Implement io::Seek for io::BufReader<R> where R: io::Seek
lilyball Apr 7, 2015
1605205
Implement io::Seek for io::BufWriter<W> where W: io::Seek
lilyball Apr 8, 2015
0e5e669
Auto merge of #24168 - kballard:clone-for-extern-c-unsafe-fns, r=alex…
bors Apr 9, 2015
613cf9a
Debug impls for a few things in syntax::codemap
nrc Apr 9, 2015
e57410c
Auto merge of #24171 - rillian:rustup, r=brson
bors Apr 9, 2015
341870a
Fix the span for `for` expressions
nrc Apr 9, 2015
ce76589
Rollup merge of #24171 - rillian:rustup, r=brson
Manishearth Apr 9, 2015
a00ab58
Rollup merge of #24175 - dhuseby:bitrig_fixing_tests_2, r=alexcrichton
Manishearth Apr 9, 2015
68100e4
Rollup merge of #24176 - kballard:bufreader-seek-impl, r=aturon
Manishearth Apr 9, 2015
e326aa1
Auto merge of #24176 - kballard:bufreader-seek-impl, r=aturon
bors Apr 9, 2015
e3f324c
Improve bounds in Iterator API
aturon Apr 9, 2015
549bd55
resurrect research paper list #24004
Apr 9, 2015
c3aa057
Add regression test for #19097
aturon Apr 9, 2015
746725a
Add librustc_data_structures crate
nikomatsakis Apr 7, 2015
af273d2
Use the newer snapshot_vec, which has a simplified delegate
nikomatsakis Apr 7, 2015
dbdb315
Port to using the newer graph, which offers iterators instead of the
nikomatsakis Apr 7, 2015
71aa0aa
Port to use the new Unify code, which has no UnifyValue trait
nikomatsakis Apr 7, 2015
ee94ee7
Add licenses.
nikomatsakis Apr 8, 2015
ead4631
Address nits
nikomatsakis Apr 8, 2015
0e0c841
Nightly gets LLVM assertions
brson Apr 9, 2015
3b87140
Rollup merge of #24191 - nikomatsakis:issue-20791, r=pnkfelix
Manishearth Apr 9, 2015
67fa4d3
Rollup merge of #24193 - lstat:needstest, r=alexcrichton
Manishearth Apr 9, 2015
2dffe78
Rollup merge of #24205 - brson:debug, r=alexcrichton
Manishearth Apr 9, 2015
4e466e7
Rollup merge of #24207 - kmcallister:llvm-plugin, r=brson
Manishearth Apr 9, 2015
5daee19
Rollup merge of #24212 - alexcrichton:destabilize-begin-unwind, r=huonw
Manishearth Apr 9, 2015
cdfbb11
Rollup merge of #24215 - alexcrichton:stabilize-clone-from, r=aturon
Manishearth Apr 9, 2015
1a6e100
Rollup merge of #24216 - alexcrichton:stabilize-from-raw-os-error, r=…
Manishearth Apr 9, 2015
b389207
Rollup merge of #24218 - lstat:remove-ignore-tidy, r=alexcrichton
Manishearth Apr 9, 2015
27ecaa2
Rollup merge of #24221 - nrc:debug-loc, r=sfackler
Manishearth Apr 9, 2015
ce825ab
Rollup merge of #24170 - omo:omo-typo-fix, r=steveklabnik
Manishearth Apr 9, 2015
ede25fe
Rollup merge of #24225 - nrc:for-span, r=pnkfelix
Manishearth Apr 9, 2015
53a609b
Rollup merge of #24217 - aturon:iterator-fixes, r=alexcrichton
Manishearth Apr 9, 2015
ea73179
fixup windows std_misc
Manishearth Apr 9, 2015
88fc543
Auto merge of #24232 - Manishearth:rollup, r=Manishearth
bors Apr 9, 2015
bf88539
TRPL: new introduction
steveklabnik Apr 9, 2015
6b95d8b
Auto merge of #24205 - brson:debug, r=alexcrichton
bors Apr 9, 2015
5a90661
Add examples for Convert
steveklabnik Apr 6, 2015
b6dc3a6
Rollup merge of #24121 - steveklabnik:gh24107, r=alexcrichton
Manishearth Apr 10, 2015
d4f89a6
Rollup merge of #24180 - huonw:optimise-max-etc, r=alexcrichton
Manishearth Apr 10, 2015
7da6065
Rollup merge of #24209 - nikomatsakis:refactor-unification, r=nrc
Manishearth Apr 10, 2015
2e3cc5f
Rollup merge of #24234 - thiagooak:academic-research, r=steveklabnik
Manishearth Apr 10, 2015
858f3c8
Rollup merge of #24236 - aturon:issue-19097, r=alexcrichton
Manishearth Apr 10, 2015
3252694
Rollup merge of #24239 - steveklabnik:editing_pass, r=steveklabnik
Manishearth Apr 10, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Encode more precise scoping rules for function params.
Function params which outlive everything in the body (incl
temporaries).  Thus if we assign them their own `CodeExtent`, the
region inference can properly show that it is sound to have
temporaries with destructors that reference the parameters (because
such temporaries will be dropped before the parameters are).

This allows us to address issue 23338 in a clean way.

As a drive-by, fix a mistake in the tyencode for
`CodeExtent::BlockRemainder`.
  • Loading branch information
pnkfelix committed Apr 4, 2015
commit 05b8a106e45b0c8381c6bc89e76e7bb94b03a84c
13 changes: 13 additions & 0 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,16 @@ fn parse_region_<F>(st: &mut PState, conv: &mut F) -> ty::Region where

fn parse_scope(st: &mut PState) -> region::CodeExtent {
match next(st) {
'P' => {
assert_eq!(next(st), '[');
let fn_id = parse_uint(st) as ast::NodeId;
assert_eq!(next(st), '|');
let body_id = parse_uint(st) as ast::NodeId;
assert_eq!(next(st), ']');
region::CodeExtent::ParameterScope {
fn_id: fn_id, body_id: body_id
}
}
'M' => {
let node_id = parse_uint(st) as ast::NodeId;
region::CodeExtent::Misc(node_id)
Expand All @@ -382,8 +392,11 @@ fn parse_scope(st: &mut PState) -> region::CodeExtent {
region::CodeExtent::DestructionScope(node_id)
}
'B' => {
assert_eq!(next(st), '[');
let node_id = parse_uint(st) as ast::NodeId;
assert_eq!(next(st), '|');
let first_stmt_index = parse_uint(st);
assert_eq!(next(st), ']');
let block_remainder = region::BlockRemainder {
block: node_id, first_statement_index: first_stmt_index,
};
Expand Down
4 changes: 3 additions & 1 deletion src/librustc/metadata/tyencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,11 @@ pub fn enc_region(w: &mut Encoder, cx: &ctxt, r: ty::Region) {

fn enc_scope(w: &mut Encoder, _cx: &ctxt, scope: region::CodeExtent) {
match scope {
region::CodeExtent::ParameterScope {
fn_id, body_id } => mywrite!(w, "P[{}|{}]", fn_id, body_id),
region::CodeExtent::Misc(node_id) => mywrite!(w, "M{}", node_id),
region::CodeExtent::Remainder(region::BlockRemainder {
block: b, first_statement_index: i }) => mywrite!(w, "B{}{}", b, i),
block: b, first_statement_index: i }) => mywrite!(w, "B[{}|{}]", b, i),
region::CodeExtent::DestructionScope(node_id) => mywrite!(w, "D{}", node_id),
}
}
Expand Down
39 changes: 33 additions & 6 deletions src/librustc/middle/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ use syntax::visit::{Visitor, FnKind};
RustcDecodable, Debug, Copy)]
pub enum CodeExtent {
Misc(ast::NodeId),
DestructionScope(ast::NodeId), // extent of destructors for temporaries of node-id

// extent of parameters passed to a function or closure (they
// outlive its body)
ParameterScope { fn_id: ast::NodeId, body_id: ast::NodeId },

// extent of destructors for temporaries of node-id
DestructionScope(ast::NodeId),

// extent of code following a `let id = expr;` binding in a block
Remainder(BlockRemainder)
}

Expand Down Expand Up @@ -153,15 +161,19 @@ impl CodeExtent {
pub fn node_id(&self) -> ast::NodeId {
match *self {
CodeExtent::Misc(node_id) => node_id,

// These cases all return rough approximations to the
// precise extent denoted by `self`.
CodeExtent::Remainder(br) => br.block,
CodeExtent::DestructionScope(node_id) => node_id,
CodeExtent::ParameterScope { fn_id: _, body_id } => body_id,
}
}

/// Maps this scope to a potentially new one according to the
/// NodeId transformer `f_id`.
pub fn map_id<F>(&self, f_id: F) -> CodeExtent where
F: FnOnce(ast::NodeId) -> ast::NodeId,
F: Fn(ast::NodeId) -> ast::NodeId,
{
match *self {
CodeExtent::Misc(node_id) => CodeExtent::Misc(f_id(node_id)),
Expand All @@ -170,6 +182,8 @@ impl CodeExtent {
block: f_id(br.block), first_statement_index: br.first_statement_index }),
CodeExtent::DestructionScope(node_id) =>
CodeExtent::DestructionScope(f_id(node_id)),
CodeExtent::ParameterScope { fn_id, body_id } =>
CodeExtent::ParameterScope { fn_id: f_id(fn_id), body_id: f_id(body_id) },
}
}

Expand All @@ -180,6 +194,7 @@ impl CodeExtent {
match ast_map.find(self.node_id()) {
Some(ast_map::NodeBlock(ref blk)) => {
match *self {
CodeExtent::ParameterScope { .. } |
CodeExtent::Misc(_) |
CodeExtent::DestructionScope(_) => Some(blk.span),

Expand Down Expand Up @@ -277,6 +292,7 @@ enum InnermostDeclaringBlock {
Block(ast::NodeId),
Statement(DeclaringStatementContext),
Match(ast::NodeId),
FnDecl { fn_id: ast::NodeId, body_id: ast::NodeId },
}

impl InnermostDeclaringBlock {
Expand All @@ -285,6 +301,8 @@ impl InnermostDeclaringBlock {
InnermostDeclaringBlock::None => {
return Option::None;
}
InnermostDeclaringBlock::FnDecl { fn_id, body_id } =>
CodeExtent::ParameterScope { fn_id: fn_id, body_id: body_id },
InnermostDeclaringBlock::Block(id) |
InnermostDeclaringBlock::Match(id) => CodeExtent::from_node_id(id),
InnermostDeclaringBlock::Statement(s) => s.to_code_extent(),
Expand Down Expand Up @@ -1198,25 +1216,34 @@ fn resolve_fn(visitor: &mut RegionResolutionVisitor,
body.id,
visitor.cx.parent);

// This scope covers the function body, which includes the
// bindings introduced by let statements as well as temporaries
// created by the fn's tail expression (if any). It does *not*
// include the fn parameters (see below).
let body_scope = CodeExtent::from_node_id(body.id);
visitor.region_maps.mark_as_terminating_scope(body_scope);

let dtor_scope = CodeExtent::DestructionScope(body.id);
visitor.region_maps.record_encl_scope(body_scope, dtor_scope);

record_superlifetime(visitor, dtor_scope, body.span);
let fn_decl_scope = CodeExtent::ParameterScope { fn_id: id, body_id: body.id };
visitor.region_maps.record_encl_scope(dtor_scope, fn_decl_scope);

record_superlifetime(visitor, fn_decl_scope, body.span);

if let Some(root_id) = visitor.cx.root_id {
visitor.region_maps.record_fn_parent(body.id, root_id);
}

let outer_cx = visitor.cx;

// The arguments and `self` are parented to the body of the fn.
// The arguments and `self` are parented to the fn.
visitor.cx = Context {
root_id: Some(body.id),
parent: InnermostEnclosingExpr::Some(body.id),
var_parent: InnermostDeclaringBlock::Block(body.id)
parent: InnermostEnclosingExpr::None,
var_parent: InnermostDeclaringBlock::FnDecl {
fn_id: id, body_id: body.id
},
};
visit::walk_fn_decl(visitor, decl);

Expand Down
5 changes: 5 additions & 0 deletions src/librustc/util/ppaux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
};
let scope_decorated_tag = match scope {
region::CodeExtent::Misc(_) => tag,
region::CodeExtent::ParameterScope { .. } => {
"scope of parameters for function"
}
region::CodeExtent::DestructionScope(_) => {
new_string = format!("destruction scope surrounding {}", tag);
&*new_string
Expand Down Expand Up @@ -952,6 +955,8 @@ impl<'tcx> Repr<'tcx> for ty::FreeRegion {
impl<'tcx> Repr<'tcx> for region::CodeExtent {
fn repr(&self, _tcx: &ctxt) -> String {
match *self {
region::CodeExtent::ParameterScope { fn_id, body_id } =>
format!("ParameterScope({}, {})", fn_id, body_id),
region::CodeExtent::Misc(node_id) =>
format!("Misc({})", node_id),
region::CodeExtent::DestructionScope(node_id) =>
Expand Down