Skip to content

Commit 1b03671

Browse files
authored
Rollup merge of #65753 - csmoe:derive_fold, r=Centril
Don't assert for different instance on impl trait alias Closes #65679 r? @Centril @nikomatsakis
2 parents 1e4a2ee + 184a61f commit 1b03671

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
@@ -2767,8 +2767,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
27672767

27682768
let mut opaque_types = self.opaque_types.borrow_mut();
27692769
for (ty, decl) in opaque_type_map {
2770-
let old_value = opaque_types.insert(ty, decl);
2771-
assert!(old_value.is_none(), "instantiated twice: {:?}/{:?}", ty, decl);
2770+
let _ = opaque_types.insert(ty, decl);
27722771
}
27732772

27742773
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)