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

is_instantiable check is broken by nested types #27497

Closed
arielb1 opened this Issue Aug 3, 2015 · 7 comments

Comments

Projects
None yet
4 participants
@arielb1
Copy link
Contributor

arielb1 commented Aug 3, 2015

STR

struct Foo<T>(T, Box<Bar<Bar<Foo<T>>>);
struct Bar<T>(T);

fn main() {
    println!("Hello, world!");
}

Results

Foo is uninhabitable, but the uninhabitability error doesn't trigger. Removing one of the Bar-s does make it trigger. This is rather suprising.

The check was added in the olden days when typeck was much less robust, and can be bypassed very easily by associated types anyway - we may want to remove it.

cc @nikomatsakis

@arielb1 arielb1 added the A-amusing label Aug 3, 2015

@arielb1

This comment has been minimized.

Copy link
Contributor Author

arielb1 commented Aug 3, 2015

is_instantiable is also broken when dealing with empty types - it treats them as instantiable, meaning that struct Foo(Box<Foo>, Void) is allowed.

@eefriedman

This comment has been minimized.

Copy link
Contributor

eefriedman commented Aug 3, 2015

is_instantiable errors are already disabled when the static_recursion feature gate is turned on. I agree that it isn't something we really need to check.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Aug 7, 2015

I'm trying to remember what motivated us to add that check in the first place, but I cannot.

@arielb1

This comment has been minimized.

Copy link
Contributor Author

arielb1 commented Aug 13, 2015

@nikomatsakis

The old type-checker was far less robust then. Can it be removed?

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Aug 15, 2015

@arielb1 seems ok to me, but cc @rust-lang/lang

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Aug 20, 2015

(I'm okay with removing the check, without going through the RFC process.)

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Aug 24, 2015

@arielb1 after discussing in lang subteam meeting, general conclusion was "seems fine to experiment with removing the is_instantiable check and see what happens". I agree it was dubious to start and is more dubious now with associated types etc.

arielb1 pushed a commit to arielb1/rust that referenced this issue Aug 31, 2015

bors added a commit that referenced this issue Sep 1, 2015

Auto merge of #28132 - arielb1:uninstantiable, r=nikomatsakis
It is *very* easy to bypass, and is a relic of a bygone age where the type-checker was *much* less robust.

Fixes #27497

r? @nikomatsakis

bors added a commit that referenced this issue Sep 1, 2015

Auto merge of #28132 - arielb1:uninstantiable, r=nikomatsakis
It is *very* easy to bypass, and is a relic of a bygone age where the type-checker was *much* less robust.

Fixes #27497

r? @nikomatsakis

@bors bors closed this in #28132 Sep 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.