Skip to content

Commit

Permalink
Auto merge of #90516 - matthiaskrgr:rollup-3dmfjkj, r=matthiaskrgr
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Nov 3, 2021
2 parents 6f40fa4 + e38844a commit 3802025
Show file tree
Hide file tree
Showing 19 changed files with 59 additions and 83 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ dependencies = [
name = "clippy"
version = "0.1.58"
dependencies = [
"cargo_metadata 0.12.0",
"cargo_metadata 0.14.0",
"clippy_lints",
"clippy_utils",
"compiletest_rs",
Expand All @@ -588,7 +588,7 @@ dependencies = [
"regex",
"rustc-workspace-hack",
"rustc_tools_util 0.2.0",
"semver 0.11.0",
"semver 1.0.3",
"serde",
"syn",
"tempfile",
Expand All @@ -613,15 +613,15 @@ dependencies = [
name = "clippy_lints"
version = "0.1.58"
dependencies = [
"cargo_metadata 0.12.0",
"cargo_metadata 0.14.0",
"clippy_utils",
"if_chain",
"itertools 0.10.1",
"pulldown-cmark 0.8.0",
"quine-mc_cluskey",
"regex-syntax",
"rustc-semver",
"semver 0.11.0",
"semver 1.0.3",
"serde",
"serde_json",
"toml",
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ declare_features! (
(accepted, macro_attributes_in_derive_output, "1.57.0", Some(81119), None),
/// Allows panicking during const eval (producing compile-time errors).
(accepted, const_panic, "1.57.0", Some(51999), None),
/// Lessens the requirements for structs to implement `Unsize`.
(accepted, relaxed_struct_unsize, "1.58.0", Some(81793), None),

// -------------------------------------------------------------------------
// feature-group-end: accepted features
Expand Down
12 changes: 8 additions & 4 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ impl Feature {
}
}

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

/// Lessens the requirements for structs to implement `Unsize`.
(active, relaxed_struct_unsize, "1.51.0", Some(81793), None),

/// Allows associated types in inherent impls.
(incomplete, inherent_associated_types, "1.52.0", Some(8995), None),

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

/// Tells rustdoc to automatically generate `#[doc(cfg(...))]`.
(active, doc_auto_cfg, "1.58.0", Some(43781), None),

// -------------------------------------------------------------------------
// feature-group-end: actual feature gates
// -------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ symbols! {
div_assign,
doc,
doc_alias,
doc_auto_cfg,
doc_cfg,
doc_cfg_hide,
doc_keyword,
Expand Down
52 changes: 12 additions & 40 deletions compiler/rustc_trait_selection/src/traits/select/confirmation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -948,52 +948,24 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let tail_field_ty = tcx.type_of(tail_field.did);

let mut unsizing_params = GrowableBitSet::new_empty();
if tcx.features().relaxed_struct_unsize {
for arg in tail_field_ty.walk(tcx) {
if let Some(i) = maybe_unsizing_param_idx(arg) {
unsizing_params.insert(i);
}
}

// Ensure none of the other fields mention the parameters used
// in unsizing.
for field in prefix_fields {
for arg in tcx.type_of(field.did).walk(tcx) {
if let Some(i) = maybe_unsizing_param_idx(arg) {
unsizing_params.remove(i);
}
}
for arg in tail_field_ty.walk(tcx) {
if let Some(i) = maybe_unsizing_param_idx(arg) {
unsizing_params.insert(i);
}
}

if unsizing_params.is_empty() {
return Err(Unimplemented);
}
} else {
let mut found = false;
for arg in tail_field_ty.walk(tcx) {
// Ensure none of the other fields mention the parameters used
// in unsizing.
for field in prefix_fields {
for arg in tcx.type_of(field.did).walk(tcx) {
if let Some(i) = maybe_unsizing_param_idx(arg) {
unsizing_params.insert(i);
found = true;
unsizing_params.remove(i);
}
}
if !found {
return Err(Unimplemented);
}
}

// Ensure none of the other fields mention the parameters used
// in unsizing.
// FIXME(eddyb) cache this (including computing `unsizing_params`)
// by putting it in a query; it would only need the `DefId` as it
// looks at declared field types, not anything substituted.
for field in prefix_fields {
for arg in tcx.type_of(field.did).walk(tcx) {
if let Some(i) = maybe_unsizing_param_idx(arg) {
if unsizing_params.contains(i) {
return Err(Unimplemented);
}
}
}
}
if unsizing_params.is_empty() {
return Err(Unimplemented);
}

// Extract `TailField<T>` and `TailField<U>` from `Struct<T>` and `Struct<U>`.
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ impl<'a> Builder<'a> {
doc::RustByExample,
doc::RustcBook,
doc::CargoBook,
doc::Clippy,
doc::EmbeddedBook,
doc::EditionGuide,
),
Expand Down
1 change: 1 addition & 0 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ tool_doc!(
"src/tools/rustfmt",
["rustfmt-nightly", "rustfmt-config_proc_macro"],
);
tool_doc!(Clippy, "clippy", "src/tools/clippy", ["clippy_utils"]);

#[derive(Ord, PartialOrd, Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct ErrorIndex {
Expand Down
2 changes: 1 addition & 1 deletion src/doc/unstable-book/src/library-features/asm.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ unsafe {
}
println!(
"L1 Cache: {}",
"L0 Cache: {}",
((ebx >> 22) + 1) * (((ebx >> 12) & 0x3ff) + 1) * ((ebx & 0xfff) + 1) * (ecx + 1)
);
```
Expand Down
9 changes: 6 additions & 3 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,7 @@ impl AttributesExt for [ast::Attribute] {
fn cfg(&self, tcx: TyCtxt<'_>, hidden_cfg: &FxHashSet<Cfg>) -> Option<Arc<Cfg>> {
let sess = tcx.sess;
let doc_cfg_active = tcx.features().doc_cfg;
let doc_auto_cfg_active = tcx.features().doc_auto_cfg;

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

let mut cfg = if doc_cfg_active {
let mut cfg = if doc_cfg_active || doc_auto_cfg_active {
let mut doc_cfg = self
.iter()
.filter(|attr| attr.has_name(sym::doc))
.flat_map(|attr| attr.meta_item_list().unwrap_or_else(Vec::new))
.filter(|attr| attr.has_name(sym::cfg))
.peekable();
if doc_cfg.peek().is_some() {
if doc_cfg.peek().is_some() && doc_cfg_active {
doc_cfg
.filter_map(|attr| Cfg::parse(attr.meta_item()?).ok())
.fold(Cfg::True, |cfg, new_cfg| cfg & new_cfg)
} else {
} else if doc_auto_cfg_active {
self.iter()
.filter(|attr| attr.has_name(sym::cfg))
.filter_map(|attr| single(attr.meta_item_list()?))
.filter_map(|attr| Cfg::parse(attr.meta_item()?).ok())
.filter(|cfg| !hidden_cfg.contains(cfg))
.fold(Cfg::True, |cfg, new_cfg| cfg & new_cfg)
} else {
Cfg::True
}
} else {
Cfg::True
Expand Down
8 changes: 8 additions & 0 deletions src/test/rustdoc/doc-auto-cfg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![feature(doc_auto_cfg)]

#![crate_name = "foo"]

// @has foo/fn.foo.html
// @has - '//*[@class="item-info"]/*[@class="stab portability"]' 'non-test'
#[cfg(not(test))]
pub fn foo() {}
2 changes: 1 addition & 1 deletion src/test/rustdoc/doc-cfg-hide.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![crate_name = "oud"]
#![feature(doc_cfg, doc_cfg_hide)]
#![feature(doc_auto_cfg, doc_cfg, doc_cfg_hide)]

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

Expand Down
2 changes: 1 addition & 1 deletion src/test/rustdoc/doc-cfg-implicit.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![crate_name = "funambulism"]
#![feature(doc_cfg)]
#![feature(doc_auto_cfg, doc_cfg)]

// @has 'funambulism/struct.Disorbed.html'
// @count - '//*[@class="stab portability"]' 1
Expand Down
8 changes: 8 additions & 0 deletions src/test/rustdoc/feature-gate-doc_auto_cfg.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![feature(doc_cfg)]

#![crate_name = "foo"]

// @has foo/fn.foo.html
// @count - '//*[@class="item-info"]/*[@class="stab portability"]' 0
#[cfg(not(test))]
pub fn foo() {}
10 changes: 0 additions & 10 deletions src/test/ui/feature-gates/feature-gate-relaxed_struct_unsize.rs

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/test/ui/unsized/unchanged-param.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![feature(relaxed_struct_unsize)]
// run-pass
// Test that we allow unsizing even if there is an unchanged param in the
// field getting unsized.
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ path = "src/driver.rs"

[dependencies]
clippy_lints = { version = "0.1", path = "clippy_lints" }
semver = "0.11"
semver = "1.0"
rustc_tools_util = { version = "0.2", path = "rustc_tools_util" }
tempfile = { version = "3.2", optional = true }

[dev-dependencies]
cargo_metadata = "0.12"
cargo_metadata = "0.14"
compiletest_rs = { version = "0.7", features = ["tmp"] }
tester = "0.9"
regex = "1.5"
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/clippy_lints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ keywords = ["clippy", "lint", "plugin"]
edition = "2021"

[dependencies]
cargo_metadata = "0.12"
cargo_metadata = "0.14"
clippy_utils = { path = "../clippy_utils" }
if_chain = "1.0"
itertools = "0.10"
Expand All @@ -21,7 +21,7 @@ serde_json = { version = "1.0", optional = true }
toml = "0.5"
unicode-normalization = "0.1"
unicode-script = { version = "0.5", default-features = false }
semver = "0.11"
semver = "1.0"
rustc-semver = "1.1"
# NOTE: cargo requires serde feat in its url dep
# see <https://github.com/rust-lang/rust/pull/63587#issuecomment-522343864>
Expand Down
1 change: 1 addition & 0 deletions src/tools/tidy/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub fn check(
&src_path.join("test/ui"),
&src_path.join("test/ui-fulldeps"),
&src_path.join("test/rustdoc-ui"),
&src_path.join("test/rustdoc"),
],
&mut |path| super::filter_dirs(path),
&mut |entry, contents| {
Expand Down

0 comments on commit 3802025

Please sign in to comment.