Change:
This code: Produces this internal compiler error: Interestingly, changing to or causes the code compile fine (modulo unused variable warnings). : Backtrace:
This is a regression in 1.17.0-beta. Earlier versions give:
Duplicate of .

Discussion:
{ debug!("note_issue_32330: terr={:?}", terr); match *terr { <del> TypeError::RegionsInsufficientlyPolymorphic(_, &Region::ReVar(vid)) | TypeError::RegionsOverlyPolymorphic(_, &Region::ReVar(vid)) => { match self.region_vars.var_origin(vid) { RegionVariableOrigin::EarlyBoundRegion(_, _, Some(Issue32330 { fn_def_id, region_name })) => { diag.note( &format!("lifetime parameter `{0}` declared on fn `{1}`  appears only in the return type,  but here is required to be higher-ranked,  which means that `{0}` must appear in both  argument and return types", region_name, self.tcx.item_path_str(fn_def_id))); diag.note( &format!("this error is the result of a recent bug fix;  for more information, see issue #33685  <https://github.com/rust-lang/rust/issues/33685>")); } _ => { } } </del> <ins> TypeError::RegionsInsufficientlyPolymorphic(_, _, Some(box Issue32330 { fn_def_id, region_name })) | TypeError::RegionsOverlyPolymorphic(_, _, Some(box Issue32330 { fn_def_id, region_name })) => { diag.note( &format!("lifetime parameter `{0}` declared on fn `{1}`  appears only in the return type,  but here is required to be higher-ranked,  which means that `{0}` must appear in both  argument and return types", region_name, self.tcx.item_path_str(fn_def_id))); diag.note( &format!("this error is the result of a recent bug fix;  for more information, see issue #33685  <https://github.com/rust-lang/rust/issues/33685>")); </ins> } <del> _ => { } </del> <ins> _ => {} </ins> } }

InferCtxt, LateBoundRegion, HigherRankedType, <ins> RegionVariableOrigin, </ins> SubregionOrigin, SkolemizationMap}; use super::combine::CombineFields;

skol_br, tainted_region); <ins> let issue_32330 = if let &ty::ReVar(vid) = tainted_region { match self.region_vars.var_origin(vid) { RegionVariableOrigin::EarlyBoundRegion(_, _, issue_32330) => { issue_32330.map(Box::new) } _ => None } } else { None }; </ins> if overly_polymorphic { debug!("Overly polymorphic!"); return Err(TypeError::RegionsOverlyPolymorphic(skol_br, <del> tainted_region)); </del> <ins> tainted_region, issue_32330)); </ins> } else { debug!("Not as polymorphic!"); return Err(TypeError::RegionsInsufficientlyPolymorphic(skol_br, <del> tainted_region)); </del> <ins> tainted_region, issue_32330)); </ins> } } }

RegionsDoesNotOutlive(&'tcx Region, &'tcx Region), RegionsNotSame(&'tcx Region, &'tcx Region), RegionsNoOverlap(&'tcx Region, &'tcx Region), <del> RegionsInsufficientlyPolymorphic(BoundRegion, &'tcx Region), RegionsOverlyPolymorphic(BoundRegion, &'tcx Region), </del> <ins> RegionsInsufficientlyPolymorphic(BoundRegion, &'tcx Region, Option<Box<ty::Issue32330>>), RegionsOverlyPolymorphic(BoundRegion, &'tcx Region, Option<Box<ty::Issue32330>>), </ins> Sorts(ExpectedFound<Ty<'tcx>>), IntMismatch(ExpectedFound<ty::IntVarValue>), FloatMismatch(ExpectedFound<ast::FloatTy>),

RegionsNoOverlap(..) => { write!(f, "lifetimes do not intersect") } <del> RegionsInsufficientlyPolymorphic(br, _) => { </del> <ins> RegionsInsufficientlyPolymorphic(br, _, _) => { </ins> write!(f, "expected bound lifetime parameter {},  found concrete lifetime", br) } <del> RegionsOverlyPolymorphic(br, _) => { </del> <ins> RegionsOverlyPolymorphic(br, _, _) => { </ins> write!(f, "expected concrete lifetime,  found bound lifetime parameter {}", br) }

self.note_and_explain_region(db, "...does not overlap ", region2, ""); } <del> RegionsInsufficientlyPolymorphic(_, conc_region) => { </del> <ins> RegionsInsufficientlyPolymorphic(_, conc_region, _) => { </ins> self.note_and_explain_region(db, "concrete lifetime that was found is ", conc_region, ""); } <del> RegionsOverlyPolymorphic(_, &ty::ReVar(_)) => { </del> <ins> RegionsOverlyPolymorphic(_, &ty::ReVar(_), _) => { </ins> // don't bother to print out the message below for // inference variables, it's not very illuminating. } <del> RegionsOverlyPolymorphic(_, conc_region) => { </del> <ins> RegionsOverlyPolymorphic(_, conc_region, _) => { </ins> self.note_and_explain_region(db, "expected concrete lifetime is ", conc_region, ""); }

RegionsNoOverlap(a, b) => { return tcx.lift(&(a, b)).map(|(a, b)| RegionsNoOverlap(a, b)) } <del> RegionsInsufficientlyPolymorphic(a, b) => { return tcx.lift(&b).map(|b| RegionsInsufficientlyPolymorphic(a, b)) </del> <ins> RegionsInsufficientlyPolymorphic(a, b, ref c) => { let c = c.clone(); return tcx.lift(&b).map(|b| RegionsInsufficientlyPolymorphic(a, b, c)) </ins> } <del> RegionsOverlyPolymorphic(a, b) => { return tcx.lift(&b).map(|b| RegionsOverlyPolymorphic(a, b)) </del> <ins> RegionsOverlyPolymorphic(a, b, ref c) => { let c = c.clone(); return tcx.lift(&b).map(|b| RegionsOverlyPolymorphic(a, b, c)) </ins> } IntMismatch(x) => IntMismatch(x), FloatMismatch(x) => FloatMismatch(x),

<ins> // Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(closure_to_fn_coercion)] fn main() { let bar: fn(&mut u32) = |_| {}; //~ ERROR mismatched types //~| expected concrete lifetime, found bound lifetime parameter fn foo(x: Box<Fn(&i32)>) {} let bar = Box::new(|x: &i32| {}) as Box<Fn(_)>; foo(bar); //~ ERROR mismatched types //~| expected concrete lifetime, found bound lifetime parameter } </ins>