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(rustc_private, box_patterns, associated_type_defaults, never_type)]
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 flux_macros::fluent_messages;
22use rustc_hir::def_id::DefId;
23use rustc_middle::ty::TyCtxt;
24
25fluent_messages! { "../locales/en-US.ftl" }
26
27pub mod const_eval;
28pub mod lowering;
29pub mod mir;
30pub mod ty;
31
32pub trait ToRustc<'tcx> {
33    type T;
34
35    fn to_rustc(&self, tcx: TyCtxt<'tcx>) -> Self::T;
36}
37
38impl<'tcx> ToRustc<'tcx> for rustc_middle::ty::Ty<'tcx> {
39    type T = Self;
40
41    fn to_rustc(&self, _tcx: TyCtxt<'tcx>) -> Self {
42        *self
43    }
44}
45
46pub fn def_id_to_string(def_id: DefId) -> String {
47    rustc_middle::ty::tls::with(|tcx| tcx.def_path_str(def_id))
48}