Skip to content

Commit 8d59daf

Browse files
committed
Auto merge of rust-lang#119557 - matthiaskrgr:rollup-ef1ienw, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - rust-lang#119184 (Switch from using `//~ERROR` annotations with `--error-format` to `error-pattern`) - rust-lang#119325 (custom mir: make it clear what the return block is) - rust-lang#119391 (Use Result::flatten in catch_with_exit_code) - rust-lang#119397 (Recover parentheses in range patterns) - rust-lang#119414 (bootstrap: Move -Clto= setting from Rustc::run to rustc_cargo) - rust-lang#119417 (Uplift some miscellaneous coroutine-specific machinery into `check_closure`) - rust-lang#119527 (don't reexport atomic::ordering via rustc_data_structures, use std import) - rust-lang#119540 (Don't synthesize host effect args inside trait object types) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 139fb22 + c5e375c commit 8d59daf

File tree

84 files changed

+1174
-952
lines changed

Some content is hidden

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

84 files changed

+1174
-952
lines changed

compiler/rustc_ast_lowering/src/lib.rs

+15-13
Original file line numberDiff line numberDiff line change
@@ -1434,19 +1434,21 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14341434
let (bounds, lifetime_bound) = self.with_dyn_type_scope(true, |this| {
14351435
let bounds =
14361436
this.arena.alloc_from_iter(bounds.iter().filter_map(|bound| match bound {
1437-
GenericBound::Trait(
1438-
ty,
1439-
TraitBoundModifiers {
1440-
polarity: BoundPolarity::Positive | BoundPolarity::Negative(_),
1441-
constness,
1442-
},
1443-
) => Some(this.lower_poly_trait_ref(ty, itctx, *constness)),
1444-
// We can safely ignore constness here, since AST validation
1445-
// will take care of invalid modifier combinations.
1446-
GenericBound::Trait(
1447-
_,
1448-
TraitBoundModifiers { polarity: BoundPolarity::Maybe(_), .. },
1449-
) => None,
1437+
// We can safely ignore constness here since AST validation
1438+
// takes care of rejecting invalid modifier combinations and
1439+
// const trait bounds in trait object types.
1440+
GenericBound::Trait(ty, modifiers) => match modifiers.polarity {
1441+
BoundPolarity::Positive | BoundPolarity::Negative(_) => {
1442+
Some(this.lower_poly_trait_ref(
1443+
ty,
1444+
itctx,
1445+
// Still, don't pass along the constness here; we don't want to
1446+
// synthesize any host effect args, it'd only cause problems.
1447+
ast::BoundConstness::Never,
1448+
))
1449+
}
1450+
BoundPolarity::Maybe(_) => None,
1451+
},
14501452
GenericBound::Outlives(lifetime) => {
14511453
if lifetime_bound.is_none() {
14521454
lifetime_bound = Some(this.lower_lifetime(lifetime));

compiler/rustc_data_structures/src/sync.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ mod parallel;
5656
pub use parallel::scope;
5757
pub use parallel::{join, par_for_each_in, par_map, parallel_guard, try_par_for_each_in};
5858

59-
pub use std::sync::atomic::Ordering;
60-
pub use std::sync::atomic::Ordering::SeqCst;
61-
6259
pub use vec::{AppendOnlyIndexVec, AppendOnlyVec};
6360

6461
mod vec;
@@ -67,8 +64,7 @@ mod freeze;
6764
pub use freeze::{FreezeLock, FreezeReadGuard, FreezeWriteGuard};
6865

6966
mod mode {
70-
use super::Ordering;
71-
use std::sync::atomic::AtomicU8;
67+
use std::sync::atomic::{AtomicU8, Ordering};
7268

7369
const UNINITIALIZED: u8 = 0;
7470
const DYN_NOT_THREAD_SAFE: u8 = 1;

compiler/rustc_driver_impl/src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![feature(lazy_cell)]
1313
#![feature(let_chains)]
1414
#![feature(panic_update_hook)]
15+
#![feature(result_flattening)]
1516
#![recursion_limit = "256"]
1617
#![deny(rustc::untranslatable_diagnostic)]
1718
#![deny(rustc::diagnostic_outside_of_impl)]
@@ -24,7 +25,6 @@ use rustc_codegen_ssa::{traits::CodegenBackend, CodegenErrors, CodegenResults};
2425
use rustc_data_structures::profiling::{
2526
get_resident_set_size, print_time_passes_entry, TimePassesFormat,
2627
};
27-
use rustc_data_structures::sync::SeqCst;
2828
use rustc_errors::registry::{InvalidErrorCode, Registry};
2929
use rustc_errors::{markdown, ColorConfig};
3030
use rustc_errors::{DiagCtxt, ErrorGuaranteed, PResult};
@@ -475,7 +475,7 @@ fn run_compiler(
475475
eprintln!(
476476
"Fuel used by {}: {}",
477477
sess.opts.unstable_opts.print_fuel.as_ref().unwrap(),
478-
sess.print_fuel.load(SeqCst)
478+
sess.print_fuel.load(Ordering::SeqCst)
479479
);
480480
}
481481

@@ -1249,8 +1249,7 @@ pub fn catch_fatal_errors<F: FnOnce() -> R, R>(f: F) -> Result<R, ErrorGuarantee
12491249
/// Variant of `catch_fatal_errors` for the `interface::Result` return type
12501250
/// that also computes the exit code.
12511251
pub fn catch_with_exit_code(f: impl FnOnce() -> interface::Result<()>) -> i32 {
1252-
let result = catch_fatal_errors(f).and_then(|result| result);
1253-
match result {
1252+
match catch_fatal_errors(f).flatten() {
12541253
Ok(()) => EXIT_SUCCESS,
12551254
Err(_) => EXIT_FAILURE,
12561255
}

compiler/rustc_hir_typeck/src/check.rs

+3-63
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ use rustc_trait_selection::traits::{ObligationCause, ObligationCauseCode};
2828
pub(super) fn check_fn<'a, 'tcx>(
2929
fcx: &mut FnCtxt<'a, 'tcx>,
3030
fn_sig: ty::FnSig<'tcx>,
31+
coroutine_types: Option<CoroutineTypes<'tcx>>,
3132
decl: &'tcx hir::FnDecl<'tcx>,
3233
fn_def_id: LocalDefId,
3334
body: &'tcx hir::Body<'tcx>,
34-
closure_kind: Option<hir::ClosureKind>,
3535
params_can_be_unsized: bool,
3636
) -> Option<CoroutineTypes<'tcx>> {
3737
let fn_id = fcx.tcx.local_def_id_to_hir_id(fn_def_id);
@@ -49,54 +49,13 @@ pub(super) fn check_fn<'a, 'tcx>(
4949
fcx.param_env,
5050
));
5151

52+
fcx.coroutine_types = coroutine_types;
5253
fcx.ret_coercion = Some(RefCell::new(CoerceMany::new(ret_ty)));
5354

5455
let span = body.value.span;
5556

5657
forbid_intrinsic_abi(tcx, span, fn_sig.abi);
5758

58-
if let Some(hir::ClosureKind::Coroutine(kind)) = closure_kind {
59-
let yield_ty = match kind {
60-
hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Gen, _)
61-
| hir::CoroutineKind::Coroutine(_) => {
62-
let yield_ty = fcx.next_ty_var(TypeVariableOrigin {
63-
kind: TypeVariableOriginKind::TypeInference,
64-
span,
65-
});
66-
fcx.require_type_is_sized(yield_ty, span, traits::SizedYieldType);
67-
yield_ty
68-
}
69-
// HACK(-Ztrait-solver=next): In the *old* trait solver, we must eagerly
70-
// guide inference on the yield type so that we can handle `AsyncIterator`
71-
// in this block in projection correctly. In the new trait solver, it is
72-
// not a problem.
73-
hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::AsyncGen, _) => {
74-
let yield_ty = fcx.next_ty_var(TypeVariableOrigin {
75-
kind: TypeVariableOriginKind::TypeInference,
76-
span,
77-
});
78-
fcx.require_type_is_sized(yield_ty, span, traits::SizedYieldType);
79-
80-
Ty::new_adt(
81-
tcx,
82-
tcx.adt_def(tcx.require_lang_item(hir::LangItem::Poll, Some(span))),
83-
tcx.mk_args(&[Ty::new_adt(
84-
tcx,
85-
tcx.adt_def(tcx.require_lang_item(hir::LangItem::Option, Some(span))),
86-
tcx.mk_args(&[yield_ty.into()]),
87-
)
88-
.into()]),
89-
)
90-
}
91-
hir::CoroutineKind::Desugared(hir::CoroutineDesugaring::Async, _) => Ty::new_unit(tcx),
92-
};
93-
94-
// Resume type defaults to `()` if the coroutine has no argument.
95-
let resume_ty = fn_sig.inputs().get(0).copied().unwrap_or_else(|| Ty::new_unit(tcx));
96-
97-
fcx.resume_yield_tys = Some((resume_ty, yield_ty));
98-
}
99-
10059
GatherLocalsVisitor::new(fcx).visit_body(body);
10160

10261
// C-variadic fns also have a `VaList` input that's not listed in `fn_sig`
@@ -147,25 +106,6 @@ pub(super) fn check_fn<'a, 'tcx>(
147106
fcx.require_type_is_sized(declared_ret_ty, return_or_body_span, traits::SizedReturnType);
148107
fcx.check_return_expr(body.value, false);
149108

150-
// We insert the deferred_coroutine_interiors entry after visiting the body.
151-
// This ensures that all nested coroutines appear before the entry of this coroutine.
152-
// resolve_coroutine_interiors relies on this property.
153-
let coroutine_ty = if let Some(hir::ClosureKind::Coroutine(coroutine_kind)) = closure_kind {
154-
let interior = fcx
155-
.next_ty_var(TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span });
156-
fcx.deferred_coroutine_interiors.borrow_mut().push((
157-
fn_def_id,
158-
body.id(),
159-
interior,
160-
coroutine_kind,
161-
));
162-
163-
let (resume_ty, yield_ty) = fcx.resume_yield_tys.unwrap();
164-
Some(CoroutineTypes { resume_ty, yield_ty, interior })
165-
} else {
166-
None
167-
};
168-
169109
// Finalize the return check by taking the LUB of the return types
170110
// we saw and assigning it to the expected return type. This isn't
171111
// really expected to fail, since the coercions would have failed
@@ -201,7 +141,7 @@ pub(super) fn check_fn<'a, 'tcx>(
201141
check_lang_start_fn(tcx, fn_sig, fn_def_id);
202142
}
203143

204-
coroutine_ty
144+
fcx.coroutine_types
205145
}
206146

207147
fn check_panic_info_fn(tcx: TyCtxt<'_>, fn_id: LocalDefId, fn_sig: ty::FnSig<'_>) {

0 commit comments

Comments
 (0)