6888 Commits

Author SHA1 Message Date
Ed Page
6d1f6be115
chore(deps): update rust crate rand to 0.9.0 (#15129)
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [rand](https://rust-random.github.io/book)
([source](https://redirect.github.com/rust-random/rand)) |
workspace.dependencies | minor | `0.8.5` -> `0.9.0` |

---

### Release Notes

<details>
<summary>rust-random/rand (rand)</summary>

###
[`v0.9.0`](https://redirect.github.com/rust-random/rand/blob/HEAD/CHANGELOG.md#090---2025-01-27)

[Compare
Source](https://redirect.github.com/rust-random/rand/compare/0.8.5...0.9.0)

##### Security and unsafe

- Policy: "rand is not a crypto library"
([#&#8203;1514](https://redirect.github.com/rust-random/rand/issues/1514))
- Remove fork-protection from `ReseedingRng` and `ThreadRng`. Instead,
it is recommended to call `ThreadRng::reseed` on fork.
([#&#8203;1379](https://redirect.github.com/rust-random/rand/issues/1379))
- Use `zerocopy` to replace some `unsafe` code
([#&#8203;1349](https://redirect.github.com/rust-random/rand/issues/1349),
[#&#8203;1393](https://redirect.github.com/rust-random/rand/issues/1393),
[#&#8203;1446](https://redirect.github.com/rust-random/rand/issues/1446),
[#&#8203;1502](https://redirect.github.com/rust-random/rand/issues/1502))

##### Dependencies

- Bump the MSRV to 1.63.0
([#&#8203;1207](https://redirect.github.com/rust-random/rand/issues/1207),
[#&#8203;1246](https://redirect.github.com/rust-random/rand/issues/1246),
[#&#8203;1269](https://redirect.github.com/rust-random/rand/issues/1269),
[#&#8203;1341](https://redirect.github.com/rust-random/rand/issues/1341),
[#&#8203;1416](https://redirect.github.com/rust-random/rand/issues/1416),
[#&#8203;1536](https://redirect.github.com/rust-random/rand/issues/1536));
note that 1.60.0 may work for dependents when using
`--ignore-rust-version`
- Update to `rand_core` v0.9.0
([#&#8203;1558](https://redirect.github.com/rust-random/rand/issues/1558))

##### Features

- Support `std` feature without `getrandom` or `rand_chacha`
([#&#8203;1354](https://redirect.github.com/rust-random/rand/issues/1354))
- Enable feature `small_rng` by default
([#&#8203;1455](https://redirect.github.com/rust-random/rand/issues/1455))
- Remove implicit feature `rand_chacha`; use `std_rng` instead.
([#&#8203;1473](https://redirect.github.com/rust-random/rand/issues/1473))
- Rename feature `serde1` to `serde`
([#&#8203;1477](https://redirect.github.com/rust-random/rand/issues/1477))
- Rename feature `getrandom` to `os_rng`
([#&#8203;1537](https://redirect.github.com/rust-random/rand/issues/1537))
- Add feature `thread_rng`
([#&#8203;1547](https://redirect.github.com/rust-random/rand/issues/1547))

##### API changes: rand_core traits

- Add fn `RngCore::read_adapter` implementing `std::io::Read`
([#&#8203;1267](https://redirect.github.com/rust-random/rand/issues/1267))
- Add trait `CryptoBlockRng: BlockRngCore`; make `trait CryptoRng:
RngCore`
([#&#8203;1273](https://redirect.github.com/rust-random/rand/issues/1273))
- Add traits `TryRngCore`, `TryCryptoRng`
([#&#8203;1424](https://redirect.github.com/rust-random/rand/issues/1424),
[#&#8203;1499](https://redirect.github.com/rust-random/rand/issues/1499))
- Rename `fn SeedableRng::from_rng` -> `try_from_rng` and add infallible
variant `fn from_rng`
([#&#8203;1424](https://redirect.github.com/rust-random/rand/issues/1424))
- Rename `fn SeedableRng::from_entropy` -> `from_os_rng` and add
fallible variant `fn try_from_os_rng`
([#&#8203;1424](https://redirect.github.com/rust-random/rand/issues/1424))
- Add bounds `Clone` and `AsRef` to associated type `SeedableRng::Seed`
([#&#8203;1491](https://redirect.github.com/rust-random/rand/issues/1491))

##### API changes: Rng trait and top-level fns

- Rename fn `rand::thread_rng()` to `rand::rng()` and remove from the
prelude
([#&#8203;1506](https://redirect.github.com/rust-random/rand/issues/1506))
- Remove fn `rand::random()` from the prelude
([#&#8203;1506](https://redirect.github.com/rust-random/rand/issues/1506))
- Add top-level fns `random_iter`, `random_range`, `random_bool`,
`random_ratio`, `fill`
([#&#8203;1488](https://redirect.github.com/rust-random/rand/issues/1488))
- Re-introduce fn `Rng::gen_iter` as `random_iter`
([#&#8203;1305](https://redirect.github.com/rust-random/rand/issues/1305),
[#&#8203;1500](https://redirect.github.com/rust-random/rand/issues/1500))
- Rename fn `Rng::gen` to `random` to avoid conflict with the new `gen`
keyword in Rust 2024
([#&#8203;1438](https://redirect.github.com/rust-random/rand/issues/1438))
- Rename fns `Rng::gen_range` to `random_range`, `gen_bool` to
`random_bool`, `gen_ratio` to `random_ratio`
([#&#8203;1505](https://redirect.github.com/rust-random/rand/issues/1505))
- Annotate panicking methods with `#[track_caller]`
([#&#8203;1442](https://redirect.github.com/rust-random/rand/issues/1442),
[#&#8203;1447](https://redirect.github.com/rust-random/rand/issues/1447))

##### API changes: RNGs

- Fix `<SmallRng as SeedableRng>::Seed` size to 256 bits
([#&#8203;1455](https://redirect.github.com/rust-random/rand/issues/1455))
- Remove first parameter (`rng`) of `ReseedingRng::new`
([#&#8203;1533](https://redirect.github.com/rust-random/rand/issues/1533))

##### API changes: Sequences

- Split trait `SliceRandom` into `IndexedRandom`, `IndexedMutRandom`,
`SliceRandom`
([#&#8203;1382](https://redirect.github.com/rust-random/rand/issues/1382))
- Add `IndexedRandom::choose_multiple_array`, `index::sample_array`
([#&#8203;1453](https://redirect.github.com/rust-random/rand/issues/1453),
[#&#8203;1469](https://redirect.github.com/rust-random/rand/issues/1469))

##### API changes: Distributions: renames

- Rename module `rand::distributions` to `rand::distr`
([#&#8203;1470](https://redirect.github.com/rust-random/rand/issues/1470))
- Rename distribution `Standard` to `StandardUniform`
([#&#8203;1526](https://redirect.github.com/rust-random/rand/issues/1526))
- Move `distr::Slice` -> `distr::slice::Choose`, `distr::EmptySlice` ->
`distr::slice::Empty`
([#&#8203;1548](https://redirect.github.com/rust-random/rand/issues/1548))
- Rename trait `distr::DistString` -> `distr::SampleString`
([#&#8203;1548](https://redirect.github.com/rust-random/rand/issues/1548))
- Rename `distr::DistIter` -> `distr::Iter`, `distr::DistMap` ->
`distr::Map`
([#&#8203;1548](https://redirect.github.com/rust-random/rand/issues/1548))

##### API changes: Distributions

- Relax `Sized` bound on `Distribution<T> for &D`
([#&#8203;1278](https://redirect.github.com/rust-random/rand/issues/1278))
- Remove impl of `Distribution<Option<T>>` for `StandardUniform`
([#&#8203;1526](https://redirect.github.com/rust-random/rand/issues/1526))
- Let distribution `StandardUniform` support all `NonZero*` types
([#&#8203;1332](https://redirect.github.com/rust-random/rand/issues/1332))
- Fns `{Uniform, UniformSampler}::{new, new_inclusive}` return a
`Result` (instead of potentially panicking)
([#&#8203;1229](https://redirect.github.com/rust-random/rand/issues/1229))
- Distribution `Uniform` implements `TryFrom` instead of `From` for
ranges
([#&#8203;1229](https://redirect.github.com/rust-random/rand/issues/1229))
- Add `UniformUsize`
([#&#8203;1487](https://redirect.github.com/rust-random/rand/issues/1487))
- Remove support for generating `isize` and `usize` values with
`StandardUniform`, `Uniform` (except via `UniformUsize`) and `Fill` and
usage as a `WeightedAliasIndex` weight
([#&#8203;1487](https://redirect.github.com/rust-random/rand/issues/1487))
- Add impl `DistString` for distributions `Slice<char>` and
`Uniform<char>`
([#&#8203;1315](https://redirect.github.com/rust-random/rand/issues/1315))
- Add fn `Slice::num_choices`
([#&#8203;1402](https://redirect.github.com/rust-random/rand/issues/1402))
- Add fn `p()` for distribution `Bernoulli` to access probability
([#&#8203;1481](https://redirect.github.com/rust-random/rand/issues/1481))

##### API changes: Weighted distributions

- Add `pub` module `rand::distr::weighted`, moving `WeightedIndex` there
([#&#8203;1548](https://redirect.github.com/rust-random/rand/issues/1548))
- Add trait `weighted::Weight`, allowing `WeightedIndex` to trap
overflow
([#&#8203;1353](https://redirect.github.com/rust-random/rand/issues/1353))
- Add fns `weight, weights, total_weight` to distribution
`WeightedIndex`
([#&#8203;1420](https://redirect.github.com/rust-random/rand/issues/1420))
- Rename enum `WeightedError` to `weighted::Error`, revising variants
([#&#8203;1382](https://redirect.github.com/rust-random/rand/issues/1382))
and mark as `#[non_exhaustive]`
([#&#8203;1480](https://redirect.github.com/rust-random/rand/issues/1480))

##### API changes: SIMD

- Switch to `std::simd`, expand SIMD & docs
([#&#8203;1239](https://redirect.github.com/rust-random/rand/issues/1239))

##### Reproducibility-breaking changes

- Make `ReseedingRng::reseed` discard remaining data from the last block
generated
([#&#8203;1379](https://redirect.github.com/rust-random/rand/issues/1379))
- Change fn `SmallRng::seed_from_u64` implementation
([#&#8203;1203](https://redirect.github.com/rust-random/rand/issues/1203))
- Allow `UniformFloat::new` samples and `UniformFloat::sample_single` to
yield `high`
([#&#8203;1462](https://redirect.github.com/rust-random/rand/issues/1462))
- Fix portability of distribution `Slice`
([#&#8203;1469](https://redirect.github.com/rust-random/rand/issues/1469))
- Make `Uniform` for `usize` portable via `UniformUsize`
([#&#8203;1487](https://redirect.github.com/rust-random/rand/issues/1487))
- Fix `IndexdRandom::choose_multiple_weighted` for very small seeds and
optimize for large input length / low memory
([#&#8203;1530](https://redirect.github.com/rust-random/rand/issues/1530))

##### Reproducibility-breaking optimisations

- Optimize fn `sample_floyd`, affecting output of
`rand::seq::index::sample` and `rand::seq::SliceRandom::choose_multiple`
([#&#8203;1277](https://redirect.github.com/rust-random/rand/issues/1277))
- New, faster algorithms for `IteratorRandom::choose` and
`choose_stable`
([#&#8203;1268](https://redirect.github.com/rust-random/rand/issues/1268))
- New, faster algorithms for `SliceRandom::shuffle` and
`partial_shuffle`
([#&#8203;1272](https://redirect.github.com/rust-random/rand/issues/1272))
- Optimize distribution `Uniform`: use Canon's method (single sampling)
/ Lemire's method (distribution sampling) for faster sampling (breaks
value stability;
[#&#8203;1287](https://redirect.github.com/rust-random/rand/issues/1287))
- Optimize fn `sample_single_inclusive` for floats (+~20% perf)
([#&#8203;1289](https://redirect.github.com/rust-random/rand/issues/1289))

##### Other optimisations

- Improve `SmallRng` initialization performance
([#&#8203;1482](https://redirect.github.com/rust-random/rand/issues/1482))
- Optimise SIMD widening multiply
([#&#8203;1247](https://redirect.github.com/rust-random/rand/issues/1247))

##### Other

- Add `Cargo.lock.msrv` file
([#&#8203;1275](https://redirect.github.com/rust-random/rand/issues/1275))
- Reformat with `rustfmt` and enforce
([#&#8203;1448](https://redirect.github.com/rust-random/rand/issues/1448))
- Apply Clippy suggestions and enforce
([#&#8203;1448](https://redirect.github.com/rust-random/rand/issues/1448),
[#&#8203;1474](https://redirect.github.com/rust-random/rand/issues/1474))
- Move all benchmarks to new `benches` crate
([#&#8203;1329](https://redirect.github.com/rust-random/rand/issues/1329),
[#&#8203;1439](https://redirect.github.com/rust-random/rand/issues/1439))
and migrate to Criterion
([#&#8203;1490](https://redirect.github.com/rust-random/rand/issues/1490))

##### Documentation

- Improve `ThreadRng` related docs
([#&#8203;1257](https://redirect.github.com/rust-random/rand/issues/1257))
- Docs: enable experimental `--generate-link-to-definition` feature
([#&#8203;1327](https://redirect.github.com/rust-random/rand/issues/1327))
- Better doc of crate features, use `doc_auto_cfg`
([#&#8203;1411](https://redirect.github.com/rust-random/rand/issues/1411),
[#&#8203;1450](https://redirect.github.com/rust-random/rand/issues/1450))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 5am on the first day of the
month" (UTC), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/rust-lang/cargo).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOS4xNDUuMCIsInVwZGF0ZWRJblZlciI6IjM5LjE0NS4wIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIiwibGFiZWxzIjpbXX0=-->
2025-02-03 22:19:09 +00:00
Ed Page
08055a443c refactor: Resolve deprecations 2025-02-03 15:07:36 -06:00
Weihang Lo
e79dae5bec
Revert "Conditionally mark the test cfg as a well known cfg (#15007)"
This reverts commit 26ce02737ae4b74a008355d302ef283375032cf6, reversing
changes made to 730d9977f1d0b6967f473d93f4034c6580d33a35.
2025-02-01 14:14:05 -05:00
Kornel
aa6c48ffea
Don't suggest cargo login for other credential providers 2025-01-30 13:39:10 +00:00
Kornel
8f12fe581a
Test login error with non-token provider 2025-01-30 13:38:58 +00:00
Ed Page
26ce02737a
Conditionally mark the test cfg as a well known cfg (#15007)
### What does this PR try to resolve?

This PR conditionally mark the `test` cfg as a well known cfg depending
on the target unit "test" field (ie `lib.test = false`, `[[bin]] test =
false` and others).

This is related to https://github.com/rust-lang/rust/issues/117778 and
https://users.rust-lang.org/t/cargo-what-is-the-purpose-of-lib-test-false/102361.

When defining `lib.test = false` (and others), any use of `cfg(test)`
will trigger the `unexpected_cfgs` lint.
```toml
[lib]
test = false  # will now warn on cfg(test)
```

### How should we test and review this PR?

Best reviewed commit by commit. Second commit removes the `test` cfg
from the `--check-cfg` args.

### Additional information

T-compiler
[MCP#785](https://github.com/rust-lang/compiler-team/issues/785) and
https://github.com/rust-lang/cargo/pull/14963 were of preparatory work.

r? @epage
2025-01-28 19:55:00 +00:00
Eric Huss
f71f565bbd
Fix shared_std_dependency_rebuild running on Windows (#15111)
This fixes the `standard_lib::shared_std_dependency_rebuild` test while
running on Windows. On my system, `CARGO_MANIFEST_DIR` is a normal
windows-style path (`D:\rust\cargo`) with backslashes. That is not valid
TOML syntax. I don't know why this doesn't fail on CI (maybe CI sets a
unix-style current dir?).
2025-01-28 03:39:35 +00:00
Eric Huss
f62525d31b
Fix warnings on Windows (#15112)
This fixes some warnings that show up on Windows:

```
warning: unused variable: `path`
    --> tests\testsuite\registry.rs:3146:24
     |
3146 |     fn set_permissions(path: &Path, permissions: u32) {
     |                        ^^^^ help: if this is intentional, prefix it with an underscore: `_path`
     |
     = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `permissions`
    --> tests\testsuite\registry.rs:3146:37
     |
3146 |     fn set_permissions(path: &Path, permissions: u32) {
     |                                     ^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_permissions`
```
2025-01-28 03:34:33 +00:00
Eric Huss
caff80d7f5 Fix shared_std_dependency_rebuild running on Windows 2025-01-27 19:06:22 -08:00
Eric Huss
e722344620 Fix warnings on Windows 2025-01-27 19:05:28 -08:00
Weihang Lo
9eda47ee04
fix(login): Deprecate CLI token (#15057)
### What does this PR try to resolve?

This came up in #13623 to avoid putting tokens into shell history.

### How should we test and review this PR?

The exact approach to deprecation can vary
- Include `<token>` in at least some docs for discovery (most likely the
man page)
- Don't warn yet

etc

I also suspect we could reorganize `cargo help login` but wanted to
decouple that from this change.

### Additional information
2025-01-28 02:53:08 +00:00
Eric Huss
c35cb56d32 Update tests to deal with linker warnings
Nightly recently introduced the `linker-messages` lint which prints any
messages from linkers. These tests were triggering that lint because
they were passing missing directories to the linker. This fixes it by
creating empty directories to pass to the linker.

Note that this lint will be downgraded soon via
https://github.com/rust-lang/rust/pull/136098, but it seemed worthwhile
to fix the underlying problem.

This also fixes a problem where build_script_needed_for_host_and_target
was not testing for the correct command-line flags. These got lost
in https://github.com/rust-lang/cargo/pull/14132.
2025-01-26 13:25:17 -08:00
Eric Huss
2c6338b856 Update test message for E0433
The text of the message was changed in https://github.com/rust-lang/rust/pull/133154
2025-01-26 12:43:34 -08:00
Weihang Lo
cecde95c11
Remove unused -C link-arg=-fuse-ld=lld (#15097)
That's a gcc flag. lld is a linker, not a C compiler, and doesn't accept
a `use-ld` flag. `-C linker=rust-lld` (which is already present in the
test) is enough.

This fixes the following warning found in rust-lang/rust#119286:
```
---- expected: tests\testsuite\freshness.rs:2822:27
++++ actual:   stderr
   1    1 | [FRESH] foo v0.1.0 ([ROOT]/foo)
        2 + [WARNING] linker stderr: rust-lld: ignoring unknown argument '-fuse-ld=lld'␍
        3 +   |
        4 +   = [NOTE] `#[warn(linker_messages)]` on by default
        5 +
        6 + [WARNING] `foo` (lib) generated 1 warning
   2    7 | [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
```

<!--
Thanks for submitting a pull request 🎉! Here are some tips for you:

* If this is your first contribution, read "Cargo Contribution Guide"
first:
  https://doc.crates.io/contrib/
* Run `cargo fmt --all` to format your code changes.
* Small commits and pull requests are always preferable and easy to
review.
* If your idea is large and needs feedback from the community, read how:
  https://doc.crates.io/contrib/process/#working-on-large-features
* Cargo takes care of compatibility. Read our design principles:
  https://doc.crates.io/contrib/design.html
* When changing help text of cargo commands, follow the steps to
generate docs:

https://github.com/rust-lang/cargo/tree/master/src/doc#building-the-man-pages
* If your PR is not finished, set it as "draft" PR or add "WIP" in its
title.
* It's ok to use the CI resources to test your PR, but please don't
abuse them.

### What does this PR try to resolve?

Explain the motivation behind this change.
A clear overview along with an in-depth explanation are helpful.

You can use `Fixes #<issue number>` to associate this PR to an existing
issue.

### How should we test and review this PR?

Demonstrate how you test this change and guide reviewers through your
PR.
With a smooth review process, a pull request usually gets reviewed
quicker.

If you don't know how to write and run your tests, please read the
guide:
https://doc.crates.io/contrib/tests

### Additional information

Other information you want to mention in this PR, such as prior arts,
future extensions, an unresolved problem, or a TODO list.
-->
2025-01-24 17:15:24 +00:00
jyn
00d4e3d1ad Remove unused -C link-arg=-fuse-ld=lld
That's a gcc flag. lld is a linker, not a C compiler, and doesn't accept
a `use-ld` flag. `-C linker` (which is already present in the test) is
enough.

This fixes the following warning found in rust-lang/rust#119286:
```
---- expected: tests\testsuite\freshness.rs:2822:27
++++ actual:   stderr
   1    1 | [FRESH] foo v0.1.0 ([ROOT]/foo)
        2 + [WARNING] linker stderr: rust-lld: ignoring unknown argument '-fuse-ld=lld'␍
        3 +   |
        4 +   = [NOTE] `#[warn(linker_messages)]` on by default
        5 +
        6 + [WARNING] `foo` (lib) generated 1 warning
   2    7 | [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
```
2025-01-24 11:44:49 -05:00
Kornel
9b3146432d Print globs when workspace members can't be found 2025-01-23 20:43:12 +00:00
Weihang Lo
53a2fdf0c0
Make --allow-dirty imply --allow-staged (#15013)
Staged changes don't really need protecting, and `--allow-dirty` is
stronger than `--allow-staged`, so it can imply `--allow-staged` to make
usage of `cargo fix` less verbose.

Closes #14176
2025-01-21 21:09:16 +00:00
Arlo Siemsen
99c57c02d7 fix(config): Don't merge unmergable config 2025-01-20 15:20:27 -06:00
Arlo Siemsen
1948c90a78 Show existing behavior 2025-01-20 14:34:08 -06:00
Weihang Lo
150bbc4d50
fix(publish): Report all unpublishable packages (#15070)
### What does this PR try to resolve?
I didn't extend this to multiple packages restricted to specific
registries.
It seems less likely to be a problem and more complex to gather and
report.

This was inspired by feedback left at #10948

### How should we test and review this PR?

### Additional information
2025-01-16 13:44:50 +00:00
Ed Page
1eafdb2656 fix(publish): Report all unpublishable packages
I didn't extend this to multiple packages restricted to specific
registries.
It seems less likely to be a problem and more complex to gather and
report.

This was inspired by feedback left at #10948
2025-01-15 20:24:52 -06:00
Ed Page
a282233ae4 test(publish): Check with multiple unpublishable packages 2025-01-15 20:23:19 -06:00
Weihang Lo
93c764d805 fix(build-std): parse as comma-separated list
Restore to the behavior prior to 30d11ce1d9f06907d1e707c4fe379ebf57305a5e
Also extend `build-std-features` to support comma-separated list.
2025-01-15 15:09:19 -08:00
Weihang Lo
ffe841c540 test: verify how build-std flag be deserialized now
It doesn't parse as comma-separated list.
It did before #14899
2025-01-15 15:09:19 -08:00
Ed Page
9bea071ff5 fix(login): Deprecate CLI token
This came up in #13623 to avoid putting tokens into shell history.
2025-01-13 10:40:13 -06:00
Weihang Lo
c518f225a9
feat: Added warning when failing to update index cache (#15014)
<!--
Thanks for submitting a pull request 🎉! Here are some tips for you:

* If this is your first contribution, read "Cargo Contribution Guide"
first:
  https://doc.crates.io/contrib/
* Run `cargo fmt --all` to format your code changes.
* Small commits and pull requests are always preferable and easy to
review.
* If your idea is large and needs feedback from the community, read how:
  https://doc.crates.io/contrib/process/#working-on-large-features
* Cargo takes care of compatibility. Read our design principles:
  https://doc.crates.io/contrib/design.html
* When changing help text of cargo commands, follow the steps to
generate docs:

https://github.com/rust-lang/cargo/tree/master/src/doc#building-the-man-pages
* If your PR is not finished, set it as "draft" PR or add "WIP" in its
title.
* It's ok to use the CI resources to test your PR, but please don't
abuse them.

### What does this PR try to resolve?

Explain the motivation behind this change.
A clear overview along with an in-depth explanation are helpful.

You can use `Fixes #<issue number>` to associate this PR to an existing
issue.

### How should we test and review this PR?

Demonstrate how you test this change and guide reviewers through your
PR.
With a smooth review process, a pull request usually gets reviewed
quicker.

If you don't know how to write and run your tests, please read the
guide:
https://doc.crates.io/contrib/tests

### Additional information

Other information you want to mention in this PR, such as prior arts,
future extensions, an unresolved problem, or a TODO list.
-->

### What does this PR try to resolve?

Fixes #13712

Adds a warning if there is an error updating the index cache.
It also attempts to avoid warning spam as requested in [this
comment](https://github.com/rust-lang/cargo/issues/13712#issuecomment-2514991597)

Below is an example output

```
    Updating crates.io index
warning: failed to write cache, path: /home/ross/.cargo/registry/index/index.crates.io-1949cf8c6b5b557f/.cache/ba/se/base64, error: Permission denied (os error 13)
   Compiling serde v1.0.217
   Compiling r-efi v5.2.0
   Compiling base64 v0.22.1
   Compiling cargo-13712 v0.1.0 (/home/ross/projects/cargo-13712)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 1.20s

```

### How should we test and review this PR?

I tested this on my machine by manually changing the owner/permission of
the index files
```sh
sudo chown root ~/.cargo/registry/index/.../.cache/r-
sudo chmod 700 ~/.cargo/registry/index/.../.cache/r-

# in a project that uses the `r-efi` crate
cargo build
```

I wasn't quiet sure about the best way to add a test to the testsuite
for this. 😅
If there is good way to create a test for this lmk
2025-01-10 15:54:06 +00:00
ranger-ross
1d9a0871fa
test: Added test to verify registry cache write error emit warnings 2025-01-10 23:57:13 +09:00
Urgau
b757af988b Add stderr checking for the conditional test well known cfg 2025-01-09 19:08:27 +01:00
Urgau
2593b86ee1 Conditionally mark the test cfg as a well known cfg 2025-01-09 19:08:27 +01:00
Weihang Lo
a4c0d39826
fix: emit warnings as warnings when learning rust target info (#15036)
### What does this PR try to resolve?

This is a horrible hack,
which lets the rustc invocation for learning target info always emit
warnings as warnings.
But at least it unblocks people who pass `-Awarnings` via RUSTFLAGS.

A long-term solution is a better interface
between build systems and the compiler.
See the discussion on Zulip:

https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Improving.20communication.20interface.20between.20cargo.2Frustc

Fixes rust-lang/cargo#8010

### How should we test and review this PR?

Ensure `CFG_DISABLE_CROSS_TESTS` is not set,
and run `cargo t --test testsuite
always_emit_warnings_as_warnings_when_learning_target_info`

This also additionally adds `wasm32-unknown-unknown` target to Cargo's
CI.

### Additional information
2025-01-08 23:37:05 +00:00
Weihang Lo
5e3558cf07
fix: emit warnings as warnings when learning rust target info
This is a horrible hack,
It lets the rustc invocation for learning target info always
emit warnings as warnings.
But at least it unblocks people who pass `-Awarnings` via RUSTFLAGS.

A long-term solution is a better interface
between build systems and the compiler.
See the discussion on Zulip:
https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Improving.20communication.20interface.20between.20cargo.2Frustc

Fixes rust-lang/cargo#8010
2025-01-08 17:27:25 -05:00
Weihang Lo
e57a2f43c2
test: show that -Awarnings fails target info probing
This will be resolved in the next commit
2025-01-08 17:27:25 -05:00
Weihang Lo
4a88f924c6
test: extract checking installed target to a function 2025-01-08 17:27:25 -05:00
Mara Bos
a9b50c201b Make "C" explicit in extern "C". 2025-01-08 18:14:15 +01:00
Ed Page
83615cfa78
Setup cargo environment for cargo rustc --print (#15026)
It turns out, running `cargo rustc --print cfg -Zunstable-options` (and
the like, https://github.com/rust-lang/cargo/issues/9357) fail with
`.cargo/config.toml` setups like
```toml
[build]
# custom target json that lives in `./targets/my-super-cool-target.json`
target = "my-super-cool-target"

[env]
RUST_TARGET_PATH = { value = "./targets", relative = true }
```
resulting in
```

❯ cargo rustc --print cfg -Zunstable-options
error: Error loading target specification: Could not find specification for target "my-super-cool-target". Run `rustc --print target-list` for a list of built-in targets

error: process didn't exit successfully: `C:\Users\lukas\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\bin\rustc.exe --target my-super-cool-target --print cfg` (exit code: 1)
```

The reason for that is that cargo recognizes the target from the
`.cargo/config` and then implicitly passes that along to the spawned
rustc process, but it does so without passing along the important
environment that is required for the target tuple to make sense.

(can add a test if desired, just tell me where)
2025-01-07 18:39:52 +00:00
Lukas Wirth
b7a0c9dc56 Setup cargo environment for cargo rustc --print 2025-01-07 18:57:54 +01:00
Lukas Wirth
cedab5d9fd Add test for cargo rustc --print cfg that relies on an env target 2025-01-07 18:57:03 +01:00
Eric Huss
506f409a2e Fix https::self_signed_should_fail for macos
This no longer generates the same error message for the same reason that
it changed for linux in https://github.com/rust-lang/cargo/pull/13970.

Note that Windows does things slightly differently, and doesn't need
adjustment.
2025-01-04 11:19:35 -08:00
Kornel
973cd5338e
Update autogenerated files 2025-01-04 14:37:39 +00:00
Urgau
208f817c83 Add preparatory tests for lib.test = false check-cfg changes 2025-01-04 13:42:59 +01:00
Kornel
22690a3236
Make --allow-dirty imply --allow-staged 2025-01-04 00:25:41 +00:00
Ed Page
2438807048 test(git): Be consistent on shallow test names 2024-12-18 15:44:01 -06:00
Ed Page
e0f8cc06da test(git): Group related shallow tests 2024-12-18 15:44:01 -06:00
Ed Page
a739b00f30 test(git): Clarify we are doing shallow fetches 2024-12-18 15:44:01 -06:00
Ed Page
adf25782e0 test(git): Extract CLI arg creation 2024-12-18 15:43:59 -06:00
Ed Page
cade73a7a0 test(git): Make test backend clearer 2024-12-18 15:43:31 -06:00
Ed Page
4e3e353978 test(git): Reduce duplication in shallow test 2024-12-18 11:57:16 -06:00
Ed Page
1c82fe420e test(git): Prefer check over build for faster tests
If check passes, it should be sufficient.
2024-12-18 11:49:51 -06:00
Ed Page
4cc7ff5ab5 test(git): Fix masquerade feature list for shallow fetch 2024-12-18 11:32:54 -06:00
Ed Page
89b89bde65 test(git): Clarify test parameter 2024-12-18 11:32:53 -06:00