Skip to main content

Crate project_model

Crate project_model 

Source
Expand description

In rust-analyzer, we maintain a strict separation between pure abstract semantic project model and a concrete model of a particular build system.

Pure model is represented by the base_db::CrateGraph from another crate.

In this crate, we are concerned with “real world” project models.

Specifically, here we have a representation for a Cargo project (CargoWorkspace) and for manually specified layout (ProjectJson).

Roughly, the things we do here are:

  • Project discovery (where’s the relevant Cargo.toml for the current dir).
  • Custom build steps (build.rs code generation and compilation of procedural macros).
  • Lowering of concrete model to a base_db::CrateGraph

Re-exports§

pub use crate::project_json::ProjectJson;
pub use crate::project_json::ProjectJsonData;

Modules§

build_dependencies 🔒
Logic to invoke cargo for building build-dependencies (build scripts and proc-macros) as well as executing the build scripts to fetch required dependency information (OUT_DIR env var, extra cfg flags, etc).
cargo_config_file 🔒
Read .cargo/config.toml as a TOML table
cargo_workspace 🔒
See CargoWorkspace.
env 🔒
Cargo-like environment variables injection.
manifest_path 🔒
See ManifestPath.
project_json
rust-project.json file format.
sysroot 🔒
Loads “sysroot” crate.
toolchain_info
workspace 🔒
Handles lowering of build-system specific workspace information (cargo metadata or rust-project.json) into representation stored in the salsa database – CrateGraph.

Structs§

CargoConfig
CargoMetadataConfig
CargoWorkspace
CargoWorkspace represents the logical structure of, well, a Cargo workspace. It pretty closely mirrors cargo metadata output.
CfgOverrides
A set of cfg-overrides per crate.
ManifestPath
More or less [AbsPathBuf] with non-None parent.
Metadata
Starting point for metadata returned by cargo metadata
PackageData
Information associated with a cargo crate
PackageDependency
PackageRoot
PackageRoot describes a package root folder. Which may be an external dependency, or a member of the current workspace.
ProjectJsonFromCommand
ProjectWorkspace
Sysroot
TargetData
Information associated with a package’s target
WorkspaceBuildScripts
Output of the build script and proc-macro building steps for a workspace.

Enums§

CargoFeatures
InvocationStrategy
ProcMacroDylibPath
ProjectManifest
ProjectWorkspaceKind
RustLibSource
Describes how to set the rustc source directory.
RustSourceWorkspaceConfig
TargetDirectoryConfig
TargetKind

Functions§

parse_cfg 🔒
utf8_stdout 🔒

Type Aliases§

FileLoader
Package
Target