Skip to content

Commit 9b97d1e

Browse files
committed
Auto merge of #50127 - alexcrichton:beta-next2, r=alexcrichton
[beta] Processing merged backports This is a backport of the following PRs: * #49386 * #49465 * #49647 * #49692 * #49695 * #49714 * #49730 * #49830 * #49981
2 parents 8423230 + 84fdaf0 commit 9b97d1e

File tree

41 files changed

+423
-127
lines changed

Some content is hidden

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

41 files changed

+423
-127
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,6 @@ matrix:
176176
if: branch = auto
177177
- env: IMAGE=x86_64-gnu-distcheck
178178
if: branch = auto
179-
- env: IMAGE=x86_64-gnu-incremental
180-
if: branch = auto
181179

182180
- stage: publish toolstate
183181
if: branch = master AND type = push

src/bootstrap/doc.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ impl Step for Test {
512512

513513
fn should_run(run: ShouldRun) -> ShouldRun {
514514
let builder = run.builder;
515-
run.krate("test").default_condition(builder.config.compiler_docs)
515+
run.krate("test").default_condition(builder.build.config.docs)
516516
}
517517

518518
fn make_run(run: RunConfig) {
@@ -555,6 +555,9 @@ impl Step for Test {
555555

556556
let mut cargo = builder.cargo(compiler, Mode::Libtest, target, "doc");
557557
compile::test_cargo(build, &compiler, target, &mut cargo);
558+
559+
cargo.arg("--no-deps").arg("-p").arg("test");
560+
558561
build.run(&mut cargo);
559562
cp_r(&my_out, &out);
560563
}

src/ci/docker/x86_64-gnu-incremental/Dockerfile

-22
This file was deleted.

src/librustc/hir/lowering.rs

+36-17
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,9 @@ impl<'a> LoweringContext<'a> {
780780
_ => None,
781781
}),
782782
|this| {
783+
let itctx = ImplTraitContext::Universal(parent_id);
783784
this.collect_in_band_defs(parent_id, anonymous_lifetime_mode, |this| {
784-
(this.lower_generics(generics), f(this))
785+
(this.lower_generics(generics, itctx), f(this))
785786
})
786787
},
787788
);
@@ -1043,7 +1044,11 @@ impl<'a> LoweringContext<'a> {
10431044
}),
10441045
|this| {
10451046
hir::TyBareFn(P(hir::BareFnTy {
1046-
generic_params: this.lower_generic_params(&f.generic_params, &NodeMap()),
1047+
generic_params: this.lower_generic_params(
1048+
&f.generic_params,
1049+
&NodeMap(),
1050+
ImplTraitContext::Disallowed,
1051+
),
10471052
unsafety: this.lower_unsafety(f.unsafety),
10481053
abi: f.abi,
10491054
decl: this.lower_fn_decl(&f.decl, None, false),
@@ -1784,7 +1789,12 @@ impl<'a> LoweringContext<'a> {
17841789
}
17851790
}
17861791

1787-
fn lower_ty_param(&mut self, tp: &TyParam, add_bounds: &[TyParamBound]) -> hir::TyParam {
1792+
fn lower_ty_param(
1793+
&mut self,
1794+
tp: &TyParam,
1795+
add_bounds: &[TyParamBound],
1796+
itctx: ImplTraitContext,
1797+
) -> hir::TyParam {
17881798
let mut name = self.lower_ident(tp.ident);
17891799

17901800
// Don't expose `Self` (recovered "keyword used as ident" parse error).
@@ -1794,7 +1804,6 @@ impl<'a> LoweringContext<'a> {
17941804
name = Symbol::gensym("Self");
17951805
}
17961806

1797-
let itctx = ImplTraitContext::Universal(self.resolver.definitions().local_def_id(tp.id));
17981807
let mut bounds = self.lower_bounds(&tp.bounds, itctx);
17991808
if !add_bounds.is_empty() {
18001809
bounds = bounds
@@ -1878,6 +1887,7 @@ impl<'a> LoweringContext<'a> {
18781887
&mut self,
18791888
params: &Vec<GenericParam>,
18801889
add_bounds: &NodeMap<Vec<TyParamBound>>,
1890+
itctx: ImplTraitContext,
18811891
) -> hir::HirVec<hir::GenericParam> {
18821892
params
18831893
.iter()
@@ -1888,12 +1898,13 @@ impl<'a> LoweringContext<'a> {
18881898
GenericParam::Type(ref ty_param) => hir::GenericParam::Type(self.lower_ty_param(
18891899
ty_param,
18901900
add_bounds.get(&ty_param.id).map_or(&[][..], |x| &x),
1901+
itctx,
18911902
)),
18921903
})
18931904
.collect()
18941905
}
18951906

1896-
fn lower_generics(&mut self, g: &Generics) -> hir::Generics {
1907+
fn lower_generics(&mut self, g: &Generics, itctx: ImplTraitContext) -> hir::Generics {
18971908
// Collect `?Trait` bounds in where clause and move them to parameter definitions.
18981909
// FIXME: This could probably be done with less rightward drift. Also looks like two control
18991910
// paths where report_error is called are also the only paths that advance to after
@@ -1946,7 +1957,7 @@ impl<'a> LoweringContext<'a> {
19461957
}
19471958

19481959
hir::Generics {
1949-
params: self.lower_generic_params(&g.params, &add_bounds),
1960+
params: self.lower_generic_params(&g.params, &add_bounds, itctx),
19501961
where_clause: self.lower_where_clause(&g.where_clause),
19511962
span: g.span,
19521963
}
@@ -1980,6 +1991,7 @@ impl<'a> LoweringContext<'a> {
19801991
bound_generic_params: this.lower_generic_params(
19811992
bound_generic_params,
19821993
&NodeMap(),
1994+
ImplTraitContext::Disallowed,
19831995
),
19841996
bounded_ty: this.lower_ty(bounded_ty, ImplTraitContext::Disallowed),
19851997
bounds: bounds
@@ -2063,7 +2075,8 @@ impl<'a> LoweringContext<'a> {
20632075
p: &PolyTraitRef,
20642076
itctx: ImplTraitContext,
20652077
) -> hir::PolyTraitRef {
2066-
let bound_generic_params = self.lower_generic_params(&p.bound_generic_params, &NodeMap());
2078+
let bound_generic_params =
2079+
self.lower_generic_params(&p.bound_generic_params, &NodeMap(), itctx);
20672080
let trait_ref = self.with_parent_impl_lifetime_defs(
20682081
&bound_generic_params
20692082
.iter()
@@ -2218,7 +2231,7 @@ impl<'a> LoweringContext<'a> {
22182231
ItemKind::GlobalAsm(ref ga) => hir::ItemGlobalAsm(self.lower_global_asm(ga)),
22192232
ItemKind::Ty(ref t, ref generics) => hir::ItemTy(
22202233
self.lower_ty(t, ImplTraitContext::Disallowed),
2221-
self.lower_generics(generics),
2234+
self.lower_generics(generics, ImplTraitContext::Disallowed),
22222235
),
22232236
ItemKind::Enum(ref enum_definition, ref generics) => hir::ItemEnum(
22242237
hir::EnumDef {
@@ -2228,15 +2241,21 @@ impl<'a> LoweringContext<'a> {
22282241
.map(|x| self.lower_variant(x))
22292242
.collect(),
22302243
},
2231-
self.lower_generics(generics),
2244+
self.lower_generics(generics, ImplTraitContext::Disallowed),
22322245
),
22332246
ItemKind::Struct(ref struct_def, ref generics) => {
22342247
let struct_def = self.lower_variant_data(struct_def);
2235-
hir::ItemStruct(struct_def, self.lower_generics(generics))
2248+
hir::ItemStruct(
2249+
struct_def,
2250+
self.lower_generics(generics, ImplTraitContext::Disallowed),
2251+
)
22362252
}
22372253
ItemKind::Union(ref vdata, ref generics) => {
22382254
let vdata = self.lower_variant_data(vdata);
2239-
hir::ItemUnion(vdata, self.lower_generics(generics))
2255+
hir::ItemUnion(
2256+
vdata,
2257+
self.lower_generics(generics, ImplTraitContext::Disallowed),
2258+
)
22402259
}
22412260
ItemKind::Impl(
22422261
unsafety,
@@ -2315,13 +2334,13 @@ impl<'a> LoweringContext<'a> {
23152334
hir::ItemTrait(
23162335
self.lower_is_auto(is_auto),
23172336
self.lower_unsafety(unsafety),
2318-
self.lower_generics(generics),
2337+
self.lower_generics(generics, ImplTraitContext::Disallowed),
23192338
bounds,
23202339
items,
23212340
)
23222341
}
23232342
ItemKind::TraitAlias(ref generics, ref bounds) => hir::ItemTraitAlias(
2324-
self.lower_generics(generics),
2343+
self.lower_generics(generics, ImplTraitContext::Disallowed),
23252344
self.lower_bounds(bounds, ImplTraitContext::Disallowed),
23262345
),
23272346
ItemKind::MacroDef(..) | ItemKind::Mac(..) => panic!("Shouldn't still be around"),
@@ -2456,7 +2475,7 @@ impl<'a> LoweringContext<'a> {
24562475

24572476
let (generics, node) = match i.node {
24582477
TraitItemKind::Const(ref ty, ref default) => (
2459-
this.lower_generics(&i.generics),
2478+
this.lower_generics(&i.generics, ImplTraitContext::Disallowed),
24602479
hir::TraitItemKind::Const(
24612480
this.lower_ty(ty, ImplTraitContext::Disallowed),
24622481
default
@@ -2497,7 +2516,7 @@ impl<'a> LoweringContext<'a> {
24972516
)
24982517
}
24992518
TraitItemKind::Type(ref bounds, ref default) => (
2500-
this.lower_generics(&i.generics),
2519+
this.lower_generics(&i.generics, ImplTraitContext::Disallowed),
25012520
hir::TraitItemKind::Type(
25022521
this.lower_bounds(bounds, ImplTraitContext::Disallowed),
25032522
default
@@ -2554,7 +2573,7 @@ impl<'a> LoweringContext<'a> {
25542573
ImplItemKind::Const(ref ty, ref expr) => {
25552574
let body_id = this.lower_body(None, |this| this.lower_expr(expr));
25562575
(
2557-
this.lower_generics(&i.generics),
2576+
this.lower_generics(&i.generics, ImplTraitContext::Disallowed),
25582577
hir::ImplItemKind::Const(
25592578
this.lower_ty(ty, ImplTraitContext::Disallowed),
25602579
body_id,
@@ -2585,7 +2604,7 @@ impl<'a> LoweringContext<'a> {
25852604
)
25862605
}
25872606
ImplItemKind::Type(ref ty) => (
2588-
this.lower_generics(&i.generics),
2607+
this.lower_generics(&i.generics, ImplTraitContext::Disallowed),
25892608
hir::ImplItemKind::Type(this.lower_ty(ty, ImplTraitContext::Disallowed)),
25902609
),
25912610
ImplItemKind::Macro(..) => panic!("Shouldn't exist any more"),

src/librustc/infer/anon_types/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -533,10 +533,14 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for ReverseMapper<'cx, 'gcx, 'tcx>
533533
match r {
534534
// ignore bound regions that appear in the type (e.g., this
535535
// would ignore `'r` in a type like `for<'r> fn(&'r u32)`.
536-
ty::ReLateBound(..) => return r,
536+
ty::ReLateBound(..) |
537537

538538
// ignore `'static`, as that can appear anywhere
539-
ty::ReStatic => return r,
539+
ty::ReStatic |
540+
541+
// ignore `ReScope`, as that can appear anywhere
542+
// See `src/test/run-pass/issue-49556.rs` for example.
543+
ty::ReScope(..) => return r,
540544

541545
_ => { }
542546
}

src/librustc/infer/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
181181
self.msg_span_from_early_bound_and_free_regions(region)
182182
},
183183
ty::ReStatic => ("the static lifetime".to_owned(), None),
184-
_ => bug!(),
184+
_ => bug!("{:?}", region),
185185
}
186186
}
187187

src/librustc/infer/type_variable.rs

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

11-
use syntax::ast;
11+
use syntax::symbol::InternedString;
1212
use syntax_pos::Span;
1313
use ty::{self, Ty};
1414

@@ -53,7 +53,7 @@ pub enum TypeVariableOrigin {
5353
MiscVariable(Span),
5454
NormalizeProjectionType(Span),
5555
TypeInference(Span),
56-
TypeParameterDefinition(Span, ast::Name),
56+
TypeParameterDefinition(Span, InternedString),
5757

5858
/// one of the upvars or closure kind parameters in a `ClosureSubsts`
5959
/// (before it has been determined)

src/librustc/middle/mem_categorization.rs

+33-4
Original file line numberDiff line numberDiff line change
@@ -503,8 +503,37 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
503503
self.resolve_type_vars_or_error(expr.hir_id, self.tables.expr_ty_adjusted_opt(expr))
504504
}
505505

506+
/// Returns the type of value that this pattern matches against.
507+
/// Some non-obvious cases:
508+
///
509+
/// - a `ref x` binding matches against a value of type `T` and gives
510+
/// `x` the type `&T`; we return `T`.
511+
/// - a pattern with implicit derefs (thanks to default binding
512+
/// modes #42640) may look like `Some(x)` but in fact have
513+
/// implicit deref patterns attached (e.g., it is really
514+
/// `&Some(x)`). In that case, we return the "outermost" type
515+
/// (e.g., `&Option<T>).
506516
fn pat_ty(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
517+
// Check for implicit `&` types wrapping the pattern; note
518+
// that these are never attached to binding patterns, so
519+
// actually this is somewhat "disjoint" from the code below
520+
// that aims to account for `ref x`.
521+
if let Some(vec) = self.tables.pat_adjustments().get(pat.hir_id) {
522+
if let Some(first_ty) = vec.first() {
523+
debug!("pat_ty(pat={:?}) found adjusted ty `{:?}`", pat, first_ty);
524+
return Ok(first_ty);
525+
}
526+
}
527+
528+
self.pat_ty_unadjusted(pat)
529+
}
530+
531+
532+
/// Like `pat_ty`, but ignores implicit `&` patterns.
533+
fn pat_ty_unadjusted(&self, pat: &hir::Pat) -> McResult<Ty<'tcx>> {
507534
let base_ty = self.node_ty(pat.hir_id)?;
535+
debug!("pat_ty(pat={:?}) base_ty={:?}", pat, base_ty);
536+
508537
// This code detects whether we are looking at a `ref x`,
509538
// and if so, figures out what the type *being borrowed* is.
510539
let ret_ty = match pat.node {
@@ -531,8 +560,8 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
531560
}
532561
_ => base_ty,
533562
};
534-
debug!("pat_ty(pat={:?}) base_ty={:?} ret_ty={:?}",
535-
pat, base_ty, ret_ty);
563+
debug!("pat_ty(pat={:?}) ret_ty={:?}", pat, ret_ty);
564+
536565
Ok(ret_ty)
537566
}
538567

@@ -1246,7 +1275,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
12461275
self.tcx.adt_def(enum_def).variant_with_id(def_id).fields.len())
12471276
}
12481277
Def::StructCtor(_, CtorKind::Fn) => {
1249-
match self.pat_ty(&pat)?.sty {
1278+
match self.pat_ty_unadjusted(&pat)?.sty {
12501279
ty::TyAdt(adt_def, _) => {
12511280
(cmt, adt_def.non_enum_variant().fields.len())
12521281
}
@@ -1297,7 +1326,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
12971326

12981327
PatKind::Tuple(ref subpats, ddpos) => {
12991328
// (p1, ..., pN)
1300-
let expected_len = match self.pat_ty(&pat)?.sty {
1329+
let expected_len = match self.pat_ty_unadjusted(&pat)?.sty {
13011330
ty::TyTuple(ref tys) => tys.len(),
13021331
ref ty => span_bug!(pat.span, "tuple pattern unexpected type {:?}", ty),
13031332
};

src/librustc/traits/error_reporting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
378378
}
379379

380380
for param in generics.types.iter() {
381-
let name = param.name.as_str().to_string();
381+
let name = param.name.to_string();
382382
let ty = trait_ref.substs.type_for_def(param);
383383
let ty_str = ty.to_string();
384384
flags.push((name.clone(),

src/librustc/traits/on_unimplemented.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedFormatString {
289289
let trait_str = tcx.item_path_str(trait_ref.def_id);
290290
let generics = tcx.generics_of(trait_ref.def_id);
291291
let generic_map = generics.types.iter().map(|param| {
292-
(param.name.as_str().to_string(),
292+
(param.name.to_string(),
293293
trait_ref.substs.type_for_def(param).to_string())
294294
}).collect::<FxHashMap<String, String>>();
295295

0 commit comments

Comments
 (0)