Skip to content

Commit 3668a8a

Browse files
committed
Auto merge of rust-lang#118277 - fmease:rollup-itucldm, r=fmease
Rollup of 9 pull requests Successful merges: - rust-lang#118220 (general improvements/fixes on bootstrap) - rust-lang#118251 (rustdoc-search: avoid infinite where clause unbox) - rust-lang#118253 (Replace `option.map(cond) == Some(true)` with `option.is_some_and(cond)`) - rust-lang#118255 (Request that rust-analyzer changes are sent upstream first if possible) - rust-lang#118259 (Move EagerResolution to rustc_infer::infer::resolve) - rust-lang#118262 (Relate Inherent Associated Types using eq) - rust-lang#118266 (Move stuff around on `stable_mir` and `rustc_smir` crate) - rust-lang#118271 (Separate `NaN`/`Inf` floats with `_`) - rust-lang#118274 (Fix smir's `Ty::Ref` pretty printing) r? `@ghost` `@rustbot` modify labels: rollup
2 parents fad6bb8 + 20d243e commit 3668a8a

File tree

32 files changed

+2512
-2360
lines changed

32 files changed

+2512
-2360
lines changed

compiler/rustc_codegen_cranelift/scripts/rustc-clif.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() {
2727
args.push(codegen_backend_arg);
2828
}
2929
if !passed_args.iter().any(|arg| {
30-
arg == "--sysroot" || arg.to_str().map(|s| s.starts_with("--sysroot=")) == Some(true)
30+
arg == "--sysroot" || arg.to_str().is_some_and(|s| s.starts_with("--sysroot="))
3131
}) {
3232
args.push(OsString::from("--sysroot"));
3333
args.push(OsString::from(sysroot.to_str().unwrap()));

compiler/rustc_codegen_cranelift/scripts/rustdoc-clif.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() {
2727
args.push(codegen_backend_arg);
2828
}
2929
if !passed_args.iter().any(|arg| {
30-
arg == "--sysroot" || arg.to_str().map(|s| s.starts_with("--sysroot=")) == Some(true)
30+
arg == "--sysroot" || arg.to_str().is_some_and(|s| s.starts_with("--sysroot="))
3131
}) {
3232
args.push(OsString::from("--sysroot"));
3333
args.push(OsString::from(sysroot.to_str().unwrap()));

compiler/rustc_expand/src/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ pub(crate) fn matches_codepattern(a: &str, b: &str) -> bool {
135135

136136
/// Advances the given peekable `Iterator` until it reaches a non-whitespace character.
137137
fn scan_for_non_ws_or_end<I: Iterator<Item = char>>(iter: &mut Peekable<I>) {
138-
while iter.peek().copied().map(rustc_lexer::is_whitespace) == Some(true) {
138+
while iter.peek().copied().is_some_and(rustc_lexer::is_whitespace) {
139139
iter.next();
140140
}
141141
}

compiler/rustc_hir_analysis/src/astconv/mod.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1674,10 +1674,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
16741674
let impl_ty = ocx.normalize(&cause, param_env, impl_ty);
16751675

16761676
// Check that the self types can be related.
1677-
// FIXME(inherent_associated_types): Should we use `eq` here? Method probing uses
1678-
// `sup` for this situtation, too. What for? To constrain inference variables?
1679-
if ocx.sup(&ObligationCause::dummy(), param_env, impl_ty, self_ty).is_err()
1680-
{
1677+
if ocx.eq(&ObligationCause::dummy(), param_env, impl_ty, self_ty).is_err() {
16811678
return false;
16821679
}
16831680

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -2293,12 +2293,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
22932293
let clone_trait =
22942294
self.tcx.require_lang_item(LangItem::Clone, Some(segment.ident.span));
22952295
if args.is_empty()
2296-
&& self.typeck_results.borrow().type_dependent_def_id(expr.hir_id).map(
2297-
|did| {
2296+
&& self
2297+
.typeck_results
2298+
.borrow()
2299+
.type_dependent_def_id(expr.hir_id)
2300+
.is_some_and(|did| {
22982301
let ai = self.tcx.associated_item(did);
22992302
ai.trait_container(self.tcx) == Some(clone_trait)
2300-
},
2301-
) == Some(true)
2303+
})
23022304
&& segment.ident.name == sym::clone
23032305
{
23042306
// If this expression had a clone call when suggesting borrowing

compiler/rustc_infer/src/infer/error_reporting/nice_region_error/util.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
161161
&& self
162162
.tcx()
163163
.opt_associated_item(scope_def_id.to_def_id())
164-
.map(|i| i.fn_has_self_parameter)
165-
== Some(true)
164+
.is_some_and(|i| i.fn_has_self_parameter)
166165
}
167166
}

compiler/rustc_infer/src/infer/resolve.rs

+82
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,85 @@ impl<'a, 'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for FullTypeResolver<'a, 'tcx> {
260260
}
261261
}
262262
}
263+
264+
///////////////////////////////////////////////////////////////////////////
265+
// EAGER RESOLUTION
266+
267+
/// Resolves ty, region, and const vars to their inferred values or their root vars.
268+
pub struct EagerResolver<'a, 'tcx> {
269+
infcx: &'a InferCtxt<'tcx>,
270+
}
271+
272+
impl<'a, 'tcx> EagerResolver<'a, 'tcx> {
273+
pub fn new(infcx: &'a InferCtxt<'tcx>) -> Self {
274+
EagerResolver { infcx }
275+
}
276+
}
277+
278+
impl<'tcx> TypeFolder<TyCtxt<'tcx>> for EagerResolver<'_, 'tcx> {
279+
fn interner(&self) -> TyCtxt<'tcx> {
280+
self.infcx.tcx
281+
}
282+
283+
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
284+
match *t.kind() {
285+
ty::Infer(ty::TyVar(vid)) => match self.infcx.probe_ty_var(vid) {
286+
Ok(t) => t.fold_with(self),
287+
Err(_) => Ty::new_var(self.infcx.tcx, self.infcx.root_var(vid)),
288+
},
289+
ty::Infer(ty::IntVar(vid)) => self.infcx.opportunistic_resolve_int_var(vid),
290+
ty::Infer(ty::FloatVar(vid)) => self.infcx.opportunistic_resolve_float_var(vid),
291+
_ => {
292+
if t.has_infer() {
293+
t.super_fold_with(self)
294+
} else {
295+
t
296+
}
297+
}
298+
}
299+
}
300+
301+
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
302+
match *r {
303+
ty::ReVar(vid) => self
304+
.infcx
305+
.inner
306+
.borrow_mut()
307+
.unwrap_region_constraints()
308+
.opportunistic_resolve_var(self.infcx.tcx, vid),
309+
_ => r,
310+
}
311+
}
312+
313+
fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
314+
match c.kind() {
315+
ty::ConstKind::Infer(ty::InferConst::Var(vid)) => {
316+
// FIXME: we need to fold the ty too, I think.
317+
match self.infcx.probe_const_var(vid) {
318+
Ok(c) => c.fold_with(self),
319+
Err(_) => {
320+
ty::Const::new_var(self.infcx.tcx, self.infcx.root_const_var(vid), c.ty())
321+
}
322+
}
323+
}
324+
ty::ConstKind::Infer(ty::InferConst::EffectVar(vid)) => {
325+
debug_assert_eq!(c.ty(), self.infcx.tcx.types.bool);
326+
match self.infcx.probe_effect_var(vid) {
327+
Some(c) => c.as_const(self.infcx.tcx),
328+
None => ty::Const::new_infer(
329+
self.infcx.tcx,
330+
ty::InferConst::EffectVar(self.infcx.root_effect_var(vid)),
331+
self.infcx.tcx.types.bool,
332+
),
333+
}
334+
}
335+
_ => {
336+
if c.has_infer() {
337+
c.super_fold_with(self)
338+
} else {
339+
c
340+
}
341+
}
342+
}
343+
}
344+
}

