-
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
Cannot infer const parameter that has a default value #83687
Comments
Default type/const parameters are not taken into consideration during type inference. This is an already known flaw. See a Reddit comment of mine. I think this is a duplicate of #27336 |
Lets take for example this code struct VirtAddr<T = ()>(*const T);
impl<T> VirtAddr<T> {
const fn new(ptr: *const T) -> Self {
Self(ptr)
}
}
fn main() {
let a: VirtAddr = VirtAddr::new(std::ptr::null());
let b: VirtAddr<()> = a;
} Clearly, EDIT: Actually, just leaving |
I guess I will close this issue as this is consistent with other behavior |
That is actually not true. Since the associated function As a result, we have Only if you were to write |
I tried this code:
I expected to see this happen:
Code compiles and
arr
isArray<1>
, because of the default.Instead, this happened:
Meta
rustc --version --verbose
:No backtrace
The text was updated successfully, but these errors were encountered: