Expand description
This file governs the overall translation of items.
Translation works as follows: we translate each TransItemSource of interest into an
appropriate item. In the process of translating an item we may find more front::DefIds of
interest; we register those as an appropriate TransItemSource, which will 1/ enqueue the item
so that it eventually gets translated too, and 2/ return an ItemId we can use to refer to
it.
We start with the DefId of the current crate (or of anything passed to --start-from) and
recursively translate everything we find.
There’s another important component at play: opacity. Each item is assigned an opacity based on
its name. By default, items from the local crate are transparent and items from foreign crates
are opaque (this can be controlled with --include, --opaque and --exclude). If an item is
opaque, its signature/“outer shell” will be translated (e.g. for functions that’s the
signature) but not its contents.
Re-exports§
use itertools::Itertools;🔒use petgraph::visit::Dfs;🔒use petgraph::visit::Walker;🔒use rustc_hash::FxHashMap;🔒use rustc_hash::FxHashSet as HashSet;🔒use rustc_hir::def_id::LOCAL_CRATE;🔒use rustc_middle::ty;🔒use rustc_middle::ty::TyCtxt;🔒use rustc_span::def_id::DefId;🔒use rustc_span::sym;🔒use std::any::Any;🔒use std::cell::RefCell;🔒use std::path::PathBuf;🔒use std::sync::Arc;🔒use crate::frontend as front;🔒use crate::frontend::BaseState;🔒use crate::frontend::SInto;🔒use charon_lib::name_matcher::NamePattern;🔒use charon_lib::options::CliOpts;🔒use charon_lib::options::ConstHandling;🔒use charon_lib::options::StartFrom;🔒use charon_lib::options::TranslateOptions;🔒use charon_lib::transform::TransformCtx;🔒use super::translate_ctx::*;🔒use charon_lib::ast::*;🔒
Structs§
- Trans
Item Source - The id of an untranslated item.
Enums§
- Rustc
Item - Refers to a rustc item. Can be either the polymorphic version (
Poly) of the item, or a monomorphization (MonoorMonoTrait) of it. ForMonoTraititems, their kind should be eithertrait declorstruct vtable: 1. the trait is translated as in poly mode, except that we don’t translate any of its associated item lists. 2. the vtable is translated with erased signature of the methods and without generic types. In other words, there is one “opaque” vtable per trait.