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

Warn for type parameter defaults on `impl` blocks #31543

Closed
bluss opened this Issue Feb 10, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@bluss
Copy link
Contributor

bluss commented Feb 10, 2016

If I understand correctly, type parameter defaults have no effect in the block impl<T = default> Foo<T> { }.

Just like in PR #30724, this should have a warning and then an error.

Example (playground)

use std::marker::PhantomData;

struct Foo<T> {
    x: PhantomData<T>,
}

impl<T = i32> Foo<T> {
    pub fn new() -> Self {
        Foo { x: PhantomData }
    }
}

fn main() {
    let x = Foo::new();  // error: unable to infer enough type information about `_`
}

cc @nikomatsakis

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Mar 15, 2016

Argh, I guess I failed to cover those?

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Mar 15, 2016

Nominating for triage.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Mar 17, 2016

triage: P-high

@nikomatsakis nikomatsakis self-assigned this Mar 17, 2016

@rust-highfive rust-highfive added P-high and removed I-nominated labels Mar 17, 2016

bors added a commit that referenced this issue Apr 13, 2016

Auto merge of #32817 - jseyfried:warn_impl_param_defaults, r=nikomats…
…akis

Warn for type parameter defaults on impl blocks

Warn for type parameter defaults on impl blocks (fixes #31543).
r? @nikomatsakis

@bors bors closed this in #32817 Apr 13, 2016

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.