-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat: in-memory only Manifest
#16409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| let document = manifest.document(); | ||
| let document = manifest.document().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should lints assume that this is a Some? I'm not familiar on how lints are used in cargo-as-a-library. Other options would probably be bail!ing out or silently stopping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need a way to run lint passes with plumbing commands, so we'll need to have a way to resolve this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will need a way to run lint passes with plumbing commands
By this, do you mean lints being run as part of an existing plumbing command, like read-manifest, or having a separate plumbing command to run lints?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unsure where we will run it atm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I think we can safely assume that the fields are Some. Within cargo itself, the calls to constructors use Some.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, we should be handling the Nones
| contents: Rc<String>, | ||
| document: Rc<toml::Spanned<toml::de::DeTable<'static>>>, | ||
| original_toml: Rc<TomlManifest>, | ||
| document: Option<Rc<toml::Spanned<toml::de::DeTable<'static>>>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like removing the .unwrap()s would need to happen before this
f857ec0 to
8d25903
Compare
8d25903 to
c9fa22d
Compare
src/cargo/ops/vendor.rs
Outdated
| ) -> CargoResult<Package> { | ||
| let contents = me.manifest().contents(); | ||
| let document = me.manifest().document(); | ||
| let contents = me.manifest().contents().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My default assumption is that this PR is not ready to merge until all .unwrap()s are resolved. Any remaining .unwrap() should have a justification, likely including switching it to an .expect() explaining what invariants are keeping it from panicking.
|
Because of #16409 (comment), I'm moving this back to a Draft |
c9fa22d to
fae3b40
Compare
src/cargo/core/compiler/mod.rs
Outdated
| spans: unit.pkg.manifest().document().unwrap().clone(), | ||
| contents: unit.pkg.manifest().contents().unwrap().to_owned(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like these are for public dependency diagnostics. Its either requiring compilation to have a complete Workspace or disabling diagnostics for public dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is no different than any other diagnostics: we should work to allow contents to be optional.
src/cargo/core/manifest.rs
Outdated
| pub fn document(&self) -> &toml::Spanned<toml::de::DeTable<'static>> { | ||
| self.document.as_ref().unwrap() | ||
| pub fn document(&self) -> Option<&toml::Spanned<toml::de::DeTable<'static>>> { | ||
| self.document.as_ref().map(|d| d.as_ref()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these maps needed?
src/cargo/lints/mod.rs
Outdated
| let contents = manifest.contents(); | ||
| let contents = manifest | ||
| .contents() | ||
| .with_context(|| "incomplete Workspace information")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that these with_context in this commit are not sufficient either. The error message is not meaningful to the end user and most or all of the functionality that they guard should be runnable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. So functionality should still be present but without the snippets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wherever possible, yes
fae3b40 to
1dfa6b3
Compare
Make `document`, `original_toml` and `contents` optional to allow creating Manifests from in-memory data.
Make `contents` and `spans` optional in ManifestErrorContext to allow disabling diagnostics.
1dfa6b3 to
4573605
Compare
4573605 to
9c99c39
Compare
Remove calls to `.unwrap` to make lints work with in-memory `Manifest`.
Change the signature for `to_real_manifest`, `to_virtual_manifest` and `missing_dep_diagnostic` to support in-memory `Manifest`.
9c99c39 to
3f8a05f
Compare
What does this PR try to resolve?
This PR supports creating an in-memory only
Manifest.Part of #16290
How to test and review this PR?
No tests should change as this is for cargo-as-a-library.