Skip to content

Commit 28f03ac

Browse files
committed
Auto merge of rust-lang#78421 - JohnTitor:rollup-bq2d7fo, r=JohnTitor
Rollup of 16 pull requests Successful merges: - rust-lang#76635 (Add [T]::as_chunks(_mut)) - rust-lang#77703 (add system-llvm-libunwind config option) - rust-lang#78219 (Prefer to use `print_def_path`) - rust-lang#78298 (Add test for bad NLL higher-ranked subtype) - rust-lang#78332 (Update description for error E0308) - rust-lang#78342 (Use check-pass in single-use-lifetime ui tests) - rust-lang#78347 (Add lexicographical comparison doc) - rust-lang#78348 (Make some functions private that don't have to be public) - rust-lang#78349 (Use its own `TypeckResults` to avoid ICE) - rust-lang#78375 (Use ? in core/std macros) - rust-lang#78377 (Fix typo in debug statement) - rust-lang#78388 (Add some regression tests) - rust-lang#78394 (fix(docs): typo in BufWriter documentation) - rust-lang#78396 (Add compiler support for LLVM's x86_64 ERMSB feature) - rust-lang#78405 (Fix typo in lint description) - rust-lang#78412 (Improve formatting of hash collections docs) Failed merges: r? `@ghost`
2 parents a4d30a7 + 4236d27 commit 28f03ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+558
-262
lines changed

compiler/rustc_codegen_ssa/src/target_features.rs

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ const X86_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
6363
("bmi1", None),
6464
("bmi2", None),
6565
("cmpxchg16b", Some(sym::cmpxchg16b_target_feature)),
66+
("ermsb", Some(sym::ermsb_target_feature)),
6667
("f16c", Some(sym::f16c_target_feature)),
6768
("fma", None),
6869
("fxsr", None),
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
Expected type did not match the received type.
22

3-
Erroneous code example:
3+
Erroneous code examples:
44

55
```compile_fail,E0308
6-
let x: i32 = "I am not a number!";
7-
// ~~~ ~~~~~~~~~~~~~~~~~~~~
8-
// | |
9-
// | initializing expression;
10-
// | compiler infers type `&str`
11-
// |
12-
// type `i32` assigned to variable `x`
6+
fn plus_one(x: i32) -> i32 {
7+
x + 1
8+
}
9+
10+
plus_one("Not a number");
11+
// ^^^^^^^^^^^^^^ expected `i32`, found `&str`
12+
13+
if "Not a bool" {
14+
// ^^^^^^^^^^^^ expected `bool`, found `&str`
15+
}
16+
17+
let x: f32 = "Not a float";
18+
// --- ^^^^^^^^^^^^^ expected `f32`, found `&str`
19+
// |
20+
// expected due to this
1321
```
1422

15-
This error occurs when the compiler is unable to infer the concrete type of a
16-
variable. It can occur in several cases, the most common being a mismatch
17-
between two types: the type the author explicitly assigned, and the type the
18-
compiler inferred.
23+
This error occurs when an expression was used in a place where the compiler
24+
expected an expression of a different type. It can occur in several cases, the
25+
most common being when calling a function and passing an argument which has a
26+
different type than the matching type in the function declaration.

compiler/rustc_feature/src/active.rs

