[rust-dev] Using rustc as crate?

Christoph Husse thesaint1987 at googlemail.com
Sat Jul 12 06:27:19 PDT 2014


Hi,

I am trying to "externalize" the builtin Lint code, because I want to
work on some tooling support and they seem to do a lot of the stuff I
would be interested in too..

But I don't want to recompile rustc for every change to my code. I
noticed most of the mods are public but still rust doesn't seem to let
me import them into my own crate.

I just wrote something like the following for testing:

####################################################

#![crate_name = "rusttooling"]
#![experimental]
#![comment = "The Rust Tooling Library"]
#![license = "MIT/ASL2"]
#![crate_type = "dylib"]
#![crate_type = "rlib"]
#![doc(html_logo_url =
"http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
      html_favicon_url = "http://www.rust-lang.org/favicon.ico",
      html_root_url = "http://doc.rust-lang.org/0.11.0/")]

#![allow(deprecated)]
#![feature(macro_rules, globs, struct_variant, managed_boxes, quote)]
#![feature(default_type_params, phase, unsafe_destructor)]

#![allow(unknown_features)] // NOTE: Remove after next snapshot
#![feature(rustc_diagnostic_macros)]

extern crate arena;
extern crate rustc;
extern crate debug;
extern crate flate;
extern crate getopts;
extern crate graphviz;
extern crate libc;
extern crate serialize;
extern crate time;
#[phase(plugin, link)] extern crate log;
#[phase(plugin, link)] extern crate syntax;


//pub mod lint;
use middle::typeck::infer;
use metadata::csearch;


####################################################

The last two lines fail for me... "error: unresolved import
`middle::typeck::infer`. Maybe a missing `extern crate middle`?"

What could be the problem?
Was it intended for Lint like stuff to even be used outside the compiler?
How would the "officially" supported way look like?

PS: I am on windows and the cargo thing doesn't seem to work there yet.

Thanks a lot!


More information about the Rust-dev mailing list