Closed
Description
I have the following code:
impl<H> AddrVec<H, DeviceId> {
pub fn device(&self) -> DeviceId {
self.tail()
}
}
I forgot to use DeviceId
, so it wasn't in scope. rustc gave me the following errors:
error[E0412]: cannot find type `DeviceId` in this scope
--> src/address.rs:343:20
|
343 | impl<H> AddrVec<H, DeviceId> {
| ^^^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
5 | use crate::device::DeviceId;
|
error[E0412]: cannot find type `DeviceId` in this scope
--> src/address.rs:344:29
|
344 | pub fn device(&self) -> DeviceId {
| ^^^^^^^^ not found in this scope
help: possible candidate is found in another module, you can import it into scope
|
5 | use crate::device::DeviceId;
|
error[E0307]: invalid method receiver type: &address::AddrVec<H, [type error]>
--> src/address.rs:344:19
|
344 | pub fn device(&self) -> DeviceId {
| ^^^^^
|
= note: type must be `Self` or a type that dereferences to it
= help: consider changing to `self`, `&self`, `&mut self`, or `self: Box<Self>`
Maybe this is the intended behavior, but it seems odd to report an invalid method receiver type error simply because the type's name was unknown.