Skip to content
This repository has been archived by the owner on Jul 6, 2019. It is now read-only.

ioregs: field enumerations does not work. #146

Closed
dpc opened this issue Aug 28, 2014 · 15 comments
Closed

ioregs: field enumerations does not work. #146

dpc opened this issue Aug 28, 2014 · 15 comments

Comments

@dpc
Copy link
Contributor

dpc commented Aug 28, 2014

I'm trying to get this to work:

dpc@2b537ce#diff-76fb405a406228f49ec4fac481c36bf4R46

but it produces compiler errors that make no sense.

@bharrisau
Copy link
Contributor

Can you post the errors?

Or can you just make up that PR for the watchdog and we can look at the whole thing.

@bgamari
Copy link
Contributor

bgamari commented Aug 28, 2014

@dpc seems like this will need a rebase.

@bgamari
Copy link
Contributor

bgamari commented Aug 28, 2014

Meh, never mind; that was trivial enough.

@bgamari
Copy link
Contributor

bgamari commented Aug 28, 2014

@dpc oh dear. It seems rustc has a distaste for similarly named variants. The following example demonstrates the issue,

enum Hi1 {Seq1 = 1}
enum Hi2 {Seq1 = 1}

which fails quite similarly,

test.rs:2:11: 2:19 error: duplicate definition of value `Seq1`
test.rs:2 enum Hi2 {Seq1 = 1}
                    ^~~~~~~~
test.rs:1:11: 1:19 note: first definition of value `Seq1` here
test.rs:1 enum Hi1 {Seq1 = 1}
                    ^~~~~~~~

This is quite unfortunate.

@bgamari
Copy link
Contributor

bgamari commented Aug 28, 2014

For now I suspect the only solution is to ensure that enum variants have unique names. This could be rather unfortunate moving forward though. Ideally I'd like to leverage namespacing a bit better in ioregs! to ensure things like this don't happen (and clean up the documentation a bit), although this isn't possible at the moment.

@bgamari
Copy link
Contributor

bgamari commented Aug 28, 2014

@dpc, I've pushed a compiling variant of your example here. Note that I had to mark std from the zinc crate as pub since app_blink_k20 is outside of this crate.

bgamari added a commit to bgamari/zinc that referenced this issue Aug 28, 2014
As demonstrated in hackndev#146 this is sometimes useful even outside of the
`zinc` crate.
@dpc
Copy link
Contributor Author

dpc commented Aug 28, 2014

The problem with colliding names is something else. (but would be nice if these could have namespaces too). I've introduced it before pushing, silly me. After renaming you will get:

rake PLATFORM=k20 build_all
rustc --opt-level 2 -Z no-landing-pads --cfg mcu_k20 --cfg arch_cortex_m4 --target thumbv7em-linux-eabi -Ctarget-cpu=cortex-m4 -C relocation_model=static  -Z lto  --emit obj  -L /home/dpc/lab/rust/zinc/build  -o /home/dpc/lab/rust/zinc/build/intermediate/blink_k20/app_blink_k20.o  /home/dpc/lab/rust/zinc/apps/app_blink_k20.rs 
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1:1: 1:4 error: failed to resolve. Maybe a missing `extern crate std`?
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1 // vim: sw=2
                                                ^~~
note: in expansion of #[deriving]
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1:1: 1:1 note: expansion site
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:2:1: 156:1 note: in expansion of ioregs!
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:38:3: 61:5 note: expansion site
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1:1: 1:1 error: attempt to implement a nonexistent trait `std::num::FromPrimitive`
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1 // vim: sw=2
                                                ^
note: in expansion of #[deriving]
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1:1: 1:1 note: expansion site
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:2:1: 156:1 note: in expansion of ioregs!
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:38:3: 61:5 note: expansion site
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1:1: 1:4 error: failed to resolve. Maybe a missing `extern crate std`?
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1 // vim: sw=2
                                                ^~~
note: in expansion of #[deriving]
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1:1: 1:1 note: expansion site
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:2:1: 156:1 note: in expansion of ioregs!
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:38:3: 61:5 note: expansion site
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1:1: 1:1 error: use of undeclared type name `std::option::Option`
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1 // vim: sw=2
                                                ^
note: in expansion of #[deriving]
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1:1: 1:1 note: expansion site
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:2:1: 156:1 note: in expansion of ioregs!
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:38:3: 61:5 note: expansion site
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:48:30: 49:2 error: failed to resolve. Maybe a missing `extern crate std`?
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:48         0xa602 => RefreshSeq1,
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:49         0xb480 => RefreshSeq2,
note: in expansion of #[deriving]
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:1:1: 1:1 note: expansion site
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:2:1: 156:1 note: in expansion of ioregs!
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:38:3: 61:5 note: expansion site
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:48:30: 48:15 error: unresolved name `std::option::Some`.
/home/dpc/lab/rust/zinc/apps/app_blink_k20.rs:48         0xa602 => RefreshSeq1,
[compier hangs herel; memory consumption increases constantly]

@dpc
Copy link
Contributor Author

dpc commented Aug 28, 2014

@bgamari: I've reproduced your changes and this works for me now. Thanks. It is weird what is going on here, especially the part of compiler hanging and making system swap insanely after a while.

@bgamari
Copy link
Contributor

bgamari commented Aug 28, 2014

@dpc Odd indeed. I saw similar behavior around a month ago when the documentation lint would start spewing lots of allocations. That doesn't seem to be what's happening here though.

@bgamari
Copy link
Contributor

bgamari commented Aug 28, 2014

@dpc are you comfortable closing this or do you suspect this issue still lurks?

@dpc
Copy link
Contributor Author

dpc commented Aug 28, 2014

It seems to me this compiler hang is still there in the erroneous situation
when std::option::Option is not available. I'm not sure if such behavior is
acceptable.

On Thu, Aug 28, 2014 at 3:40 AM, Ben Gamari notifications@github.com
wrote:

@dpc https://github.com/dpc are you comfortable closing this or do you
suspect this issue still lurks?


Reply to this email directly or view it on GitHub
#146 (comment).

Dawid Ciężarkiewicz

@bgamari
Copy link
Contributor

bgamari commented Aug 28, 2014

@dpc Do you think you could try to come up with a minimal reproduction case? It might be good to bring this upstream.

@dpc
Copy link
Contributor Author

dpc commented Aug 28, 2014

I will try.

On Thu, Aug 28, 2014 at 12:00 PM, Ben Gamari notifications@github.com
wrote:

@dpc https://github.com/dpc Do you think you could try to come up with
a minimal reproduction case? It might be good to bring this upstream.


Reply to this email directly or view it on GitHub
#146 (comment).

Dawid Ciężarkiewicz

@bgamari
Copy link
Contributor

bgamari commented Oct 5, 2014

Any progress on this?

@bgamari
Copy link
Contributor

bgamari commented Nov 24, 2014

I'm going to close this for now. Let me know if you can produce a test case.

@bgamari bgamari closed this as completed Nov 24, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants