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

'do' and 'for' cannot instantiate polymorphic functions at requisite closure type #3203

Closed
bblum opened this issue Aug 15, 2012 · 3 comments
Closed
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) A-type-system Area: Type system

Comments

@bblum
Copy link
Contributor

bblum commented Aug 15, 2012

This compiles:

fn not<T>(_x: T) { }

fn main() {
    not(|| { error!("Hello world"); })
}

This does not (or should I say, it does not do not):

fn not<T>(_x: T) { }

fn main() {
    do not { error!("Hello world"); }
}

I am not sure it ever makes sense to have to do this instantiation except in this particular corner case, so feel free to wontfix this.

@pcwalton
Copy link
Contributor

I don't think this is a backwards compatibility issue. Renominating.

@graydon
Copy link
Contributor

graydon commented Jun 13, 2013

closing WONTFIX, do notation doesn't need to work here

@graydon graydon closed this as completed Jun 13, 2013
@bblum
Copy link
Contributor Author

bblum commented Jun 13, 2013

but wouldn't it be nice (more consistent) if it could?

It is conceivable that this could be more than the trivial program I posted above:

trait Hello { fn hello(self); }
impl Hello for &fn() {
    fn hello(self) { self(); }
}
fn hello<T: Hello>(x: T) {
    x.hello();
}
fn main() {
    do hello { error!("Hello world"); }
}

I'd say far-future milestone.

RalfJung pushed a commit to RalfJung/rust that referenced this issue Dec 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-frontend Area: Compiler frontend (errors, parsing and HIR) A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

3 participants