Skip to content

Commit b7c2766

Browse files
committed
Auto merge of #40675 - alexcrichton:beta-next, r=brson
[beta] Backports and version bump This PR backports these PRs to beta: * #40583 * #40398 * #40542 and it also includes a version bump to push out a beta with all recent backports.
2 parents 456ca95 + 3808ae8 commit b7c2766

File tree

12 files changed

+138
-23
lines changed

12 files changed

+138
-23
lines changed

src/bootstrap/channel.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub const CFG_RELEASE_NUM: &'static str = "1.17.0";
2828
// An optional number to put after the label, e.g. '.2' -> '-beta.2'
2929
// Be sure to make this starts with a dot to conform to semver pre-release
3030
// versions (section 9)
31-
pub const CFG_PRERELEASE_VERSION: &'static str = ".1";
31+
pub const CFG_PRERELEASE_VERSION: &'static str = ".2";
3232

3333
pub struct GitInfo {
3434
inner: Option<Info>,

src/librustc_metadata/creader.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,8 @@ impl<'a> CrateLoader<'a> {
236236
// path (this is a top-level dependency) as we don't want to
237237
// implicitly load anything inside the dependency lookup path.
238238
let prev_kind = source.dylib.as_ref().or(source.rlib.as_ref())
239-
.unwrap().1;
239+
.or(source.rmeta.as_ref())
240+
.expect("No sources for crate").1;
240241
if ret.is_none() && (prev_kind == kind || prev_kind == PathKind::All) {
241242
ret = Some(cnum);
242243
}

src/librustc_resolve/build_reduced_graph.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use {resolve_error, resolve_struct_error, ResolutionError};
2323

2424
use rustc::middle::cstore::LoadedMacro;
2525
use rustc::hir::def::*;
26-
use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId};
26+
use rustc::hir::def_id::{CrateNum, BUILTIN_MACROS_CRATE, CRATE_DEF_INDEX, DefId};
2727
use rustc::ty;
2828

2929
use std::cell::Cell;
@@ -496,6 +496,9 @@ impl<'a> Resolver<'a> {
496496
let def_id = self.macro_defs[&expansion];
497497
if let Some(id) = self.definitions.as_local_node_id(def_id) {
498498
self.local_macro_def_scopes[&id]
499+
} else if def_id.krate == BUILTIN_MACROS_CRATE {
500+
// FIXME(jseyfried): This happens when `include!()`ing a `$crate::` path, c.f, #40469.
501+
self.graph_root
499502
} else {
500503
let module_def_id = ty::DefIdTree::parent(&*self, def_id).unwrap();
501504
self.get_extern_crate_root(module_def_id.krate)

src/librustc_typeck/check/callee.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
254254

255255
// Call the generic checker.
256256
let expected_arg_tys =
257-
self.expected_types_for_fn_args(call_expr.span,
257+
self.expected_inputs_for_expected_output(call_expr.span,
258258
expected,
259259
fn_sig.output(),
260260
fn_sig.inputs());
@@ -280,7 +280,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
280280
// do know the types expected for each argument and the return
281281
// type.
282282

283-
let expected_arg_tys = self.expected_types_for_fn_args(call_expr.span,
283+
let expected_arg_tys = self.expected_inputs_for_expected_output(call_expr.span,
284284
expected,
285285
fn_sig.output().clone(),
286286
fn_sig.inputs());

src/librustc_typeck/check/mod.rs

+31-18
Original file line numberDiff line numberDiff line change
@@ -2292,7 +2292,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
22922292
match method_fn_ty.sty {
22932293
ty::TyFnDef(def_id, .., ref fty) => {
22942294
// HACK(eddyb) ignore self in the definition (see above).
2295-
let expected_arg_tys = self.expected_types_for_fn_args(
2295+
let expected_arg_tys = self.expected_inputs_for_expected_output(
22962296
sp,
22972297
expected,
22982298
fty.0.output(),
@@ -2645,14 +2645,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
26452645
TypeAndSubsts { substs: substs, ty: substd_ty }
26462646
}
26472647

2648-
/// Unifies the return type with the expected type early, for more coercions
2649-
/// and forward type information on the argument expressions.
2650-
fn expected_types_for_fn_args(&self,
2651-
call_span: Span,
2652-
expected_ret: Expectation<'tcx>,
2653-
formal_ret: Ty<'tcx>,
2654-
formal_args: &[Ty<'tcx>])
2655-
-> Vec<Ty<'tcx>> {
2648+
/// Unifies the output type with the expected type early, for more coercions
2649+
/// and forward type information on the input expressions.
2650+
fn expected_inputs_for_expected_output(&self,
2651+
call_span: Span,
2652+
expected_ret: Expectation<'tcx>,
2653+
formal_ret: Ty<'tcx>,
2654+
formal_args: &[Ty<'tcx>])
2655+
-> Vec<Ty<'tcx>> {
26562656
let expected_args = expected_ret.only_has_type(self).and_then(|ret_ty| {
26572657
self.fudge_regions_if_ok(&RegionVariableOrigin::Coercion(call_span), || {
26582658
// Attempt to apply a subtyping relationship between the formal
@@ -2675,7 +2675,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
26752675
}).collect())
26762676
}).ok()
26772677
}).unwrap_or(vec![]);
2678-
debug!("expected_types_for_fn_args(formal={:?} -> {:?}, expected={:?} -> {:?})",
2678+
debug!("expected_inputs_for_expected_output(formal={:?} -> {:?}, expected={:?} -> {:?})",
26792679
formal_args, formal_ret,
26802680
expected_args, expected_ret);
26812681
expected_args
@@ -3032,14 +3032,22 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
30323032

30333033
fn check_expr_struct_fields(&self,
30343034
adt_ty: Ty<'tcx>,
3035+
expected: Expectation<'tcx>,
30353036
expr_id: ast::NodeId,
30363037
span: Span,
30373038
variant: &'tcx ty::VariantDef,
30383039
ast_fields: &'gcx [hir::Field],
30393040
check_completeness: bool) {
30403041
let tcx = self.tcx;
3041-
let (substs, adt_kind, kind_name) = match adt_ty.sty {
3042-
ty::TyAdt(adt, substs) => (substs, adt.adt_kind(), adt.variant_descr()),
3042+
3043+
let adt_ty_hint =
3044+
self.expected_inputs_for_expected_output(span, expected, adt_ty, &[adt_ty])
3045+
.get(0).cloned().unwrap_or(adt_ty);
3046+
3047+
let (substs, hint_substs, adt_kind, kind_name) = match (&adt_ty.sty, &adt_ty_hint.sty) {
3048+
(&ty::TyAdt(adt, substs), &ty::TyAdt(_, hint_substs)) => {
3049+
(substs, hint_substs, adt.adt_kind(), adt.variant_descr())
3050+
}
30433051
_ => span_bug!(span, "non-ADT passed to check_expr_struct_fields")
30443052
};
30453053

@@ -3054,10 +3062,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
30543062

30553063
// Typecheck each field.
30563064
for field in ast_fields {
3057-
let expected_field_type;
3065+
let final_field_type;
3066+
let field_type_hint;
30583067

30593068
if let Some(v_field) = remaining_fields.remove(&field.name.node) {
3060-
expected_field_type = self.field_ty(field.span, v_field, substs);
3069+
final_field_type = self.field_ty(field.span, v_field, substs);
3070+
field_type_hint = self.field_ty(field.span, v_field, hint_substs);
30613071

30623072
seen_fields.insert(field.name.node, field.span);
30633073

@@ -3069,7 +3079,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
30693079
}
30703080
} else {
30713081
error_happened = true;
3072-
expected_field_type = tcx.types.err;
3082+
final_field_type = tcx.types.err;
3083+
field_type_hint = tcx.types.err;
30733084
if let Some(_) = variant.find_field_named(field.name.node) {
30743085
let mut err = struct_span_err!(self.tcx.sess,
30753086
field.name.span,
@@ -3091,7 +3102,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
30913102

30923103
// Make sure to give a type to the field even if there's
30933104
// an error, so we can continue typechecking
3094-
self.check_expr_coercable_to_type(&field.expr, expected_field_type);
3105+
let ty = self.check_expr_with_hint(&field.expr, field_type_hint);
3106+
self.demand_coerce(&field.expr, ty, final_field_type);
30953107
}
30963108

30973109
// Make sure the programmer specified correct number of fields.
@@ -3201,6 +3213,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
32013213

32023214
fn check_expr_struct(&self,
32033215
expr: &hir::Expr,
3216+
expected: Expectation<'tcx>,
32043217
qpath: &hir::QPath,
32053218
fields: &'gcx [hir::Field],
32063219
base_expr: &'gcx Option<P<hir::Expr>>) -> Ty<'tcx>
@@ -3219,7 +3232,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
32193232
hir::QPath::TypeRelative(ref qself, _) => qself.span
32203233
};
32213234

3222-
self.check_expr_struct_fields(struct_ty, expr.id, path_span, variant, fields,
3235+
self.check_expr_struct_fields(struct_ty, expected, expr.id, path_span, variant, fields,
32233236
base_expr.is_none());
32243237
if let &Some(ref base_expr) = base_expr {
32253238
self.check_expr_has_type(base_expr, struct_ty);
@@ -3764,7 +3777,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
37643777
}
37653778
}
37663779
hir::ExprStruct(ref qpath, ref fields, ref base_expr) => {
3767-
self.check_expr_struct(expr, qpath, fields, base_expr)
3780+
self.check_expr_struct(expr, expected, qpath, fields, base_expr)
37683781
}
37693782
hir::ExprField(ref base, ref field) => {
37703783
self.check_field(expr, lvalue_pref, &base, field)
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# The ICE occurred in the following situation:
2+
# * `foo` declares `extern crate bar, baz`, depends only on `bar` (forgetting `baz` in `Cargo.toml`)
3+
# * `bar` declares and depends on `extern crate baz`
4+
# * All crates built in metadata-only mode (`cargo check`)
5+
all:
6+
# cc https://github.com/rust-lang/rust/issues/40623
7+
$(RUSTC) baz.rs --emit=metadata --out-dir=$(TMPDIR)
8+
$(RUSTC) bar.rs --emit=metadata --extern baz=$(TMPDIR)/libbaz.rmeta --out-dir=$(TMPDIR)
9+
$(RUSTC) foo.rs --emit=metadata --extern bar=$(TMPDIR)/libbar.rmeta --out-dir=$(TMPDIR) 2>&1 | \
10+
grep -vq "unexpectedly panicked"
11+
# ^ Succeeds if it doesn't find the ICE message

src/test/run-make/issue-40535/bar.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2017 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+
#![crate_type = "lib"]
12+
13+
extern crate baz;

src/test/run-make/issue-40535/baz.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2017 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+
#![crate_type = "lib"]

src/test/run-make/issue-40535/foo.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2017 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+
#![crate_type = "lib"]
12+
13+
extern crate bar;
14+
extern crate baz;
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2017 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+
macro_rules! m { () => { $crate::main(); } }

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

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2017 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 Struct<K: 'static> {
12+
pub field: K,
13+
}
14+
15+
// Partial fix for #31260, doesn't work without {...}.
16+
static STRUCT: Struct<&'static [u8]> = Struct {
17+
field: {&[1]}
18+
};
19+
20+
fn main() {}

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

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2017 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+
// ignore-pretty issue #37195
12+
13+
#![allow(dead_code)]
14+
15+
include!("auxiliary/issue_40469.rs");
16+
fn f() { m!(); }
17+
18+
fn main() {}

0 commit comments

Comments
 (0)