Skip to content

Workspace root detection can print warnings without context #15167

Open
@ehuss

Description

Problem

When there is a package in a subdirectory of another package, and the root package generates warnings, then cargo will print a warning, but not tell you where it is coming from. This can be confusing, since the package in the root doesn't actually have any bearing on the package in the subdirectory (it only needs to be parsed to know if it defines a workspace). In a normal workspace, cargo prints the path to the manifest generating the warning.

Steps

Root has:

# Root Cargo.toml
[package]
name = "foo"

and in a subdirectory:

# bar/Cargo.toml
[package]
name = "bar"
version = "0.1.0"
edition = "2024"

building in bar will result in:

warning: no edition set: defaulting to the 2015 edition while the latest is 2024

This warning does not indicate where it is coming from. I believe this happens somewhere in find_workspace_root_with_loader.

Possible Solution(s)

Two possible solutions I can think of:

  • Don't display any warnings loading a manifest during workspace discovery if it determines it isn't actually a workspace (i.e. the root manifest ends up being ignored).
  • Include the path to the manifest when printing warnings during workspace discovery.

Notes

No response

Version

cargo 1.86.0-nightly (2928e3273 2025-02-07)
release: 1.86.0-nightly
commit-hash: 2928e32734b04925ee51e1ae88bea9a83d2fd451
commit-date: 2025-02-07
host: aarch64-apple-darwin
libgit2: 1.9.0 (sys:0.20.0 vendored)
libcurl: 8.7.1 (sys:0.4.74+curl-8.9.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 14.6.1 [64-bit]

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Error and warning messages generated by Cargo itself.C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions