Skip to content

Commit 50a5ce3

Browse files
committed
---
yaml --- r: 159679 b: refs/heads/auto c: e691192 h: refs/heads/master i: 159677: e7d188d 159675: 5012ab3 159671: 0841b23 159663: 126b930 159647: 0828ed5 159615: 0a8b10a v: v3
1 parent def7dad commit 50a5ce3

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
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: f8403aac81d5720bb722a85a9120c14ceb763eb9
13+
refs/heads/auto: e691192042c8505b79e55d7bbb0f3c4ebd2f7992
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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)