Skip to content

Commit 1fb3c4e

Browse files
committed
Auto merge of #64209 - Centril:rollup-x9kvjb7, r=Centril
Rollup of 10 pull requests Successful merges: - #63676 (Use wasi crate for Core API) - #64094 (Improve searching in rustdoc and add tests) - #64111 (or-patterns: Uniformly use `PatKind::Or` in AST & Fix/Cleanup resolve) - #64156 (Assume non-git LLVM is fresh if the stamp file exists) - #64161 (Point at variant on pattern field count mismatch) - #64174 (Add missing code examples on Iterator trait) - #64175 (Fix invalid span generation when it should be div) - #64186 (std: Improve downstream codegen in `Command::env`) - #64190 (fill metadata in rustc_lexer's Cargo.toml) - #64198 (Add Fuchsia to actually_monotonic) Failed merges: r? @ghost
2 parents 6b5f9b2 + 61fcd05 commit 1fb3c4e

Some content is hidden

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

73 files changed

+1991
-1163
lines changed

Cargo.lock

+12
Original file line numberDiff line numberDiff line change
@@ -3870,6 +3870,7 @@ dependencies = [
38703870
"rustc_msan",
38713871
"rustc_tsan",
38723872
"unwind",
3873+
"wasi",
38733874
]
38743875

38753876
[[package]]
@@ -4686,6 +4687,17 @@ dependencies = [
46864687
"try-lock",
46874688
]
46884689

4690+
[[package]]
4691+
name = "wasi"
4692+
version = "0.7.0"
4693+
source = "registry+https://github.com/rust-lang/crates.io-index"
4694+
checksum = "b89c3ce4ce14bdc6fb6beaf9ec7928ca331de5df7e5ea278375642a2f478570d"
4695+
dependencies = [
4696+
"compiler_builtins",
4697+
"rustc-std-workspace-alloc",
4698+
"rustc-std-workspace-core",
4699+
]
4700+
46894701
[[package]]
46904702
name = "winapi"
46914703
version = "0.2.8"

src/bootstrap/native.rs

+14-13
Original file line numberDiff line numberDiff line change
@@ -81,26 +81,29 @@ impl Step for Llvm {
8181
(info, "src/llvm-project/llvm", builder.llvm_out(target), dir.join("bin"))
8282
};
8383

84-
if !llvm_info.is_git() {
85-
println!(
86-
"git could not determine the LLVM submodule commit hash. \
87-
Assuming that an LLVM build is necessary.",
88-
);
89-
}
90-
9184
let build_llvm_config = llvm_config_ret_dir
9285
.join(exe("llvm-config", &*builder.config.build));
9386
let done_stamp = out_dir.join("llvm-finished-building");
9487

95-
if let Some(llvm_commit) = llvm_info.sha() {
96-
if done_stamp.exists() {
88+
if done_stamp.exists() {
89+
if let Some(llvm_commit) = llvm_info.sha() {
9790
let done_contents = t!(fs::read(&done_stamp));
9891

9992
// If LLVM was already built previously and the submodule's commit didn't change
10093
// from the previous build, then no action is required.
10194
if done_contents == llvm_commit.as_bytes() {
102-
return build_llvm_config
95+
return build_llvm_config;
10396
}
97+
} else {
98+
builder.info(
99+
"Could not determine the LLVM submodule commit hash. \
100+
Assuming that an LLVM rebuild is not necessary.",
101+
);
102+
builder.info(&format!(
103+
"To force LLVM to rebuild, remove the file `{}`",
104+
done_stamp.display()
105+
));
106+
return build_llvm_config;
104107
}
105108
}
106109

@@ -303,9 +306,7 @@ impl Step for Llvm {
303306

304307
cfg.build();
305308

306-
if let Some(llvm_commit) = llvm_info.sha() {
307-
t!(fs::write(&done_stamp, llvm_commit));
308-
}
309+
t!(fs::write(&done_stamp, llvm_info.sha().unwrap_or("")));
309310

310311
build_llvm_config
311312
}

src/libcore/iter/traits/iterator.rs

+80
Original file line numberDiff line numberDiff line change
@@ -2546,6 +2546,16 @@ pub trait Iterator {
25462546

25472547
/// Lexicographically compares the elements of this `Iterator` with those
25482548
/// of another.
2549+
///
2550+
/// # Examples
2551+
///
2552+
/// ```
2553+
/// use std::cmp::Ordering;
2554+
///
2555+
/// assert_eq!([1].iter().cmp([1].iter()), Ordering::Equal);
2556+
/// assert_eq!([1].iter().cmp([1, 2].iter()), Ordering::Less);
2557+
/// assert_eq!([1, 2].iter().cmp([1].iter()), Ordering::Greater);
2558+
/// ```
25492559
#[stable(feature = "iter_order", since = "1.5.0")]
25502560
fn cmp<I>(mut self, other: I) -> Ordering where
25512561
I: IntoIterator<Item = Self::Item>,
@@ -2578,6 +2588,18 @@ pub trait Iterator {
25782588

25792589
/// Lexicographically compares the elements of this `Iterator` with those
25802590
/// of another.
2591+
///
2592+
/// # Examples
2593+
///
2594+
/// ```
2595+
/// use std::cmp::Ordering;
2596+
///
2597+
/// assert_eq!([1.].iter().partial_cmp([1.].iter()), Some(Ordering::Equal));
2598+
/// assert_eq!([1.].iter().partial_cmp([1., 2.].iter()), Some(Ordering::Less));
2599+
/// assert_eq!([1., 2.].iter().partial_cmp([1.].iter()), Some(Ordering::Greater));
2600+
///
2601+
/// assert_eq!([std::f64::NAN].iter().partial_cmp([1.].iter()), None);
2602+
/// ```
25812603
#[stable(feature = "iter_order", since = "1.5.0")]
25822604
fn partial_cmp<I>(mut self, other: I) -> Option<Ordering> where
25832605
I: IntoIterator,
@@ -2610,6 +2632,13 @@ pub trait Iterator {
26102632

26112633
/// Determines if the elements of this `Iterator` are equal to those of
26122634
/// another.
2635+
///
2636+
/// # Examples
2637+
///
2638+
/// ```
2639+
/// assert_eq!([1].iter().eq([1].iter()), true);
2640+
/// assert_eq!([1].iter().eq([1, 2].iter()), false);
2641+
/// ```
26132642
#[stable(feature = "iter_order", since = "1.5.0")]
26142643
fn eq<I>(mut self, other: I) -> bool where
26152644
I: IntoIterator,
@@ -2635,6 +2664,13 @@ pub trait Iterator {
26352664

26362665
/// Determines if the elements of this `Iterator` are unequal to those of
26372666
/// another.
2667+
///
2668+
/// # Examples
2669+
///
2670+
/// ```
2671+
/// assert_eq!([1].iter().ne([1].iter()), false);
2672+
/// assert_eq!([1].iter().ne([1, 2].iter()), true);
2673+
/// ```
26382674
#[stable(feature = "iter_order", since = "1.5.0")]
26392675
fn ne<I>(self, other: I) -> bool where
26402676
I: IntoIterator,
@@ -2646,6 +2682,14 @@ pub trait Iterator {
26462682

26472683
/// Determines if the elements of this `Iterator` are lexicographically
26482684
/// less than those of another.
2685+
///
2686+
/// # Examples
2687+
///
2688+
/// ```
2689+
/// assert_eq!([1].iter().lt([1].iter()), false);
2690+
/// assert_eq!([1].iter().lt([1, 2].iter()), true);
2691+
/// assert_eq!([1, 2].iter().lt([1].iter()), false);
2692+
/// ```
26492693
#[stable(feature = "iter_order", since = "1.5.0")]
26502694
fn lt<I>(self, other: I) -> bool where
26512695
I: IntoIterator,
@@ -2657,6 +2701,14 @@ pub trait Iterator {
26572701

26582702
/// Determines if the elements of this `Iterator` are lexicographically
26592703
/// less or equal to those of another.
2704+
///
2705+
/// # Examples
2706+
///
2707+
/// ```
2708+
/// assert_eq!([1].iter().le([1].iter()), true);
2709+
/// assert_eq!([1].iter().le([1, 2].iter()), true);
2710+
/// assert_eq!([1, 2].iter().le([1].iter()), false);
2711+
/// ```
26602712
#[stable(feature = "iter_order", since = "1.5.0")]
26612713
fn le<I>(self, other: I) -> bool where
26622714
I: IntoIterator,
@@ -2671,6 +2723,14 @@ pub trait Iterator {
26712723

26722724
/// Determines if the elements of this `Iterator` are lexicographically
26732725
/// greater than those of another.
2726+
///
2727+
/// # Examples
2728+
///
2729+
/// ```
2730+
/// assert_eq!([1].iter().gt([1].iter()), false);
2731+
/// assert_eq!([1].iter().gt([1, 2].iter()), false);
2732+
/// assert_eq!([1, 2].iter().gt([1].iter()), true);
2733+
/// ```
26742734
#[stable(feature = "iter_order", since = "1.5.0")]
26752735
fn gt<I>(self, other: I) -> bool where
26762736
I: IntoIterator,
@@ -2682,6 +2742,14 @@ pub trait Iterator {
26822742

26832743
/// Determines if the elements of this `Iterator` are lexicographically
26842744
/// greater than or equal to those of another.
2745+
///
2746+
/// # Examples
2747+
///
2748+
/// ```
2749+
/// assert_eq!([1].iter().ge([1].iter()), true);
2750+
/// assert_eq!([1].iter().ge([1, 2].iter()), false);
2751+
/// assert_eq!([1, 2].iter().ge([1].iter()), true);
2752+
/// ```
26852753
#[stable(feature = "iter_order", since = "1.5.0")]
26862754
fn ge<I>(self, other: I) -> bool where
26872755
I: IntoIterator,
@@ -2730,6 +2798,18 @@ pub trait Iterator {
27302798
/// function to determine the ordering of two elements. Apart from that, it's equivalent to
27312799
/// [`is_sorted`]; see its documentation for more information.
27322800
///
2801+
/// # Examples
2802+
///
2803+
/// ```
2804+
/// #![feature(is_sorted)]
2805+
///
2806+
/// assert!([1, 2, 2, 9].iter().is_sorted_by(|a, b| a.partial_cmp(b)));
2807+
/// assert!(![1, 3, 2, 4].iter().is_sorted_by(|a, b| a.partial_cmp(b)));
2808+
/// assert!([0].iter().is_sorted_by(|a, b| a.partial_cmp(b)));
2809+
/// assert!(std::iter::empty::<i32>().is_sorted_by(|a, b| a.partial_cmp(b)));
2810+
/// assert!(![0.0, 1.0, std::f32::NAN].iter().is_sorted_by(|a, b| a.partial_cmp(b)));
2811+
/// ```
2812+
///
27332813
/// [`is_sorted`]: trait.Iterator.html#method.is_sorted
27342814
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
27352815
fn is_sorted_by<F>(mut self, mut compare: F) -> bool

src/librustc/hir/lowering.rs

+33-8
Original file line numberDiff line numberDiff line change
@@ -425,19 +425,44 @@ impl<'a> LoweringContext<'a> {
425425

426426
impl<'tcx, 'interner> Visitor<'tcx> for MiscCollector<'tcx, 'interner> {
427427
fn visit_pat(&mut self, p: &'tcx Pat) {
428-
match p.node {
428+
if let PatKind::Paren(..) | PatKind::Rest = p.node {
429429
// Doesn't generate a HIR node
430-
PatKind::Paren(..) | PatKind::Rest => {},
431-
_ => {
432-
if let Some(owner) = self.hir_id_owner {
433-
self.lctx.lower_node_id_with_owner(p.id, owner);
434-
}
435-
}
436-
};
430+
} else if let Some(owner) = self.hir_id_owner {
431+
self.lctx.lower_node_id_with_owner(p.id, owner);
432+
}
437433

438434
visit::walk_pat(self, p)
439435
}
440436

437+
// HACK(or_patterns; Centril | dlrobertson): Avoid creating
438+
// HIR nodes for `PatKind::Or` for the top level of a `ast::Arm`.
439+
// This is a temporary hack that should go away once we push down
440+
// `arm.pats: HirVec<P<Pat>>` -> `arm.pat: P<Pat>` to HIR. // Centril
441+
fn visit_arm(&mut self, arm: &'tcx Arm) {
442+
match &arm.pat.node {
443+
PatKind::Or(pats) => pats.iter().for_each(|p| self.visit_pat(p)),
444+
_ => self.visit_pat(&arm.pat),
445+
}
446+
walk_list!(self, visit_expr, &arm.guard);
447+
self.visit_expr(&arm.body);
448+
walk_list!(self, visit_attribute, &arm.attrs);
449+
}
450+
451+
// HACK(or_patterns; Centril | dlrobertson): Same as above. // Centril
452+
fn visit_expr(&mut self, e: &'tcx Expr) {
453+
if let ExprKind::Let(pat, scrutinee) = &e.node {
454+
walk_list!(self, visit_attribute, e.attrs.iter());
455+
match &pat.node {
456+
PatKind::Or(pats) => pats.iter().for_each(|p| self.visit_pat(p)),
457+
_ => self.visit_pat(&pat),
458+
}
459+
self.visit_expr(scrutinee);
460+
self.visit_expr_post(e);
461+
return;
462+
}
463+
visit::walk_expr(self, e)
464+
}
465+
441466
fn visit_item(&mut self, item: &'tcx Item) {
442467
let hir_id = self.lctx.allocate_hir_id_counter(item.id);
443468

0 commit comments

Comments
 (0)