Closed
Description
Code
fn atticus_megatron<T>(xs: &mut [T]) -> usize
where
T: Copy + Eq,
{
if xs.len > 2 {}
0
}
Current output
error[E0615]: attempted to take value of method `len` on type `&mut [T]`
--> lib.rs:294:11
|
294 | if xs.len > 2 {}
| ^^^ method, not a field
|
help: use parentheses to call the method
|
294 | if xs.len() > 2 {}
| ++
error[E0308]: mismatched types
--> lib.rs:294:17
|
290 | fn atticus_megatron<T>(xs: &mut [T]) -> usize
| - expected this type parameter
...
294 | if xs.len > 2 {}
| ^ expected type parameter `T`, found integer
|
= note: expected type parameter `T`
found type `{integer}`
Desired output
Second error message is wrong, rustc doesn't expect `T` and if you pass `T` - it won't work. Skip it?
Rationale and extra context
No response
Other cases
No response
Rust Version
rustc 1.76.0 (07dca489a 2024-02-04)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: x86_64-unknown-linux-gnu
release: 1.76.0
LLVM version: 17.0.6
or most recent nightly as of today
Anything else?
No response