-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Different results when expanding macros manually #6788
Comments
@jensnockert the gist no longer exists :( Can you create another testcase? |
I'll just repost the Gist, https://gist.github.com/jensnockert/ab64d115023bf9d20261. I changed my username from JensNockert to jensnockert, and the link broke :( |
Copying the unexpanded version of source code here, to avoid the link-death problems in the future: #[link(name = "min", vers = "0.1", uuid = "430a7e67-8e6a-4041-be05-643fabff74cf")];
#[crate_type = "lib"];
#[nolink]
#[link_args = "-framework OpenCL"]
#[cfg(target_os = "macos")]
extern { }
#[nolink]
#[link_args = "-lOpenCL"]
#[cfg(target_os = "linux")]
extern { }
#[nolink]
extern {
unsafe fn clGetPlatformInfo(platform: *libc::c_void, name: u32, value_size: libc::size_t, value: *mut libc::c_void, value_size_ret: *mut libc::size_t) -> i32;
}
macro_rules! cl_call(($name:ident : $($arg:expr),+) => ({
let error = unsafe { $name($($arg),+) };
if (error != 0) {
return result::Err(error);
}
}))
macro_rules! cl_call_unknown_length(($name:ident, $n:ty, $in:ty, $out:ty : $($arg:expr),+) => ({
let mut n:$n = 0;
cl_call!($name: $($arg),+, 0, ptr::mut_null(), ptr::to_mut_unsafe_ptr(&mut n));
let mut result:~[$out] = vec::with_capacity(n as uint);
cl_call!($name: $($arg),+, n, vec::raw::to_mut_ptr(result) as *mut $in, ptr::mut_null());
unsafe { vec::raw::set_len(&mut result, n as uint) };
result
}))
pub fn get_info(id: *libc::c_void, name: u32) -> result::Result<~str, i32> {
return result::Ok(str::from_bytes(cl_call_unknown_length!(clGetPlatformInfo, libc::size_t, libc::c_void, u8: id, name)));
} |
Triage: the following update seems to work (at least, it compiles for me, but I don't have opencl so it fails in linking). #[link(name = "min", vers = "0.1", uuid = "430a7e67-8e6a-4041-be05-643fabff74cf")];
#[feature(macro_rules)];
#[crate_type = "lib"];
use std::{libc, result, ptr, vec, str};
#[nolink]
#[link_args = "-framework OpenCL"]
#[cfg(target_os = "macos")]
extern { }
#[nolink]
#[link_args = "-lOpenCL"]
#[cfg(target_os = "linux")]
extern { }
#[nolink]
extern {
fn clGetPlatformInfo(platform: *libc::c_void, name: u32, value_size: libc::size_t, value: *mut libc::c_void, value_size_ret: *mut libc::size_t) -> i32;
}
macro_rules! cl_call(($name:ident : $($arg:expr),+) => ({
let error = unsafe { $name($($arg),+) };
if (error != 0) {
return result::Err(error);
}
}))
macro_rules! cl_call_unknown_length(
($name:ident, $n:ty, $in_:ty, $out:ty <- $($arg:expr),*) => ({
let mut n:$n = 0;
cl_call!($name: $($arg),*, 0, ptr::mut_null(), ptr::to_mut_unsafe_ptr(&mut n));
let mut result:~[$out] = vec::with_capacity(n as uint);
cl_call!($name: $($arg),*, n, vec::raw::to_mut_ptr(result) as *mut $in_, ptr::mut_null());
unsafe { vec::raw::set_len(&mut result, n as uint) };
result
}))
#[fixed_stack_segment]
pub fn get_info(id: *libc::c_void, name: u32) -> result::Result<~str, i32> {
return result::Ok(str::from_utf8_owned(
cl_call_unknown_length!(clGetPlatformInfo,
libc::size_t,
libc::c_void,
u8 <- id, name)));
} @jensnockert could you confirm? (And reopen if it's not behaving as you expect.) |
@huonw would it be possible to add a testcase for this? |
…ip1995 move upper_case_acronyms back to style, but make the default behaviour less aggressive by default (can be unleashed via config option) Previous discussion in the bi-weekly clippy meeting for reference: https://rust-lang.zulipchat.com/#narrow/stream/257328-clippy/topic/Meeting.202021-02-23/near/227458019 Move the `upper_case_acronyms` lint back to the style group. Only warn on fully-capitalized names by default. Add add a clippy-config option `upper-case-acronyms-aggressive: true/false` to enabled more aggressive linting on all substrings that could be capitalized acronyms. --- changelog: reenable upper_case_acronyms by default but make the more aggressive linting opt-in via config option
The code https://gist.github.com/jensnockert/ab64d115023bf9d20261 (unfortunately requires OpenCL to link with) produces the following warnings
When compiled like
rust build min.rs
, but when doing the two-step processrustc --pretty expanded min.rs > min-expanded.rs
thenrust build min-expanded.rs
it builds without warning.The text was updated successfully, but these errors were encountered: