Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #328
Part of #328
Synopsis
This is an alternative solution to the double reference problem reported in #328.
Solution
Instead of dereferencing macro-generated bindings such as
_0
at the use sites, do the the following:In binding generation, generate
let _0 = self.0
instead oflet _0 = &self.0
in case the fieldself.0
is already a reference type.In body generation, add
&
before#ident
in the callderive_more::core::fmt::#trait_ident::fmt(#ident, __derive_more_f)
, because the functionfmt
dereferences.In bounds generation, strip
&
in the bounded type for traits other thanPointer
because thefmt
function of those traits dereferences exhaustively.Open questions
All previous test function names are
assert
. The tests added in this PR have distinct names so that they can be executed alone viacargo test <substring-of-test-function-name>
. Is there a reason for the naming conventionassert
? If so I'd rename the new tests.Are the improvements to tests in Fix incorrect
fmt::Pointer
implementations #328 important? I can incorporate them if needed.Are there any breaking changes? I'm not 100% sure.
Checklist