On 16/07/2013 19:52, Svetoslav Neykov wrote:

On 15.07.13 23:37, Patrick Walton wrote:

>On 7/14/13 1:04 PM, Svetoslav Neykov wrote:

>> ยท"unsafe" is not a normal block and doesn't return a value, can't be

>> used as an expression. This made it impossible to wrap the unsafe casts

>> from fixed memory locations to borrowed pointers in macros. Instead I

>> had to use inline functions and assign the resulting value to a local

>> function variable.

>

>This should not be the case. There may be a bug in the way macros

>interact with unsafe checking. Do you have a test case by any chance?

Yes, my bad. I double checked, there is no problem using "unsafe" as an expression or wrapping it inside of a macro.

The real problem, turns out, is that the macro can't be used as an expression unless wrapped inside parentheses.

GPIOD!().MODER //doesn't compile (error: unexpected token: `.`)

(GPIOD!()).MODER //OK

Svetoslav.



_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev
Yes I believe this is filed under the following ticket:

" Syntax extensions (and macros) that start a line want to be a whole statement"
  https://github.com/mozilla/rust/issues/5941

(I noted on that bug that we could probably provide a better error message here.)

Cheers,
-Felix

--
irc: pnkfelix on irc.mozilla.org
email: {fklock, pnkfelix}@mozilla.com

_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to