Stream: t-compiler/help

Topic: How to depend on external crates in ui tests?


David Ross (Feb 02 2020 at 02:16, on Zulip):

Anyone have tips for building test files which depend on extern crates?

I'm trying to write a test case for issue 59191, which involves using a proc macro to replace the crate root with a non-module item.

I've copied one of the other tests which places a support file in an auxiliary/ directory and then uses extern crate to refer to it - but since the test involves a macro executed at the top level, I can't use extern crate. So instead I tried to make it 2018-edition and just using the auxiliary file, but it can't find it.

I've committed both test files at https://github.com/daboross/rust/commit/beb41493045fdcbca6c77840eb924ddf9f39e389

The actual test is https://github.com/daboross/rust/blob/beb41493045fdcbca6c77840eb924ddf9f39e389/src/test/ui/proc-macro/issue-59191-replace-root-with-fn.rs

and the support is https://github.com/daboross/rust/blob/beb41493045fdcbca6c77840eb924ddf9f39e389/src/test/ui/proc-macro/auxiliary/issue-59191.rs

The main error is just "error[E0433]: failed to resolve: use of undeclared type or module issue_59191".

Anyone who's more familiar with the test suite and its configuration flags have advice?

David Ross (Feb 02 2020 at 02:22, on Zulip):

I know the issue isn't with the macro / the compiler since if I change the macro to operate on a sub-module rather than the crate root, then it still fails.

This fails:

// edition:2018
// aux-build:issue-59191.rs

#![feature(custom_inner_attributes)]

#[issue_59191::no_main]
mod x {}

And succeeds only if I add extern crate issue_59191;.

Last update: Sep 22 2020 at 00:45UTC