Skip to main content

flux_rustc_bridge/
lib.rs

1//! This crate contains simplified versions of some structures in rustc. The definitions
2//! in this module can be understood as the current supported subset of rust. As we implement
3//! more features we should be able to work directly on rustc's structures.
4
5#![feature(deref_patterns, rustc_private)]
6
7extern crate rustc_abi;
8extern crate rustc_borrowck;
9extern crate rustc_data_structures;
10extern crate rustc_errors;
11extern crate rustc_hir;
12extern crate rustc_index;
13extern crate rustc_infer;
14extern crate rustc_macros;
15extern crate rustc_middle;
16extern crate rustc_serialize;
17extern crate rustc_span;
18extern crate rustc_trait_selection;
19extern crate rustc_type_ir;
20
21use rustc_hir::def_id::DefId;
22use rustc_middle::ty::TyCtxt;
23
24pub mod const_eval;
25pub mod lowering;
26pub mod mir;
27pub mod ty;
28
29pub trait ToRustc<'tcx> {
30    type T;
31
32    fn to_rustc(&self, tcx: TyCtxt<'tcx>) -> Self::T;
33}
34
35impl<'tcx> ToRustc<'tcx> for rustc_middle::ty::Ty<'tcx> {
36    type T = Self;
37
38    fn to_rustc(&self, _tcx: TyCtxt<'tcx>) -> Self {
39        *self
40    }
41}
42
43pub fn def_id_to_string(def_id: DefId) -> String {
44    rustc_middle::ty::tls::with(|tcx| tcx.def_path_str(def_id))
45}