Skip to content

Commit 3802025

Browse files
committed
Auto merge of #90516 - matthiaskrgr:rollup-3dmfjkj, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #90084 (Make printed message match the code comment) - #90354 (Document clippy on nightly-rustc) - #90417 (stabilize `relaxed_struct_unsize`) - #90472 (Clarify what to do with accepted feature gates) - #90500 (Update Clippy dependencies) - #90502 (Split doc_cfg and doc_auto_cfg features) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6f40fa4 + e38844a commit 3802025

File tree

19 files changed

+59
-83
lines changed

19 files changed

+59
-83
lines changed

Cargo.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ dependencies = [
576576
name = "clippy"
577577
version = "0.1.58"
578578
dependencies = [
579-
"cargo_metadata 0.12.0",
579+
"cargo_metadata 0.14.0",
580580
"clippy_lints",
581581
"clippy_utils",
582582
"compiletest_rs",
@@ -588,7 +588,7 @@ dependencies = [
588588
"regex",
589589
"rustc-workspace-hack",
590590
"rustc_tools_util 0.2.0",
591-
"semver 0.11.0",
591+
"semver 1.0.3",
592592
"serde",
593593
"syn",
594594
"tempfile",
@@ -613,15 +613,15 @@ dependencies = [
613613
name = "clippy_lints"
614614
version = "0.1.58"
615615
dependencies = [
616-
"cargo_metadata 0.12.0",
616+
"cargo_metadata 0.14.0",
617617
"clippy_utils",
618618
"if_chain",
619619
"itertools 0.10.1",
620620
"pulldown-cmark 0.8.0",
621621
"quine-mc_cluskey",
622622
"regex-syntax",
623623
"rustc-semver",
624-
"semver 0.11.0",
624+
"semver 1.0.3",
625625
"serde",
626626
"serde_json",
627627
"toml",

compiler/rustc_feature/src/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ declare_features! (
297297
(accepted, macro_attributes_in_derive_output, "1.57.0", Some(81119), None),
298298
/// Allows panicking during const eval (producing compile-time errors).
299299
(accepted, const_panic, "1.57.0", Some(51999), None),
300+
/// Lessens the requirements for structs to implement `Unsize`.
301+
(accepted, relaxed_struct_unsize, "1.58.0", Some(81793), None),
300302

301303
// -------------------------------------------------------------------------
302304
// feature-group-end: accepted features

compiler/rustc_feature/src/active.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,13 @@ impl Feature {
101101
}
102102
}
103103

104+
// See https://rustc-dev-guide.rust-lang.org/feature-gates.html#feature-gates for more
105+
// documentation about handling feature gates.
106+
//
104107
// If you change this, please modify `src/doc/unstable-book` as well.
105108
//
106-
// Don't ever remove anything from this list; move them to `removed.rs`.
109+
// Don't ever remove anything from this list; move them to `accepted.rs` if
110+
// accepted or `removed.rs` if removed.
107111
//
108112
// The version numbers here correspond to the version in which the current status
109113
// was set. This is most important for knowing when a particular feature became
@@ -589,9 +593,6 @@ declare_features! (
589593
/// Allows `extern "C-cmse-nonsecure-call" fn()`.
590594
(active, abi_c_cmse_nonsecure_call, "1.51.0", Some(81391), None),
591595

592-
/// Lessens the requirements for structs to implement `Unsize`.
593-
(active, relaxed_struct_unsize, "1.51.0", Some(81793), None),
594-
595596
/// Allows associated types in inherent impls.
596597
(incomplete, inherent_associated_types, "1.52.0", Some(8995), None),
597598

@@ -688,6 +689,9 @@ declare_features! (
688689
/// not changed from prior instances of the same struct (RFC #2528)
689690
(incomplete, type_changing_struct_update, "1.58.0", Some(86555), None),
690691

692+
/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
693+
(active, doc_auto_cfg, "1.58.0", Some(43781), None),
694+
691695
// -------------------------------------------------------------------------
692696
// feature-group-end: actual feature gates
693697
// -------------------------------------------------------------------------

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ symbols! {
549549
div_assign,
550550
doc,
551551
doc_alias,
552+
doc_auto_cfg,
552553
doc_cfg,
553554
doc_cfg_hide,
554555
doc_keyword,

compiler/rustc_trait_selection/src/traits/select/confirmation.rs

+12-40
Original file line numberDiff line numberDiff line change
@@ -948,52 +948,24 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
948948
let tail_field_ty = tcx.type_of(tail_field.did);
949949

950950
let mut unsizing_params = GrowableBitSet::new_empty();
951-
if tcx.features().relaxed_struct_unsize {
952-
for arg in tail_field_ty.walk(tcx) {
953-
if let Some(i) = maybe_unsizing_param_idx(arg) {
954-
unsizing_params.insert(i);
955-
}
956-
}
957-
958-
// Ensure none of the other fields mention the parameters used
959-
// in unsizing.
960-
for field in prefix_fields {
961-
for arg in tcx.type_of(field.did).walk(tcx) {
962-
if let Some(i) = maybe_unsizing_param_idx(arg) {
963-
unsizing_params.remove(i);
964-
}
965-
}
951+
for arg in tail_field_ty.walk(tcx) {
952+
if let Some(i) = maybe_unsizing_param_idx(arg) {
953+
unsizing_params.insert(i);
966954
}
955+
}
967956

968-
if unsizing_params.is_empty() {
969-
return Err(Unimplemented);
970-
}
971-
} else {
972-
let mut found = false;
973-
for arg in tail_field_ty.walk(tcx) {
957+
// Ensure none of the other fields mention the parameters used
958+
// in unsizing.
959+
for field in prefix_fields {
960+
for arg in tcx.type_of(field.did).walk(tcx) {
974961
if let Some(i) = maybe_unsizing_param_idx(arg) {
975-
unsizing_params.insert(i);
976-
found = true;
962+
unsizing_params.remove(i);
977963
}
978964
}
979-
if !found {
980-
return Err(Unimplemented);
981-
}
965+
}
982966

983-
// Ensure none of the other fields mention the parameters used
984-
// in unsizing.
985-
// FIXME(eddyb) cache this (including computing `unsizing_params`)
986-
// by putting it in a query; it would only need the `DefId` as it
987-
// looks at declared field types, not anything substituted.
988-
for field in prefix_fields {
989-
for arg in tcx.type_of(field.did).walk(tcx) {
990-
if let Some(i) = maybe_unsizing_param_idx(arg) {
991-
if unsizing_params.contains(i) {
992-
return Err(Unimplemented);
993-
}
994-
}
995-
}
996-
}
967+
if unsizing_params.is_empty() {
968+
return Err(Unimplemented);
997969
}
998970

999971
// Extract `TailField<T>` and `TailField<U>` from `Struct<T>` and `Struct<U>`.

src/bootstrap/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ impl<'a> Builder<'a> {
482482
doc::RustByExample,
483483
doc::RustcBook,
484484
doc::CargoBook,
485+
doc::Clippy,
485486
doc::EmbeddedBook,
486487
doc::EditionGuide,
487488
),

src/bootstrap/doc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ tool_doc!(
755755
"src/tools/rustfmt",
756756
["rustfmt-nightly", "rustfmt-config_proc_macro"],
757757
);
758+
tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"]);
758759

759760
#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)]
760761
pub struct ErrorIndex {

src/doc/unstable-book/src/library-features/asm.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ unsafe {
257257
}
258258
259259
println!(
260-
"L1 Cache: {}",
260+
"L0 Cache: {}",
261261
((ebx >> 22) + 1) * (((ebx >> 12) & 0x3ff) + 1) * ((ebx & 0xfff) + 1) * (ecx + 1)
262262
);
263263
```

src/librustdoc/clean/types.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,7 @@ impl AttributesExt for [ast::Attribute] {
789789
fn cfg(&self, tcx: TyCtxt<'_>, hidden_cfg: &FxHashSet<Cfg>) -> Option<Arc<Cfg>> {
790790
let sess = tcx.sess;
791791
let doc_cfg_active = tcx.features().doc_cfg;
792+
let doc_auto_cfg_active = tcx.features().doc_auto_cfg;
792793

793794
fn single<T: IntoIterator>(it: T) -> Option<T::Item> {
794795
let mut iter = it.into_iter();
@@ -799,24 +800,26 @@ impl AttributesExt for [ast::Attribute] {
799800
Some(item)
800801
}
801802

802-
let mut cfg = if doc_cfg_active {
803+
let mut cfg = if doc_cfg_active || doc_auto_cfg_active {
803804
let mut doc_cfg = self
804805
.iter()
805806
.filter(|attr| attr.has_name(sym::doc))
806807
.flat_map(|attr| attr.meta_item_list().unwrap_or_else(Vec::new))
807808
.filter(|attr| attr.has_name(sym::cfg))
808809
.peekable();
809-
if doc_cfg.peek().is_some() {
810+
if doc_cfg.peek().is_some() && doc_cfg_active {
810811
doc_cfg
811812
.filter_map(|attr| Cfg::parse(attr.meta_item()?).ok())
812813
.fold(Cfg::True, |cfg, new_cfg| cfg & new_cfg)
813-
} else {
814+
} else if doc_auto_cfg_active {
814815
self.iter()
815816
.filter(|attr| attr.has_name(sym::cfg))
816817
.filter_map(|attr| single(attr.meta_item_list()?))
817818
.filter_map(|attr| Cfg::parse(attr.meta_item()?).ok())
818819
.filter(|cfg| !hidden_cfg.contains(cfg))
819820
.fold(Cfg::True, |cfg, new_cfg| cfg & new_cfg)
821+
} else {
822+
Cfg::True
820823
}
821824
} else {
822825
Cfg::True

src/test/rustdoc/doc-auto-cfg.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(doc_auto_cfg)]
2+
3+
#![crate_name = "foo"]
4+
5+
// @has foo/fn.foo.html
6+
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'non-test'
7+
#[cfg(not(test))]
8+
pub fn foo() {}

src/test/rustdoc/doc-cfg-hide.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "oud"]
2-
#![feature(doc_cfg, doc_cfg_hide)]
2+
#![feature(doc_auto_cfg, doc_cfg, doc_cfg_hide)]
33

44
#![doc(cfg_hide(feature = "solecism"))]
55

src/test/rustdoc/doc-cfg-implicit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![crate_name = "funambulism"]
2-
#![feature(doc_cfg)]
2+
#![feature(doc_auto_cfg, doc_cfg)]
33

44
// @has 'funambulism/struct.Disorbed.html'
55
// @count - '//*[@class="stab portability"]' 1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(doc_cfg)]
2+
3+
#![crate_name = "foo"]
4+
5+
// @has foo/fn.foo.html
6+
// @count - '//*[@class="item-info"]/*[@class="stab portability"]' 0
7+
#[cfg(not(test))]
8+
pub fn foo() {}

src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.rs

-10
This file was deleted.

src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.stderr

-14
This file was deleted.

src/test/ui/unsized/unchanged-param.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(relaxed_struct_unsize)]
21
// run-pass
32
// Test that we allow unsizing even if there is an unchanged param in the
43
// field getting unsized.

src/tools/clippy/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ path = "src/driver.rs"
2222

2323
[dependencies]
2424
clippy_lints = { version = "0.1", path = "clippy_lints" }
25-
semver = "0.11"
25+
semver = "1.0"
2626
rustc_tools_util = { version = "0.2", path = "rustc_tools_util" }
2727
tempfile = { version = "3.2", optional = true }
2828

2929
[dev-dependencies]
30-
cargo_metadata = "0.12"
30+
cargo_metadata = "0.14"
3131
compiletest_rs = { version = "0.7", features = ["tmp"] }
3232
tester = "0.9"
3333
regex = "1.5"

src/tools/clippy/clippy_lints/Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ keywords = ["clippy", "lint", "plugin"]
99
edition = "2021"
1010

1111
[dependencies]
12-
cargo_metadata = "0.12"
12+
cargo_metadata = "0.14"
1313
clippy_utils = { path = "../clippy_utils" }
1414
if_chain = "1.0"
1515
itertools = "0.10"
@@ -21,7 +21,7 @@ serde_json = { version = "1.0", optional = true }
2121
toml = "0.5"
2222
unicode-normalization = "0.1"
2323
unicode-script = { version = "0.5", default-features = false }
24-
semver = "0.11"
24+
semver = "1.0"
2525
rustc-semver = "1.1"
2626
# NOTE: cargo requires serde feat in its url dep
2727
# see <https://github.com/rust-lang/rust/pull/63587#issuecomment-522343864>

src/tools/tidy/src/features.rs

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ pub fn check(
9797
&src_path.join("test/ui"),
9898
&src_path.join("test/ui-fulldeps"),
9999
&src_path.join("test/rustdoc-ui"),
100+
&src_path.join("test/rustdoc"),
100101
],
101102
&mut |path| super::filter_dirs(path),
102103
&mut |entry, contents| {

0 commit comments

Comments
 (0)