+1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ declare_features! (
243243
(active, rtm_target_feature, "1.35.0", Some(44839), None),
244244
(active, f16c_target_feature, "1.36.0", Some(44839), None),
245245
(active, riscv_target_feature, "1.45.0", Some(44839), None),
246+
(active, ermsb_target_feature, "1.49.0", Some(44839), None),
246247

247248
// -------------------------------------------------------------------------
248249
// feature-group-end: actual feature gates (target features)

compiler/rustc_middle/src/ty/print/pretty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ pub trait PrettyPrinter<'tcx>:
658658
let span = self.tcx().hir().span(hir_id);
659659
p!(write("@{}", self.tcx().sess.source_map().span_to_string(span)));
660660
} else {
661-
p!(write("@{}", self.tcx().def_path_str(did)));
661+
p!(write("@"), print_def_path(did, substs));
662662
}
663663
} else {
664664
p!(print_def_path(did, substs));
@@ -694,7 +694,7 @@ pub trait PrettyPrinter<'tcx>:
694694
p!(write("@{}", self.tcx().sess.source_map().span_to_string(span)));
695695
}
696696
} else {
697-
p!(write("@{}", self.tcx().def_path_str(did)));
697+
p!(write("@"), print_def_path(did, substs));
698698
}
699699
} else {
700700
p!(print_def_path(did, substs));

compiler/rustc_mir_build/src/build/matches/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
231231
let arm_end_blocks: Vec<_> = arm_candidates
232232
.into_iter()
233233
.map(|(arm, candidate)| {
234-
debug!("lowering arm {:?}\ncanidate = {:?}", arm, candidate);
234+
debug!("lowering arm {:?}\ncandidate = {:?}", arm, candidate);
235235

236236
let arm_source_info = self.source_info(arm.span);
237237
let arm_scope = (arm.scope, arm_source_info);

compiler/rustc_save_analysis/src/lib.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -630,9 +630,14 @@ impl<'tcx> SaveContext<'tcx> {
630630
})
631631
| Node::Ty(&hir::Ty { kind: hir::TyKind::Path(ref qpath), .. }) => match qpath {
632632
hir::QPath::Resolved(_, path) => path.res,
633-
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => self
634-
.maybe_typeck_results
635-
.map_or(Res::Err, |typeck_results| typeck_results.qpath_res(qpath, hir_id)),
633+
hir::QPath::TypeRelative(..) | hir::QPath::LangItem(..) => {
634+
// #75962: `self.typeck_results` may be different from the `hir_id`'s result.
635+
if self.tcx.has_typeck_results(hir_id.owner.to_def_id()) {
636+
self.tcx.typeck(hir_id.owner).qpath_res(qpath, hir_id)
637+
} else {
638+
Res::Err
639+
}
640+
}
636641
},
637642

638643
Node::Binding(&hir::Pat {

compiler/rustc_save_analysis/src/sig.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ impl<'hir> Sig for hir::Ty<'hir> {
262262
} else {
263263
let start = offset + prefix.len() + 5;
264264
let end = start + name.len();
265-
// FIXME should put the proper path in there, not elipses.
265+
// FIXME should put the proper path in there, not ellipsis.
266266
Ok(Signature {
267267
text: prefix + "...::" + &name,
268268
defs: vec![],
@@ -272,7 +272,7 @@ impl<'hir> Sig for hir::Ty<'hir> {
272272
}
273273
hir::TyKind::Path(hir::QPath::TypeRelative(ty, segment)) => {
274274
let nested_ty = ty.make(offset + 1, id, scx)?;
275-
let prefix = format!("<{}>::", nested_ty.text,);
275+
let prefix = format!("<{}>::", nested_ty.text);
276276

277277
let name = path_segment_to_string(segment);
278278
let res = scx.get_path_res(id.ok_or("Missing id for Path")?);
@@ -551,7 +551,7 @@ impl<'hir> Sig for hir::Item<'hir> {
551551
// FIXME where clause
552552
}
553553
hir::ItemKind::ForeignMod(_) => Err("extern mod"),
554-
hir::ItemKind::GlobalAsm(_) => Err("glboal asm"),
554+
hir::ItemKind::GlobalAsm(_) => Err("global asm"),
555555
hir::ItemKind::ExternCrate(_) => Err("extern crate"),
556556
hir::ItemKind::OpaqueTy(..) => Err("opaque type"),
557557
// FIXME should implement this (e.g., pub use).

compiler/rustc_session/src/lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2648,7 +2648,7 @@ declare_lint! {
26482648
}
26492649

26502650
declare_lint! {
2651-
/// The `uninhabited_static` lint detects uninhbaited statics.
2651+
/// The `uninhabited_static` lint detects uninhabited statics.
26522652
///
26532653
/// ### Example
26542654
///

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ symbols! {
467467
encode,
468468
env,
469469
eq,
470+
ermsb_target_feature,
470471
err,
471472
exact_div,
472473
except,

compiler/rustc_typeck/src/collect.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2409,6 +2409,7 @@ fn from_target_feature(
24092409
Some(sym::movbe_target_feature) => rust_features.movbe_target_feature,
24102410
Some(sym::rtm_target_feature) => rust_features.rtm_target_feature,
24112411
Some(sym::f16c_target_feature) => rust_features.f16c_target_feature,
2412+
Some(sym::ermsb_target_feature) => rust_features.ermsb_target_feature,
24122413
Some(name) => bug!("unknown target feature gate {}", name),
24132414
None => true,
24142415
};

config.toml.example

+2-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,8 @@ changelog-seen = 2
527527
#test-compare-mode = false
528528

529529
# Use LLVM libunwind as the implementation for Rust's unwinder.
530-
#llvm-libunwind = false
530+
# Accepted values are 'in-tree' (formerly true), 'system' or 'no' (formerly false).
531+
#llvm-libunwind = 'no'
531532

532533
# Enable Windows Control Flow Guard checks in the standard library.
533534
# This only applies from stage 1 onwards, and only for Windows targets.

library/alloc/src/vec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2566,7 +2566,7 @@ __impl_slice_eq1! { [const N: usize] Vec<A>, &[B; N], #[stable(feature = "rust1"
25662566
//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &[B; N], }
25672567
//__impl_slice_eq1! { [const N: usize] Cow<'a, [A]>, &mut [B; N], }
25682568

2569-
/// Implements comparison of vectors, lexicographically.
2569+
/// Implements comparison of vectors, [lexicographically](core::cmp::Ord#lexicographical-comparison).
25702570
#[stable(feature = "rust1", since = "1.0.0")]
25712571
impl<T: PartialOrd> PartialOrd for Vec<T> {
25722572
#[inline]
@@ -2578,7 +2578,7 @@ impl<T: PartialOrd> PartialOrd for Vec<T> {
25782578
#[stable(feature = "rust1", since = "1.0.0")]
25792579
impl<T: Eq> Eq for Vec<T> {}
25802580

2581-
/// Implements ordering of vectors, lexicographically.
2581+
/// Implements ordering of vectors, [lexicographically](core::cmp::Ord#lexicographical-comparison).
25822582
#[stable(feature = "rust1", since = "1.0.0")]
25832583
impl<T: Ord> Ord for Vec<T> {
25842584
#[inline]

library/core/src/array/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl<T: PartialOrd, const N: usize> PartialOrd for [T; N] {
344344
}
345345
}
346346

347-
/// Implements comparison of arrays lexicographically.
347+
/// Implements comparison of arrays [lexicographically](Ord#lexicographical-comparison).
348348
#[stable(feature = "rust1", since = "1.0.0")]
349349
impl<T: Ord, const N: usize> Ord for [T; N] {
350350
#[inline]

library/core/src/cmp.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,19 @@ impl<T: Ord> Ord for Reverse<T> {
506506
/// ## Derivable
507507
///
508508
/// This trait can be used with `#[derive]`. When `derive`d on structs, it will produce a
509-
/// lexicographic ordering based on the top-to-bottom declaration order of the struct's members.
509+
/// [lexicographic](https://en.wikipedia.org/wiki/Lexicographic_order) ordering based on the top-to-bottom declaration order of the struct's members.
510510
/// When `derive`d on enums, variants are ordered by their top-to-bottom discriminant order.
511511
///
512+
/// ## Lexicographical comparison
513+
///
514+
/// Lexicographical comparison is an operation with the following properties:
515+
/// - Two sequences are compared element by element.
516+
/// - The first mismatching element defines which sequence is lexicographically less or greater than the other.
517+
/// - If one sequence is a prefix of another, the shorter sequence is lexicographically less than the other.
518+
/// - If two sequence have equivalent elements and are of the same length, then the sequences are lexicographically equal.
519+
/// - An empty sequence is lexicographically less than any non-empty sequence.
520+
/// - Two empty sequences are lexicographically equal.
521+
///
512522
/// ## How can I implement `Ord`?
513523
///
514524
/// `Ord` requires that the type also be [`PartialOrd`] and [`Eq`] (which requires [`PartialEq`]).

library/core/src/iter/traits/iterator.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -2851,7 +2851,7 @@ pub trait Iterator {
28512851
Product::product(self)
28522852
}
28532853

2854-
/// Lexicographically compares the elements of this [`Iterator`] with those
2854+
/// [Lexicographically](Ord#lexicographical-comparison) compares the elements of this [`Iterator`] with those
28552855
/// of another.
28562856
///
28572857
/// # Examples
@@ -2873,7 +2873,7 @@ pub trait Iterator {
28732873
self.cmp_by(other, |x, y| x.cmp(&y))
28742874
}
28752875

2876-
/// Lexicographically compares the elements of this [`Iterator`] with those
2876+
/// [Lexicographically](Ord#lexicographical-comparison) compares the elements of this [`Iterator`] with those
28772877
/// of another with respect to the specified comparison function.
28782878
///
28792879
/// # Examples
@@ -2925,7 +2925,7 @@ pub trait Iterator {
29252925
}
29262926
}
29272927

2928-
/// Lexicographically compares the elements of this [`Iterator`] with those
2928+
/// [Lexicographically](Ord#lexicographical-comparison) compares the elements of this [`Iterator`] with those
29292929
/// of another.
29302930
///
29312931
/// # Examples
@@ -2949,7 +2949,7 @@ pub trait Iterator {
29492949
self.partial_cmp_by(other, |x, y| x.partial_cmp(&y))
29502950
}
29512951

2952-
/// Lexicographically compares the elements of this [`Iterator`] with those
2952+
/// [Lexicographically](Ord#lexicographical-comparison) compares the elements of this [`Iterator`] with those
29532953
/// of another with respect to the specified comparison function.
29542954
///
29552955
/// # Examples
@@ -3089,7 +3089,7 @@ pub trait Iterator {
30893089
!self.eq(other)
30903090
}
30913091

3092-
/// Determines if the elements of this [`Iterator`] are lexicographically
3092+
/// Determines if the elements of this [`Iterator`] are [lexicographically](Ord#lexicographical-comparison)
30933093
/// less than those of another.
30943094
///
30953095
/// # Examples
@@ -3110,7 +3110,7 @@ pub trait Iterator {
31103110
self.partial_cmp(other) == Some(Ordering::Less)
31113111
}
31123112

3113-
/// Determines if the elements of this [`Iterator`] are lexicographically
3113+
/// Determines if the elements of this [`Iterator`] are [lexicographically](Ord#lexicographical-comparison)
31143114
/// less or equal to those of another.
31153115
///
31163116
/// # Examples
@@ -3131,7 +3131,7 @@ pub trait Iterator {
31313131
matches!(self.partial_cmp(other), Some(Ordering::Less | Ordering::Equal))
31323132
}
31333133

3134-
/// Determines if the elements of this [`Iterator`] are lexicographically
3134+
/// Determines if the elements of this [`Iterator`] are [lexicographically](Ord#lexicographical-comparison)
31353135
/// greater than those of another.
31363136
///
31373137
/// # Examples
@@ -3152,7 +3152,7 @@ pub trait Iterator {
31523152
self.partial_cmp(other) == Some(Ordering::Greater)
31533153
}
31543154

3155-
/// Determines if the elements of this [`Iterator`] are lexicographically
3155+
/// Determines if the elements of this [`Iterator`] are [lexicographically](Ord#lexicographical-comparison)
31563156
/// greater than or equal to those of another.
31573157
///
31583158
/// # Examples

0 commit comments

Comments
 (0)