-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed as duplicate of#24066
Closed as duplicate of#24066
Copy link
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.E-needs-investigationCall for partcipation: This issues needs some investigation to determine current statusCall for partcipation: This issues needs some investigation to determine current statusT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)The Rustc Trait System Refactor Initiative (-Znext-solver)
Description
I tried this code:
use rust_decimal::{
// The important thing about this type is that you can do Decimal::from(1).
Decimal,
};
fn this_is_not_generic() {
Decimal::from(1); // This is accepted.
}
fn this_is_indeed_generic<Inp>(inp: Inp)
where
// All I am saying here is that you can convert from Inp to Decimal.
// I am NOT saying that ONLY Inp can be converted to Decimal.
Decimal: From<Inp>
{
Decimal::from(1); // This is rejected. WTF?
}
I expected to see this happen: My code is accepted.
Instead, this happened: My code is rejected. More precisely,
error[E0308]: mismatched types
--> src/lib.rs:16:19
|
10 | fn this_is_indeed_generic<Inp>(inp: Inp)
| --- expected this type parameter
...
16 | Decimal::from(1); // This is rejected. WTF?
| ------------- ^ expected type parameter `Inp`, found integer
| |
| arguments to this function are incorrect
|
= note: expected type parameter `Inp`
found type `{integer}`
note: associated function defined here
--> /rustc/051478957371ee0084a7c0913941d2a8c4757bb9/library/core/src/convert/mod.rs:585:8
For more information about this error, try `rustc --explain E0308`.
error: could not compile `repro` (lib) due to 1 previous error
Meta
$ rustc --version --verbose
rustc 1.80.0 (051478957 2024-07-21)
binary: rustc
commit-hash: 051478957371ee0084a7c0913941d2a8c4757bb9
commit-date: 2024-07-21
host: aarch64-apple-darwin
release: 1.80.0
LLVM version: 18.1.7
Behavior on +nightly
:
error[E0308]: mismatched types
--> src/lib.rs:16:19
|
10 | fn this_is_indeed_generic<Inp>(inp: Inp)
| --- expected this type parameter
...
16 | Decimal::from(1); // This is rejected. WTF?
| ------------- ^ expected type parameter `Inp`, found integer
| |
| arguments to this function are incorrect
|
= note: expected type parameter `Inp`
found type `{integer}`
note: associated function defined here
--> /rustc/52fd9983996d9fcfb719749838336be66dee68f9/library/core/src/convert/mod.rs:585:8
For more information about this error, try `rustc --explain E0308`.
error: could not compile `repro` (lib) due to 1 previous error
Metadata
Metadata
Assignees
Labels
A-trait-systemArea: Trait systemArea: Trait systemC-bugCategory: This is a bug.Category: This is a bug.E-needs-investigationCall for partcipation: This issues needs some investigation to determine current statusCall for partcipation: This issues needs some investigation to determine current statusT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.WG-trait-system-refactorThe Rustc Trait System Refactor Initiative (-Znext-solver)The Rustc Trait System Refactor Initiative (-Znext-solver)