Rollup merge of #65753 - csmoe:derive_fold, r=Centril

Don't assert for different instance on impl trait alias

Closes https://github.com/rust-lang/rust/issues/65679
r? @Centril @nikomatsakis
This commit is contained in:
Mazdak Farrokhzad 2019-10-24 20:20:07 +02:00 committed by GitHub
commit 1b0367146a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View file

@ -2767,8 +2767,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut opaque_types = self.opaque_types.borrow_mut();
for (ty, decl) in opaque_type_map {
let old_value = opaque_types.insert(ty, decl);
assert!(old_value.is_none(), "instantiated twice: {:?}/{:?}", ty, decl);
let _ = opaque_types.insert(ty, decl);
}
value

View file

@ -0,0 +1,17 @@
// check-pass
#![feature(type_alias_impl_trait)]
type T = impl Sized;
// The concrete type referred by impl-trait-type-alias(`T`) is guaranteed
// to be the same as where it occurs, whereas `impl Trait`'s instance is location sensitive;
// so difference assertion should not be declared on impl-trait-type-alias's instances.
// for details, check RFC-2515:
// https://github.com/rust-lang/rfcs/blob/master/text/2515-type_alias_impl_trait.md
fn take(_: fn() -> T) {}
fn main() {
take(|| {});
take(|| {});
}