Skip to content

Commit ab69e0c

Browse files
committed
---
yaml --- r: 159214 b: refs/heads/snap-stage3 c: e691192 h: refs/heads/master v: v3
1 parent 48b531b commit ab69e0c

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 40fb87d40f681f5356af42175fc7b85da387f037
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: f8403aac81d5720bb722a85a9120c14ceb763eb9
4+
refs/heads/snap-stage3: e691192042c8505b79e55d7bbb0f3c4ebd2f7992
55
refs/heads/try: f58aad6dce273570fb130b4df008ef9acd5a5be2
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/librustc/middle/typeck/check/method/probe.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,32 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
827827
method.fty.sig.inputs[0].repr(self.tcx()),
828828
substs.repr(self.tcx()));
829829

830+
// It is possible for type parameters or early-bound lifetimes
831+
// to appear in the signature of `self`. The substitutions we
832+
// are given do not include type/lifetime parameters for the
833+
// method yet. So create fresh variables here for those too,
834+
// if there are any.
835+
assert_eq!(substs.types.len(subst::FnSpace), 0);
836+
assert_eq!(substs.regions().len(subst::FnSpace), 0);
837+
let mut substs = substs;
838+
let placeholder;
839+
if
840+
!method.generics.types.is_empty_in(subst::FnSpace) ||
841+
!method.generics.regions.is_empty_in(subst::FnSpace)
842+
{
843+
let method_types =
844+
self.infcx().next_ty_vars(
845+
method.generics.types.len(subst::FnSpace));
846+
847+
let method_regions =
848+
self.infcx().region_vars_for_defs(
849+
self.span,
850+
method.generics.regions.get_slice(subst::FnSpace));
851+
852+
placeholder = (*substs).clone().with_method(method_types, method_regions);
853+
substs = &placeholder;
854+
}
855+
830856
let xform_self_ty = method.fty.sig.inputs[0].subst(self.tcx(), substs);
831857
self.infcx().replace_late_bound_regions_with_fresh_var(method.fty.sig.binder_id,
832858
self.span,
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright 2012 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+
// Check that we successfully handle methods where the `self` type has
12+
// an early-bound lifetime. Issue #18208.
13+
14+
#![allow(dead_code)]
15+
16+
struct Cursor<'a>;
17+
18+
trait CursorNavigator {
19+
fn init_cursor<'a, 'b:'a>(&'a self, cursor: &mut Cursor<'b>) -> bool;
20+
}
21+
22+
struct SimpleNavigator;
23+
24+
impl CursorNavigator for SimpleNavigator {
25+
fn init_cursor<'a, 'b: 'a>(&'a self, _cursor: &mut Cursor<'b>) -> bool {
26+
false
27+
}
28+
}
29+
30+
fn main() {
31+
let mut c = Cursor;
32+
let n = SimpleNavigator;
33+
n.init_cursor(&mut c);
34+
}

0 commit comments

Comments
 (0)