Closed
Description
Summary
When I try to use a crate with proc macros, I cannot, even if I enable the feature and macro_use the crate.
Code
From https://github.com/termoshtt/accel#example (with an added #[macro_use]
on line 4)
#![feature(proc_macro, custom_attribute)]
extern crate accel;
#[macro_use]
extern crate accel_derive;
use accel_derive::kernel;
use accel::*;
#[kernel]
#[crate("accel-core" = "0.2.0")]
#[build_path(".rust2ptx")]
pub unsafe fn add(a: *const f64, b: *const f64, c: *mut f64, n: usize) {
let i = accel_core::index();
if (i as usize) < n {
*c.offset(i) = *a.offset(i) + *b.offset(i);
}
}
fn main() {
let n = 32;
let mut a = UVec::new(n).unwrap();
let mut b = UVec::new(n).unwrap();
let mut c = UVec::new(n).unwrap();
for i in 0..n {
a[i] = i as f64;
b[i] = 2.0 * i as f64;
}
println!("a = {:?}", a.as_slice());
println!("b = {:?}", b.as_slice());
let grid = Grid::x(1);
let block = Block::x(n as u32);
add(grid, block, a.as_ptr(), b.as_ptr(), c.as_mut_ptr(), n);
device::sync().unwrap();
println!("c = {:?}", c.as_slice());
}
Expected results:
It compiles.
Actual results:
It fails, with the following:
error[E0432]: unresolved import `accel_derive::kernel`==============> ] 32/33: cuda-test
--> src/main.rs:6:5
|
6 | use accel_derive::kernel;
| ^^^^^^^^^^^^^^^^^^^^ no `kernel` in the root
error[E0658]: attribute procedural macros are experimental (see issue #38356)
--> src/main.rs:9:1
|
3 | #[macro_use]
| ------------ procedural macro imported here
...
9 | #[kernel]
| ^^^^^^^^^
|
= help: add #![feature(proc_macro)] to the crate attributes to enable
error[E0433]: failed to resolve. Use of undeclared type or module `accel_core`
--> src/main.rs:13:13
|
13 | let i = accel_core::index();
| ^^^^^^^^^^ Use of undeclared type or module `accel_core`
error: expected one of `)` or `,`, found `=`
--> src/main.rs:10:22
|
10 | #[crate("accel-core" = "0.2.0")]
| ^ expected one of `)` or `,` here
error: unexpected token: `"0.2.0"`
--> src/main.rs:10:24
|
10 | #[crate("accel-core" = "0.2.0")]
| ^^^^^^^ unexpected token after this
error: aborting due to 5 previous errors
Some errors occurred: E0432, E0433, E0658.
For more information about an error, try `rustc --explain E0432`.
error: Could not compile `cuda-test`.
Note that I don't expect to get this working at this point, I wanted to report what to me (and someone on #rust who suggested I open this) a bug.
rustc data:
rustc 1.29.0-nightly (12ed235ad 2018-07-18)
binary: rustc
commit-hash: 12ed235adc62e63b16bb4f715b143c37a5efa00d
commit-date: 2018-07-18
host: x86_64-unknown-linux-gnu
release: 1.29.0-nightly
LLVM version: 7.0
Metadata
Metadata
Assignees
Labels
No labels