Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 48b2bbd

Browse filesBrowse files
Structurally resolve before matching on type of projection
1 parent f2abf82 commit 48b2bbd
Copy full SHA for 48b2bbd

File tree

Expand file treeCollapse file tree

2 files changed

+27
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+27
-2
lines changed

‎compiler/rustc_hir_typeck/src/upvar.rs

Copy file name to clipboardExpand all lines: compiler/rustc_hir_typeck/src/upvar.rs
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,7 +1802,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18021802
let mut is_mutbl = bm.1;
18031803

18041804
for pointer_ty in place.deref_tys() {
1805-
match pointer_ty.kind() {
1805+
match self.structurally_resolve_type(self.tcx.hir().span(var_hir_id), pointer_ty).kind()
1806+
{
18061807
// We don't capture derefs of raw ptrs
18071808
ty::RawPtr(_, _) => unreachable!(),
18081809

@@ -1816,7 +1817,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18161817
// Dereferencing a box doesn't change mutability
18171818
ty::Adt(def, ..) if def.is_box() => {}
18181819

1819-
unexpected_ty => bug!("deref of unexpected pointer type {:?}", unexpected_ty),
1820+
unexpected_ty => span_bug!(
1821+
self.tcx.hir().span(var_hir_id),
1822+
"deref of unexpected pointer type {:?}",
1823+
unexpected_ty
1824+
),
18201825
}
18211826
}
18221827

+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ check-pass
2+
//@ compile-flags: -Znext-solver
3+
4+
trait Mirror {
5+
type Assoc;
6+
}
7+
impl<T> Mirror for T {
8+
type Assoc = T;
9+
}
10+
11+
struct Place {
12+
field: <&'static [u8] as Mirror>::Assoc,
13+
}
14+
15+
fn main() {
16+
let local = Place { field: &[] };
17+
let z = || {
18+
let y = &local.field[0];
19+
};
20+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.