Uh oh!
There was an error while loading. Please reload this page.
Implement DerefImm and DerefMut #7141 - #12491
Conversation
eddyb
commented
Feb 23, 2014
But then there's Oh, and how could #12402 happen while I can't seem to call a method on the right trait (if it's not in EDIT: I didn't realize it at first, but |
nikomatsakis
commented
Feb 24, 2014
Is this ready for review? |
eddyb
commented
Feb 26, 2014
Ended up fixing #12402 and removing |
nikomatsakis
commented
Feb 27, 2014
/me will review |
pnkfelix
commented
Feb 27, 2014
@eddyb please put a description into the issue at some point, since bors will not pick up its title when it merges. |
nikomatsakis
commented
Mar 4, 2014
This looks excellent. You're missing a few tests. Here is a patch to apply: https://gist.github.com/nikomatsakis/9348385 r+ once the new tests are applied and nit corrected (and rebased, of course ;) |
nikomatsakis
commented
Mar 4, 2014
Actually, the one other thing I'd like to see: Some new run-pass tests that: (1) do not depend on (2) are targeted at checking that the correct method (deref vs deref_mut) is invoked in the correct times. I'm envisioning a type which either modifies a |
nikomatsakis
commented
Mar 4, 2014
Regarding the existing overloaded operator test, arguably it should be moved to |
nikomatsakis
commented
Mar 4, 2014
Updated my patch with some fns for the compile-fail tests. |
Add the `Deref` and `DerefMut` traits and implement overloading explicit dereferences.
Enables the dereference overloads introduced by #12491 to be applied wherever automatic dereferences would be used (field accesses, method calls and indexing).
fix span calculation for non-ascii in `needless_return` Fixesrust-lang#12491 Probably fixesrust-lang#12328 as well, but that one has no reproducer, so 🤷 The bug was that the lint used `rfind()` for finding the byte index of the start of the previous non-whitespace character: ``` // abc\n return; ^ ``` ... then subtracting one to get the byte index of the actual whitespace (the `\n` here). (Subtracting instead of adding because it treats this as the length from the `return` token to the `\n`) That's correct for ascii, like here, and will get us to the `\n`, however for non ascii, the `c` could be multiple bytes wide, which would put us in the middle of a codepoint if we simply subtract 1 and is what caused the ICE. There's probably a lot of ways we could fix this. This PR changes it to iterate backwards using bytes instead of characters, so that when `rposition()` finally finds a non-whitespace byte, we *know* that we've skipped exactly 1 byte. This was *probably*(?) what the code was intending to do changelog: Fix ICE in [`needless_return`] when previous line end in a non-ascii character
Add the
DerefandDerefMuttraits and implement overloading explicit dereferences.