-
Notifications
You must be signed in to change notification settings - Fork 225
Build error 'identifier appears more than once in list' after update to rust 1.50 #459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, What version of RTIC are you using? Could you provide a minimal reproducible example as well? |
I an using 0.5.6. I will try to reproduce this error with a minimal example. |
Thanks! |
|
|
Hi, from what I can see this is not an error from RTIC, but the macro. I have no idea how this framework of yours works unfortunately. The error originates from |
I have not found an error in the macro.
|
At rust 1.46 this works well. What could have changed in rust >1.46? |
Just to clarify, with
Tried the versions with a question mark?, could be helpful for narrowing down which version introduce a change causing breakage for you. Just speculation, could it be the two stage macro execution somehow having changed? First your macro and then RTIC-macro would be the expected order. |
Rust 1.46: Works |
The error message originates from here or here. Looking at the code it is unhappy about having multiple identical identifiers, however it is unclear if it is resources or "ident" (line 158 or line 140) since the error message is identical. Unfamiliar with your framework, do you think there's some name collision or such? This is what I get when running it with macro-backtrace:
|
I think this is not a resource name collision. Because cargo expand gives a working code. To expand the code without 4c4
< #[rtic::app(
---
> #[xrtic::app( This is what I get when running it with cargo expand: rasaro rtic-platform $ cargo +nightly expand --example "usart-drv"
Checking cortex-m-rtic-platform v0.1.0 (/home/rasaro/Development/sandbox/tmp/rtic-platform)
... some build errors ...
... some prelude ...
pub mod uart0_drv {
use crate::board::hal;
use crate::board::device;
use ::cortex_m_rtic_platform::driver::usart as usart_drv;
pub type Device = device::UART0;
pub type HwResource = hal::usart::Usart<Device>;
pub use usart_drv::rtic_task_handler;
pub use usart_drv::rtic_irq_handler;
pub type TaskResources = usart_drv::TaskResources;
pub type IrqResources = usart_drv::IrqResources;
}
# [ xrtic :: app ( device = crate :: board :: device , peripherals = true , monotonic = :: cortex_m_rtic_platform :: rtic_time :: MonotonicTimer ) ]
const APP: () = {
struct Resources {
usart_drv_counter: i8,
uart0_drv_rsx: uart0_drv::IrqResources,
uart0_drv_rst: uart0_drv::TaskResources,
}
# [ init ( spawn = [ usart_test_task , uart0_drv_task ] ) ]
fn rtic_init(cx: rtic_init::Context) -> rtic_init::LateResources {
#[allow(unused_variables)]
let hw_resources = hw_init(cx.core, cx.device);
if 15 != 2_u8.pow(crate::board::device::NVIC_PRIO_BITS.into()) - 1 {
::core::panicking::panic("SYSTEM TIMER: priority is not max");
}
#[allow(unused_mut)]
let (uart0_drv_rsx, uart0_drv_rst) = {
let uart0_drv_rst = uart0_drv::TaskResources {};
(uart0_drv::IrqResources {}, uart0_drv_rst)
};
cx.spawn.usart_test_task().unwrap();
cx.spawn.uart0_drv_task().unwrap();
rtic_init::LateResources {
usart_drv_counter: 0,
uart0_drv_rsx,
uart0_drv_rst,
}
}
# [ task ( resources = [ uart0_drv_rst , usart_drv_counter , ] , priority = 2 , capacity = 16 , spawn = [ uart0_drv_task ] , ) ]
#[allow(unused_mut)]
fn uart0_drv_task(mut cx: uart0_drv_task::Context) {
let rs = cx.resources.uart0_drv_rst;
match cx.resources.usart_drv_counter.checked_add(1) {
Some(count) => {
*cx.resources.usart_drv_counter = count;
}
None => {
*cx.resources.usart_drv_counter = -1;
}
}
uart0_drv::rtic_task_handler(rs);
}
# [ task ( binds = UART0 , resources = [ uart0_drv_rsx ] , spawn = [ uart0_drv_task ] , priority = 4 , ) ]
#[allow(unused_mut)]
fn uart0_irq(cx: uart0_irq::Context) {
let spawn = cx.spawn;
spawn.uart0_drv_task().unwrap();
}
# [ task ( priority = 1 , spawn = [ uart0_drv_task ] , schedule = [ usart_test_task ] , resources = [ usart_drv_counter ] , ) ]
#[allow(unused_mut)]
fn usart_test_task(mut cx: usart_test_task::Context) {
cx.spawn.uart0_drv_task().unwrap();
if cx.resources.usart_drv_counter.lock(|x| *x != -1) {}
}
extern "C" {
fn TIMER_0A();
fn TIMER_0B();
}
}; If you insert this code instead of rtiс_app! {...}, then it will work with routine improvements |
Any difference when testing with latest Rust and RTIC RC? |
@AfoHT Trying use latest Rust and RTIC 0.6-rc.2 but got errors
|
The field |
@AfoHT Thanks! https://github.com/rtic-rs/cortex-m-rtic/tags |
Nice catch! We've forgotten to push tags, will fix that ASAP. Other alternatives would be to use the releases via cargo, or latest master like you said. |
Even better than a tag! I didn't even think that the RC might be in the cargo version. |
@andrey-shigantsov Any luck with the latest release? :) |
I've been very busy at work lately and can't find time to finish... |
I get a similar error with RTIC RC.
|
Hello, I recall from the previous discussion it works flawlessly with 1.46 but anything later than that is broken. With that in mind I think the way to solve this is to modify your macro-transformation code to adopt or handle the underlying change by the compiler. Did you attempt this approach? |
Hi) I realized that the approach I had chosen was not the right one here. My macro is too difficult to maintain, and the resulting code cannot be debugged with a debugger. In the future, I plan to switch to code generation, so this issue can be closed. |
It is not easy, debugging macros running on output generated by macros... not for the feint of heart 😅 I will close this issue then, hopefully code generation will be an easier approach 😃 |
Hi.
I get this error when I use my macro to generate the
rtic::app
structure.If I expand the code of my macro only with cargo expand and compile it, it works on rust v 1.50 too.
Rolling back to rust v 1.46 has solved this problem for me.
But I want use latest rust.
The text was updated successfully, but these errors were encountered: