Skip to content

Commit 76a04dd

Browse files
committed
Auto merge of rust-lang#84644 - JohnTitor:rollup-nzq9rjz, r=JohnTitor
Rollup of 5 pull requests Successful merges: - rust-lang#84529 (Improve coverage spans for chained function calls) - rust-lang#84616 (Fix empty dom toggle) - rust-lang#84622 (Make traits with GATs not object safe) - rust-lang#84624 (Make sentence in env::args_os' docs plain and simple) - rust-lang#84642 (Stabilize vec_extend_from_within) Failed merges: - rust-lang#84636 (rustdoc: change aliases attribute to data-aliases) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 855c2d1 + 7ebe5b9 commit 76a04dd

File tree

26 files changed

+499
-136
lines changed

26 files changed

+499
-136
lines changed

compiler/rustc_middle/src/traits/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,9 @@ pub enum ObjectSafetyViolation {
670670

671671
/// Associated const.
672672
AssocConst(Symbol, Span),
673+
674+
/// GAT
675+
GAT(Symbol, Span),
673676
}
674677

675678
impl ObjectSafetyViolation {
@@ -715,6 +718,9 @@ impl ObjectSafetyViolation {
715718
format!("it contains associated `const` `{}`", name).into()
716719
}
717720
ObjectSafetyViolation::AssocConst(..) => "it contains this associated `const`".into(),
721+
ObjectSafetyViolation::GAT(name, _) => {
722+
format!("it contains the generic associated type `{}`", name).into()
723+
}
718724
}
719725
}
720726

