Skip to content
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

Rust-analyzer not respecting default target #8430

Closed
luciusmagn opened this issue Apr 8, 2021 · 0 comments · Fixed by #8774
Closed

Rust-analyzer not respecting default target #8430

luciusmagn opened this issue Apr 8, 2021 · 0 comments · Fixed by #8774
Labels
S-actionable Someone could pick this issue up and work on it right now

Comments

@luciusmagn
Copy link

luciusmagn commented Apr 8, 2021

Hi, I ran into an issue where types where wrongly ellided and I think I managed to narrow it down to rust-analyzer.

I am running this code:

extern crate libc;
extern crate rayon;

use libc::{clock_gettime, timespec, CLOCK_MONOTONIC};
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use rayon::prelude::*;

fn main() {
    (0..3000000).into_par_iter().for_each(|_| {
        thread_local! {
            static THREAD_NAME: String = thread_rng()
                .sample_iter(&Alphanumeric)
                .take(30)
                .map(char::from)
                .collect();
        }
        let name = THREAD_NAME.with(|x| x.clone());

        for _ in 0..3000 {
            let mut ts1 = timespec {
                tv_sec: 0,
                tv_nsec: 0,
            };
            let mut ts2 = timespec {
                tv_sec: 0,
                tv_nsec: 0,
            };

            let res1 = unsafe { clock_gettime(CLOCK_MONOTONIC, &mut ts1) };
            let res2 = unsafe { clock_gettime(CLOCK_MONOTONIC, &mut ts2) };
            let (secs_start, nsecs_start) = (ts1.tv_sec, ts1.tv_nsec);
            let (secs_finish, nsecs_finish) = (ts2.tv_sec, ts2.tv_nsec);

            let start_total = secs_start * 1_000_000_000 + nsecs_start;
            let stop_total = secs_finish * 1_000_000_000 + nsecs_finish;

            if start_total > stop_total {
                println!(
                    "back to the future: {} <= {} [{}] s_start: {} s_finish: {} ns_start: {} ns_finish: {}",
                    start_total,
                    stop_total,
                    name,
                    secs_start,
                    secs_finish,
                    nsecs_start,
                    nsecs_finish,
                );
                assert!(res1 + res2 == 0, "one of the time functions failed");
            }
        }
    });
}

secs_start, secs_finish, nsecs_start, nsecs_finish all resolve to i64 in my editor, but that is not the case for the arm architecture I am testing for, where these are defined as i32.

The appropriate target is set as default in .cargo/config.

@flodiebold flodiebold added the S-actionable Someone could pick this issue up and work on it right now label Apr 11, 2021
@bors bors bot closed this as completed in #8774 May 9, 2021
@bors bors bot closed this as completed in 6c0cdc5 May 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants