Skip to content

Commit 73811ec

Browse files
committed
---
yaml --- r: 234396 b: refs/heads/tmp c: 0e764ec h: refs/heads/master v: v3
1 parent 3772964 commit 73811ec

File tree

2 files changed

+40
-23
lines changed

2 files changed

+40
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: d2e13e822a73e0ea46ae9e21afdd3155fc997f6d
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: 714f2a8921b1e686ae2ba02965fcd3b3e733e4c3
28+
refs/heads/tmp: 0e764ec5ce24be6d6306188673b05f8d9b4f81e5
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: ab792abf1fcc28afbd315426213f6428da25c085
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/librustc/middle/ty.rs

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5191,28 +5191,12 @@ impl<'tcx> TyS<'tcx> {
51915191

51925192
if !adjusted_ty.references_error() {
51935193
for i in 0..adj.autoderefs {
5194-
let method_call = MethodCall::autoderef(expr_id, i as u32);
5195-
match method_type(method_call) {
5196-
Some(method_ty) => {
5197-
// Overloaded deref operators have all late-bound
5198-
// regions fully instantiated and coverge.
5199-
let fn_ret =
5200-
cx.no_late_bound_regions(&method_ty.fn_ret()).unwrap();
5201-
adjusted_ty = fn_ret.unwrap();
5202-
}
5203-
None => {}
5204-
}
5205-
match adjusted_ty.builtin_deref(true, NoPreference) {
5206-
Some(mt) => { adjusted_ty = mt.ty; }
5207-
None => {
5208-
cx.sess.span_bug(
5209-
span,
5210-
&format!("the {}th autoderef failed: {}",
5211-
i,
5212-
adjusted_ty)
5213-
);
5214-
}
5215-
}
5194+
adjusted_ty =
5195+
adjusted_ty.adjust_for_autoderef(cx,
5196+
expr_id,
5197+
span,
5198+
i as u32,
5199+
&mut method_type);
52165200
}
52175201
}
52185202

@@ -5228,6 +5212,39 @@ impl<'tcx> TyS<'tcx> {
52285212
};
52295213
}
52305214

5215+
pub fn adjust_for_autoderef<F>(&'tcx self,
5216+
cx: &ctxt<'tcx>,
5217+
expr_id: ast::NodeId,
5218+
expr_span: Span,
5219+
autoderef: u32, // how many autoderefs so far?
5220+
mut method_type: F)
5221+
-> Ty<'tcx> where
5222+
F: FnMut(MethodCall) -> Option<Ty<'tcx>>,
5223+
{
5224+
let method_call = MethodCall::autoderef(expr_id, autoderef);
5225+
let mut adjusted_ty = self;
5226+
match method_type(method_call) {
5227+
Some(method_ty) => {
5228+
// Method calls always have all late-bound regions
5229+
// fully instantiated.
5230+
let fn_ret = cx.no_late_bound_regions(&method_ty.fn_ret()).unwrap();
5231+
adjusted_ty = fn_ret.unwrap();
5232+
}
5233+
None => {}
5234+
}
5235+
match adjusted_ty.builtin_deref(true, NoPreference) {
5236+
Some(mt) => mt.ty,
5237+
None => {
5238+
cx.sess.span_bug(
5239+
expr_span,
5240+
&format!("the {}th autoderef failed: {}",
5241+
autoderef,
5242+
adjusted_ty)
5243+
);
5244+
}
5245+
}
5246+
}
5247+
52315248
pub fn adjust_for_autoref(&'tcx self, cx: &ctxt<'tcx>,
52325249
autoref: Option<AutoRef<'tcx>>)
52335250
-> Ty<'tcx> {

0 commit comments

Comments
 (0)