-
Notifications
You must be signed in to change notification settings - Fork 219
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
chore: Remove the concept of CrateType
#1868
Conversation
I don't understand the reason to remove this; since a binary crate and something having a main function are not the same thing. Also curious as to how this plays out with workspaces |
crates/noirc_frontend/src/hir/mod.rs
Outdated
pub fn is_binary_crate(&self, crate_id: &CrateId) -> bool { | ||
// Currently, anything with a `main` function is a binary crate | ||
matches!(self.get_main_function(crate_id), 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.
A library (lib.nr
) with a main
function would be treated as a binary crate here.
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 think that is fine though; although, in rust, the extra main
would be ignored and clippy would give a warning that it is unused. I could see us doing that, wdyt?
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 still has the concept of a crate-type in the frontend, its just that it is implicit by having a main function IIUC. I think its better to be explicit about the crate-type
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.
Clippy !== frontend in rust. Clippy is a linting tool that runs some phases of the compiler and then gives you feedback. The cargo abstraction defines what a lib or bin actually is, including specifying custom paths (you can specify src/lib.rs
as the path for a [[bin]]
iirc).
From the compiler perspective, anything through the check phase doesn't care about this at all. The only thing that cares about this is dependency resolution and the final step of "compile_main". And it could be argued that it is not something that dependency resolution should care about (e.g. cargo allows a
I'm not exactly sure how you view workspaces, as I view anything with a Nargo.toml as a workspace because it is a grouping of files; however, if there is additional logic needed inside nargo (which is the "workspace tool") then it should happen inside nargo, instead deep in the frontend which should just be compiling source code. |
196299f
to
9417e80
Compare
b480f01
to
60db9c6
Compare
I was using the same definition as cargo workspaces : https://doc.rust-lang.org/book/ch14-03-cargo-workspaces.html
That makes sense, but I think we want to be explicit in defining a crate to be a library or a binary, then if there is a main function in a library crate, "clippy" can give a warning. Instead of it being inferred via the main function |
If you want to give a clippy-style warning, this should just be a "nargo thing" not a "noirc thing" (or "frontend thing"). The frontend should have no concept of the crate type |
60db9c6
to
22bda3e
Compare
CrateType
Looks like this has been blocked by #1913. We'll need to revert/rework some of the changes in this PR to be able to progress on this. |
Converting to draft, as my rebase removes some of the premature-merge workspace logic |
22bda3e
to
ebd55ba
Compare
This is being replaced by #2134 |
Description
Problem*
Towards #1838
Summary*
This removes the concept of a
CrateType
as it doesn't really matter except for adding dependencies and doing a "full" compilation (with backend, etc). In the cases where we need to know if something is a "binary crate" we can just check to see if it has a main function.Documentation
This PR requires documentation updates when merged.
Additional Context
PR Checklist*
cargo fmt
on default settings.