You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
struct Foo { x: int }
impl io::Reader for Foo {
fn read(&self, _bytes: &mut [u8], _len: uint) -> uint { fail!() }
fn read_byte(&self) -> int { fail!() }
fn eof(&self) -> bool { fail!() }
fn seek(&self, _position: int, _style: io::SeekStyle) { fail!() }
fn tell(&self) -> uint { fail!() }
}
impl Foo {
fn bar(&mut self) {
self.read_be_u32(); // read_be_u32 is defined by io::ReaderUtil, which is defined for all <T: io::Reader>
}
}
fn main() {}
rustc fails with this error:
test-impl-for-t.rs:15:12: 15:31 error: failed to find an implementation of trait core::io::Reader for &mut Foo
test-impl-for-t.rs:15 self.read_be_u32();
^~~~~~~~~~~~~~~~~~~
I don't think that rustc should have a problem with this code.
Note that this error seems to be related to &mut pointers and immutable borrows, because if the bar function is changed to the following then rustc is happy:
let iself: &Foo = self;
iself.read_be_u32();
The text was updated successfully, but these errors were encountered:
More proc-macro detection
fixesrust-lang#6514fixesrust-lang#8683fixesrust-lang#6858fixesrust-lang#6594
This is a more general way of checking if an expression comes from a macro and could be trivially applied to other lints. Ideally this would be fixed in rustc's proc-macro api, but I don't see that happening any time soon.
changelog: FPs: [`unit_arg`] [`default_trait_access`] [`missing_docs_in_private_items`]: No longer trigger in code generated from proc-macros.
This code doesn't compile:
rustc fails with this error:
I don't think that rustc should have a problem with this code.
Note that this error seems to be related to
&mut
pointers and immutable borrows, because if the bar function is changed to the following then rustc is happy:The text was updated successfully, but these errors were encountered: