Skip to content

Conversation

@joshlf
Copy link
Member

@joshlf joshlf commented Sep 11, 2023

TODO:

  • Cleaner way to pass name of validator to impl_block?
  • Cleaner way to parse validator attribute?
  • Safety comment in emitted call to validate
  • Tests (especially including tests for the error message resulting from passing a validator with the wrong type signature - test for both argument types and return types)
    • Also test for invalid zerocopy attributes
  • Other misc TODO comments in code

return Ok(None);
};
if let Some(attr) = attrs.next() {
return Err(Error::new_spanned(attr, "multiple attributes are unsupported"));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change this to "multiple zerocopy attributes"

// the compiler is worse at optimizing it?
let validate: fn(&Self) -> bool = Self::#validator;
// SAFETY: TODO
validate(unsafe { candidate.as_ref() })
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember: This must be sound in the face of validate panicking.

@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 5e660a4 to 6f2adbd Compare September 11, 2023 22:28
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from c2db8b1 to 342026f Compare September 11, 2023 22:28
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 6f2adbd to d638597 Compare September 11, 2023 22:52
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 342026f to 7286c44 Compare September 11, 2023 22:52
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from d638597 to bb5a5ae Compare September 11, 2023 23:05
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 7286c44 to bff9a97 Compare September 11, 2023 23:05
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from bb5a5ae to 98942f6 Compare September 11, 2023 23:31
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from bff9a97 to d463caf Compare September 11, 2023 23:31
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 98942f6 to 5b61210 Compare September 12, 2023 00:34
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from d463caf to 90c2aed Compare September 12, 2023 00:34
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 5b61210 to 8e079ad Compare September 12, 2023 00:48
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 90c2aed to 7707fb1 Compare September 12, 2023 00:48
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 8e079ad to 1083475 Compare September 12, 2023 00:48
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 7707fb1 to de82f0e Compare September 12, 2023 00:48
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 1083475 to d838a87 Compare September 12, 2023 01:19
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from de82f0e to 575c570 Compare September 12, 2023 01:19
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from d838a87 to 85d0bcb Compare September 12, 2023 01:40
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 575c570 to ceb1983 Compare September 12, 2023 01:40
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 85d0bcb to c068ed5 Compare September 12, 2023 02:22
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from ceb1983 to 98ca637 Compare September 12, 2023 02:22
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from c068ed5 to f52abdf Compare September 12, 2023 02:48
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 98ca637 to 8eff3b0 Compare September 12, 2023 02:49
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from f52abdf to c816899 Compare September 12, 2023 03:19
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 8eff3b0 to 4004cbe Compare September 12, 2023 03:20
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from c816899 to 9bfd4fa Compare September 12, 2023 03:43
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch 2 times, most recently from 8595f94 to 843e2ee Compare September 12, 2023 06:02
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 9bfd4fa to 38e9af7 Compare September 12, 2023 06:16
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 843e2ee to a46bdc1 Compare September 12, 2023 06:16
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 38e9af7 to ac566bc Compare September 12, 2023 15:41
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from a46bdc1 to e1cd6a7 Compare September 12, 2023 15:41
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from ac566bc to 3bda0f4 Compare September 12, 2023 15:44
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from e1cd6a7 to 55aee47 Compare September 12, 2023 15:44
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 3bda0f4 to 3c385c8 Compare September 12, 2023 16:47
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 55aee47 to e250332 Compare September 12, 2023 16:47
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 3c385c8 to a093d6f Compare September 19, 2023 02:05
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from e250332 to aeea5f2 Compare September 19, 2023 02:05
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from a093d6f to f262f98 Compare September 19, 2023 16:31
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from aeea5f2 to 5c45ea8 Compare September 19, 2023 16:32
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from f262f98 to 6de1129 Compare September 19, 2023 16:43
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 5c45ea8 to 3271ca4 Compare September 19, 2023 16:43
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 6de1129 to d19a443 Compare September 19, 2023 18:46
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 3271ca4 to 5737178 Compare September 19, 2023 18:46
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from d19a443 to 3dd3531 Compare September 19, 2023 18:57
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 5737178 to 1439d4b Compare September 19, 2023 18:57
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 3dd3531 to 77ef559 Compare September 19, 2023 22:33
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from 1439d4b to fe3118f Compare September 19, 2023 22:33
TODO:
- Cleaner way to pass name of validator to `impl_block`?
- Cleaner way to parse validator attribute?
- Safety comment in emitted call to `validate`
- Tests (especially including tests for the error message resulting from
  passing a validator with the wrong type signature - test for both
  argument types and return types)
  - Also test for invalid zerocopy attributes
  - Also test for hygiene - that the validator can't access variables
    from the `is_bit_valid` function body scope
- Other misc TODO comments in code
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive branch from 77ef559 to 9e01587 Compare October 12, 2023 21:41
@joshlf joshlf force-pushed the try-from-bytes-raw-argument-to-is-bit-valid--derive-validator branch from fe3118f to 1f8ff06 Compare October 12, 2023 21:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant