Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c185610

Browse files
committedDec 11, 2021
Auto merge of rust-lang#91761 - matthiaskrgr:rollup-bjowmvz, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang#91668 (Remove the match on `ErrorKind::Other`) - rust-lang#91678 (Add tests fixed by rust-lang#90023) - rust-lang#91679 (Move core/stream/stream/mod.rs to core/stream/stream.rs) - rust-lang#91681 (fix typo in `intrinsics::raw_eq` docs) - rust-lang#91686 (Fix `Vec::reserve_exact` documentation) - rust-lang#91697 (Delete Utf8Lossy::from_str) - rust-lang#91706 (Add unstable book entries for parts of asm that are not being stabilized) - rust-lang#91709 (Replace iterator-based set construction by *Set::From<[T; N]>) - rust-lang#91716 (Improve x.py logging and defaults a bit more) - rust-lang#91747 (Add pierwill to .mailmap) - rust-lang#91755 (Fix since attribute for const_linked_list_new feature) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 82575a1 + 637859b commit c185610

File tree

24 files changed

+614
-76
lines changed

24 files changed

+614
-76
lines changed
 

‎.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ Philipp Brüschweiler <blei42@gmail.com> <bruphili@student.ethz.ch>
246246
Philipp Krones <hello@philkrones.com> flip1995 <hello@philkrones.com>
247247
Philipp Krones <hello@philkrones.com> <philipp.krones@embecosm.com>
248248
Philipp Matthias Schäfer <philipp.matthias.schaefer@posteo.de>
249+
pierwill <pierwill@users.noreply.github.com> <19642016+pierwill@users.noreply.github.com>
249250
Przemysław Wesołek <jest@go.art.pl> Przemek Wesołek <jest@go.art.pl>
250251
Rafael Ávila de Espíndola <respindola@mozilla.com> Rafael Avila de Espindola <espindola@dream.(none)>
251252
Ralph Giles <giles@thaumas.net> Ralph Giles <giles@mozilla.com>

