Skip to content

Old syntax suggestion#13874

Merged
bors merged 5 commits into
rust-lang:masterfrom
torhovland:old-syntax-suggestion
May 8, 2024
Merged

Old syntax suggestion#13874
bors merged 5 commits into
rust-lang:masterfrom
torhovland:old-syntax-suggestion

Conversation

@torhovland

Copy link
Copy Markdown
Contributor

Fixes #13868.

The build error in the issue will now include a suggestion:

   Compiling zerocopy v0.8.0-alpha.9
error: the `cargo::` syntax for build script output instructions was added in Rust 1.77.0, but the minimum supported Rust version of `zerocopy v0.8.0-alpha.9` is 1.56.0.
Consider using the old `cargo:` syntax in front of `rustc-check-cfg=`.
See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script for more information about build script outputs.

The suggestion is only included for reserved prefixes.

A test has been added.

@rustbot

rustbot commented May 7, 2024

Copy link
Copy Markdown
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @weihanglo (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added A-build-scripts Area: build.rs scripts S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 7, 2024
Comment thread tests/testsuite/build_script.rs Outdated
Comment thread tests/testsuite/build_script.rs
Comment thread src/cargo/core/compiler/custom_build.rs Outdated
.contains(&&*prefix)
.then(|| {
format!(
"Consider using the old `cargo:` syntax in front of `{prefix}`.\n"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo splitting up the suggestion like this feels a little more awkward to read.

Maybe

Suggested change
"Consider using the old `cargo:` syntax in front of `{prefix}`.\n"
"Switch to `cargo:{prefix}` (note the single colon).\n"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make it clear that the single colon is an old syntax. What do you think?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of splitting the full instruction to two places, I'd like to see it combined.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, how about now?

Comment thread src/cargo/core/compiler/custom_build.rs Outdated
Comment thread src/cargo/core/compiler/custom_build.rs Outdated
if !new_syntax_added_in.is_compatible_with(msrv.as_partial()) {
let prefix = format!("{key}=");

let old_syntax_suggestion = RESERVED_PREFIXES

@epage epage May 7, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When it isn't in RESERVED_PREFIXES, if the key is metadata, we should suggest cargo:{value}

Unsure if we should say much more otherwise. The key is either not supported on their MSRV or they didn't realize they should use metadata= first with cargo::

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@torhovland torhovland marked this pull request as draft May 7, 2024 09:03
@torhovland torhovland force-pushed the old-syntax-suggestion branch from 9686982 to e4e6261 Compare May 7, 2024 10:40
@torhovland torhovland marked this pull request as ready for review May 7, 2024 10:43
@torhovland

Copy link
Copy Markdown
Contributor Author

@rustbot review

@weihanglo weihanglo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work!

It would be great if you could clean up some intermediate commits, and make the git history easier to track in the future.

@torhovland torhovland force-pushed the old-syntax-suggestion branch from 7663e63 to 3ea3638 Compare May 8, 2024 21:06
@torhovland

Copy link
Copy Markdown
Contributor Author

OK, I squashed a couple commits. Hope that's better.

@weihanglo

Copy link
Copy Markdown
Member

@bors r+

Thanks!

(To me I might also make git commit messages clearer. You can see how people did it in this repo. Let's don't bother on this at this moment and move on 👍🏾)

@bors

bors commented May 8, 2024

Copy link
Copy Markdown
Contributor

📌 Commit 3ea3638 has been approved by weihanglo

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 8, 2024
@bors

bors commented May 8, 2024

Copy link
Copy Markdown
Contributor

⌛ Testing commit 3ea3638 with merge 1fec089...

@bors

bors commented May 8, 2024

Copy link
Copy Markdown
Contributor

☀️ Test successful - checks-actions
Approved by: weihanglo
Pushing 1fec089 to master...

@bors bors merged commit 1fec089 into rust-lang:master May 8, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request May 11, 2024
Update cargo

7 commits in 0ca60e940821c311c9b25a6423b59ccdbcea218f..4de0094ac78743d2c8ff682489e35c8a7cafe8e4
2024-05-08 01:54:25 +0000 to 2024-05-09 16:09:22 +0000
- Fix docs for unstable script feature (rust-lang/cargo#13893)
- Refactor cargo lint tests (rust-lang/cargo#13880)
- test(rustfix): run some tests only on nightly (rust-lang/cargo#13890)
- Old syntax suggestion (rust-lang/cargo#13874)
- docs: clarify dash replacement rule in target name (rust-lang/cargo#13887)
- Add local-only build scripts example in check-cfg docs (rust-lang/cargo#13884)
- docs(changelog): also mention `--message-format=json` (rust-lang/cargo#13882)

r? ghost
@rustbot rustbot added this to the 1.80.0 milestone May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-scripts Area: build.rs scripts S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo:: syntax should be permitted despite MSRV with the right configuration

6 participants