Skip to content

Commit f4a7756

Browse files
committed
rollup merge of rust-lang#19298: nikomatsakis/unboxed-closure-parse-the-plus
Implements RFC 438. Fixes rust-lang#19092. This is a [breaking-change]: change types like `&Foo+Send` or `&'a mut Foo+'a` to `&(Foo+Send)` and `&'a mut (Foo+'a)`, respectively. r? @brson
2 parents 702127f + 21d5d13 commit f4a7756

Some content is hidden

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

63 files changed

+478
-372
lines changed

src/libcore/fmt/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub struct Formatter<'a> {
8585
width: Option<uint>,
8686
precision: Option<uint>,
8787

88-
buf: &'a mut FormatWriter+'a,
88+
buf: &'a mut (FormatWriter+'a),
8989
curarg: slice::Items<'a, Argument<'a>>,
9090
args: &'a [Argument<'a>],
9191
}
@@ -565,7 +565,7 @@ impl<'a, Sized? T: Show> Show for &'a T {
565565
impl<'a, Sized? T: Show> Show for &'a mut T {
566566
fn fmt(&self, f: &mut Formatter) -> Result { (**self).fmt(f) }
567567
}
568-
impl<'a> Show for &'a Show+'a {
568+
impl<'a> Show for &'a (Show+'a) {
569569
fn fmt(&self, f: &mut Formatter) -> Result { (*self).fmt(f) }
570570
}
571571

@@ -724,7 +724,7 @@ macro_rules! tuple (
724724

725725
tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, }
726726

727-
impl<'a> Show for &'a any::Any+'a {
727+
impl<'a> Show for &'a (any::Any+'a) {
728728
fn fmt(&self, f: &mut Formatter) -> Result { f.pad("&Any") }
729729
}
730730

src/librustc/diagnostics.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,6 @@ register_diagnostics!(
146146
E0167,
147147
E0168,
148148
E0169,
149-
E0170
149+
E0170,
150+
E0171
150151
)

src/librustc/lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
421421
impl<'a, 'tcx, 'v> Visitor<'v> for ImproperCTypesVisitor<'a, 'tcx> {
422422
fn visit_ty(&mut self, ty: &ast::Ty) {
423423
match ty.node {
424-
ast::TyPath(_, _, id) => self.check_def(ty.span, ty.id, id),
424+
ast::TyPath(_, id) => self.check_def(ty.span, ty.id, id),
425425
_ => (),
426426
}
427427
visit::walk_ty(self, ty);

src/librustc/metadata/encoder.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1230,10 +1230,9 @@ fn encode_info_for_item(ecx: &EncodeContext,
12301230
encode_name(rbml_w, item.ident.name);
12311231
encode_attributes(rbml_w, item.attrs.as_slice());
12321232
match ty.node {
1233-
ast::TyPath(ref path, ref bounds, _) if path.segments
1233+
ast::TyPath(ref path, _) if path.segments
12341234
.len() == 1 => {
12351235
let ident = path.segments.last().unwrap().identifier;
1236-
assert!(bounds.is_none());
12371236
encode_impl_type_basename(rbml_w, ident);
12381237
}
12391238
_ => {}

src/librustc/middle/expr_use_visitor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ impl OverloadedCallType {
295295
pub struct ExprUseVisitor<'d,'t,'tcx,TYPER:'t> {
296296
typer: &'t TYPER,
297297
mc: mc::MemCategorizationContext<'t,TYPER>,
298-
delegate: &'d mut Delegate<'tcx>+'d,
298+
delegate: &'d mut (Delegate<'tcx>+'d),
299299
}
300300

301301
// If the TYPER results in an error, it's because the type check

src/librustc/middle/privacy.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
243243
// * Private trait impls for private types can be completely ignored
244244
ast::ItemImpl(_, _, ref ty, ref impl_items) => {
245245
let public_ty = match ty.node {
246-
ast::TyPath(_, _, id) => {
246+
ast::TyPath(_, id) => {
247247
match self.tcx.def_map.borrow()[id].clone() {
248248
def::DefPrimTy(..) => true,
249249
def => {
@@ -311,7 +311,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> {
311311

312312
ast::ItemTy(ref ty, _) if public_first => {
313313
match ty.node {
314-
ast::TyPath(_, _, id) => {
314+
ast::TyPath(_, id) => {
315315
match self.tcx.def_map.borrow()[id].clone() {
316316
def::DefPrimTy(..) | def::DefTyParam(..) => {},
317317
def => {
@@ -616,7 +616,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
616616
// was private.
617617
ast::ItemImpl(_, _, ref ty, _) => {
618618
let id = match ty.node {
619-
ast::TyPath(_, _, id) => id,
619+
ast::TyPath(_, id) => id,
620620
_ => return Some((err_span, err_msg, None)),
621621
};
622622
let def = self.tcx.def_map.borrow()[id].clone();
@@ -1292,7 +1292,7 @@ impl<'a, 'tcx> VisiblePrivateTypesVisitor<'a, 'tcx> {
12921292
impl<'a, 'b, 'tcx, 'v> Visitor<'v> for CheckTypeForPrivatenessVisitor<'a, 'b, 'tcx> {
12931293
fn visit_ty(&mut self, ty: &ast::Ty) {
12941294
match ty.node {
1295-
ast::TyPath(_, _, path_id) => {
1295+
ast::TyPath(_, path_id) => {
12961296
if self.inner.path_is_private_type(path_id) {
12971297
self.contains_private = true;
12981298
// found what we're looking for so let's stop
@@ -1493,7 +1493,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for VisiblePrivateTypesVisitor<'a, 'tcx> {
14931493

14941494
fn visit_ty(&mut self, t: &ast::Ty) {
14951495
match t.node {
1496-
ast::TyPath(ref p, _, path_id) => {
1496+
ast::TyPath(ref p, path_id) => {
14971497
if !self.tcx.sess.features.borrow().visible_private_types &&
14981498
self.path_is_private_type(path_id) {
14991499
self.tcx.sess.span_err(p.span,

src/librustc/middle/resolve.rs

+64-46
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ use syntax::ast::{PolyTraitRef, PrimTy, Public, SelfExplicit, SelfStatic};
6363
use syntax::ast::{RegionTyParamBound, StmtDecl, StructField};
6464
use syntax::ast::{StructVariantKind, TraitRef, TraitTyParamBound};
6565
use syntax::ast::{TupleVariantKind, Ty, TyBool, TyChar, TyClosure, TyF32};
66-
use syntax::ast::{TyF64, TyFloat, TyI, TyI8, TyI16, TyI32, TyI64, TyInt};
66+
use syntax::ast::{TyF64, TyFloat, TyI, TyI8, TyI16, TyI32, TyI64, TyInt, TyObjectSum};
6767
use syntax::ast::{TyParam, TyParamBound, TyPath, TyPtr, TyPolyTraitRef, TyProc, TyQPath};
6868
use syntax::ast::{TyRptr, TyStr, TyU, TyU8, TyU16, TyU32, TyU64, TyUint};
6969
use syntax::ast::{TypeImplItem, UnnamedField};
@@ -1392,29 +1392,53 @@ impl<'a> Resolver<'a> {
13921392
// methods within to a new module, if the type was defined
13931393
// within this module.
13941394

1395-
// Create the module and add all methods.
1396-
match ty.node {
1397-
TyPath(ref path, _, _) if path.segments.len() == 1 => {
1395+
let mod_name = match ty.node {
1396+
TyPath(ref path, _) if path.segments.len() == 1 => {
13981397
// FIXME(18446) we should distinguish between the name of
13991398
// a trait and the name of an impl of that trait.
1400-
let mod_name = path.segments.last().unwrap().identifier.name;
1399+
Some(path.segments.last().unwrap().identifier.name)
1400+
}
1401+
TyObjectSum(ref lhs_ty, _) => {
1402+
match lhs_ty.node {
1403+
TyPath(ref path, _) if path.segments.len() == 1 => {
1404+
Some(path.segments.last().unwrap().identifier.name)
1405+
}
1406+
_ => {
1407+
None
1408+
}
1409+
}
1410+
}
1411+
_ => {
1412+
None
1413+
}
1414+
};
14011415

1416+
match mod_name {
1417+
None => {
1418+
self.resolve_error(ty.span,
1419+
"inherent implementations may \
1420+
only be implemented in the same \
1421+
module as the type they are \
1422+
implemented for")
1423+
}
1424+
Some(mod_name) => {
1425+
// Create the module and add all methods.
14021426
let parent_opt = parent.module().children.borrow()
1403-
.get(&mod_name).cloned();
1427+
.get(&mod_name).cloned();
14041428
let new_parent = match parent_opt {
14051429
// It already exists
14061430
Some(ref child) if child.get_module_if_available()
1407-
.is_some() &&
1408-
(child.get_module().kind.get() == ImplModuleKind ||
1409-
child.get_module().kind.get() == TraitModuleKind) => {
1410-
ModuleReducedGraphParent(child.get_module())
1411-
}
1431+
.is_some() &&
1432+
(child.get_module().kind.get() == ImplModuleKind ||
1433+
child.get_module().kind.get() == TraitModuleKind) => {
1434+
ModuleReducedGraphParent(child.get_module())
1435+
}
14121436
Some(ref child) if child.get_module_if_available()
1413-
.is_some() &&
1414-
child.get_module().kind.get() ==
1415-
EnumModuleKind => {
1416-
ModuleReducedGraphParent(child.get_module())
1417-
}
1437+
.is_some() &&
1438+
child.get_module().kind.get() ==
1439+
EnumModuleKind => {
1440+
ModuleReducedGraphParent(child.get_module())
1441+
}
14181442
// Create the module
14191443
_ => {
14201444
let name_bindings =
@@ -1429,7 +1453,7 @@ impl<'a> Resolver<'a> {
14291453
let ns = TypeNS;
14301454
let is_public =
14311455
!name_bindings.defined_in_namespace(ns) ||
1432-
name_bindings.defined_in_public_namespace(ns);
1456+
name_bindings.defined_in_public_namespace(ns);
14331457

14341458
name_bindings.define_module(parent_link,
14351459
Some(def_id),
@@ -1455,21 +1479,21 @@ impl<'a> Resolver<'a> {
14551479
ForbidDuplicateValues,
14561480
method.span);
14571481
let def = match method.pe_explicit_self()
1458-
.node {
1459-
SelfStatic => {
1460-
// Static methods become
1461-
// `DefStaticMethod`s.
1462-
DefStaticMethod(local_def(method.id),
1463-
FromImpl(local_def(item.id)))
1464-
}
1465-
_ => {
1466-
// Non-static methods become
1467-
// `DefMethod`s.
1468-
DefMethod(local_def(method.id),
1469-
None,
1470-
FromImpl(local_def(item.id)))
1471-
}
1472-
};
1482+
.node {
1483+
SelfStatic => {
1484+
// Static methods become
1485+
// `DefStaticMethod`s.
1486+
DefStaticMethod(local_def(method.id),
1487+
FromImpl(local_def(item.id)))
1488+
}
1489+
_ => {
1490+
// Non-static methods become
1491+
// `DefMethod`s.
1492+
DefMethod(local_def(method.id),
1493+
None,
1494+
FromImpl(local_def(item.id)))
1495+
}
1496+
};
14731497

14741498
// NB: not IMPORTABLE
14751499
let modifiers = if method.pe_vis() == ast::Public {
@@ -1492,7 +1516,7 @@ impl<'a> Resolver<'a> {
14921516
ForbidDuplicateTypesAndModules,
14931517
typedef.span);
14941518
let def = DefAssociatedTy(local_def(
1495-
typedef.id));
1519+
typedef.id));
14961520
// NB: not IMPORTABLE
14971521
let modifiers = if typedef.vis == ast::Public {
14981522
PUBLIC
@@ -1507,13 +1531,6 @@ impl<'a> Resolver<'a> {
15071531
}
15081532
}
15091533
}
1510-
_ => {
1511-
self.resolve_error(ty.span,
1512-
"inherent implementations may \
1513-
only be implemented in the same \
1514-
module as the type they are \
1515-
implemented for")
1516-
}
15171534
}
15181535

15191536
parent
@@ -4721,7 +4738,7 @@ impl<'a> Resolver<'a> {
47214738
// type, the result will be that the type name resolves to a module but not
47224739
// a type (shadowing any imported modules or types with this name), leading
47234740
// to weird user-visible bugs. So we ward this off here. See #15060.
4724-
TyPath(ref path, _, path_id) => {
4741+
TyPath(ref path, path_id) => {
47254742
match self.def_map.borrow().get(&path_id) {
47264743
// FIXME: should we catch other options and give more precise errors?
47274744
Some(&DefMod(_)) => {
@@ -4887,7 +4904,7 @@ impl<'a> Resolver<'a> {
48874904
// Like path expressions, the interpretation of path types depends
48884905
// on whether the path has multiple elements in it or not.
48894906

4890-
TyPath(ref path, ref bounds, path_id) => {
4907+
TyPath(ref path, path_id) => {
48914908
// This is a path in the type namespace. Walk through scopes
48924909
// looking for it.
48934910
let mut result_def = None;
@@ -4957,11 +4974,12 @@ impl<'a> Resolver<'a> {
49574974
self.resolve_error(ty.span, msg.as_slice());
49584975
}
49594976
}
4977+
}
49604978

4961-
bounds.as_ref().map(|bound_vec| {
4962-
self.resolve_type_parameter_bounds(ty.id, bound_vec,
4979+
TyObjectSum(ref ty, ref bound_vec) => {
4980+
self.resolve_type(&**ty);
4981+
self.resolve_type_parameter_bounds(ty.id, bound_vec,
49634982
TraitBoundingTypeParameter);
4964-
});
49654983
}
49664984

49674985
TyQPath(ref qpath) => {
@@ -5598,7 +5616,7 @@ impl<'a> Resolver<'a> {
55985616
fn extract_path_and_node_id(t: &Ty, allow: FallbackChecks)
55995617
-> Option<(Path, NodeId, FallbackChecks)> {
56005618
match t.node {
5601-
TyPath(ref path, _, node_id) => Some((path.clone(), node_id, allow)),
5619+
TyPath(ref path, node_id) => Some((path.clone(), node_id, allow)),
56025620
TyPtr(ref mut_ty) => extract_path_and_node_id(&*mut_ty.ty, OnlyTraitAndStatics),
56035621
TyRptr(_, ref mut_ty) => extract_path_and_node_id(&*mut_ty.ty, allow),
56045622
// This doesn't handle the remaining `Ty` variants as they are not

src/librustc/middle/resolve_lifetime.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -162,21 +162,14 @@ impl<'a, 'v> Visitor<'v> for LifetimeContext<'a> {
162162
visit::walk_ty(this, ty);
163163
});
164164
}
165-
ast::TyPath(ref path, ref opt_bounds, id) => {
165+
ast::TyPath(ref path, id) => {
166166
// if this path references a trait, then this will resolve to
167167
// a trait ref, which introduces a binding scope.
168168
match self.def_map.borrow().get(&id) {
169169
Some(&def::DefTrait(..)) => {
170170
self.with(LateScope(&Vec::new(), self.scope), |this| {
171171
this.visit_path(path, id);
172172
});
173-
174-
match *opt_bounds {
175-
Some(ref bounds) => {
176-
visit::walk_ty_param_bounds_helper(self, bounds);
177-
}
178-
None => { }
179-
}
180173
}
181174
_ => {
182175
visit::walk_ty(self, ty);

src/librustc/middle/traits/select.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use util::ppaux::Repr;
4343
pub struct SelectionContext<'cx, 'tcx:'cx> {
4444
infcx: &'cx InferCtxt<'cx, 'tcx>,
4545
param_env: &'cx ty::ParameterEnvironment<'tcx>,
46-
typer: &'cx Typer<'tcx>+'cx,
46+
typer: &'cx (Typer<'tcx>+'cx),
4747

4848
/// Skolemizer used specifically for skolemizing entries on the
4949
/// obligation stack. This ensures that all entries on the stack

0 commit comments

Comments
 (0)