Skip to content

Commit f313f0b

Browse files
authored
Merge pull request #35172 from alexcrichton/beta-next
Backporting PRs to beta
2 parents bac49e3 + be0bd7f commit f313f0b

File tree

9 files changed

+92
-13
lines changed

9 files changed

+92
-13
lines changed

mk/main.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ CFG_RELEASE_NUM=1.11.0
1818
# An optional number to put after the label, e.g. '.2' -> '-beta.2'
1919
# NB Make sure it starts with a dot to conform to semver pre-release
2020
# versions (section 9)
21-
CFG_PRERELEASE_VERSION=.2
21+
CFG_PRERELEASE_VERSION=.3
2222

2323
# Append a version-dependent hash to each library, so we can install different
2424
# versions in the same place

src/librustc_trans/base.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ use debuginfo::{self, DebugLoc, ToDebugLoc};
7575
use declare;
7676
use expr;
7777
use glue;
78-
use inline;
7978
use machine;
8079
use machine::{llalign_of_min, llsize_of, llsize_of_real};
8180
use meth;
@@ -1407,19 +1406,17 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
14071406
pub fn new(ccx: &'blk CrateContext<'blk, 'tcx>,
14081407
llfndecl: ValueRef,
14091408
fn_ty: FnType,
1410-
definition: Option<(Instance<'tcx>, &ty::FnSig<'tcx>, Abi)>,
1409+
definition: Option<(Instance<'tcx>, &ty::FnSig<'tcx>, Abi, ast::NodeId)>,
14111410
block_arena: &'blk TypedArena<common::BlockS<'blk, 'tcx>>)
14121411
-> FunctionContext<'blk, 'tcx> {
1413-
let (param_substs, def_id) = match definition {
1414-
Some((instance, _, _)) => {
1412+
let (param_substs, def_id, inlined_id) = match definition {
1413+
Some((instance, _, _, inlined_id)) => {
14151414
common::validate_substs(instance.substs);
1416-
(instance.substs, Some(instance.def))
1415+
(instance.substs, Some(instance.def), Some(inlined_id))
14171416
}
1418-
None => (ccx.tcx().mk_substs(Substs::empty()), None)
1417+
None => (ccx.tcx().mk_substs(Substs::empty()), None, None)
14191418
};
14201419

1421-
let inlined_did = def_id.and_then(|def_id| inline::get_local_instance(ccx, def_id));
1422-
let inlined_id = inlined_did.and_then(|id| ccx.tcx().map.as_local_node_id(id));
14231420
let local_id = def_id.and_then(|id| ccx.tcx().map.as_local_node_id(id));
14241421

14251422
debug!("FunctionContext::new({})",
@@ -1454,7 +1451,7 @@ impl<'blk, 'tcx> FunctionContext<'blk, 'tcx> {
14541451
};
14551452

14561453
let debug_context = if let (false, Some(definition)) = (no_debug, definition) {
1457-
let (instance, sig, abi) = definition;
1454+
let (instance, sig, abi, _) = definition;
14581455
debuginfo::create_function_debug_context(ccx, instance, sig, abi, llfndecl)
14591456
} else {
14601457
debuginfo::empty_function_debug_context(ccx)
@@ -1850,7 +1847,11 @@ pub fn trans_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
18501847

18511848
let (arena, fcx): (TypedArena<_>, FunctionContext);
18521849
arena = TypedArena::new();
1853-
fcx = FunctionContext::new(ccx, llfndecl, fn_ty, Some((instance, sig, abi)), &arena);
1850+
fcx = FunctionContext::new(ccx,
1851+
llfndecl,
1852+
fn_ty,
1853+
Some((instance, sig, abi, inlined_id)),
1854+
&arena);
18541855

18551856
if fcx.mir.is_some() {
18561857
return mir::trans_mir(&fcx);

src/libsyntax/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub fn strip_unconfigured_items(mut krate: ast::Crate, sess: &ParseSess, should_
124124
};
125125

126126
let err_count = sess.span_diagnostic.err_count();
127-
let krate_attrs = strip_unconfigured.process_cfg_attrs(krate.attrs.clone());
127+
let krate_attrs = strip_unconfigured.configure(krate.attrs.clone()).unwrap_or_default();
128128
features = get_features(&sess.span_diagnostic, &krate_attrs);
129129
if err_count < sess.span_diagnostic.err_count() {
130130
krate.attrs = krate_attrs.clone(); // Avoid reconfiguring malformed `cfg_attr`s

src/libsyntax/ext/base.rs

+6
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,12 @@ impl<'a> ExtCtxt<'a> {
820820
/// compilation on error, merely emits a non-fatal error and returns None.
821821
pub fn expr_to_string(cx: &mut ExtCtxt, expr: P<ast::Expr>, err_msg: &str)
822822
-> Option<(InternedString, ast::StrStyle)> {
823+
// Update `expr.span`'s expn_id now in case expr is an `include!` macro invocation.
824+
let expr = expr.map(|mut expr| {
825+
expr.span.expn_id = cx.backtrace;
826+
expr
827+
});
828+
823829
// we want to be able to handle e.g. concat("foo", "bar")
824830
let expr = cx.expander().fold_expr(expr);
825831
match expr.node {

src/test/compile-fail/macro-expanded-include/foo/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@
1313
macro_rules! m {
1414
() => { include!("file.txt"); }
1515
}
16+
17+
macro_rules! n {
18+
() => { unsafe { asm!(include_str!("file.txt")); } }
19+
}

src/test/compile-fail/macro-expanded-include/test.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(rustc_attrs)]
11+
#![feature(asm, rustc_attrs)]
12+
#![allow(unused)]
1213

1314
#[macro_use]
1415
mod foo;
1516

1617
m!();
18+
fn f() { n!(); }
1719

1820
#[rustc_error]
1921
fn main() {} //~ ERROR compilation successful
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub struct Request {
12+
pub id: String,
13+
pub arg: String,
14+
}
15+
16+
pub fn decode<T>() -> Result<Request, ()> {
17+
(|| {
18+
Ok(Request {
19+
id: "hi".to_owned(),
20+
arg: match Err(()) {
21+
Ok(v) => v,
22+
Err(e) => return Err(e)
23+
},
24+
})
25+
})()
26+
}

src/test/run-pass/issue-34932.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-flags:--test
12+
// rustc-env:RUSTC_BOOTSTRAP_KEY=
13+
// ignore-pretty : (#23623) problems when ending with // comments
14+
15+
#![cfg(any())] // This test should be configured away
16+
#![feature(rustc_attrs)] // Test that this is allowed on stable/beta
17+
#![feature(iter_arith_traits)] // Test that this is not unused
18+
#![deny(unused_features)]
19+
20+
#[test]
21+
fn dummy() {
22+
let () = "this should not reach type-checking";
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:xcrate_generic_fn_nested_return.rs
12+
13+
extern crate xcrate_generic_fn_nested_return as test;
14+
15+
pub fn main() {
16+
assert!(test::decode::<()>().is_err());
17+
}

0 commit comments

Comments
 (0)