@@ -773,6 +779,7 @@ impl ObjectSafetyViolation {
773779
);
774780
}
775781
ObjectSafetyViolation::AssocConst(name, _)
782+
| ObjectSafetyViolation::GAT(name, _)
776783
| ObjectSafetyViolation::Method(name, ..) => {
777784
err.help(&format!("consider moving `{}` to another trait", name));
778785
}
@@ -786,6 +793,7 @@ impl ObjectSafetyViolation {
786793
ObjectSafetyViolation::SupertraitSelf(spans)
787794
| ObjectSafetyViolation::SizedSelf(spans) => spans.clone(),
788795
ObjectSafetyViolation::AssocConst(_, span)
796+
| ObjectSafetyViolation::GAT(_, span)
789797
| ObjectSafetyViolation::Method(_, _, span)
790798
if *span != DUMMY_SP =>
791799
{

compiler/rustc_mir/src/transform/coverage/spans.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -717,11 +717,21 @@ pub(super) fn filtered_terminator_span(
717717
| TerminatorKind::FalseEdge { .. }
718718
| TerminatorKind::Goto { .. } => None,
719719

720+
// Call `func` operand can have a more specific span when part of a chain of calls
721+
| TerminatorKind::Call { ref func, .. } => {
722+
let mut span = terminator.source_info.span;
723+
if let mir::Operand::Constant(box constant) = func {
724+
if constant.span.lo() > span.lo() {
725+
span = span.with_lo(constant.span.lo());
726+
}
727+
}
728+
Some(function_source_span(span, body_span))
729+
}
730+
720731
// Retain spans from all other terminators
721732
TerminatorKind::Resume
722733
| TerminatorKind::Abort
723734
| TerminatorKind::Return
724-
| TerminatorKind::Call { .. }
725735
| TerminatorKind::Yield { .. }
726736
| TerminatorKind::GeneratorDrop
727737
| TerminatorKind::FalseUnwind { .. }

compiler/rustc_trait_selection/src/traits/object_safety.rs

+8
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ fn object_safety_violations_for_trait(
132132
.map(|item| ObjectSafetyViolation::AssocConst(item.ident.name, item.ident.span)),
133133
);
134134

135+
violations.extend(
136+
tcx.associated_items(trait_def_id)
137+
.in_definition_order()
138+
.filter(|item| item.kind == ty::AssocKind::Type)
139+
.filter(|item| !tcx.generics_of(item.def_id).params.is_empty())
140+
.map(|item| ObjectSafetyViolation::GAT(item.ident.name, item.ident.span)),
141+
);
142+
135143
debug!(
136144
"object_safety_violations_for_trait(trait_def_id={:?}) = {:?}",
137145
trait_def_id, violations

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -462,12 +462,11 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
462462

463463
for assoc_type in assoc_types {
464464
if !tcx.generics_of(assoc_type).params.is_empty() {
465-
// FIXME(generic_associated_types) generate placeholders to
466-
// extend the trait substs.
467-
tcx.sess.span_fatal(
465+
tcx.sess.delay_span_bug(
468466
obligation.cause.span,
469-
"generic associated types in trait objects are not supported yet",
467+
"GATs in trait object shouldn't have been considered",
470468
);
469+
return Err(SelectionError::Unimplemented);
471470
}
472471
// This maybe belongs in wf, but that can't (doesn't) handle
473472
// higher-ranked things.

library/alloc/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
#![cfg_attr(test, feature(test))]
7777
#![cfg_attr(test, feature(new_uninit))]
7878
#![feature(allocator_api)]
79-
#![feature(vec_extend_from_within)]
8079
#![feature(array_chunks)]
8180
#![feature(array_methods)]
8281
#![feature(array_windows)]

library/alloc/src/vec/mod.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2124,8 +2124,6 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
21242124
/// ## Examples
21252125
///
21262126
/// ```
2127-
/// #![feature(vec_extend_from_within)]
2128-
///
21292127
/// let mut vec = vec![0, 1, 2, 3, 4];
21302128
///
21312129
/// vec.extend_from_within(2..);
@@ -2137,7 +2135,7 @@ impl<T: Clone, A: Allocator> Vec<T, A> {
21372135
/// vec.extend_from_within(4..8);
21382136
/// assert_eq!(vec, [0, 1, 2, 3, 4, 2, 3, 4, 0, 1, 4, 2, 3, 4]);
21392137
/// ```
2140-
#[unstable(feature = "vec_extend_from_within", issue = "81656")]
2138+
#[stable(feature = "vec_extend_from_within", since = "1.53.0")]
21412139
pub fn extend_from_within<R>(&mut self, src: R)
21422140
where
21432141
R: RangeBounds<usize>,

library/alloc/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#![feature(vecdeque_binary_search)]
2121
#![feature(slice_group_by)]
2222
#![feature(slice_partition_dedup)]
23-
#![feature(vec_extend_from_within)]
2423
#![feature(vec_spare_capacity)]
2524
#![feature(string_remove_matches)]
2625

library/std/src/env.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ pub fn args() -> Args {
752752
/// does on macOS and Windows.
753753
///
754754
/// Note that the returned iterator will not check if the arguments to the
755-
/// process are valid Unicode. To ensure UTF-8 validity,
755+
/// process are valid Unicode. If you want to panic on invalid UTF-8,
756756
/// use the [`args`] function instead.
757757
///
758758
/// # Examples

src/librustdoc/html/format.rs

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ impl Buffer {
8282
self.buffer.push_str(s);
8383
}
8484

85+
crate fn push_buffer(&mut self, other: Buffer) {
86+
self.buffer.push_str(&other.buffer);
87+
}
88+
8589
// Intended for consumption by write! and writeln! (std::fmt) but without
8690
// the fmt::Result return type imposed by fmt::Write (and avoiding the trait
8791
// import).

src/librustdoc/html/render/mod.rs

+108-97
Original file line numberDiff line numberDiff line change
@@ -1281,99 +1281,6 @@ fn render_impl(
12811281
let trait_ = i.trait_did_full(cache).map(|did| &traits[&did]);
12821282
let mut close_tags = String::new();
12831283

1284-
if render_mode == RenderMode::Normal {
1285-
let id = cx.derive_id(match i.inner_impl().trait_ {
1286-
Some(ref t) => {
1287-
if is_on_foreign_type {
1288-
get_id_for_impl_on_foreign_type(&i.inner_impl().for_, t, cx)
1289-
} else {
1290-
format!("impl-{}", small_url_encode(format!("{:#}", t.print(cx))))
1291-
}
1292-
}
1293-
None => "impl".to_string(),
1294-
});
1295-
let aliases = if aliases.is_empty() {
1296-
String::new()
1297-
} else {
1298-
format!(" aliases=\"{}\"", aliases.join(","))
1299-
};
1300-
if let Some(use_absolute) = use_absolute {
1301-
write!(
1302-
w,
1303-
"<details class=\"rustdoc-toggle implementors-toggle\" open>\
1304-
<summary>\
1305-
<h3 id=\"{}\" class=\"impl\"{}>\
1306-
<code class=\"in-band\">",
1307-
id, aliases
1308-
);
1309-
close_tags.insert_str(0, "</details>");
1310-
write!(w, "{}", i.inner_impl().print(use_absolute, cx));
1311-
if show_def_docs {
1312-
for it in &i.inner_impl().items {
1313-
if let clean::TypedefItem(ref tydef, _) = *it.kind {
1314-
w.write_str("<span class=\"where fmt-newline\"> ");
1315-
assoc_type(
1316-
w,
1317-
it,
1318-
&[],
1319-
Some(&tydef.type_),
1320-
AssocItemLink::Anchor(None),
1321-
"",
1322-
cx,
1323-
);
1324-
w.write_str(";</span>");
1325-
}
1326-
}
1327-
}
1328-
w.write_str("</code>");
1329-
} else {
1330-
write!(
1331-
w,
1332-
"<details class=\"rustdoc-toggle implementors-toggle\" open>\
1333-
<summary>\
1334-
<h3 id=\"{}\" class=\"impl\"{}>\
1335-
<code class=\"in-band\">{}</code>",
1336-
id,
1337-
aliases,
1338-
i.inner_impl().print(false, cx)
1339-
);
1340-
close_tags.insert_str(0, "</details>");
1341-
}
1342-
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
1343-
render_stability_since_raw(
1344-
w,
1345-
i.impl_item.stable_since(tcx).as_deref(),
1346-
i.impl_item.const_stable_since(tcx).as_deref(),
1347-
outer_version,
1348-
outer_const_version,
1349-
);
1350-
write_srclink(cx, &i.impl_item, w);
1351-
w.write_str("</h3></summary>");
1352-
1353-
if trait_.is_some() {
1354-
if let Some(portability) = portability(&i.impl_item, Some(parent)) {
1355-
write!(w, "<div class=\"item-info\">{}</div>", portability);
1356-
}
1357-
}
1358-
1359-
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
1360-
let mut ids = cx.id_map.borrow_mut();
1361-
write!(
1362-
w,
1363-
"<div class=\"docblock\">{}</div>",
1364-
Markdown(
1365-
&*dox,
1366-
&i.impl_item.links(cx),
1367-
&mut ids,
1368-
cx.shared.codes,
1369-
cx.shared.edition(),
1370-
&cx.shared.playground
1371-
)
1372-
.into_string()
1373-
);
1374-
}
1375-
}
1376-
13771284
fn doc_impl_item(
13781285
w: &mut Buffer,
13791286
cx: &Context<'_>,
@@ -1549,11 +1456,10 @@ fn render_impl(
15491456
}
15501457
}
15511458

1552-
w.write_str("<div class=\"impl-items\">");
1553-
close_tags.insert_str(0, "</div>");
1459+
let mut impl_items = Buffer::empty_from(w);
15541460
for trait_item in &i.inner_impl().items {
15551461
doc_impl_item(
1556-
w,
1462+
&mut impl_items,
15571463
cx,
15581464
trait_item,
15591465
if trait_.is_some() { &i.impl_item } else { parent },
@@ -1609,7 +1515,7 @@ fn render_impl(
16091515
if show_default_items {
16101516
if let Some(t) = trait_ {
16111517
render_default_items(
1612-
w,
1518+
&mut impl_items,
16131519
cx,
16141520
&t.trait_,
16151521
&i.inner_impl(),
@@ -1621,6 +1527,111 @@ fn render_impl(
16211527
);
16221528
}
16231529
}
1530+
let details_str = if impl_items.is_empty() {
1531+
""
1532+
} else {
1533+
"<details class=\"rustdoc-toggle implementors-toggle\" open><summary>"
1534+
};
1535+
if render_mode == RenderMode::Normal {
1536+
let id = cx.derive_id(match i.inner_impl().trait_ {
1537+
Some(ref t) => {
1538+
if is_on_foreign_type {
1539+
get_id_for_impl_on_foreign_type(&i.inner_impl().for_, t, cx)
1540+
} else {
1541+
format!("impl-{}", small_url_encode(format!("{:#}", t.print(cx))))
1542+
}
1543+
}
1544+
None => "impl".to_string(),
1545+
});
1546+
let aliases = if aliases.is_empty() {
1547+
String::new()
1548+
} else {
1549+
format!(" aliases=\"{}\"", aliases.join(","))
1550+
};
1551+
if let Some(use_absolute) = use_absolute {
1552+
write!(
1553+
w,
1554+
"{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">",
1555+
details_str, id, aliases
1556+
);
1557+
if !impl_items.is_empty() {
1558+
close_tags.insert_str(0, "</details>");
1559+
}
1560+
write!(w, "{}", i.inner_impl().print(use_absolute, cx));
1561+
if show_def_docs {
1562+
for it in &i.inner_impl().items {
1563+
if let clean::TypedefItem(ref tydef, _) = *it.kind {
1564+
w.write_str("<span class=\"where fmt-newline\"> ");
1565+
assoc_type(
1566+
w,
1567+
it,
1568+
&[],
1569+
Some(&tydef.type_),
1570+
AssocItemLink::Anchor(None),
1571+
"",
1572+
cx,
1573+
);
1574+
w.write_str(";</span>");
1575+
}
1576+
}
1577+
}
1578+
w.write_str("</code>");
1579+
} else {
1580+
write!(
1581+
w,
1582+
"{}<h3 id=\"{}\" class=\"impl\"{}><code class=\"in-band\">{}</code>",
1583+
details_str,
1584+
id,
1585+
aliases,
1586+
i.inner_impl().print(false, cx)
1587+
);
1588+
if !impl_items.is_empty() {
1589+
close_tags.insert_str(0, "</details>");
1590+
}
1591+
}
1592+
write!(w, "<a href=\"#{}\" class=\"anchor\"></a>", id);
1593+
render_stability_since_raw(
1594+
w,
1595+
i.impl_item.stable_since(tcx).as_deref(),
1596+
i.impl_item.const_stable_since(tcx).as_deref(),
1597+
outer_version,
1598+
outer_const_version,
1599+
);
1600+
write_srclink(cx, &i.impl_item, w);
1601+
if impl_items.is_empty() {
1602+
w.write_str("</h3>");
1603+
} else {
1604+
w.write_str("</h3></summary>");
1605+
}
1606+
1607+
if trait_.is_some() {
1608+
if let Some(portability) = portability(&i.impl_item, Some(parent)) {
1609+
write!(w, "<div class=\"item-info\">{}</div>", portability);
1610+
}
1611+
}
1612+
1613+
if let Some(ref dox) = cx.shared.maybe_collapsed_doc_value(&i.impl_item) {
1614+
let mut ids = cx.id_map.borrow_mut();
1615+
write!(
1616+
w,
1617+
"<div class=\"docblock\">{}</div>",
1618+
Markdown(
1619+
&*dox,
1620+
&i.impl_item.links(cx),
1621+
&mut ids,
1622+
cx.shared.codes,
1623+
cx.shared.edition(),
1624+
&cx.shared.playground
1625+
)
1626+
.into_string()
1627+
);
1628+
}
1629+
}
1630+
if !impl_items.is_empty() {
1631+
w.write_str("<div class=\"impl-items\">");
1632+
w.push_buffer(impl_items);
1633+
close_tags.insert_str(0, "</div>");
1634+
}
16241635
w.write_str(&close_tags);
16251636
}
16261637

0 commit comments

Comments
 (0)