diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 6807985278e6..be6e8376eea5 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -15,6 +15,7 @@ use crate::command_prelude::*; use crate::util::is_rustup; use cargo::util::style; +#[tracing::instrument(skip_all)] pub fn main(config: &mut LazyConfig) -> CliResult { let args = cli().try_get_matches()?; @@ -258,6 +259,7 @@ fn add_ssl(version_string: &mut String) { /// [`GlobalArgs`] need to be extracted before expanding aliases because the /// clap code for extracting a subcommand discards global options /// (appearing before the subcommand). +#[tracing::instrument(skip_all)] fn expand_aliases( config: &mut Config, args: ArgMatches, @@ -363,6 +365,7 @@ For more information, see issue #12207 CliResult { match self { Self::Builtin(exec) => exec(config, subcommand_args), @@ -514,6 +518,7 @@ impl GlobalArgs { } } +#[tracing::instrument(skip_all)] pub fn cli() -> Command { let usage = if is_rustup() { color_print::cstr!("cargo [+toolchain] [OPTIONS] [COMMAND]\n cargo [+toolchain] [OPTIONS] -Zscript <> [ARGS]...") diff --git a/src/bin/cargo/main.rs b/src/bin/cargo/main.rs index 93149d21e4f3..42d201d99333 100644 --- a/src/bin/cargo/main.rs +++ b/src/bin/cargo/main.rs @@ -46,7 +46,7 @@ fn setup_logger() -> Option { .with_filter(env); let (profile_layer, profile_guard) = - #[allow(clippy::disallowed_methods)] + #![allow(clippy::disallowed_methods)] if env_to_bool(std::env::var_os("_CARGO_LOG_PROFILE").as_deref()) { let capture_args = env_to_bool(std::env::var_os("_CARGO_LOG_PROFILE_CAPTURE_ARGS").as_deref()); @@ -303,6 +303,7 @@ fn search_directories(config: &Config) -> Vec { } /// Initialize libgit2. +#[tracing::instrument(skip_all)] fn init_git(config: &Config) { // Disabling the owner validation in git can, in theory, lead to code execution // vulnerabilities. However, libgit2 does not launch executables, which is the foundation of diff --git a/src/cargo/core/compiler/context/mod.rs b/src/cargo/core/compiler/context/mod.rs index 3aedf515cc7b..f5be089e8615 100644 --- a/src/cargo/core/compiler/context/mod.rs +++ b/src/cargo/core/compiler/context/mod.rs @@ -324,6 +324,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { .map(|output| output.bin_dst().clone())) } + #[tracing::instrument(skip_all)] pub fn prepare_units(&mut self) -> CargoResult<()> { let dest = self.bcx.profiles.get_dir_name(); let host_layout = Layout::new(self.bcx.ws, None, &dest)?; @@ -349,6 +350,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// Prepare this context, ensuring that all filesystem directories are in /// place. + #[tracing::instrument(skip_all)] pub fn prepare(&mut self) -> CargoResult<()> { let _p = profile::start("preparing layout"); @@ -451,6 +453,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// Check if any output file name collision happens. /// See for more. + #[tracing::instrument(skip_all)] fn check_collisions(&self) -> CargoResult<()> { let mut output_collisions = HashMap::new(); let describe_collision = |unit: &Unit, other_unit: &Unit, path: &PathBuf| -> String { @@ -633,6 +636,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { /// If the current crate has reverse-dependencies, such a Check unit should exist, and so /// we use that crate's metadata. If not, we use the crate's Doc unit so at least examples /// scraped from the current crate can be used when documenting the current crate. + #[tracing::instrument(skip_all)] pub fn compute_metadata_for_doc_units(&mut self) { for unit in self.bcx.unit_graph.keys() { if !unit.mode.is_doc() && !unit.mode.is_doc_scrape() { diff --git a/src/cargo/core/compiler/job_queue/mod.rs b/src/cargo/core/compiler/job_queue/mod.rs index 79ea60dfd49a..0db447d3a7f3 100644 --- a/src/cargo/core/compiler/job_queue/mod.rs +++ b/src/cargo/core/compiler/job_queue/mod.rs @@ -462,6 +462,7 @@ impl<'cfg> JobQueue<'cfg> { /// This function will spawn off `config.jobs()` workers to build all of the /// necessary dependencies, in order. Freshness is propagated as far as /// possible along each dependency chain. + #[tracing::instrument(skip_all)] pub fn execute(mut self, cx: &mut Context<'_, '_>, plan: &mut BuildPlan) -> CargoResult<()> { let _p = profile::start("executing the job graph"); self.queue.queue_finished(); diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 19a77173e922..0f496330e4c6 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -158,6 +158,7 @@ impl Executor for DefaultExecutor { /// Note that **no actual work is executed as part of this**, that's all done /// next as part of [`JobQueue::execute`] function which will run everything /// in order with proper parallelism. +#[tracing::instrument(skip(cx, jobs, plan, exec))] fn compile<'cfg>( cx: &mut Context<'_, 'cfg>, jobs: &mut JobQueue<'cfg>, diff --git a/src/cargo/core/compiler/unit_dependencies.rs b/src/cargo/core/compiler/unit_dependencies.rs index e2a237d339ec..39c926609807 100644 --- a/src/cargo/core/compiler/unit_dependencies.rs +++ b/src/cargo/core/compiler/unit_dependencies.rs @@ -81,6 +81,7 @@ impl IsArtifact { /// Then entry point for building a dependency graph of compilation units. /// /// You can find some information for arguments from doc of [`State`]. +#[tracing::instrument(skip_all)] pub fn build_unit_dependencies<'a, 'cfg>( ws: &'a Workspace<'cfg>, package_set: &'a PackageSet<'cfg>, diff --git a/src/cargo/core/global_cache_tracker.rs b/src/cargo/core/global_cache_tracker.rs index 21f9b31c3ca2..75e656b90a05 100644 --- a/src/cargo/core/global_cache_tracker.rs +++ b/src/cargo/core/global_cache_tracker.rs @@ -1567,6 +1567,7 @@ impl DeferredGlobalLastUse { /// Saves all of the deferred information to the database. /// /// This will also clear the state of `self`. + #[tracing::instrument(skip_all)] pub fn save(&mut self, tracker: &mut GlobalCacheTracker) -> CargoResult<()> { let _p = crate::util::profile::start("saving last-use data"); trace!(target: "gc", "saving last-use data"); diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index 8675b0ab2523..d59b000e6f11 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -497,6 +497,7 @@ impl<'cfg> PackageSet<'cfg> { } /// Downloads any packages accessible from the give root ids. + #[tracing::instrument(skip_all)] pub fn download_accessible( &self, resolve: &Resolve, diff --git a/src/cargo/core/resolver/features.rs b/src/cargo/core/resolver/features.rs index f1c2aebcc98e..c05b7b1d886d 100644 --- a/src/cargo/core/resolver/features.rs +++ b/src/cargo/core/resolver/features.rs @@ -444,6 +444,7 @@ pub struct FeatureResolver<'a, 'cfg> { impl<'a, 'cfg> FeatureResolver<'a, 'cfg> { /// Runs the resolution algorithm and returns a new [`ResolvedFeatures`] /// with the result. + #[tracing::instrument(skip_all)] pub fn resolve( ws: &Workspace<'cfg>, target_data: &'a mut RustcTargetData<'cfg>, diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 4b12f2cf32cc..5a8d96edfb44 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -120,6 +120,7 @@ mod version_prefs; /// /// * `config` - a location to print warnings and such, or `None` if no warnings /// should be printed +#[tracing::instrument(skip_all)] pub fn resolve( summaries: &[(Summary, ResolveOpts)], replacements: &[(PackageIdSpec, Dependency)], diff --git a/src/cargo/ops/cargo_compile/mod.rs b/src/cargo/ops/cargo_compile/mod.rs index 04ebe7db1e48..a97149d1f34f 100644 --- a/src/cargo/ops/cargo_compile/mod.rs +++ b/src/cargo/ops/cargo_compile/mod.rs @@ -142,6 +142,7 @@ pub fn compile_with_exec<'a>( } /// Like [`compile_with_exec`] but without warnings from manifest parsing. +#[tracing::instrument(skip_all)] pub fn compile_ws<'a>( ws: &Workspace<'a>, options: &CompileOptions, @@ -197,6 +198,7 @@ pub fn print<'a>( /// /// For how it works and what data it collects, /// please see the [module-level documentation](self). +#[tracing::instrument(skip_all)] pub fn create_bcx<'a, 'cfg>( ws: &'a Workspace<'cfg>, options: &'a CompileOptions, diff --git a/src/cargo/ops/lockfile.rs b/src/cargo/ops/lockfile.rs index 2160b6f01541..e14d9f9e9a1d 100644 --- a/src/cargo/ops/lockfile.rs +++ b/src/cargo/ops/lockfile.rs @@ -6,6 +6,7 @@ use crate::util::Filesystem; use anyhow::Context as _; +#[tracing::instrument(skip_all)] pub fn load_pkg_lockfile(ws: &Workspace<'_>) -> CargoResult> { let lock_root = lock_root(ws); if !lock_root.as_path_unlocked().join("Cargo.lock").exists() { @@ -32,6 +33,7 @@ pub fn resolve_to_string(ws: &Workspace<'_>, resolve: &mut Resolve) -> CargoResu Ok(out) } +#[tracing::instrument(skip_all)] pub fn write_pkg_lockfile(ws: &Workspace<'_>, resolve: &mut Resolve) -> CargoResult<()> { let (orig, mut out, lock_root) = resolve_to_string_orig(ws, resolve); diff --git a/src/cargo/ops/resolve.rs b/src/cargo/ops/resolve.rs index b00dc15004ea..5d0714bab8eb 100644 --- a/src/cargo/ops/resolve.rs +++ b/src/cargo/ops/resolve.rs @@ -239,6 +239,7 @@ pub fn resolve_ws_with_opts<'cfg>( }) } +#[tracing::instrument(skip_all)] fn resolve_with_registry<'cfg>( ws: &Workspace<'cfg>, registry: &mut PackageRegistry<'cfg>, @@ -278,6 +279,7 @@ fn resolve_with_registry<'cfg>( /// /// If `register_patches` is true, then entries from the `[patch]` table in /// the manifest will be added to the given `PackageRegistry`. +#[tracing::instrument(skip_all)] pub fn resolve_with_previous<'cfg>( registry: &mut PackageRegistry<'cfg>, ws: &Workspace<'cfg>, @@ -536,6 +538,7 @@ pub fn resolve_with_previous<'cfg>( /// Read the `paths` configuration variable to discover all path overrides that /// have been configured. +#[tracing::instrument(skip_all)] pub fn add_overrides<'a>( registry: &mut PackageRegistry<'a>, ws: &Workspace<'a>, diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index b0584fb63787..29d4658756d3 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -500,6 +500,7 @@ pub trait ArgMatchesExt { root_manifest(self._value_of("manifest-path").map(Path::new), config) } + #[tracing::instrument(skip_all)] fn workspace<'a>(&self, config: &'a Config) -> CargoResult> { let root = self.root_manifest(config)?; let mut ws = Workspace::new(&root, config)?; diff --git a/src/cargo/util/config/mod.rs b/src/cargo/util/config/mod.rs index 901357dbc595..ac531cd6f7bb 100644 --- a/src/cargo/util/config/mod.rs +++ b/src/cargo/util/config/mod.rs @@ -1917,6 +1917,7 @@ impl Config { /// Locks are usually acquired via [`Config::acquire_package_cache_lock`] /// or [`Config::try_acquire_package_cache_lock`]. #[track_caller] + #[tracing::instrument(skip_all)] pub fn assert_package_cache_locked<'a>( &self, mode: CacheLockMode, @@ -1937,6 +1938,7 @@ impl Config { /// /// See [`crate::util::cache_lock`] for an in-depth discussion of locking /// and lock modes. + #[tracing::instrument(skip_all)] pub fn acquire_package_cache_lock(&self, mode: CacheLockMode) -> CargoResult> { self.package_cache_lock.lock(self, mode) } @@ -1946,6 +1948,7 @@ impl Config { /// /// See [`crate::util::cache_lock`] for an in-depth discussion of locking /// and lock modes. + #[tracing::instrument(skip_all)] pub fn try_acquire_package_cache_lock( &self, mode: CacheLockMode, diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index f4c3b9034c7f..b35a4002e824 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -42,6 +42,7 @@ use self::targets::targets; /// within the manifest. For virtual manifests, these paths can only /// come from patched or replaced dependencies. These paths are not /// canonicalized. +#[tracing::instrument(skip(config))] pub fn read_manifest( path: &Path, source_id: SourceId,