Skip to content

Commit 184a61f

Browse files
committed
Don't assert for different instance on impl trait alias
1 parent 4a8c5b2 commit 184a61f

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/librustc_typeck/check/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2761,8 +2761,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
27612761

27622762
let mut opaque_types = self.opaque_types.borrow_mut();
27632763
for (ty, decl) in opaque_type_map {
2764-
let old_value = opaque_types.insert(ty, decl);
2765-
assert!(old_value.is_none(), "instantiated twice: {:?}/{:?}", ty, decl);
2764+
let _ = opaque_types.insert(ty, decl);
27662765
}
27672766

27682767
value
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// check-pass
2+
3+
#![feature(type_alias_impl_trait)]
4+
5+
type T = impl Sized;
6+
// The concrete type referred by impl-trait-type-alias(`T`) is guaranteed
7+
// to be the same as where it occurs, whereas `impl Trait`'s instance is location sensitive;
8+
// so difference assertion should not be declared on impl-trait-type-alias's instances.
9+
// for details, check RFC-2515:
10+
// https://github.com/rust-lang/rfcs/blob/master/text/2515-type_alias_impl_trait.md
11+
12+
fn take(_: fn() -> T) {}
13+
14+
fn main() {
15+
take(|| {});
16+
take(|| {});
17+
}

0 commit comments

Comments
 (0)