Skip to content

Commit d049942

Browse files
committed
---
yaml --- r: 231814 b: refs/heads/auto c: 0e764ec h: refs/heads/master v: v3
1 parent 1c7a71b commit d049942

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
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 714f2a8921b1e686ae2ba02965fcd3b3e733e4c3
11+
refs/heads/auto: 0e764ec5ce24be6d6306188673b05f8d9b4f81e5
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

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