Skip to content

Commit 319f529

Browse files
committed
Auto merge of rust-lang#135059 - matthiaskrgr:rollup-0ka9o3h, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - rust-lang#131729 (Make the `test` cfg a userspace check-cfg) - rust-lang#134241 (more concrete source url of std docs [V2]) - rust-lang#135042 (taint fcx on selection errors during unsizing) - rust-lang#135049 (Remove unused fields from RepeatElementCopy obligation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ac00fe8 + 0053aa4 commit 319f529

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+200
-106
lines changed

compiler/rustc_hir_typeck/src/coercion.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,12 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
666666

667667
// Dyn-compatibility violations or miscellaneous.
668668
Err(err) => {
669-
self.err_ctxt().report_selection_error(obligation.clone(), &obligation, &err);
669+
let guar = self.err_ctxt().report_selection_error(
670+
obligation.clone(),
671+
&obligation,
672+
&err,
673+
);
674+
self.fcx.set_tainted_by_errors(guar);
670675
// Treat this like an obligation and follow through
671676
// with the unsizing - the lack of a coercion should
672677
// be silent, as it causes a type mismatch later.

compiler/rustc_hir_typeck/src/expr.rs

+2-15
Original file line numberDiff line numberDiff line change
@@ -1907,21 +1907,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
19071907
};
19081908

19091909
let lang_item = self.tcx.require_lang_item(LangItem::Copy, None);
1910-
let code = traits::ObligationCauseCode::RepeatElementCopy {
1911-
is_constable,
1912-
elt_type: element_ty,
1913-
elt_span: element.span,
1914-
elt_stmt_span: self
1915-
.tcx
1916-
.hir()
1917-
.parent_iter(element.hir_id)
1918-
.find_map(|(_, node)| match node {
1919-
hir::Node::Item(it) => Some(it.span),
1920-
hir::Node::Stmt(stmt) => Some(stmt.span),
1921-
_ => None,
1922-
})
1923-
.expect("array repeat expressions must be inside an item or statement"),
1924-
};
1910+
let code =
1911+
traits::ObligationCauseCode::RepeatElementCopy { is_constable, elt_span: element.span };
19251912
self.require_type_meets(element_ty, element.span, code, lang_item);
19261913
}
19271914

compiler/rustc_middle/src/traits/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,11 @@ pub enum ObligationCauseCode<'tcx> {
247247
/// If element is a `const fn` or const ctor we display a help message suggesting
248248
/// to move it to a new `const` item while saying that `T` doesn't implement `Copy`.
249249
is_constable: IsConstable,
250-
elt_type: Ty<'tcx>,
250+
251+
/// Span of the repeat element.
252+
///
253+
/// This is used to suggest wrapping it in a `const { ... }` block.
251254
elt_span: Span,
252-
/// Span of the statement/item in which the repeat expression occurs. We can use this to
253-
/// place a `const` declaration before it
254-
elt_stmt_span: Span,
255255
},
256256

257257
/// Types of fields (other than the last, except for packed structs) in a struct must be sized.