‎library/alloc/src/collections/btree/set.rs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ impl<T> BTreeSet<T> {
491491
/// ```
492492
/// use std::collections::BTreeSet;
493493
///
494-
/// let set: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
494+
/// let set = BTreeSet::from([1, 2, 3]);
495495
/// assert_eq!(set.contains(&1), true);
496496
/// assert_eq!(set.contains(&4), false);
497497
/// ```
@@ -515,7 +515,7 @@ impl<T> BTreeSet<T> {
515515
/// ```
516516
/// use std::collections::BTreeSet;
517517
///
518-
/// let set: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
518+
/// let set = BTreeSet::from([1, 2, 3]);
519519
/// assert_eq!(set.get(&2), Some(&2));
520520
/// assert_eq!(set.get(&4), None);
521521
/// ```
@@ -536,7 +536,7 @@ impl<T> BTreeSet<T> {
536536
/// ```
537537
/// use std::collections::BTreeSet;
538538
///
539-
/// let a: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
539+
/// let a = BTreeSet::from([1, 2, 3]);
540540
/// let mut b = BTreeSet::new();
541541
///
542542
/// assert_eq!(a.is_disjoint(&b), true);
@@ -562,7 +562,7 @@ impl<T> BTreeSet<T> {
562562
/// ```
563563
/// use std::collections::BTreeSet;
564564
///
565-
/// let sup: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
565+
/// let sup = BTreeSet::from([1, 2, 3]);
566566
/// let mut set = BTreeSet::new();
567567
///
568568
/// assert_eq!(set.is_subset(&sup), true);
@@ -639,7 +639,7 @@ impl<T> BTreeSet<T> {
639639
/// ```
640640
/// use std::collections::BTreeSet;
641641
///
642-
/// let sub: BTreeSet<_> = [1, 2].iter().cloned().collect();
642+
/// let sub = BTreeSet::from([1, 2]);
643643
/// let mut set = BTreeSet::new();
644644
///
645645
/// assert_eq!(set.is_superset(&sub), false);
@@ -853,7 +853,7 @@ impl<T> BTreeSet<T> {
853853
/// ```
854854
/// use std::collections::BTreeSet;
855855
///
856-
/// let mut set: BTreeSet<_> = [1, 2, 3].iter().cloned().collect();
856+
/// let mut set = BTreeSet::from([1, 2, 3]);
857857
/// assert_eq!(set.take(&2), Some(2));
858858
/// assert_eq!(set.take(&2), None);
859859
/// ```
@@ -876,8 +876,7 @@ impl<T> BTreeSet<T> {
876876
/// ```
877877
/// use std::collections::BTreeSet;
878878
///
879-
/// let xs = [1, 2, 3, 4, 5, 6];
880-
/// let mut set: BTreeSet<i32> = xs.iter().cloned().collect();
879+
/// let mut set = BTreeSet::from([1, 2, 3, 4, 5, 6]);
881880
/// // Keep only the even numbers.
882881
/// set.retain(|&k| k % 2 == 0);
883882
/// assert!(set.iter().eq([2, 4, 6].iter()));
@@ -1009,7 +1008,7 @@ impl<T> BTreeSet<T> {
10091008
/// ```
10101009
/// use std::collections::BTreeSet;
10111010
///
1012-
/// let set: BTreeSet<usize> = [1, 2, 3].iter().cloned().collect();
1011+
/// let set = BTreeSet::from([1, 2, 3]);
10131012
/// let mut set_iter = set.iter();
10141013
/// assert_eq!(set_iter.next(), Some(&1));
10151014
/// assert_eq!(set_iter.next(), Some(&2));
@@ -1022,7 +1021,7 @@ impl<T> BTreeSet<T> {
10221021
/// ```
10231022
/// use std::collections::BTreeSet;
10241023
///
1025-
/// let set: BTreeSet<usize> = [3, 1, 2].iter().cloned().collect();
1024+
/// let set = BTreeSet::from([3, 1, 2]);
10261025
/// let mut set_iter = set.iter();
10271026
/// assert_eq!(set_iter.next(), Some(&1));
10281027
/// assert_eq!(set_iter.next(), Some(&2));
@@ -1124,7 +1123,7 @@ impl<T> IntoIterator for BTreeSet<T> {
11241123
/// ```
11251124
/// use std::collections::BTreeSet;
11261125
///
1127-
/// let set: BTreeSet<usize> = [1, 2, 3, 4].iter().cloned().collect();
1126+
/// let set = BTreeSet::from([1, 2, 3, 4]);
11281127
///
11291128
/// let v: Vec<_> = set.into_iter().collect();
11301129
/// assert_eq!(v, [1, 2, 3, 4]);
@@ -1243,8 +1242,8 @@ impl<T: Ord + Clone> Sub<&BTreeSet<T>> for &BTreeSet<T> {
12431242
/// ```
12441243
/// use std::collections::BTreeSet;
12451244
///
1246-
/// let a: BTreeSet<_> = vec![1, 2, 3].into_iter().collect();
1247-
/// let b: BTreeSet<_> = vec![3, 4, 5].into_iter().collect();
1245+
/// let a = BTreeSet::from([1, 2, 3]);
1246+
/// let b = BTreeSet::from([3, 4, 5]);
12481247
///
12491248
/// let result = &a - &b;
12501249
/// let result_vec: Vec<_> = result.into_iter().collect();
@@ -1266,8 +1265,8 @@ impl<T: Ord + Clone> BitXor<&BTreeSet<T>> for &BTreeSet<T> {
12661265
/// ```
12671266
/// use std::collections::BTreeSet;
12681267
///
1269-
/// let a: BTreeSet<_> = vec![1, 2, 3].into_iter().collect();
1270-
/// let b: BTreeSet<_> = vec![2, 3, 4].into_iter().collect();
1268+
/// let a = BTreeSet::from([1, 2, 3]);
1269+
/// let b = BTreeSet::from([2, 3, 4]);
12711270
///
12721271
/// let result = &a ^ &b;
12731272
/// let result_vec: Vec<_> = result.into_iter().collect();
@@ -1289,8 +1288,8 @@ impl<T: Ord + Clone> BitAnd<&BTreeSet<T>> for &BTreeSet<T> {
12891288
/// ```
12901289
/// use std::collections::BTreeSet;
12911290
///
1292-
/// let a: BTreeSet<_> = vec![1, 2, 3].into_iter().collect();
1293-
/// let b: BTreeSet<_> = vec![2, 3, 4].into_iter().collect();
1291+
/// let a = BTreeSet::from([1, 2, 3]);
1292+
/// let b = BTreeSet::from([2, 3, 4]);
12941293
///
12951294
/// let result = &a & &b;
12961295
/// let result_vec: Vec<_> = result.into_iter().collect();
@@ -1312,8 +1311,8 @@ impl<T: Ord + Clone> BitOr<&BTreeSet<T>> for &BTreeSet<T> {
13121311
/// ```
13131312
/// use std::collections::BTreeSet;
13141313
///
1315-
/// let a: BTreeSet<_> = vec![1, 2, 3].into_iter().collect();
1316-
/// let b: BTreeSet<_> = vec![3, 4, 5].into_iter().collect();
1314+
/// let a = BTreeSet::from([1, 2, 3]);
1315+
/// let b = BTreeSet::from([3, 4, 5]);
13171316
///
13181317
/// let result = &a | &b;
13191318
/// let result_vec: Vec<_> = result.into_iter().collect();

‎library/alloc/src/collections/linked_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ impl<T> LinkedList<T> {
417417
/// let list: LinkedList<u32> = LinkedList::new();
418418
/// ```
419419
#[inline]
420-
#[rustc_const_stable(feature = "const_linked_list_new", since = "1.32.0")]
420+
#[rustc_const_stable(feature = "const_linked_list_new", since = "1.39.0")]
421421
#[stable(feature = "rust1", since = "1.0.0")]
422422
#[must_use]
423423
pub const fn new() -> Self {

‎library/alloc/src/vec/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,7 @@ impl<T, A: Allocator> Vec<T, A> {
822822
///
823823
/// # Panics
824824
///
825-
/// Panics if the new capacity overflows `usize`.
825+
/// Panics if the new capacity exceeds `isize::MAX` bytes.
826826
///
827827
/// # Examples
828828
///

‎library/core/src/intrinsics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1919,7 +1919,7 @@ extern "rust-intrinsic" {
19191919

19201920
/// Determines whether the raw bytes of the two values are equal.
19211921
///
1922-
/// The is particularly handy for arrays, since it allows things like just
1922+
/// This is particularly handy for arrays, since it allows things like just
19231923
/// comparing `i96`s instead of forcing `alloca`s for `[6 x i16]`.
19241924
///
19251925
/// Above some backend-decided threshold this will emit calls to `memcmp`,

‎library/core/src/str/lossy.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ pub struct Utf8Lossy {
1212
}
1313

1414
impl Utf8Lossy {
15-
#[must_use]
16-
pub fn from_str(s: &str) -> &Utf8Lossy {
17-
Utf8Lossy::from_bytes(s.as_bytes())
18-
}
19-
2015
#[must_use]
2116
pub fn from_bytes(bytes: &[u8]) -> &Utf8Lossy {
2217
// SAFETY: Both use the same memory layout, and UTF-8 correctness isn't required.

‎library/std/src/collections/hash/set.rs

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl<T, S> HashSet<T, S> {
233233
/// ```
234234
/// use std::collections::HashSet;
235235
///
236-
/// let mut set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
236+
/// let mut set = HashSet::from([1, 2, 3]);
237237
/// assert!(!set.is_empty());
238238
///
239239
/// // print 1, 2, 3 in an arbitrary order
@@ -489,8 +489,8 @@ where
489489
///
490490
/// ```
491491
/// use std::collections::HashSet;
492-
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
493-
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
492+
/// let a = HashSet::from([1, 2, 3]);
493+
/// let b = HashSet::from([4, 2, 3, 4]);
494494
///
495495
/// // Can be seen as `a - b`.
496496
/// for x in a.difference(&b) {
@@ -518,8 +518,8 @@ where
518518
///
519519
/// ```
520520
/// use std::collections::HashSet;
521-
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
522-
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
521+
/// let a = HashSet::from([1, 2, 3]);
522+
/// let b = HashSet::from([4, 2, 3, 4]);
523523
///
524524
/// // Print 1, 4 in arbitrary order.
525525
/// for x in a.symmetric_difference(&b) {
@@ -548,8 +548,8 @@ where
548548
///
549549
/// ```
550550
/// use std::collections::HashSet;
551-
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
552-
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
551+
/// let a = HashSet::from([1, 2, 3]);
552+
/// let b = HashSet::from([4, 2, 3, 4]);
553553
///
554554
/// // Print 2, 3 in arbitrary order.
555555
/// for x in a.intersection(&b) {
@@ -576,8 +576,8 @@ where
576576
///
577577
/// ```
578578
/// use std::collections::HashSet;
579-
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
580-
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
579+
/// let a = HashSet::from([1, 2, 3]);
580+
/// let b = HashSet::from([4, 2, 3, 4]);
581581
///
582582
/// // Print 1, 2, 3, 4 in arbitrary order.
583583
/// for x in a.union(&b) {
@@ -608,7 +608,7 @@ where
608608
/// ```
609609
/// use std::collections::HashSet;
610610
///
611-
/// let set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
611+
/// let set = HashSet::from([1, 2, 3]);
612612
/// assert_eq!(set.contains(&1), true);
613613
/// assert_eq!(set.contains(&4), false);
614614
/// ```
@@ -633,7 +633,7 @@ where
633633
/// ```
634634
/// use std::collections::HashSet;
635635
///
636-
/// let set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
636+
/// let set = HashSet::from([1, 2, 3]);
637637
/// assert_eq!(set.get(&2), Some(&2));
638638
/// assert_eq!(set.get(&4), None);
639639
/// ```
@@ -657,7 +657,7 @@ where
657657
///
658658
/// use std::collections::HashSet;
659659
///
660-
/// let mut set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
660+
/// let mut set = HashSet::from([1, 2, 3]);
661661
/// assert_eq!(set.len(), 3);
662662
/// assert_eq!(set.get_or_insert(2), &2);
663663
/// assert_eq!(set.get_or_insert(100), &100);
@@ -744,7 +744,7 @@ where
744744
/// ```
745745
/// use std::collections::HashSet;
746746
///
747-
/// let a: HashSet<_> = [1, 2, 3].iter().cloned().collect();
747+
/// let a = HashSet::from([1, 2, 3]);
748748
/// let mut b = HashSet::new();
749749
///
750750
/// assert_eq!(a.is_disjoint(&b), true);
@@ -770,7 +770,7 @@ where
770770
/// ```
771771
/// use std::collections::HashSet;
772772
///
773-
/// let sup: HashSet<_> = [1, 2, 3].iter().cloned().collect();
773+
/// let sup = HashSet::from([1, 2, 3]);
774774
/// let mut set = HashSet::new();
775775
///
776776
/// assert_eq!(set.is_subset(&sup), true);
@@ -792,7 +792,7 @@ where
792792
/// ```
793793
/// use std::collections::HashSet;
794794
///
795-
/// let sub: HashSet<_> = [1, 2].iter().cloned().collect();
795+
/// let sub = HashSet::from([1, 2]);
796796
/// let mut set = HashSet::new();
797797
///
798798
/// assert_eq!(set.is_superset(&sub), false);
@@ -893,7 +893,7 @@ where
893893
/// ```
894894
/// use std::collections::HashSet;
895895
///
896-
/// let mut set: HashSet<_> = [1, 2, 3].iter().cloned().collect();
896+
/// let mut set = HashSet::from([1, 2, 3]);
897897
/// assert_eq!(set.take(&2), Some(2));
898898
/// assert_eq!(set.take(&2), None);
899899
/// ```
@@ -917,8 +917,7 @@ where
917917
/// ```
918918
/// use std::collections::HashSet;
919919
///
920-
/// let xs = [1, 2, 3, 4, 5, 6];
921-
/// let mut set: HashSet<i32> = xs.iter().cloned().collect();
920+
/// let mut set = HashSet::from([1, 2, 3, 4, 5, 6]);
922921
/// set.retain(|&k| k % 2 == 0);
923922
/// assert_eq!(set.len(), 3);
924923
/// ```
@@ -1097,8 +1096,8 @@ where
10971096
/// ```
10981097
/// use std::collections::HashSet;
10991098
///
1100-
/// let a: HashSet<_> = vec![1, 2, 3].into_iter().collect();
1101-
/// let b: HashSet<_> = vec![3, 4, 5].into_iter().collect();
1099+
/// let a = HashSet::from([1, 2, 3]);
1100+
/// let b = HashSet::from([3, 4, 5]);
11021101
///
11031102
/// let set = &a | &b;
11041103
///
@@ -1130,8 +1129,8 @@ where
11301129
/// ```
11311130
/// use std::collections::HashSet;
11321131
///
1133-
/// let a: HashSet<_> = vec![1, 2, 3].into_iter().collect();
1134-
/// let b: HashSet<_> = vec![2, 3, 4].into_iter().collect();
1132+
/// let a = HashSet::from([1, 2, 3]);
1133+
/// let b = HashSet::from([2, 3, 4]);
11351134
///
11361135
/// let set = &a & &b;
11371136
///
@@ -1163,8 +1162,8 @@ where
11631162
/// ```
11641163
/// use std::collections::HashSet;
11651164
///
1166-
/// let a: HashSet<_> = vec![1, 2, 3].into_iter().collect();
1167-
/// let b: HashSet<_> = vec![3, 4, 5].into_iter().collect();
1165+
/// let a = HashSet::from([1, 2, 3]);
1166+
/// let b = HashSet::from([3, 4, 5]);
11681167
///
11691168
/// let set = &a ^ &b;
11701169
///
@@ -1196,8 +1195,8 @@ where
11961195
/// ```
11971196
/// use std::collections::HashSet;
11981197
///
1199-
/// let a: HashSet<_> = vec![1, 2, 3].into_iter().collect();
1200-
/// let b: HashSet<_> = vec![3, 4, 5].into_iter().collect();
1198+
/// let a = HashSet::from([1, 2, 3]);
1199+
/// let b = HashSet::from([3, 4, 5]);
12011200
///
12021201
/// let set = &a - &b;
12031202
///
@@ -1226,7 +1225,7 @@ where
12261225
/// ```
12271226
/// use std::collections::HashSet;
12281227
///
1229-
/// let a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1228+
/// let a = HashSet::from([1, 2, 3]);
12301229
///
12311230
/// let mut iter = a.iter();
12321231
/// ```
@@ -1248,7 +1247,7 @@ pub struct Iter<'a, K: 'a> {
12481247
/// ```
12491248
/// use std::collections::HashSet;
12501249
///
1251-
/// let a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1250+
/// let a = HashSet::from([1, 2, 3]);
12521251
///
12531252
/// let mut iter = a.into_iter();
12541253
/// ```
@@ -1269,7 +1268,7 @@ pub struct IntoIter<K> {
12691268
/// ```
12701269
/// use std::collections::HashSet;
12711270
///
1272-
/// let mut a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1271+
/// let mut a = HashSet::from([1, 2, 3]);
12731272
///
12741273
/// let mut drain = a.drain();
12751274
/// ```
@@ -1291,7 +1290,7 @@ pub struct Drain<'a, K: 'a> {
12911290
///
12921291
/// use std::collections::HashSet;
12931292
///
1294-
/// let mut a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1293+
/// let mut a = HashSet::from([1, 2, 3]);
12951294
///
12961295
/// let mut drain_filtered = a.drain_filter(|v| v % 2 == 0);
12971296
/// ```
@@ -1315,8 +1314,8 @@ where
13151314
/// ```
13161315
/// use std::collections::HashSet;
13171316
///
1318-
/// let a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1319-
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
1317+
/// let a = HashSet::from([1, 2, 3]);
1318+
/// let b = HashSet::from([4, 2, 3, 4]);
13201319
///
13211320
/// let mut intersection = a.intersection(&b);
13221321
/// ```
@@ -1342,8 +1341,8 @@ pub struct Intersection<'a, T: 'a, S: 'a> {
13421341
/// ```
13431342
/// use std::collections::HashSet;
13441343
///
1345-
/// let a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1346-
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
1344+
/// let a = HashSet::from([1, 2, 3]);
1345+
/// let b = HashSet::from([4, 2, 3, 4]);
13471346
///
13481347
/// let mut difference = a.difference(&b);
13491348
/// ```
@@ -1369,8 +1368,8 @@ pub struct Difference<'a, T: 'a, S: 'a> {
13691368
/// ```
13701369
/// use std::collections::HashSet;
13711370
///
1372-
/// let a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1373-
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
1371+
/// let a = HashSet::from([1, 2, 3]);
1372+
/// let b = HashSet::from([4, 2, 3, 4]);
13741373
///
13751374
/// let mut intersection = a.symmetric_difference(&b);
13761375
/// ```
@@ -1393,8 +1392,8 @@ pub struct SymmetricDifference<'a, T: 'a, S: 'a> {
13931392
/// ```
13941393
/// use std::collections::HashSet;
13951394
///
1396-
/// let a: HashSet<u32> = vec![1, 2, 3].into_iter().collect();
1397-
/// let b: HashSet<_> = [4, 2, 3, 4].iter().cloned().collect();
1395+
/// let a = HashSet::from([1, 2, 3]);
1396+
/// let b = HashSet::from([4, 2, 3, 4]);
13981397
///
13991398
/// let mut union_iter = a.union(&b);
14001399
/// ```

‎src/bootstrap/bootstrap.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ def default_build_triple(verbose):
189189
host = next(x for x in version.split('\n') if x.startswith("host: "))
190190
triple = host.split("host: ")[1]
191191
if verbose:
192-
print("detected default triple {}".format(triple))
192+
print("detected default triple {} from pre-installed rustc".format(triple))
193193
return triple
194194
except Exception as e:
195195
if verbose:
196-
print("rustup not detected: {}".format(e))
196+
print("pre-installed rustc not detected: {}".format(e))
197197
print("falling back to auto-detect")
198198

199199
required = sys.platform != 'win32'
@@ -726,12 +726,15 @@ def maybe_download_ci_toolchain(self):
726726
status = subprocess.call(["git", "diff-index", "--quiet", commit, "--", compiler, library])
727727
if status != 0:
728728
if download_rustc == "if-unchanged":
729+
if self.verbose:
730+
print("warning: saw changes to compiler/ or library/ since {}; " \
731+
"ignoring `download-rustc`".format(commit))
729732
return None
730-
print("warning: `download-rustc` is enabled, but there are changes to \
731-
compiler/ or library/")
733+
print("warning: `download-rustc` is enabled, but there are changes to " \
734+
"compiler/ or library/")
732735

733736
if self.verbose:
734-
print("using downloaded stage1 artifacts from CI (commit {})".format(commit))
737+
print("using downloaded stage2 artifacts from CI (commit {})".format(commit))
735738
self.rustc_commit = commit
736739
# FIXME: support downloading artifacts from the beta channel
737740
self.download_toolchain(False, "nightly")

‎src/bootstrap/builder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,11 +1578,11 @@ impl<'a> Builder<'a> {
15781578
panic!("{}", out);
15791579
}
15801580
if let Some(out) = self.cache.get(&step) {
1581-
self.verbose(&format!("{}c {:?}", " ".repeat(stack.len()), step));
1581+
self.verbose_than(1, &format!("{}c {:?}", " ".repeat(stack.len()), step));
15821582

15831583
return out;
15841584
}
1585-
self.verbose(&format!("{}> {:?}", " ".repeat(stack.len()), step));
1585+
self.verbose_than(1, &format!("{}> {:?}", " ".repeat(stack.len()), step));
15861586
stack.push(Box::new(step.clone()));
15871587
}
15881588

@@ -1605,7 +1605,7 @@ impl<'a> Builder<'a> {
16051605
let cur_step = stack.pop().expect("step stack empty");
16061606
assert_eq!(cur_step.downcast_ref(), Some(&step));
16071607
}
1608-
self.verbose(&format!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step));
1608+
self.verbose_than(1, &format!("{}< {:?}", " ".repeat(self.stack.borrow().len()), step));
16091609
self.cache.put(step, out.clone());
16101610
out
16111611
}

‎src/bootstrap/clean.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ fn rm_rf(path: &Path) {
7575
do_op(path, "remove dir", |p| {
7676
fs::remove_dir(p).or_else(|e| {
7777
// Check for dir not empty on Windows
78+
// FIXME: Once `ErrorKind::DirectoryNotEmpty` is stabilized,
79+
// match on `e.kind()` instead.
7880
#[cfg(windows)]
79-
if matches!(e.kind(), std::io::ErrorKind::Other)
80-
&& e.raw_os_error() == Some(145)
81-
{
81+
if e.raw_os_error() == Some(145) {
8282
return Ok(());
8383
}
8484

‎src/bootstrap/defaults/config.tools.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ incremental = true
1111
# This cuts compile times by almost 60x, but means you can't modify the compiler.
1212
download-rustc = "if-unchanged"
1313

14+
[build]
15+
# Document with the in-tree rustdoc by default, since `download-rustc` makes it quick to compile.
16+
doc-stage = 2
17+
1418
[llvm]
1519
# Will download LLVM from CI if available on your platform.
1620
download-ci-llvm = "if-available"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# `asm_const`
2+
3+
The tracking issue for this feature is: [#72016]
4+
5+
[#72016]: https://github.com/rust-lang/rust/issues/72016
6+
7+
------------------------
8+
9+
This feature adds a `const <expr>` operand type to `asm!` and `global_asm!`.
10+
- `<expr>` must be an integer constant expression.
11+
- The value of the expression is formatted as a string and substituted directly into the asm template string.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
# `asm_experimental_arch`
2+
3+
The tracking issue for this feature is: [#72016]
4+
5+
[#72016]: https://github.com/rust-lang/rust/issues/72016
6+
7+
------------------------
8+
9+
This feature tracks `asm!` and `global_asm!` support for the following architectures:
10+
- NVPTX
11+
- PowerPC
12+
- Hexagon
13+
- MIPS32r2 and MIPS64r2
14+
- wasm32
15+
- BPF
16+
- SPIR-V
17+
- AVR
18+
19+
## Register classes
20+
21+
| Architecture | Register class | Registers | LLVM constraint code |
22+
| ------------ | -------------- | ---------------------------------- | -------------------- |
23+
| MIPS | `reg` | `$[2-25]` | `r` |
24+
| MIPS | `freg` | `$f[0-31]` | `f` |
25+
| NVPTX | `reg16` | None\* | `h` |
26+
| NVPTX | `reg32` | None\* | `r` |
27+
| NVPTX | `reg64` | None\* | `l` |
28+
| Hexagon | `reg` | `r[0-28]` | `r` |
29+
| PowerPC | `reg` | `r[0-31]` | `r` |
30+
| PowerPC | `reg_nonzero` | `r[1-31]` | `b` |
31+
| PowerPC | `freg` | `f[0-31]` | `f` |
32+
| PowerPC | `cr` | `cr[0-7]`, `cr` | Only clobbers |
33+
| PowerPC | `xer` | `xer` | Only clobbers |
34+
| wasm32 | `local` | None\* | `r` |
35+
| BPF | `reg` | `r[0-10]` | `r` |
36+
| BPF | `wreg` | `w[0-10]` | `w` |
37+
| AVR | `reg` | `r[2-25]`, `XH`, `XL`, `ZH`, `ZL` | `r` |
38+
| AVR | `reg_upper` | `r[16-25]`, `XH`, `XL`, `ZH`, `ZL` | `d` |
39+
| AVR | `reg_pair` | `r3r2` .. `r25r24`, `X`, `Z` | `r` |
40+
| AVR | `reg_iw` | `r25r24`, `X`, `Z` | `w` |
41+
| AVR | `reg_ptr` | `X`, `Z` | `e` |
42+
43+
> **Notes**:
44+
> - NVPTX doesn't have a fixed register set, so named registers are not supported.
45+
>
46+
> - WebAssembly doesn't have registers, so named registers are not supported.
47+
48+
# Register class supported types
49+
50+
| Architecture | Register class | Target feature | Allowed types |
51+
| ------------ | ------------------------------- | -------------- | --------------------------------------- |
52+
| MIPS32 | `reg` | None | `i8`, `i16`, `i32`, `f32` |
53+
| MIPS32 | `freg` | None | `f32`, `f64` |
54+
| MIPS64 | `reg` | None | `i8`, `i16`, `i32`, `i64`, `f32`, `f64` |
55+
| MIPS64 | `freg` | None | `f32`, `f64` |
56+
| NVPTX | `reg16` | None | `i8`, `i16` |
57+
| NVPTX | `reg32` | None | `i8`, `i16`, `i32`, `f32` |
58+
| NVPTX | `reg64` | None | `i8`, `i16`, `i32`, `f32`, `i64`, `f64` |
59+
| Hexagon | `reg` | None | `i8`, `i16`, `i32`, `f32` |
60+
| PowerPC | `reg` | None | `i8`, `i16`, `i32` |
61+
| PowerPC | `reg_nonzero` | None | `i8`, `i16`, `i32` |
62+
| PowerPC | `freg` | None | `f32`, `f64` |
63+
| PowerPC | `cr` | N/A | Only clobbers |
64+
| PowerPC | `xer` | N/A | Only clobbers |
65+
| wasm32 | `local` | None | `i8` `i16` `i32` `i64` `f32` `f64` |
66+
| BPF | `reg` | None | `i8` `i16` `i32` `i64` |
67+
| BPF | `wreg` | `alu32` | `i8` `i16` `i32` |
68+
| AVR | `reg`, `reg_upper` | None | `i8` |
69+
| AVR | `reg_pair`, `reg_iw`, `reg_ptr` | None | `i16` |
70+
71+
## Register aliases
72+
73+
| Architecture | Base register | Aliases |
74+
| ------------ | ------------- | --------- |
75+
| Hexagon | `r29` | `sp` |
76+
| Hexagon | `r30` | `fr` |
77+
| Hexagon | `r31` | `lr` |
78+
| BPF | `r[0-10]` | `w[0-10]` |
79+
| AVR | `XH` | `r27` |
80+
| AVR | `XL` | `r26` |
81+
| AVR | `ZH` | `r31` |
82+
| AVR | `ZL` | `r30` |
83+
84+
## Unsupported registers
85+
86+
| Architecture | Unsupported register | Reason |
87+
| ------------ | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
88+
| All | `sp` | The stack pointer must be restored to its original value at the end of an asm code block. |
89+
| All | `fr` (Hexagon), `$fp` (MIPS), `Y` (AVR) | The frame pointer cannot be used as an input or output. |
90+
| All | `r19` (Hexagon) | This is used internally by LLVM as a "base pointer" for functions with complex stack frames. |
91+
| MIPS | `$0` or `$zero` | This is a constant zero register which can't be modified. |
92+
| MIPS | `$1` or `$at` | Reserved for assembler. |
93+
| MIPS | `$26`/`$k0`, `$27`/`$k1` | OS-reserved registers. |
94+
| MIPS | `$28`/`$gp` | Global pointer cannot be used as inputs or outputs. |
95+
| MIPS | `$ra` | Return address cannot be used as inputs or outputs. |
96+
| Hexagon | `lr` | This is the link register which cannot be used as an input or output. |
97+
| AVR | `r0`, `r1`, `r1r0` | Due to an issue in LLVM, the `r0` and `r1` registers cannot be used as inputs or outputs. If modified, they must be restored to their original values before the end of the block. |
98+
99+
## Template modifiers
100+
101+
| Architecture | Register class | Modifier | Example output | LLVM modifier |
102+
| ------------ | -------------- | -------- | -------------- | ------------- |
103+
| MIPS | `reg` | None | `$2` | None |
104+
| MIPS | `freg` | None | `$f0` | None |
105+
| NVPTX | `reg16` | None | `rs0` | None |
106+
| NVPTX | `reg32` | None | `r0` | None |
107+
| NVPTX | `reg64` | None | `rd0` | None |
108+
| Hexagon | `reg` | None | `r0` | None |
109+
| PowerPC | `reg` | None | `0` | None |
110+
| PowerPC | `reg_nonzero` | None | `3` | `b` |
111+
| PowerPC | `freg` | None | `0` | None |
112+
113+
# Flags covered by `preserves_flags`
114+
115+
These flags registers must be restored upon exiting the asm block if the `preserves_flags` option is set:
116+
- AVR
117+
- The status register `SREG`.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# `asm_sym`
2+
3+
The tracking issue for this feature is: [#72016]
4+
5+
[#72016]: https://github.com/rust-lang/rust/issues/72016
6+
7+
------------------------
8+
9+
This feature adds a `sym <path>` operand type to `asm!` and `global_asm!`.
10+
- `<path>` must refer to a `fn` or `static`.
11+
- A mangled symbol name referring to the item is substituted into the asm template string.
12+
- The substituted string does not include any modifiers (e.g. GOT, PLT, relocations, etc).
13+
- `<path>` is allowed to point to a `#[thread_local]` static, in which case the asm code can combine the symbol with relocations (e.g. `@plt`, `@TPOFF`) to read from thread-local data.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# `asm_unwind`
2+
3+
The tracking issue for this feature is: [#72016]
4+
5+
[#72016]: https://github.com/rust-lang/rust/issues/72016
6+
7+
------------------------
8+
9+
This feature adds a `may_unwind` option to `asm!` which allows an `asm` block to unwind stack and be part of the stack unwinding process. This option is only supported by the LLVM backend right now.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![feature(const_fn_trait_bound, generic_const_exprs)]
2+
#![allow(incomplete_features)]
3+
4+
trait MiniTypeId {
5+
const TYPE_ID: u64;
6+
}
7+
8+
impl<T> MiniTypeId for T {
9+
const TYPE_ID: u64 = 0;
10+
}
11+
12+
enum Lift<const V: bool> {}
13+
14+
trait IsFalse {}
15+
impl IsFalse for Lift<false> {}
16+
17+
const fn is_same_type<T: MiniTypeId, U: MiniTypeId>() -> bool {
18+
T::TYPE_ID == U::TYPE_ID
19+
}
20+
21+
fn requires_distinct<A, B>(_a: A, _b: B) where
22+
A: MiniTypeId, B: MiniTypeId,
23+
Lift<{is_same_type::<A, B>()}>: IsFalse {}
24+
25+
fn main() {
26+
requires_distinct("str", 12);
27+
//~^ ERROR mismatched types
28+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/issue-79674.rs:26:5
3+
|
4+
LL | requires_distinct("str", 12);
5+
| ^^^^^^^^^^^^^^^^^ expected `true`, found `false`
6+
|
7+
= note: expected type `true`
8+
found type `false`
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
#![feature(generic_const_exprs)]
2+
#![allow(incomplete_features)]
3+
4+
trait TensorDimension {
5+
const DIM : usize;
6+
const ISSCALAR : bool = Self::DIM == 0;
7+
fn is_scalar(&self) -> bool {Self::ISSCALAR}
8+
}
9+
10+
trait TensorSize : TensorDimension {
11+
fn size(&self) -> [usize;Self::DIM];
12+
fn inbounds(&self,index : [usize;Self::DIM]) -> bool {
13+
index.iter().zip(self.size().iter()).all(|(i,s)| i < s)
14+
}
15+
}
16+
17+
18+
trait Broadcastable: TensorSize + Sized {
19+
type Element;
20+
fn bget(&self, index:[usize;Self::DIM]) -> Option<Self::Element>;
21+
fn lazy_updim<const NEWDIM : usize>(&self, size : [usize;NEWDIM] ) ->
22+
LazyUpdim<Self,{Self::DIM},NEWDIM>
23+
{
24+
assert!(NEWDIM >= Self::DIM,
25+
"Updimmed tensor cannot have fewer indices than the initial one.");
26+
LazyUpdim {size,reference:&self}
27+
}
28+
fn bmap<T,F :Fn(Self::Element) -> T>(&self,foo : F) -> BMap<T,Self,F,{Self::DIM}>{
29+
BMap {reference:self,closure : foo}
30+
}
31+
}
32+
33+
34+
struct LazyUpdim<'a,T : Broadcastable,const OLDDIM : usize, const DIM : usize> {
35+
size : [usize;DIM],
36+
reference : &'a T
37+
}
38+
39+
impl<'a,T : Broadcastable,const DIM : usize> TensorDimension for LazyUpdim<'a,T,{T::DIM},DIM> {
40+
const DIM : usize = DIM;
41+
}
42+
43+
impl<'a,T : Broadcastable,const DIM : usize> TensorSize for LazyUpdim<'a,T,{T::DIM},DIM> {
44+
fn size(&self) -> [usize;DIM] {self.size}
45+
//~^ ERROR method not compatible with trait
46+
}
47+
48+
impl<'a,T : Broadcastable,const DIM : usize> Broadcastable for LazyUpdim<'a,T,{T::DIM},DIM>
49+
{
50+
type Element = T::Element;
51+
fn bget(&self,index:[usize;DIM]) -> Option<Self::Element> {
52+
//~^ ERROR method not compatible with trait
53+
assert!(DIM >= T::DIM);
54+
if !self.inbounds(index) {return None}
55+
//~^ ERROR unconstrained generic constant
56+
//~| ERROR mismatched types
57+
let size = self.size();
58+
//~^ ERROR unconstrained generic constant
59+
let newindex : [usize;T::DIM] = Default::default();
60+
//~^ ERROR the trait bound `[usize; _]: Default` is not satisfied
61+
self.reference.bget(newindex)
62+
}
63+
}
64+
65+
struct BMap<'a,R, T : Broadcastable, F : Fn(T::Element) -> R , const DIM: usize> {
66+
reference : &'a T,
67+
closure : F
68+
}
69+
70+
impl<'a,R, T : Broadcastable, F : Fn(T::Element) -> R,
71+
const DIM: usize> TensorDimension for BMap<'a,R,T,F,DIM> {
72+
73+
const DIM : usize = DIM;
74+
}
75+
impl<'a,R, T : Broadcastable, F : Fn(T::Element) -> R ,
76+
const DIM: usize> TensorSize for BMap<'a,R,T,F,DIM> {
77+
78+
fn size(&self) -> [usize;DIM] {self.reference.size()}
79+
//~^ ERROR unconstrained generic constant
80+
//~| ERROR mismatched types
81+
//~| ERROR method not compatible with trait
82+
}
83+
84+
impl<'a,R, T : Broadcastable, F : Fn(T::Element) -> R ,
85+
const DIM: usize> Broadcastable for BMap<'a,R,T,F,DIM> {
86+
87+
type Element = R;
88+
fn bget(&self,index:[usize;DIM]) -> Option<Self::Element> {
89+
//~^ ERROR method not compatible with trait
90+
self.reference.bget(index).map(&self.closure)
91+
//~^ ERROR unconstrained generic constant
92+
//~| ERROR mismatched types
93+
}
94+
}
95+
96+
impl<T> TensorDimension for Vec<T> {
97+
const DIM : usize = 1;
98+
}
99+
impl<T> TensorSize for Vec<T> {
100+
fn size(&self) -> [usize;1] {[self.len()]}
101+
}
102+
impl<T: Clone> Broadcastable for Vec<T> {
103+
type Element = T;
104+
fn bget(& self,index : [usize;1]) -> Option<T> {
105+
self.get(index[0]).cloned()
106+
}
107+
}
108+
109+
fn main() {
110+
let v = vec![1,2,3];
111+
let bv = v.lazy_updim([3,4]);
112+
let bbv = bv.bmap(|x| x*x);
113+
114+
println!("The size of v is {:?}",bbv.bget([0,2]).expect("Out of bounds."));
115+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
error[E0308]: method not compatible with trait
2+
--> $DIR/issue-83765.rs:44:5
3+
|
4+
LL | fn size(&self) -> [usize;DIM] {self.size}
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
6+
|
7+
= note: expected type `Self::DIM`
8+
found type `DIM`
9+
10+
error[E0308]: method not compatible with trait
11+
--> $DIR/issue-83765.rs:51:5
12+
|
13+
LL | fn bget(&self,index:[usize;DIM]) -> Option<Self::Element> {
14+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
15+
|
16+
= note: expected type `Self::DIM`
17+
found type `DIM`
18+
19+
error[E0308]: method not compatible with trait
20+
--> $DIR/issue-83765.rs:78:5
21+
|
22+
LL | fn size(&self) -> [usize;DIM] {self.reference.size()}
23+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
24+
|
25+
= note: expected type `Self::DIM`
26+
found type `DIM`
27+
28+
error[E0308]: method not compatible with trait
29+
--> $DIR/issue-83765.rs:88:5
30+
|
31+
LL | fn bget(&self,index:[usize;DIM]) -> Option<Self::Element> {
32+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Self::DIM`, found `DIM`
33+
|
34+
= note: expected type `Self::DIM`
35+
found type `DIM`
36+
37+
error: unconstrained generic constant
38+
--> $DIR/issue-83765.rs:54:18
39+
|
40+
LL | if !self.inbounds(index) {return None}
41+
| ^^^^^^^^
42+
|
43+
= help: try adding a `where` bound using this expression: `where [(); Self::DIM]:`
44+
note: required by a bound in `TensorSize::inbounds`
45+
--> $DIR/issue-83765.rs:12:38
46+
|
47+
LL | fn inbounds(&self,index : [usize;Self::DIM]) -> bool {
48+
| ^^^^^^^^^ required by this bound in `TensorSize::inbounds`
49+
50+
error[E0308]: mismatched types
51+
--> $DIR/issue-83765.rs:54:27
52+
|
53+
LL | if !self.inbounds(index) {return None}
54+
| ^^^^^ expected `Self::DIM`, found `DIM`
55+
|
56+
= note: expected type `Self::DIM`
57+
found type `DIM`
58+
59+
error: unconstrained generic constant
60+
--> $DIR/issue-83765.rs:57:25
61+
|
62+
LL | let size = self.size();
63+
| ^^^^
64+
|
65+
= help: try adding a `where` bound using this expression: `where [(); Self::DIM]:`
66+
note: required by a bound in `TensorSize::size`
67+
--> $DIR/issue-83765.rs:11:30
68+
|
69+
LL | fn size(&self) -> [usize;Self::DIM];
70+
| ^^^^^^^^^ required by this bound in `TensorSize::size`
71+
72+
error[E0277]: the trait bound `[usize; _]: Default` is not satisfied
73+
--> $DIR/issue-83765.rs:59:41
74+
|
75+
LL | let newindex : [usize;T::DIM] = Default::default();
76+
| ^^^^^^^^^^^^^^^^ the trait `Default` is not implemented for `[usize; _]`
77+
|
78+
help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
79+
|
80+
LL | impl<'a,T : Broadcastable,const DIM : usize> Broadcastable for LazyUpdim<'a,T,{T::DIM},DIM> where [usize; _]: Default
81+
| +++++++++++++++++++++++++
82+
83+
error: unconstrained generic constant
84+
--> $DIR/issue-83765.rs:78:51
85+
|
86+
LL | fn size(&self) -> [usize;DIM] {self.reference.size()}
87+
| ^^^^
88+
|
89+
= help: try adding a `where` bound using this expression: `where [(); Self::DIM]:`
90+
note: required by a bound in `TensorSize::size`
91+
--> $DIR/issue-83765.rs:11:30
92+
|
93+
LL | fn size(&self) -> [usize;Self::DIM];
94+
| ^^^^^^^^^ required by this bound in `TensorSize::size`
95+
96+
error[E0308]: mismatched types
97+
--> $DIR/issue-83765.rs:78:36
98+
|
99+
LL | fn size(&self) -> [usize;DIM] {self.reference.size()}
100+
| ^^^^^^^^^^^^^^^^^^^^^ expected `DIM`, found `Self::DIM`
101+
|
102+
= note: expected type `DIM`
103+
found type `Self::DIM`
104+
105+
error: unconstrained generic constant
106+
--> $DIR/issue-83765.rs:90:24
107+
|
108+
LL | self.reference.bget(index).map(&self.closure)
109+
| ^^^^
110+
|
111+
= help: try adding a `where` bound using this expression: `where [(); Self::DIM]:`
112+
note: required by a bound in `Broadcastable::bget`
113+
--> $DIR/issue-83765.rs:20:33
114+
|
115+
LL | fn bget(&self, index:[usize;Self::DIM]) -> Option<Self::Element>;
116+
| ^^^^^^^^^ required by this bound in `Broadcastable::bget`
117+
118+
error[E0308]: mismatched types
119+
--> $DIR/issue-83765.rs:90:29
120+
|
121+
LL | self.reference.bget(index).map(&self.closure)
122+
| ^^^^^ expected `Self::DIM`, found `DIM`
123+
|
124+
= note: expected type `Self::DIM`
125+
found type `DIM`
126+
127+
error: aborting due to 12 previous errors
128+
129+
Some errors have detailed explanations: E0277, E0308.
130+
For more information about an error, try `rustc --explain E0277`.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// check-pass
2+
3+
#![feature(generic_const_exprs)]
4+
#![allow(incomplete_features)]
5+
6+
pub trait IsTrue<const T: bool> {}
7+
impl IsTrue<true> for () {}
8+
9+
pub trait IsZST {}
10+
11+
impl<T> IsZST for T
12+
where
13+
(): IsTrue<{ std::mem::size_of::<T>() == 0 }>
14+
{}
15+
16+
fn _func() -> impl IsZST {
17+
|| {}
18+
}
19+
20+
fn main() {}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// check-pass
2+
3+
#![allow(incomplete_features)]
4+
#![feature(generic_const_exprs)]
5+
6+
pub struct Assert<const COND: bool>();
7+
pub trait IsTrue {}
8+
impl IsTrue for Assert<true> {}
9+
10+
pub trait IsNotZST {}
11+
impl<T> IsNotZST for T where Assert<{ std::mem::size_of::<T>() > 0 }>: IsTrue {}
12+
13+
fn main() {}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#![feature(const_type_id)]
2+
#![feature(generic_const_exprs)]
3+
#![feature(core_intrinsics)]
4+
#![allow(incomplete_features)]
5+
6+
use std::any::TypeId;
7+
8+
struct If<const B: bool>;
9+
pub trait True {}
10+
impl True for If<true> {}
11+
12+
fn consume<T: 'static>(_val: T)
13+
where
14+
If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
15+
//~^ ERROR: overly complex generic constant
16+
//~| ERROR: calls in constants are limited to constant functions
17+
{
18+
}
19+
20+
fn test<T: 'static>()
21+
where
22+
If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
23+
//~^ ERROR: overly complex generic constant
24+
//~| ERROR: calls in constants are limited to constant functions
25+
{
26+
}
27+
28+
fn main() {
29+
let a = ();
30+
consume(0i32);
31+
consume(a);
32+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
error: overly complex generic constant
2+
--> $DIR/issue-90318.rs:14:8
3+
|
4+
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
5+
| ^^-----------------^^^^^^^^^^^^^^^^^^^^^^^^
6+
| |
7+
| borrowing is not supported in generic constants
8+
|
9+
= help: consider moving this anonymous constant into a `const` function
10+
= note: this operation may be supported in the future
11+
12+
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
13+
--> $DIR/issue-90318.rs:14:10
14+
|
15+
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
16+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
17+
18+
error: overly complex generic constant
19+
--> $DIR/issue-90318.rs:22:8
20+
|
21+
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
22+
| ^^-----------------^^^^^^^^^^^^^^^^^^^^^^^^
23+
| |
24+
| borrowing is not supported in generic constants
25+
|
26+
= help: consider moving this anonymous constant into a `const` function
27+
= note: this operation may be supported in the future
28+
29+
error[E0015]: calls in constants are limited to constant functions, tuple structs and tuple variants
30+
--> $DIR/issue-90318.rs:22:10
31+
|
32+
LL | If<{ TypeId::of::<T>() != TypeId::of::<()>() }>: True,
33+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34+
35+
error: aborting due to 4 previous errors
36+
37+
For more information about this error, try `rustc --explain E0015`.

0 commit comments

Comments
 (0)
This repository has been archived.