Should type errors display type synonyms where applicable?

Code: http://is.gd/D5ASNr

This piece of code exports a public type synonym Interface but hides some internal types within the module (namely Internal and Adaptor). Tryping to export either in a function’s signature is an error, as expected, while exporting the public type synonym Interface is perfectly valid. This is good news for everyone, as that means Rust properly supports abstract types.

However, this currently produces an error that contains the line: "found a::Adaptor<a::Internal>". Neither of these types would be in the documentation for the a module, so why should the type errors display it, either? Is this a bug? I don’t think resorting to newtypes is necessarily the appropriate solution in this case because the pub Synonym = PrivateInternalType pattern is currently a valid one, and I like it a lot (it reminds me of ML).

Yes, this is a bug, but it is quite hard to fix.

https://github.com/rust-lang/rust/issues/25694

I tried googling “type synonym bug Rust” but didn’t find this. Thanks for sharing :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.