-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Default type parameters are not used in type inference #99727
Labels
A-inference
Area: Type inference
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Comments
agluszak
changed the title
Cannot infer the default type for type parameter
Cannot infer the default type for type parameter in a struct
Jul 25, 2022
agluszak
changed the title
Cannot infer the default type for type parameter in a struct
Default type parameters are not used in type inference
Jul 25, 2022
This is expected behavior #27336 The suggestion reads correctly to me, but is definitely a general one. Do you expect it to suggest the default type or something else? |
yodaldevoid
added a commit
to yodaldevoid/embassy
that referenced
this issue
Dec 9, 2022
It would be nice if a default value could be used so old code would mostly just work, but defaults are not used while determining types so adding a default does nothing here. It would also be nice if we could calculate the number of interfaces needed at compile time, but I'll leave that as an exercise for later. rust-lang/rust#95486 rust-lang/rust#99727 rust-lang/rust#27336
yodaldevoid
added a commit
to yodaldevoid/embassy
that referenced
this issue
Dec 9, 2022
It would be nice if a default value could be used so old code would mostly just work, but defaults are not used while determining types so adding a default does nothing here. It would also be nice if we could calculate the number of interfaces needed at compile time, but I'll leave that as an exercise for later. rust-lang/rust#95486 rust-lang/rust#99727 rust-lang/rust#27336
yodaldevoid
added a commit
to yodaldevoid/embassy
that referenced
this issue
Dec 9, 2022
It would be nice if a default value could be used so old code would mostly just work, but defaults are not used while determining types so adding a default does nothing here. It would also be nice if we could calculate the number of interfaces needed at compile time, but I'll leave that as an exercise for later. rust-lang/rust#95486 rust-lang/rust#99727 rust-lang/rust#27336
yodaldevoid
added a commit
to yodaldevoid/embassy
that referenced
this issue
Dec 9, 2022
It would be nice if a default value could be used so old code would mostly just work, but defaults are not used while determining types so adding a default does nothing here. It would also be nice if we could calculate the number of interfaces needed at compile time, but I'll leave that as an exercise for later. rust-lang/rust#95486 rust-lang/rust#99727 rust-lang/rust#27336
yodaldevoid
added a commit
to yodaldevoid/embassy
that referenced
this issue
Dec 9, 2022
It would be nice if a default value could be used so old code would mostly just work, but defaults are not used while determining types so adding a default does nothing here. It would also be nice if we could calculate the number of interfaces needed at compile time, but I'll leave that as an exercise for later. rust-lang/rust#95486 rust-lang/rust#99727 rust-lang/rust#27336
yodaldevoid
added a commit
to yodaldevoid/embassy
that referenced
this issue
Dec 14, 2022
It would be nice if a default value could be used so old code would mostly just work, but defaults are not used while determining types so adding a default does nothing here. It would also be nice if we could calculate the number of interfaces needed at compile time, but I'll leave that as an exercise for later. rust-lang/rust#95486 rust-lang/rust#99727 rust-lang/rust#27336
@agluszak can this be closed? Or do you think the error message should be improved to talk about associated type defaults and leave it open? |
fmease
added
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
A-inference
Area: Type inference
labels
Jan 25, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-inference
Area: Type inference
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code:
I expected
_boxy_err
to compile (i.e. that the compiler would use the default type during inference, as it does with_boxy_ok3
).Instead, this happened:
In the best case, this is working as intended (but that's unintuitive) and the suggestion is wrong ("where the type for type parameter
T
is specified"). But maybe that's a bug in the compiler.If it's a bug, I can try to fix it if I get some guidance.
Meta
rustc --version --verbose
:cargo +nightly rustc -- --version --verbose
:Setting the backtrace doesn't change anything in the output
The text was updated successfully, but these errors were encountered: