mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 11:48:30 +00:00
Auto merge of #94673 - matthiaskrgr:rollup-2tnifg9, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #93412 (Improve rustdoc const bounds) - #94617 (Update `itertools`) - #94669 (Update -Z unpretty error message) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
a64180f67f
39
Cargo.lock
39
Cargo.lock
@ -337,7 +337,7 @@ dependencies = [
|
|||||||
"humantime 2.0.1",
|
"humantime 2.0.1",
|
||||||
"ignore",
|
"ignore",
|
||||||
"im-rc",
|
"im-rc",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lazycell",
|
"lazycell",
|
||||||
@ -442,7 +442,7 @@ dependencies = [
|
|||||||
"flate2",
|
"flate2",
|
||||||
"git2",
|
"git2",
|
||||||
"glob",
|
"glob",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"remove_dir_all",
|
"remove_dir_all",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@ -560,7 +560,7 @@ dependencies = [
|
|||||||
"chalk-ir",
|
"chalk-ir",
|
||||||
"ena",
|
"ena",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"petgraph",
|
"petgraph",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"tracing",
|
"tracing",
|
||||||
@ -624,7 +624,7 @@ dependencies = [
|
|||||||
"filetime",
|
"filetime",
|
||||||
"futures 0.3.19",
|
"futures 0.3.19",
|
||||||
"if_chain",
|
"if_chain",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"num_cpus",
|
"num_cpus",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"quote",
|
"quote",
|
||||||
@ -647,7 +647,7 @@ dependencies = [
|
|||||||
"cargo_metadata",
|
"cargo_metadata",
|
||||||
"clap 2.34.0",
|
"clap 2.34.0",
|
||||||
"indoc",
|
"indoc",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"opener",
|
"opener",
|
||||||
"regex",
|
"regex",
|
||||||
"shell-escape",
|
"shell-escape",
|
||||||
@ -661,7 +661,7 @@ dependencies = [
|
|||||||
"cargo_metadata",
|
"cargo_metadata",
|
||||||
"clippy_utils",
|
"clippy_utils",
|
||||||
"if_chain",
|
"if_chain",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"pulldown-cmark",
|
"pulldown-cmark",
|
||||||
"quine-mc_cluskey",
|
"quine-mc_cluskey",
|
||||||
"regex-syntax",
|
"regex-syntax",
|
||||||
@ -1783,15 +1783,6 @@ dependencies = [
|
|||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "itertools"
|
|
||||||
version = "0.9.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b"
|
|
||||||
dependencies = [
|
|
||||||
"either",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itertools"
|
name = "itertools"
|
||||||
version = "0.10.1"
|
version = "0.10.1"
|
||||||
@ -3138,7 +3129,7 @@ dependencies = [
|
|||||||
"futures 0.3.19",
|
"futures 0.3.19",
|
||||||
"heck",
|
"heck",
|
||||||
"home",
|
"home",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"jsonrpc-core",
|
"jsonrpc-core",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
@ -3180,7 +3171,7 @@ dependencies = [
|
|||||||
"derive-new",
|
"derive-new",
|
||||||
"env_logger 0.9.0",
|
"env_logger 0.9.0",
|
||||||
"fst",
|
"fst",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"json",
|
"json",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
@ -3411,7 +3402,7 @@ dependencies = [
|
|||||||
name = "rustc_ast_passes"
|
name = "rustc_ast_passes"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"rustc_ast",
|
"rustc_ast",
|
||||||
"rustc_ast_pretty",
|
"rustc_ast_pretty",
|
||||||
"rustc_attr",
|
"rustc_attr",
|
||||||
@ -3454,7 +3445,7 @@ name = "rustc_borrowck"
|
|||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"either",
|
"either",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"polonius-engine",
|
"polonius-engine",
|
||||||
"rustc_const_eval",
|
"rustc_const_eval",
|
||||||
"rustc_data_structures",
|
"rustc_data_structures",
|
||||||
@ -3536,7 +3527,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cc",
|
"cc",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"libc",
|
"libc",
|
||||||
"object 0.28.1",
|
"object 0.28.1",
|
||||||
@ -4019,7 +4010,7 @@ name = "rustc_mir_transform"
|
|||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"coverage_test_macros",
|
"coverage_test_macros",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"rustc_ast",
|
"rustc_ast",
|
||||||
"rustc_attr",
|
"rustc_attr",
|
||||||
"rustc_const_eval",
|
"rustc_const_eval",
|
||||||
@ -4419,7 +4410,7 @@ dependencies = [
|
|||||||
"askama",
|
"askama",
|
||||||
"atty",
|
"atty",
|
||||||
"expect-test",
|
"expect-test",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"minifier",
|
"minifier",
|
||||||
"pulldown-cmark",
|
"pulldown-cmark",
|
||||||
"rayon",
|
"rayon",
|
||||||
@ -4501,7 +4492,7 @@ dependencies = [
|
|||||||
"env_logger 0.8.4",
|
"env_logger 0.8.4",
|
||||||
"getopts",
|
"getopts",
|
||||||
"ignore",
|
"ignore",
|
||||||
"itertools 0.9.0",
|
"itertools",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"regex",
|
"regex",
|
||||||
@ -5181,7 +5172,7 @@ checksum = "744e9ed5b352340aa47ce033716991b5589e23781acb97cad37d4ea70560f55b"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"combine",
|
"combine",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itertools 0.10.1",
|
"itertools",
|
||||||
"kstring",
|
"kstring",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
@ -4,7 +4,7 @@ version = "0.0.0"
|
|||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
itertools = "0.10"
|
itertools = "0.10.1"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
|
rustc_ast_pretty = { path = "../rustc_ast_pretty" }
|
||||||
rustc_attr = { path = "../rustc_attr" }
|
rustc_attr = { path = "../rustc_attr" }
|
||||||
|
@ -8,7 +8,7 @@ doctest = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
either = "1.5.0"
|
either = "1.5.0"
|
||||||
itertools = "0.10"
|
itertools = "0.10.1"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
polonius-engine = "0.13.0"
|
polonius-engine = "0.13.0"
|
||||||
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
|
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
|
||||||
|
@ -9,7 +9,7 @@ test = false
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.2.1"
|
bitflags = "1.2.1"
|
||||||
cc = "1.0.69"
|
cc = "1.0.69"
|
||||||
itertools = "0.10"
|
itertools = "0.10.1"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
libc = "0.2.50"
|
libc = "0.2.50"
|
||||||
jobserver = "0.1.22"
|
jobserver = "0.1.22"
|
||||||
|
@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
itertools = "0.10"
|
itertools = "0.10.1"
|
||||||
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
|
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
rustc_ast = { path = "../rustc_ast" }
|
rustc_ast = { path = "../rustc_ast" }
|
||||||
|
@ -2628,11 +2628,10 @@ fn parse_pretty(debugging_opts: &DebuggingOptions, efmt: ErrorOutputType) -> Opt
|
|||||||
name => early_error(
|
name => early_error(
|
||||||
efmt,
|
efmt,
|
||||||
&format!(
|
&format!(
|
||||||
"argument to `unpretty` must be one of `normal`, \
|
"argument to `unpretty` must be one of `normal`, `identified`, \
|
||||||
`expanded`, `identified`, `expanded,identified`, \
|
`expanded`, `expanded,identified`, `expanded,hygiene`, \
|
||||||
`expanded,hygiene`, `everybody_loops`, \
|
|
||||||
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
|
`ast-tree`, `ast-tree,expanded`, `hir`, `hir,identified`, \
|
||||||
`hir,typed`, `hir-tree`, `mir` or `mir-cfg`; got {}",
|
`hir,typed`, `hir-tree`, `thir-tree`, `mir` or `mir-cfg`; got {}",
|
||||||
name
|
name
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -17,7 +17,7 @@ serde = { version = "1.0", features = ["derive"] }
|
|||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
smallvec = "1.6.1"
|
smallvec = "1.6.1"
|
||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
itertools = "0.10"
|
itertools = "0.10.1"
|
||||||
regex = "1"
|
regex = "1"
|
||||||
rustdoc-json-types = { path = "../rustdoc-json-types" }
|
rustdoc-json-types = { path = "../rustdoc-json-types" }
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
|
@ -143,11 +143,14 @@ impl Buffer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn comma_sep<T: fmt::Display>(items: impl Iterator<Item = T>) -> impl fmt::Display {
|
fn comma_sep<T: fmt::Display>(
|
||||||
|
items: impl Iterator<Item = T>,
|
||||||
|
space_after_comma: bool,
|
||||||
|
) -> impl fmt::Display {
|
||||||
display_fn(move |f| {
|
display_fn(move |f| {
|
||||||
for (i, item) in items.enumerate() {
|
for (i, item) in items.enumerate() {
|
||||||
if i != 0 {
|
if i != 0 {
|
||||||
write!(f, ", ")?;
|
write!(f, ",{}", if space_after_comma { " " } else { "" })?;
|
||||||
}
|
}
|
||||||
fmt::Display::fmt(&item, f)?;
|
fmt::Display::fmt(&item, f)?;
|
||||||
}
|
}
|
||||||
@ -248,9 +251,9 @@ impl clean::Generics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
write!(f, "<{:#}>", comma_sep(real_params.map(|g| g.print(cx))))
|
write!(f, "<{:#}>", comma_sep(real_params.map(|g| g.print(cx)), true))
|
||||||
} else {
|
} else {
|
||||||
write!(f, "<{}>", comma_sep(real_params.map(|g| g.print(cx))))
|
write!(f, "<{}>", comma_sep(real_params.map(|g| g.print(cx)), true))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -266,10 +269,80 @@ crate fn print_where_clause<'a, 'tcx: 'a>(
|
|||||||
end_newline: bool,
|
end_newline: bool,
|
||||||
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
) -> impl fmt::Display + 'a + Captures<'tcx> {
|
||||||
display_fn(move |f| {
|
display_fn(move |f| {
|
||||||
if gens.where_predicates.is_empty() {
|
let mut where_predicates = gens.where_predicates.iter().filter(|pred| {
|
||||||
|
!matches!(pred, clean::WherePredicate::BoundPredicate { bounds, .. } if bounds.is_empty())
|
||||||
|
}).map(|pred| {
|
||||||
|
display_fn(move |f| {
|
||||||
|
if f.alternate() {
|
||||||
|
f.write_str(" ")?;
|
||||||
|
} else {
|
||||||
|
f.write_str("<br>")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
match pred {
|
||||||
|
clean::WherePredicate::BoundPredicate { ty, bounds, bound_params } => {
|
||||||
|
let bounds = bounds;
|
||||||
|
let for_prefix = if bound_params.is_empty() {
|
||||||
|
String::new()
|
||||||
|
} else if f.alternate() {
|
||||||
|
format!(
|
||||||
|
"for<{:#}> ",
|
||||||
|
comma_sep(bound_params.iter().map(|lt| lt.print()), true)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
format!(
|
||||||
|
"for<{}> ",
|
||||||
|
comma_sep(bound_params.iter().map(|lt| lt.print()), true)
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
if f.alternate() {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"{}{:#}: {:#}",
|
||||||
|
for_prefix,
|
||||||
|
ty.print(cx),
|
||||||
|
print_generic_bounds(bounds, cx)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"{}{}: {}",
|
||||||
|
for_prefix,
|
||||||
|
ty.print(cx),
|
||||||
|
print_generic_bounds(bounds, cx)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clean::WherePredicate::RegionPredicate { lifetime, bounds } => {
|
||||||
|
write!(
|
||||||
|
f,
|
||||||
|
"{}: {}",
|
||||||
|
lifetime.print(),
|
||||||
|
bounds
|
||||||
|
.iter()
|
||||||
|
.map(|b| b.print(cx).to_string())
|
||||||
|
.collect::<Vec<_>>()
|
||||||
|
.join(" + ")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
clean::WherePredicate::EqPredicate { lhs, rhs } => {
|
||||||
|
if f.alternate() {
|
||||||
|
write!(f, "{:#} == {:#}", lhs.print(cx), rhs.print(cx),)
|
||||||
|
} else {
|
||||||
|
write!(f, "{} == {}", lhs.print(cx), rhs.print(cx),)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}).peekable();
|
||||||
|
|
||||||
|
if where_predicates.peek().is_none() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut clause = String::new();
|
let mut clause = String::new();
|
||||||
|
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
clause.push_str(" where");
|
clause.push_str(" where");
|
||||||
} else {
|
} else {
|
||||||
@ -279,72 +352,11 @@ crate fn print_where_clause<'a, 'tcx: 'a>(
|
|||||||
clause.push_str(" <span class=\"where\">where");
|
clause.push_str(" <span class=\"where\">where");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (i, pred) in gens.where_predicates.iter().enumerate() {
|
|
||||||
if f.alternate() {
|
|
||||||
clause.push(' ');
|
|
||||||
} else {
|
|
||||||
clause.push_str("<br>");
|
|
||||||
}
|
|
||||||
|
|
||||||
match pred {
|
clause.push_str(&comma_sep(where_predicates, false).to_string());
|
||||||
clean::WherePredicate::BoundPredicate { ty, bounds, bound_params } => {
|
|
||||||
let bounds = bounds;
|
|
||||||
let for_prefix = match bound_params.len() {
|
|
||||||
0 => String::new(),
|
|
||||||
_ if f.alternate() => {
|
|
||||||
format!(
|
|
||||||
"for<{:#}> ",
|
|
||||||
comma_sep(bound_params.iter().map(|lt| lt.print()))
|
|
||||||
)
|
|
||||||
}
|
|
||||||
_ => format!(
|
|
||||||
"for<{}> ",
|
|
||||||
comma_sep(bound_params.iter().map(|lt| lt.print()))
|
|
||||||
),
|
|
||||||
};
|
|
||||||
|
|
||||||
if f.alternate() {
|
|
||||||
clause.push_str(&format!(
|
|
||||||
"{}{:#}: {:#}",
|
|
||||||
for_prefix,
|
|
||||||
ty.print(cx),
|
|
||||||
print_generic_bounds(bounds, cx)
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
clause.push_str(&format!(
|
|
||||||
"{}{}: {}",
|
|
||||||
for_prefix,
|
|
||||||
ty.print(cx),
|
|
||||||
print_generic_bounds(bounds, cx)
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
clean::WherePredicate::RegionPredicate { lifetime, bounds } => {
|
|
||||||
clause.push_str(&format!(
|
|
||||||
"{}: {}",
|
|
||||||
lifetime.print(),
|
|
||||||
bounds
|
|
||||||
.iter()
|
|
||||||
.map(|b| b.print(cx).to_string())
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.join(" + ")
|
|
||||||
));
|
|
||||||
}
|
|
||||||
clean::WherePredicate::EqPredicate { lhs, rhs } => {
|
|
||||||
if f.alternate() {
|
|
||||||
clause.push_str(&format!("{:#} == {:#}", lhs.print(cx), rhs.print(cx),));
|
|
||||||
} else {
|
|
||||||
clause.push_str(&format!("{} == {}", lhs.print(cx), rhs.print(cx),));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if i < gens.where_predicates.len() - 1 || end_newline {
|
|
||||||
clause.push(',');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if end_newline {
|
if end_newline {
|
||||||
|
clause.push(',');
|
||||||
// add a space so stripping <br> tags and breaking spaces still renders properly
|
// add a space so stripping <br> tags and breaking spaces still renders properly
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
clause.push(' ');
|
clause.push(' ');
|
||||||
@ -394,13 +406,13 @@ impl clean::PolyTrait {
|
|||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"for<{:#}> ",
|
"for<{:#}> ",
|
||||||
comma_sep(self.generic_params.iter().map(|g| g.print(cx)))
|
comma_sep(self.generic_params.iter().map(|g| g.print(cx)), true)
|
||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"for<{}> ",
|
"for<{}> ",
|
||||||
comma_sep(self.generic_params.iter().map(|g| g.print(cx)))
|
comma_sep(self.generic_params.iter().map(|g| g.print(cx)), true)
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -424,7 +436,8 @@ impl clean::GenericBound {
|
|||||||
let modifier_str = match modifier {
|
let modifier_str = match modifier {
|
||||||
hir::TraitBoundModifier::None => "",
|
hir::TraitBoundModifier::None => "",
|
||||||
hir::TraitBoundModifier::Maybe => "?",
|
hir::TraitBoundModifier::Maybe => "?",
|
||||||
hir::TraitBoundModifier::MaybeConst => "~const",
|
// ~const is experimental; do not display those bounds in rustdoc
|
||||||
|
hir::TraitBoundModifier::MaybeConst => "",
|
||||||
};
|
};
|
||||||
if f.alternate() {
|
if f.alternate() {
|
||||||
write!(f, "{}{:#}", modifier_str, ty.print(cx))
|
write!(f, "{}{:#}", modifier_str, ty.print(cx))
|
||||||
@ -1111,7 +1124,7 @@ impl clean::BareFunctionDecl {
|
|||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
"for<{}> ",
|
"for<{}> ",
|
||||||
comma_sep(self.generic_params.iter().map(|g| g.print(cx)))
|
comma_sep(self.generic_params.iter().map(|g| g.print(cx)), true)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
// make sure that `ConstEvaluatable` predicates dont cause rustdoc to ICE #77647
|
// make sure that `ConstEvaluatable` predicates dont cause rustdoc to ICE #77647
|
||||||
// @has foo/struct.Ice.html '//pre[@class="rust struct"]' \
|
// @has foo/struct.Ice.html '//pre[@class="rust struct"]' \
|
||||||
// 'pub struct Ice<const N: usize> where [(); N + 1]: ;'
|
// 'pub struct Ice<const N: usize>;'
|
||||||
pub struct Ice<const N: usize> where [(); N + 1]:;
|
pub struct Ice<const N: usize> where [(); N + 1]:;
|
||||||
|
60
src/test/rustdoc/rfc-2632-const-trait-impl.rs
Normal file
60
src/test/rustdoc/rfc-2632-const-trait-impl.rs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// Test that we do not currently display `~const` in rustdoc
|
||||||
|
// as that syntax is currently provisional; `~const Drop` has
|
||||||
|
// no effect on stable code so it should be hidden as well.
|
||||||
|
//
|
||||||
|
// To future blessers: make sure that `const_trait_impl` is
|
||||||
|
// stabilized when changing `@!has` to `@has`, and please do
|
||||||
|
// not remove this test.
|
||||||
|
#![feature(const_trait_impl)]
|
||||||
|
#![crate_name = "foo"]
|
||||||
|
|
||||||
|
pub struct S<T>(T);
|
||||||
|
|
||||||
|
// @!has foo/trait.Tr.html '//pre[@class="rust trait"]/code/a[@class="trait"]' '~const'
|
||||||
|
// @!has - '//pre[@class="rust trait"]/code/a[@class="trait"]' 'Drop'
|
||||||
|
// @has - '//pre[@class="rust trait"]/code/a[@class="trait"]' 'Clone'
|
||||||
|
// @!has - '//pre[@class="rust trait"]/code/span[@class="where"]' '~const'
|
||||||
|
// @!has - '//pre[@class="rust trait"]/code/span[@class="where"]' 'Drop'
|
||||||
|
// @has - '//pre[@class="rust trait"]/code/span[@class="where"]' ': Clone'
|
||||||
|
pub trait Tr<T> {
|
||||||
|
// @!has - '//div[@id="method.a"]/h4[@class="code-header"]' '~const'
|
||||||
|
// @!has - '//div[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Drop'
|
||||||
|
// @has - '//div[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone'
|
||||||
|
// @!has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const'
|
||||||
|
// @!has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' 'Drop'
|
||||||
|
// @has - '//div[@id="method.a"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
|
||||||
|
#[default_method_body_is_const]
|
||||||
|
fn a<A: ~const Drop + ~const Clone>() where Option<A>: ~const Drop + ~const Clone {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @!has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]' '~const'
|
||||||
|
// @!has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/a[@class="trait"]' 'Drop'
|
||||||
|
// @has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/a[@class="trait"]' 'Clone'
|
||||||
|
// @!has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/span[@class="where"]' '~const'
|
||||||
|
// @!has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/span[@class="where fmt-newline"]' 'Drop'
|
||||||
|
// @has - '//section[@id="impl-Tr%3CT%3E"]/h3[@class="code-header in-band"]/span[@class="where fmt-newline"]' ': Clone'
|
||||||
|
impl<T: ~const Drop + ~const Clone> const Tr<T> for T where Option<T>: ~const Drop + ~const Clone {
|
||||||
|
fn a<A: ~const Drop + ~const Clone>() where Option<A>: ~const Drop + ~const Clone {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// @!has foo/fn.foo.html '//pre[@class="rust fn"]/code/a[@class="trait"]' '~const'
|
||||||
|
// @!has - '//pre[@class="rust fn"]/code/a[@class="trait"]' 'Drop'
|
||||||
|
// @has - '//pre[@class="rust fn"]/code/a[@class="trait"]' 'Clone'
|
||||||
|
// @!has - '//pre[@class="rust fn"]/code/span[@class="where fmt-newline"]' '~const'
|
||||||
|
// @!has - '//pre[@class="rust fn"]/code/span[@class="where fmt-newline"]' 'Drop'
|
||||||
|
// @has - '//pre[@class="rust fn"]/code/span[@class="where fmt-newline"]' ': Clone'
|
||||||
|
pub const fn foo<F: ~const Drop + ~const Clone>() where Option<F>: ~const Drop + ~const Clone {
|
||||||
|
F::a()
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> S<T> {
|
||||||
|
// @!has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const'
|
||||||
|
// @!has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Drop'
|
||||||
|
// @has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Clone'
|
||||||
|
// @!has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const'
|
||||||
|
// @!has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' 'Drop'
|
||||||
|
// @has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where fmt-newline"]' ': Clone'
|
||||||
|
pub const fn foo<B: ~const Drop + ~const Clone>() where B: ~const Drop + ~const Clone {
|
||||||
|
B::a()
|
||||||
|
}
|
||||||
|
}
|
@ -43,7 +43,7 @@ rustc-workspace-hack = "1.0"
|
|||||||
clippy_utils = { path = "clippy_utils" }
|
clippy_utils = { path = "clippy_utils" }
|
||||||
derive-new = "0.5"
|
derive-new = "0.5"
|
||||||
if_chain = "1.0"
|
if_chain = "1.0"
|
||||||
itertools = "0.10"
|
itertools = "0.10.1"
|
||||||
quote = "1.0"
|
quote = "1.0"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
syn = { version = "1.0", features = ["full"] }
|
syn = { version = "1.0", features = ["full"] }
|
||||||
|
@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
bytecount = "0.6"
|
bytecount = "0.6"
|
||||||
clap = "2.33"
|
clap = "2.33"
|
||||||
indoc = "1.0"
|
indoc = "1.0"
|
||||||
itertools = "0.10"
|
itertools = "0.10.1"
|
||||||
opener = "0.5"
|
opener = "0.5"
|
||||||
regex = "1.5"
|
regex = "1.5"
|
||||||
shell-escape = "0.1"
|
shell-escape = "0.1"
|
||||||
|
@ -12,7 +12,7 @@ edition = "2021"
|
|||||||
cargo_metadata = "0.14"
|
cargo_metadata = "0.14"
|
||||||
clippy_utils = { path = "../clippy_utils" }
|
clippy_utils = { path = "../clippy_utils" }
|
||||||
if_chain = "1.0"
|
if_chain = "1.0"
|
||||||
itertools = "0.10"
|
itertools = "0.10.1"
|
||||||
pulldown-cmark = { version = "0.9", default-features = false }
|
pulldown-cmark = { version = "0.9", default-features = false }
|
||||||
quine-mc_cluskey = "0.2"
|
quine-mc_cluskey = "0.2"
|
||||||
regex-syntax = "0.6"
|
regex-syntax = "0.6"
|
||||||
|
@ -33,7 +33,7 @@ rustfmt-format-diff = []
|
|||||||
generic-simd = ["bytecount/generic-simd"]
|
generic-simd = ["bytecount/generic-simd"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
itertools = "0.9"
|
itertools = "0.10.1"
|
||||||
toml = "0.5"
|
toml = "0.5"
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
Loading…
Reference in New Issue
Block a user