compiler/rustc_session/src/config/cfg.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ impl CheckCfg {
332332
// Note that symbols inserted conditionally in `default_configuration`
333333
// are inserted unconditionally here.
334334
//
335+
// One exception is the `test` cfg which is consider to be a "user-space"
336+
// cfg, despite being also set by in `default_configuration` above.
337+
// It allows the build system to "deny" using the config by not marking it
338+
// as expected (e.g. `lib.test = false` for Cargo).
339+
//
335340
// When adding a new config here you should also update
336341
// `tests/ui/check-cfg/well-known-values.rs` (in order to test the
337342
// expected values of the new config) and bless the all directory.
@@ -453,8 +458,6 @@ impl CheckCfg {
453458

454459
ins!(sym::target_thread_local, no_values);
455460

456-
ins!(sym::test, no_values);
457-
458461
ins!(sym::ub_checks, no_values);
459462

460463
ins!(sym::unix, no_values);

compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -2966,12 +2966,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
29662966
"required for the cast from `{source}` to `{target}`",
29672967
)));
29682968
}
2969-
ObligationCauseCode::RepeatElementCopy {
2970-
is_constable,
2971-
elt_type: _,
2972-
elt_span,
2973-
elt_stmt_span: _,
2974-
} => {
2969+
ObligationCauseCode::RepeatElementCopy { is_constable, elt_span } => {
29752970
err.note(
29762971
"the `Copy` trait is required because this value will be copied for each element of the array",
29772972
);

library/std/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
//! Check out the Rust contribution guidelines [here](
9090
//! https://rustc-dev-guide.rust-lang.org/contributing.html#writing-documentation).
9191
//! The source for this documentation can be found on
92-
//! [GitHub](https://github.com/rust-lang/rust).
92+
//! [GitHub](https://github.com/rust-lang/rust) in the 'library/std/' directory.
9393
//! To contribute changes, make sure you read the guidelines first, then submit
9494
//! pull-requests for your suggested changes.
9595
//!

src/bootstrap/src/core/builder/cargo.rs

+2
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,8 @@ impl Builder<'_> {
624624
// get warnings about it being unexpected.
625625
hostflags.arg("-Zunstable-options");
626626
hostflags.arg("--check-cfg=cfg(bootstrap)");
627+
// #[cfg(bootstrap)] as we are transition `test` to userspace cfg
628+
hostflags.arg("--check-cfg=cfg(test)");
627629

628630
// FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
629631
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See

src/bootstrap/src/lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ const LLD_FILE_NAMES: &[&str] = &["ld.lld", "ld64.lld", "lld-link", "wasm-ld"];
7777
#[allow(clippy::type_complexity)] // It's fine for hard-coded list and type is explained above.
7878
const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
7979
(None, "bootstrap", None),
80+
// #[cfg(bootstrap)] to be removed when Cargo is updated
81+
(None, "test", None),
8082
(Some(Mode::Rustc), "llvm_enzyme", None),
8183
(Some(Mode::Codegen), "llvm_enzyme", None),
8284
(Some(Mode::ToolRustc), "llvm_enzyme", None),

src/doc/rustc/src/check-cfg.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ the need to specify them manually.
9999
Well known names and values are implicitly added as long as at least one `--check-cfg` argument
100100
is present.
101101
102-
As of `2024-08-20T`, the list of known names is as follows:
102+
As of `2025-01-02T`, the list of known names is as follows:
103103
104104
<!--- See CheckCfg::fill_well_known in compiler/rustc_session/src/config.rs -->
105105
@@ -130,11 +130,13 @@ As of `2024-08-20T`, the list of known names is as follows:
130130
- `target_pointer_width`
131131
- `target_thread_local`
132132
- `target_vendor`
133-
- `test`
134133
- `ub_checks`
135134
- `unix`
136135
- `windows`
137136
137+
> Starting with CURRENT_RUSTC_VERSION, the `test` cfg is consider to be a "userspace" config
138+
> despite being also set by `rustc` and should be managed by the build-system it-self.
139+
138140
Like with `values(any())`, well known names checking can be disabled by passing `cfg(any())`
139141
as argument to `--check-cfg`.
140142

src/tools/compiletest/src/runtest.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,9 @@ impl<'test> TestCx<'test> {
506506
// Generate `cfg(FALSE, REV1, ..., REVN)` (for all possible revisions)
507507
//
508508
// For compatibility reason we consider the `FALSE` cfg to be expected
509-
// since it is extensively used in the testsuite.
510-
check_cfg.push_str("cfg(FALSE");
509+
// since it is extensively used in the testsuite, as well as the `test`
510+
// cfg since we have tests that uses it.
511+
check_cfg.push_str("cfg(test,FALSE");
511512
for revision in &self.props.revisions {
512513
check_cfg.push(',');
513514
check_cfg.push_str(&normalize_revision(revision));

tests/crashes/130521.rs

-13
This file was deleted.

tests/ui/check-cfg/allow-same-level.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `FALSE`
44
LL | #[cfg(FALSE)]
55
| ^^^^^
66
|
7-
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
7+
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `ub_checks`, `unix`, and `windows`
88
= help: to expect this configuration use `--check-cfg=cfg(FALSE)`
99
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
1010
= note: `#[warn(unexpected_cfgs)]` on by default

tests/ui/check-cfg/cargo-build-script.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `has_foo`
44
LL | #[cfg(has_foo)]
55
| ^^^^^^^
66
|
7-
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `has_bar`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
7+
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `has_bar`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `ub_checks`, `unix`, and `windows`
88
= help: consider using a Cargo feature instead
99
= help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
1010
[lints.rust]

tests/ui/check-cfg/cargo-feature.none.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable`
2525
LL | #[cfg(tokio_unstable)]
2626
| ^^^^^^^^^^^^^^
2727
|
28-
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
28+
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `ub_checks`, `unix`, and `windows`
2929
= help: consider using a Cargo feature instead
3030
= help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
3131
[lints.rust]

tests/ui/check-cfg/cargo-feature.some.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable`
2525
LL | #[cfg(tokio_unstable)]
2626
| ^^^^^^^^^^^^^^
2727
|
28-
= help: expected names are: `CONFIG_NVME`, `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
28+
= help: expected names are: `CONFIG_NVME`, `clippy`, `debug_assertions`, `doc`, `doctest`, `feature`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `ub_checks`, `unix`, and `windows`
2929
= help: consider using a Cargo feature instead
3030
= help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint:
3131
[lints.rust]

tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `value`
44
LL | #[cfg(value)]
55
| ^^^^^
66
|
7-
= help: expected names are: `bar`, `bee`, `clippy`, `cow`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `foo`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
7+
= help: expected names are: `bar`, `bee`, `clippy`, `cow`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `foo`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `ub_checks`, `unix`, and `windows`
88
= help: to expect this configuration use `--check-cfg=cfg(value)`
99
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
1010
= note: `#[warn(unexpected_cfgs)]` on by default

tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_value`
44
LL | #[cfg(my_value)]
55
| ^^^^^^^^
66
|
7-
= help: expected names are: `bar`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `foo`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
7+
= help: expected names are: `bar`, `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `foo`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `ub_checks`, `unix`, and `windows`
88
= help: to expect this configuration use `--check-cfg=cfg(my_value)`
99
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
1010
= note: `#[warn(unexpected_cfgs)]` on by default

tests/ui/check-cfg/cfg-value-for-cfg-name.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `linux`
44
LL | #[cfg(linux)]
55
| ^^^^^ help: found config with similar value: `target_os = "linux"`
66
|
7-
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
7+
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `ub_checks`, `unix`, and `windows`
88
= help: to expect this configuration use `--check-cfg=cfg(linux)`
99
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
1010
= note: `#[warn(unexpected_cfgs)]` on by default

tests/ui/check-cfg/compact-names.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `target_architecture`
44
LL | #[cfg(target(os = "linux", architecture = "arm"))]
55
| ^^^^^^^^^^^^^^^^^^^^
66
|
7-
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `test`, `ub_checks`, `unix`, and `windows`
7+
= help: expected names are: `clippy`, `debug_assertions`, `doc`, `doctest`, `fmt_debug`, `miri`, `overflow_checks`, `panic`, `proc_macro`, `relocation_model`, `rustfmt`, `sanitize`, `sanitizer_cfi_generalize_pointers`, `sanitizer_cfi_normalize_integers`, `target_abi`, `target_arch`, `target_endian`, `target_env`, `target_family`, `target_feature`, `target_has_atomic`, `target_has_atomic_equal_alignment`, `target_has_atomic_load_store`, `target_os`, `target_pointer_width`, `target_thread_local`, `target_vendor`, `ub_checks`, `unix`, and `windows`
88
= help: to expect this configuration use `--check-cfg=cfg(target_architecture, values("arm"))`
99
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
1010
= note: `#[warn(unexpected_cfgs)]` on by default

0 commit comments

Comments
 (0)