compiler/rustc_lint/src/non_fmt_panic.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -154,17 +154,13 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
154154

155155
let infcx = cx.tcx.infer_ctxt().build();
156156
let suggest_display = is_str
157-
|| cx
158-
.tcx
159-
.get_diagnostic_item(sym::Display)
160-
.map(|t| infcx.type_implements_trait(t, [ty], cx.param_env).may_apply())
161-
== Some(true);
157+
|| cx.tcx.get_diagnostic_item(sym::Display).is_some_and(|t| {
158+
infcx.type_implements_trait(t, [ty], cx.param_env).may_apply()
159+
});
162160
let suggest_debug = !suggest_display
163-
&& cx
164-
.tcx
165-
.get_diagnostic_item(sym::Debug)
166-
.map(|t| infcx.type_implements_trait(t, [ty], cx.param_env).may_apply())
167-
== Some(true);
161+
&& cx.tcx.get_diagnostic_item(sym::Debug).is_some_and(|t| {
162+
infcx.type_implements_trait(t, [ty], cx.param_env).may_apply()
163+
});
168164

169165
let suggest_panic_any = !is_str && panic == sym::std_panic_macro;
170166

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::ty::{
88
};
99
use crate::ty::{GenericArg, GenericArgKind};
1010
use rustc_apfloat::ieee::{Double, Single};
11+
use rustc_apfloat::Float;
1112
use rustc_data_structures::fx::{FxHashMap, FxIndexMap};
1213
use rustc_data_structures::sso::SsoHashSet;
1314
use rustc_hir as hir;
@@ -1477,10 +1478,12 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
14771478
ty::Bool if int == ScalarInt::TRUE => p!("true"),
14781479
// Float
14791480
ty::Float(ty::FloatTy::F32) => {
1480-
p!(write("{}f32", Single::try_from(int).unwrap()))
1481+
let val = Single::try_from(int).unwrap();
1482+
p!(write("{}{}f32", val, if val.is_finite() { "" } else { "_" }))
14811483
}
14821484
ty::Float(ty::FloatTy::F64) => {
1483-
p!(write("{}f64", Double::try_from(int).unwrap()))
1485+
let val = Double::try_from(int).unwrap();
1486+
p!(write("{}{}f64", val, if val.is_finite() { "" } else { "_" }))
14841487
}
14851488
// Int
14861489
ty::Uint(_) | ty::Int(_) => {

compiler/rustc_smir/src/rustc_internal/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! For that, we define APIs that will temporarily be public to 3P that exposes rustc internal APIs
44
//! until stable MIR is complete.
55
6-
use crate::rustc_smir::{Stable, Tables, TablesWrapper};
6+
use crate::rustc_smir::{context::TablesWrapper, Stable, Tables};
77
use rustc_data_structures::fx;
88
use rustc_data_structures::fx::FxIndexMap;
99
use rustc_middle::mir::interpret::AllocId;
@@ -181,7 +181,7 @@ where
181181
instances: IndexMap::default(),
182182
constants: IndexMap::default(),
183183
}));
184-
stable_mir::run(&tables, || init(&tables, f))
184+
stable_mir::compiler_interface::run(&tables, || init(&tables, f))
185185
}
186186

187187
#[macro_export]

0 commit comments

Comments
 (0)