Skip to content

Commit dbc3cfd

Browse files
committed
Auto merge of #70983 - Centril:rollup-npabk7c, r=Centril
Rollup of 8 pull requests Successful merges: - #70784 (Consider methods on fundamental `impl` when method is not found on numeric type) - #70843 (Remove the Ord bound that was plaguing drain_filter) - #70913 (Replace "rc"/"arc" lang items with Rc/Arc diagnostic items.) - #70932 (De-abuse TyKind::Error in pattern type checking) - #70952 (Clean up E0511 explanation) - #70964 (rustc_session CLI lint parsing: mark a temporary hack as such) - #70969 (Fix JSON file_name documentation for macros.) - #70975 (Fix internal doc comment nits.) Failed merges: r? @ghost
2 parents 167510f + 68e0e6b commit dbc3cfd

File tree

28 files changed

+150
-153
lines changed

28 files changed

+150
-153
lines changed

src/doc/rustc/src/json.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ Diagnostics have the following format:
5959
"spans": [
6060
{
6161
/* The file where the span is located.
62-
For spans located within a macro expansion, this will be the
63-
name of the expanded macro in the format "<MACRONAME macros>".
62+
Note that this path may not exist. For example, if the path
63+
points to the standard library, and the rust src is not
64+
available in the sysroot, then it may point to a non-existent
65+
file. Beware that this may also point to the source of an
66+
external crate.
6467
*/
6568
"file_name": "lib.rs",
6669
/* The byte offset where the span starts (0-based, inclusive). */

src/liballoc/collections/btree/map.rs

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,52 +1727,44 @@ impl<K, V> Clone for Values<'_, K, V> {
17271727
#[unstable(feature = "btree_drain_filter", issue = "70530")]
17281728
pub struct DrainFilter<'a, K, V, F>
17291729
where
1730-
K: 'a + Ord, // This Ord bound should be removed before stabilization.
1730+
K: 'a,
17311731
V: 'a,
17321732
F: 'a + FnMut(&K, &mut V) -> bool,
17331733
{
17341734
pred: F,
17351735
inner: DrainFilterInner<'a, K, V>,
17361736
}
1737-
pub(super) struct DrainFilterInner<'a, K, V>
1738-
where
1739-
K: 'a + Ord,
1740-
V: 'a,
1741-
{
1737+
pub(super) struct DrainFilterInner<'a, K: 'a, V: 'a> {
17421738
length: &'a mut usize,
17431739
cur_leaf_edge: Option<Handle<NodeRef<marker::Mut<'a>, K, V, marker::Leaf>, marker::Edge>>,
17441740
}
17451741

17461742
#[unstable(feature = "btree_drain_filter", issue = "70530")]
1747-
impl<'a, K, V, F> Drop for DrainFilter<'a, K, V, F>
1743+
impl<K, V, F> Drop for DrainFilter<'_, K, V, F>
17481744
where
1749-
K: 'a + Ord,
1750-
V: 'a,
1751-
F: 'a + FnMut(&K, &mut V) -> bool,
1745+
F: FnMut(&K, &mut V) -> bool,
17521746
{
17531747
fn drop(&mut self) {
17541748
self.for_each(drop);
17551749
}
17561750
}
17571751

17581752
#[unstable(feature = "btree_drain_filter", issue = "70530")]
1759-
impl<'a, K, V, F> fmt::Debug for DrainFilter<'a, K, V, F>
1753+
impl<K, V, F> fmt::Debug for DrainFilter<'_, K, V, F>
17601754
where
1761-
K: 'a + fmt::Debug + Ord,
1762-
V: 'a + fmt::Debug,
1763-
F: 'a + FnMut(&K, &mut V) -> bool,
1755+
K: fmt::Debug,
1756+
V: fmt::Debug,
1757+
F: FnMut(&K, &mut V) -> bool,
17641758
{
17651759
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17661760
f.debug_tuple("DrainFilter").field(&self.inner.peek()).finish()
17671761
}
17681762
}
17691763

17701764
#[unstable(feature = "btree_drain_filter", issue = "70530")]
1771-
impl<'a, K, V, F> Iterator for DrainFilter<'a, K, V, F>
1765+
impl<K, V, F> Iterator for DrainFilter<'_, K, V, F>
17721766
where
1773-
K: 'a + Ord,
1774-
V: 'a,
1775-
F: 'a + FnMut(&K, &mut V) -> bool,
1767+
F: FnMut(&K, &mut V) -> bool,
17761768
{
17771769
type Item = (K, V);
17781770

@@ -1785,11 +1777,7 @@ where
17851777
}
17861778
}
17871779

1788-
impl<'a, K, V> DrainFilterInner<'a, K, V>
1789-
where
1790-
K: 'a + Ord,
1791-
V: 'a,
1792-
{
1780+
impl<'a, K: 'a, V: 'a> DrainFilterInner<'a, K, V> {
17931781
/// Allow Debug implementations to predict the next element.
17941782
pub(super) fn peek(&self) -> Option<(&K, &V)> {
17951783
let edge = self.cur_leaf_edge.as_ref()?;
@@ -1828,12 +1816,7 @@ where
18281816
}
18291817

18301818
#[unstable(feature = "btree_drain_filter", issue = "70530")]
1831-
impl<K, V, F> FusedIterator for DrainFilter<'_, K, V, F>
1832-
where
1833-
K: Ord,
1834-
F: FnMut(&K, &mut V) -> bool,
1835-
{
1836-
}
1819+
impl<K, V, F> FusedIterator for DrainFilter<'_, K, V, F> where F: FnMut(&K, &mut V) -> bool {}
18371820

18381821
#[stable(feature = "btree_range", since = "1.17.0")]
18391822
impl<'a, K, V> Iterator for Range<'a, K, V> {

src/liballoc/collections/btree/set.rs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,40 +1094,38 @@ impl<'a, T> IntoIterator for &'a BTreeSet<T> {
10941094
#[unstable(feature = "btree_drain_filter", issue = "70530")]
10951095
pub struct DrainFilter<'a, T, F>
10961096
where
1097-
T: 'a + Ord,
1097+
T: 'a,
10981098
F: 'a + FnMut(&T) -> bool,
10991099
{
11001100
pred: F,
11011101
inner: super::map::DrainFilterInner<'a, T, ()>,
11021102
}
11031103

11041104
#[unstable(feature = "btree_drain_filter", issue = "70530")]
1105-
impl<'a, T, F> Drop for DrainFilter<'a, T, F>
1105+
impl<T, F> Drop for DrainFilter<'_, T, F>
11061106
where
1107-
T: 'a + Ord,
1108-
F: 'a + FnMut(&T) -> bool,
1107+
F: FnMut(&T) -> bool,
11091108
{
11101109
fn drop(&mut self) {
11111110
self.for_each(drop);
11121111
}
11131112
}
11141113

11151114
#[unstable(feature = "btree_drain_filter", issue = "70530")]
1116-
impl<'a, T, F> fmt::Debug for DrainFilter<'a, T, F>
1115+
impl<T, F> fmt::Debug for DrainFilter<'_, T, F>
11171116
where
1118-
T: 'a + Ord + fmt::Debug,
1119-
F: 'a + FnMut(&T) -> bool,
1117+
T: fmt::Debug,
1118+
F: FnMut(&T) -> bool,
11201119
{
11211120
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
11221121
f.debug_tuple("DrainFilter").field(&self.inner.peek().map(|(k, _)| k)).finish()
11231122
}
11241123
}
11251124

11261125
#[unstable(feature = "btree_drain_filter", issue = "70530")]
1127-
impl<'a, 'f, T, F> Iterator for DrainFilter<'a, T, F>
1126+
impl<'a, T, F> Iterator for DrainFilter<'_, T, F>
11281127
where
1129-
T: 'a + Ord,
1130-
F: 'a + 'f + FnMut(&T) -> bool,
1128+
F: 'a + FnMut(&T) -> bool,
11311129
{
11321130
type Item = T;
11331131

@@ -1143,12 +1141,7 @@ where
11431141
}
11441142

11451143
#[unstable(feature = "btree_drain_filter", issue = "70530")]
1146-
impl<'a, T, F> FusedIterator for DrainFilter<'a, T, F>
1147-
where
1148-
T: 'a + Ord,
1149-
F: 'a + FnMut(&T) -> bool,
1150-
{
1151-
}
1144+
impl<T, F> FusedIterator for DrainFilter<'_, T, F> where F: FnMut(&T) -> bool {}
11521145

11531146
#[stable(feature = "rust1", since = "1.0.0")]
11541147
impl<T: Ord> Extend<T> for BTreeSet<T> {

src/liballoc/rc.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,8 @@ struct RcBox<T: ?Sized> {
279279
/// type `T`.
280280
///
281281
/// [get_mut]: #method.get_mut
282-
#[cfg_attr(not(test), lang = "rc")]
282+
#[cfg_attr(all(bootstrap, not(test)), lang = "rc")]
283+
#[cfg_attr(not(test), rustc_diagnostic_item = "Rc")]
283284
#[stable(feature = "rust1", since = "1.0.0")]
284285
pub struct Rc<T: ?Sized> {
285286
ptr: NonNull<RcBox<T>>,

src/liballoc/sync.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ macro_rules! acquire {
207207
/// counting in general.
208208
///
209209
/// [rc_examples]: ../../std/rc/index.html#examples
210-
#[cfg_attr(not(test), lang = "arc")]
210+
#[cfg_attr(all(bootstrap, not(test)), lang = "arc")]
211+
#[cfg_attr(not(test), rustc_diagnostic_item = "Arc")]
211212
#[stable(feature = "rust1", since = "1.0.0")]
212213
pub struct Arc<T: ?Sized> {
213214
ptr: NonNull<ArcInner<T>>,

src/librustc_error_codes/error_codes/E0152.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Erroneous code example:
55
```compile_fail,E0152
66
#![feature(lang_items)]
77
8-
#[lang = "arc"]
9-
struct Foo; // error: duplicate lang item found: `arc`
8+
#[lang = "owned_box"]
9+
struct Foo; // error: duplicate lang item found: `owned_box`
1010
```
1111

1212
Lang items are already implemented in the standard library. Unless you are

src/librustc_error_codes/error_codes/E0511.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
Invalid monomorphization of an intrinsic function was used. Erroneous code
2-
example:
1+
Invalid monomorphization of an intrinsic function was used.
2+
3+
Erroneous code example:
34

45
```compile_fail,E0511
56
#![feature(platform_intrinsics)]

src/librustc_error_codes/error_codes/E0718.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Examples of erroneous code:
66
```compile_fail,E0718
77
#![feature(lang_items)]
88
9-
#[lang = "arc"]
9+
#[lang = "owned_box"]
1010
static X: u32 = 42;
1111
```

src/librustc_hir/lang_items.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,4 @@ language_item_table! {
254254
AlignOffsetLangItem, "align_offset", align_offset_fn, Target::Fn;
255255

256256
TerminationTraitLangItem, "termination", termination, Target::Trait;
257-
258-
Arc, "arc", arc, Target::Struct;
259-
Rc, "rc", rc, Target::Struct;
260257
}

src/librustc_middle/ty/context.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2209,6 +2209,12 @@ impl<'tcx> TyCtxt<'tcx> {
22092209
Some(self.mk_generic_adt(def_id, ty))
22102210
}
22112211

2212+
#[inline]
2213+
pub fn mk_diagnostic_item(self, ty: Ty<'tcx>, name: Symbol) -> Option<Ty<'tcx>> {
2214+
let def_id = self.get_diagnostic_item(name)?;
2215+
Some(self.mk_generic_adt(def_id, ty))
2216+
}
2217+
22122218
#[inline]
22132219
pub fn mk_maybe_uninit(self, ty: Ty<'tcx>) -> Ty<'tcx> {
22142220
let def_id = self.require_lang_item(lang_items::MaybeUninitLangItem, None);

0 commit comments

Comments
 (0)