Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't assert for different instance on impl trait alias #65753

Merged
merged 1 commit into from
Oct 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2761,8 +2761,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
Expand Down
Original file line number Diff line number Diff line change
@@ -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(|| {});
}