Skip to content

Commit 65cf906

Browse files
committed
---
yaml --- r: 235847 b: refs/heads/stable c: a5c12f4 h: refs/heads/master i: 235845: fd68228 235843: b61fd33 235839: 5963f11 v: v3
1 parent d5bf3c8 commit 65cf906

File tree

4 files changed

+64
-45
lines changed

4 files changed

+64
-45
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: afae2ff723393b3ab4ccffef6ac7c6d1809e2da0
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: f859507de8c410b648d934d8f5ec1c52daac971d
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 5ad36cb887dadc7fe564cfed1ccac52d009a59c8
32+
refs/heads/stable: a5c12f4e39d32af3c951b66bd2839bc0b5a1125b
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/librustc_typeck/astconv.rs

Lines changed: 25 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ use middle::traits;
6060
use middle::ty::{self, RegionEscape, Ty, ToPredicate, HasTypeFlags};
6161
use middle::ty_fold;
6262
use require_c_abi_if_variadic;
63-
use rscope::{self, UnelidableRscope, RegionScope, ElidableRscope, ExplicitRscope,
63+
use rscope::{self, UnelidableRscope, RegionScope, ElidableRscope,
6464
ObjectLifetimeDefaultRscope, ShiftedRscope, BindingRscope,
6565
ElisionFailureInfo, ElidedLifetime};
6666
use util::common::{ErrorReported, FN_OUTPUT_NAME};
@@ -1216,40 +1216,33 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
12161216
(_, def::DefSelfTy(Some(trait_did), Some((impl_id, _)))) => {
12171217
// `Self` in an impl of a trait - we have a concrete self type and a
12181218
// trait reference.
1219-
match tcx.map.expect_item(impl_id).node {
1220-
ast::ItemImpl(_, _, _, Some(ref trait_ref), _, _) => {
1221-
if this.ensure_super_predicates(span, trait_did).is_err() {
1222-
return (tcx.types.err, ty_path_def);
1223-
}
1219+
let trait_ref = tcx.impl_trait_ref(ast_util::local_def(impl_id)).unwrap();
1220+
let trait_ref = if let Some(free_substs) = this.get_free_substs() {
1221+
trait_ref.subst(tcx, free_substs)
1222+
} else {
1223+
trait_ref
1224+
};
12241225

1225-
let trait_segment = &trait_ref.path.segments.last().unwrap();
1226-
let trait_ref = ast_path_to_mono_trait_ref(this,
1227-
&ExplicitRscope,
1228-
span,
1229-
PathParamMode::Explicit,
1230-
trait_did,
1231-
Some(ty),
1232-
trait_segment);
1233-
1234-
let candidates: Vec<ty::PolyTraitRef> =
1235-
traits::supertraits(tcx, ty::Binder(trait_ref.clone()))
1236-
.filter(|r| this.trait_defines_associated_type_named(r.def_id(),
1237-
assoc_name))
1238-
.collect();
1239-
1240-
match one_bound_for_assoc_type(tcx,
1241-
candidates,
1242-
"Self",
1243-
&token::get_name(assoc_name),
1244-
span) {
1245-
Ok(bound) => bound,
1246-
Err(ErrorReported) => return (tcx.types.err, ty_path_def),
1247-
}
1248-
}
1249-
_ => unreachable!()
1226+
if this.ensure_super_predicates(span, trait_did).is_err() {
1227+
return (tcx.types.err, ty_path_def);
1228+
}
1229+
1230+
let candidates: Vec<ty::PolyTraitRef> =
1231+
traits::supertraits(tcx, ty::Binder(trait_ref))
1232+
.filter(|r| this.trait_defines_associated_type_named(r.def_id(),
1233+
assoc_name))
1234+
.collect();
1235+
1236+
match one_bound_for_assoc_type(tcx,
1237+
candidates,
1238+
"Self",
1239+
&token::get_name(assoc_name),
1240+
span) {
1241+
Ok(bound) => bound,
1242+
Err(ErrorReported) => return (tcx.types.err, ty_path_def),
12501243
}
12511244
}
1252-
(&ty::TyParam(_), def::DefSelfTy(Some(trait_did), None)) => {
1245+
(&ty::TyParam(_), def::DefSelfTy(Some(trait_did), None)) => {
12531246
assert_eq!(trait_did.krate, ast::LOCAL_CRATE);
12541247
match find_bound_for_assoc_item(this,
12551248
trait_did.node,

branches/stable/src/librustc_typeck/collect.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,18 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
840840
ty: selfty });
841841
tcx.predicates.borrow_mut().insert(local_def(it.id),
842842
ty_predicates.clone());
843+
if let &Some(ref ast_trait_ref) = opt_trait_ref {
844+
tcx.impl_trait_refs.borrow_mut().insert(
845+
local_def(it.id),
846+
Some(astconv::instantiate_mono_trait_ref(&ccx.icx(&ty_predicates),
847+
&ExplicitRscope,
848+
ast_trait_ref,
849+
Some(selfty)))
850+
);
851+
} else {
852+
tcx.impl_trait_refs.borrow_mut().insert(local_def(it.id), None);
853+
}
854+
843855

844856
// If there is a trait reference, treat the methods as always public.
845857
// This is to work around some incorrect behavior in privacy checking:
@@ -939,18 +951,6 @@ fn convert_item(ccx: &CrateCtxt, it: &ast::Item) {
939951
}
940952
}
941953

942-
if let &Some(ref ast_trait_ref) = opt_trait_ref {
943-
tcx.impl_trait_refs.borrow_mut().insert(
944-
local_def(it.id),
945-
Some(astconv::instantiate_mono_trait_ref(&ccx.icx(&ty_predicates),
946-
&ExplicitRscope,
947-
ast_trait_ref,
948-
Some(selfty)))
949-
);
950-
} else {
951-
tcx.impl_trait_refs.borrow_mut().insert(local_def(it.id), None);
952-
}
953-
954954
enforce_impl_params_are_constrained(tcx,
955955
generics,
956956
local_def(it.id),
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Copyright 2015 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 trait Trait<'a> {
12+
type T;
13+
type U;
14+
fn foo(&self, s: &'a ()) -> &'a ();
15+
}
16+
17+
impl<'a> Trait<'a> for () {
18+
type T = &'a ();
19+
type U = Self::T;
20+
21+
fn foo(&self, s: &'a ()) -> &'a () {
22+
let t: Self::T = s; t
23+
}
24+
}
25+
26+
fn main() {}

0 commit comments

Comments
 (0)