Skip to content

Commit 8e440b0

Browse files
committed
Auto merge of rust-lang#105328 - matthiaskrgr:rollup-qnfksmq, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#104912 (PartialEq: PERs are homogeneous) - rust-lang#104952 (Streamline the user experience for `x.py setup`) - rust-lang#104953 (Ensure required submodules at the same time as updating existing submodules) - rust-lang#105180 (Use proper HirId for async track_caller attribute check) - rust-lang#105222 (std update libc version and freebsd image build dependencies) - rust-lang#105223 (suggest parenthesis around ExprWithBlock BinOp ExprWithBlock) - rust-lang#105230 (Skip recording resolution for duplicated generic params.) - rust-lang#105301 (update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents e1d8195 + 612e89a commit 8e440b0

File tree

25 files changed

+359
-172
lines changed

25 files changed

+359
-172
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -2085,9 +2085,9 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
20852085

20862086
[[package]]
20872087
name = "libc"
2088-
version = "0.2.135"
2088+
version = "0.2.138"
20892089
source = "registry+https://github.com/rust-lang/crates.io-index"
2090-
checksum = "68783febc7782c6c5cb401fbda4de5a9898be1762314da0bb2c10ced61f18b0c"
2090+
checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
20912091
dependencies = [
20922092
"rustc-std-workspace-core",
20932093
]

compiler/rustc_ast_lowering/src/expr.rs

+18-14
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
147147
),
148148
ExprKind::Async(capture_clause, closure_node_id, block) => self.make_async_expr(
149149
*capture_clause,
150+
None,
150151
*closure_node_id,
151152
None,
152153
e.span,
@@ -584,6 +585,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
584585
pub(super) fn make_async_expr(
585586
&mut self,
586587
capture_clause: CaptureBy,
588+
outer_hir_id: Option<hir::HirId>,
587589
closure_node_id: NodeId,
588590
ret_ty: Option<hir::FnRetTy<'hir>>,
589591
span: Span,
@@ -651,18 +653,20 @@ impl<'hir> LoweringContext<'_, 'hir> {
651653

652654
hir::ExprKind::Closure(c)
653655
};
654-
let parent_has_track_caller = self
655-
.attrs
656-
.values()
657-
.find(|attrs| attrs.into_iter().find(|attr| attr.has_name(sym::track_caller)).is_some())
658-
.is_some();
659-
let unstable_span =
660-
self.mark_span_with_reason(DesugaringKind::Async, span, self.allow_gen_future.clone());
661656

662-
let hir_id = if parent_has_track_caller {
663-
let generator_hir_id = self.lower_node_id(closure_node_id);
657+
let track_caller = outer_hir_id
658+
.and_then(|id| self.attrs.get(&id.local_id))
659+
.map_or(false, |attrs| attrs.into_iter().any(|attr| attr.has_name(sym::track_caller)));
660+
661+
let hir_id = self.lower_node_id(closure_node_id);
662+
if track_caller {
663+
let unstable_span = self.mark_span_with_reason(
664+
DesugaringKind::Async,
665+
span,
666+
self.allow_gen_future.clone(),
667+
);
664668
self.lower_attrs(
665-
generator_hir_id,
669+
hir_id,
666670
&[Attribute {
667671
kind: AttrKind::Normal(ptr::P(NormalAttr {
668672
item: AttrItem {
@@ -677,10 +681,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
677681
span: unstable_span,
678682
}],
679683
);
680-
generator_hir_id
681-
} else {
682-
self.lower_node_id(closure_node_id)
683-
};
684+
}
684685

685686
let generator = hir::Expr { hir_id, kind: generator_kind, span: self.lower_span(span) };
686687

@@ -1019,6 +1020,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
10191020

10201021
let async_body = this.make_async_expr(
10211022
capture_clause,
1023+
// FIXME(nbdd0121): This should also use a proper HIR id so `#[track_caller]`
1024+
// can be applied on async closures as well.
1025+
None,
10221026
inner_closure_id,
10231027
async_ret_ty,
10241028
body.span,

compiler/rustc_ast_lowering/src/item.rs

+20-8
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
253253
// only cares about the input argument patterns in the function
254254
// declaration (decl), not the return types.
255255
let asyncness = header.asyncness;
256-
let body_id =
257-
this.lower_maybe_async_body(span, &decl, asyncness, body.as_deref());
256+
let body_id = this.lower_maybe_async_body(
257+
span,
258+
hir_id,
259+
&decl,
260+
asyncness,
261+
body.as_deref(),
262+
);
258263

259264
let mut itctx = ImplTraitContext::Universal;
260265
let (generics, decl) = this.lower_generics(generics, id, &mut itctx, |this| {
@@ -701,6 +706,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
701706

702707
fn lower_trait_item(&mut self, i: &AssocItem) -> &'hir hir::TraitItem<'hir> {
703708
let hir_id = self.lower_node_id(i.id);
709+
self.lower_attrs(hir_id, &i.attrs);
704710
let trait_item_def_id = hir_id.expect_owner();
705711

706712
let (generics, kind, has_default) = match &i.kind {
@@ -724,7 +730,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
724730
AssocItemKind::Fn(box Fn { sig, generics, body: Some(body), .. }) => {
725731
let asyncness = sig.header.asyncness;
726732
let body_id =
727-
self.lower_maybe_async_body(i.span, &sig.decl, asyncness, Some(&body));
733+
self.lower_maybe_async_body(i.span, hir_id, &sig.decl, asyncness, Some(&body));
728734
let (generics, sig) = self.lower_method_sig(
729735
generics,
730736
sig,
@@ -759,7 +765,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
759765
AssocItemKind::MacCall(..) => panic!("macro item shouldn't exist at this point"),
760766
};
761767

762-
self.lower_attrs(hir_id, &i.attrs);
763768
let item = hir::TraitItem {
764769
owner_id: trait_item_def_id,
765770
ident: self.lower_ident(i.ident),
@@ -798,6 +803,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
798803
// Since `default impl` is not yet implemented, this is always true in impls.
799804
let has_value = true;
800805
let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);
806+
let hir_id = self.lower_node_id(i.id);
807+
self.lower_attrs(hir_id, &i.attrs);
801808

802809
let (generics, kind) = match &i.kind {
803810
AssocItemKind::Const(_, ty, expr) => {
@@ -810,8 +817,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
810817
AssocItemKind::Fn(box Fn { sig, generics, body, .. }) => {
811818
self.current_item = Some(i.span);
812819
let asyncness = sig.header.asyncness;
813-
let body_id =
814-
self.lower_maybe_async_body(i.span, &sig.decl, asyncness, body.as_deref());
820+
let body_id = self.lower_maybe_async_body(
821+
i.span,
822+
hir_id,
823+
&sig.decl,
824+
asyncness,
825+
body.as_deref(),
826+
);
815827
let (generics, sig) = self.lower_method_sig(
816828
generics,
817829
sig,
@@ -844,8 +856,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
844856
AssocItemKind::MacCall(..) => panic!("`TyMac` should have been expanded by now"),
845857
};
846858

847-
let hir_id = self.lower_node_id(i.id);
848-
self.lower_attrs(hir_id, &i.attrs);
849859
let item = hir::ImplItem {
850860
owner_id: hir_id.expect_owner(),
851861
ident: self.lower_ident(i.ident),
@@ -978,6 +988,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
978988
fn lower_maybe_async_body(
979989
&mut self,
980990
span: Span,
991+
fn_id: hir::HirId,
981992
decl: &FnDecl,
982993
asyncness: Async,
983994
body: Option<&Block>,
@@ -1128,6 +1139,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
11281139

11291140
let async_expr = this.make_async_expr(
11301141
CaptureBy::Value,
1142+
Some(fn_id),
11311143
closure_id,
11321144
None,
11331145
body.span,

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
3232
}
3333

3434
pub(in super::super) fn suggest_semicolon_at_end(&self, span: Span, err: &mut Diagnostic) {
35+
// This suggestion is incorrect for
36+
// fn foo() -> bool { match () { () => true } || match () { () => true } }
3537
err.span_suggestion_short(
3638
span.shrink_to_hi(),
3739
"consider using a semicolon here",
3840
";",
39-
Applicability::MachineApplicable,
41+
Applicability::MaybeIncorrect,
4042
);
4143
}
4244

compiler/rustc_parse/src/parser/expr.rs

+5-14
Original file line numberDiff line numberDiff line change
@@ -390,20 +390,11 @@ impl<'a> Parser<'a> {
390390
// want to keep their span info to improve diagnostics in these cases in a later stage.
391391
(true, Some(AssocOp::Multiply)) | // `{ 42 } *foo = bar;` or `{ 42 } * 3`
392392
(true, Some(AssocOp::Subtract)) | // `{ 42 } -5`
393-
(true, Some(AssocOp::Add)) // `{ 42 } + 42
394-
// If the next token is a keyword, then the tokens above *are* unambiguously incorrect:
395-
// `if x { a } else { b } && if y { c } else { d }`
396-
if !self.look_ahead(1, |t| t.is_used_keyword()) => {
397-
// These cases are ambiguous and can't be identified in the parser alone.
398-
let sp = self.sess.source_map().start_point(self.token.span);
399-
self.sess.ambiguous_block_expr_parse.borrow_mut().insert(sp, lhs.span);
400-
false
401-
}
402-
(true, Some(AssocOp::LAnd)) |
403-
(true, Some(AssocOp::LOr)) |
404-
(true, Some(AssocOp::BitOr)) => {
405-
// `{ 42 } &&x` (#61475) or `{ 42 } && if x { 1 } else { 0 }`. Separated from the
406-
// above due to #74233.
393+
(true, Some(AssocOp::Add)) | // `{ 42 } + 42` (unary plus)
394+
(true, Some(AssocOp::LAnd)) | // `{ 42 } &&x` (#61475) or `{ 42 } && if x { 1 } else { 0 }`
395+
(true, Some(AssocOp::LOr)) | // `{ 42 } || 42` ("logical or" or closure)
396+
(true, Some(AssocOp::BitOr)) // `{ 42 } | 42` or `{ 42 } |x| 42`
397+
=> {
407398
// These cases are ambiguous and can't be identified in the parser alone.
408399
//
409400
// Bitwise AND is left out because guessing intent is hard. We can make

compiler/rustc_resolve/src/late.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2360,8 +2360,8 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
23602360
if let GenericParamKind::Lifetime = param.kind {
23612361
// Record lifetime res, so lowering knows there is something fishy.
23622362
self.record_lifetime_param(param.id, LifetimeRes::Error);
2363-
continue;
23642363
}
2364+
continue;
23652365
}
23662366
Entry::Vacant(entry) => {
23672367
entry.insert(param.ident.span);

library/core/src/cmp.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ use crate::marker::StructuralPartialEq;
2929

3030
use self::Ordering::*;
3131

32-
/// Trait for equality comparisons which are [partial equivalence
33-
/// relations](https://en.wikipedia.org/wiki/Partial_equivalence_relation).
32+
/// Trait for equality comparisons.
3433
///
3534
/// `x.eq(y)` can also be written `x == y`, and `x.ne(y)` can be written `x != y`.
3635
/// We use the easier-to-read infix notation in the remainder of this documentation.
3736
///
3837
/// This trait allows for partial equality, for types that do not have a full
3938
/// equivalence relation. For example, in floating point numbers `NaN != NaN`,
4039
/// so floating point types implement `PartialEq` but not [`trait@Eq`].
40+
/// Formally speaking, when `Rhs == Self`, this trait corresponds to a [partial equivalence
41+
/// relation](https://en.wikipedia.org/wiki/Partial_equivalence_relation).
4142
///
4243
/// Implementations must ensure that `eq` and `ne` are consistent with each other:
4344
///

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ cfg-if = { version = "1.0", features = ['rustc-dep-of-std'] }
1515
panic_unwind = { path = "../panic_unwind", optional = true }
1616
panic_abort = { path = "../panic_abort" }
1717
core = { path = "../core" }
18-
libc = { version = "0.2.135", default-features = false, features = ['rustc-dep-of-std'] }
18+
libc = { version = "0.2.138", default-features = false, features = ['rustc-dep-of-std'] }
1919
compiler_builtins = { version = "0.1.82" }
2020
profiler_builtins = { path = "../profiler_builtins", optional = true }
2121
unwind = { path = "../unwind" }

src/bootstrap/flags.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub enum Subcommand {
143143
args: Vec<String>,
144144
},
145145
Setup {
146-
profile: Profile,
146+
profile: Option<Profile>,
147147
},
148148
}
149149

@@ -628,14 +628,15 @@ Arguments:
628628
|path| format!("{} is not a valid UTF8 string", path.to_string_lossy())
629629
));
630630

631-
profile_string.parse().unwrap_or_else(|err| {
631+
let profile = profile_string.parse().unwrap_or_else(|err| {
632632
eprintln!("error: {}", err);
633633
eprintln!("help: the available profiles are:");
634634
eprint!("{}", Profile::all_for_help("- "));
635635
crate::detail_exit(1);
636-
})
636+
});
637+
Some(profile)
637638
} else {
638-
t!(crate::setup::interactive_path())
639+
None
639640
};
640641
Subcommand::Setup { profile }
641642
}

src/bootstrap/lib.rs

+28-22
Original file line numberDiff line numberDiff line change
@@ -542,16 +542,6 @@ impl Build {
542542
metrics: metrics::BuildMetrics::init(),
543543
};
544544

545-
build.verbose("finding compilers");
546-
cc_detect::find(&mut build);
547-
// When running `setup`, the profile is about to change, so any requirements we have now may
548-
// be different on the next invocation. Don't check for them until the next time x.py is
549-
// run. This is ok because `setup` never runs any build commands, so it won't fail if commands are missing.
550-
if !matches!(build.config.cmd, Subcommand::Setup { .. }) {
551-
build.verbose("running sanity check");
552-
sanity::check(&mut build);
553-
}
554-
555545
// If local-rust is the same major.minor as the current version, then force a
556546
// local-rebuild
557547
let local_version_verbose =
@@ -567,16 +557,34 @@ impl Build {
567557
build.local_rebuild = true;
568558
}
569559

570-
// Make sure we update these before gathering metadata so we don't get an error about missing
571-
// Cargo.toml files.
572-
let rust_submodules =
573-
["src/tools/rust-installer", "src/tools/cargo", "library/backtrace", "library/stdarch"];
574-
for s in rust_submodules {
575-
build.update_submodule(Path::new(s));
576-
}
560+
build.verbose("finding compilers");
561+
cc_detect::find(&mut build);
562+
// When running `setup`, the profile is about to change, so any requirements we have now may
563+
// be different on the next invocation. Don't check for them until the next time x.py is
564+
// run. This is ok because `setup` never runs any build commands, so it won't fail if commands are missing.
565+
//
566+
// Similarly, for `setup` we don't actually need submodules or cargo metadata.
567+
if !matches!(build.config.cmd, Subcommand::Setup { .. }) {
568+
build.verbose("running sanity check");
569+
sanity::check(&mut build);
570+
571+
// Make sure we update these before gathering metadata so we don't get an error about missing
572+
// Cargo.toml files.
573+
let rust_submodules = [
574+
"src/tools/rust-installer",
575+
"src/tools/cargo",
576+
"library/backtrace",
577+
"library/stdarch",
578+
];
579+
for s in rust_submodules {
580+
build.update_submodule(Path::new(s));
581+
}
582+
// Now, update all existing submodules.
583+
build.update_existing_submodules();
577584

578-
build.verbose("learning about cargo");
579-
metadata::build(&mut build);
585+
build.verbose("learning about cargo");
586+
metadata::build(&mut build);
587+
}
580588

581589
build
582590
}
@@ -668,7 +676,7 @@ impl Build {
668676

669677
/// If any submodule has been initialized already, sync it unconditionally.
670678
/// This avoids contributors checking in a submodule change by accident.
671-
pub fn maybe_update_submodules(&self) {
679+
pub fn update_existing_submodules(&self) {
672680
// Avoid running git when there isn't a git checkout.
673681
if !self.config.submodules(&self.rust_info()) {
674682
return;
@@ -697,8 +705,6 @@ impl Build {
697705
job::setup(self);
698706
}
699707

700-
self.maybe_update_submodules();
701-
702708
if let Subcommand::Format { check, paths } = &self.config.cmd {
703709
return format::format(&builder::Builder::new(&self), *check, &paths);
704710
}

0 commit comments

Comments
 (0)