if $c:expr { Some($r:expr) } else { None }
=>> $c.then(|| $r)
This commit is contained in:
parent
af3c8b2726
commit
8751fa1a9a
@ -271,7 +271,7 @@ fn invalid_visibility(&self, vis: &Visibility, note: Option<InvalidVisibilityNot
|
||||
|
||||
self.session.emit_err(InvalidVisibility {
|
||||
span: vis.span,
|
||||
implied: if vis.kind.is_pub() { Some(vis.span) } else { None },
|
||||
implied: vis.kind.is_pub().then(|| vis.span),
|
||||
note,
|
||||
});
|
||||
}
|
||||
|
@ -1186,11 +1186,7 @@ fn suggest_using_local_if_applicable(
|
||||
return None;
|
||||
};
|
||||
debug!("checking call args for uses of inner_param: {:?}", args);
|
||||
if args.contains(&Operand::Move(inner_param)) {
|
||||
Some((loc, term))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
args.contains(&Operand::Move(inner_param)).then(|| (loc, term))
|
||||
}) else {
|
||||
debug!("no uses of inner_param found as a by-move call arg");
|
||||
return;
|
||||
|
@ -280,17 +280,10 @@ fn give_name_from_error_region(&self, fr: RegionVid) -> Option<RegionName> {
|
||||
|
||||
debug!("give_region_a_name: error_region = {:?}", error_region);
|
||||
match *error_region {
|
||||
ty::ReEarlyBound(ebr) => {
|
||||
if ebr.has_name() {
|
||||
let span = tcx.hir().span_if_local(ebr.def_id).unwrap_or(DUMMY_SP);
|
||||
Some(RegionName {
|
||||
name: ebr.name,
|
||||
source: RegionNameSource::NamedEarlyBoundRegion(span),
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
ty::ReEarlyBound(ebr) => ebr.has_name().then(|| {
|
||||
let span = tcx.hir().span_if_local(ebr.def_id).unwrap_or(DUMMY_SP);
|
||||
RegionName { name: ebr.name, source: RegionNameSource::NamedEarlyBoundRegion(span) }
|
||||
}),
|
||||
|
||||
ty::ReStatic => {
|
||||
Some(RegionName { name: kw::StaticLifetime, source: RegionNameSource::Static })
|
||||
|
@ -50,13 +50,11 @@ pub(super) fn generate<'mir, 'tcx>(
|
||||
compute_relevant_live_locals(typeck.tcx(), &free_regions, &body);
|
||||
let facts_enabled = use_polonius || AllFacts::enabled(typeck.tcx());
|
||||
|
||||
let polonius_drop_used = if facts_enabled {
|
||||
let polonius_drop_used = facts_enabled.then(|| {
|
||||
let mut drop_used = Vec::new();
|
||||
polonius::populate_access_facts(typeck, body, location_table, move_data, &mut drop_used);
|
||||
Some(drop_used)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
drop_used
|
||||
});
|
||||
|
||||
trace::trace(
|
||||
typeck,
|
||||
|
@ -135,19 +135,17 @@ fn expr_for_field(
|
||||
}
|
||||
|
||||
// `let names: &'static _ = &["field1", "field2"];`
|
||||
let names_let = if is_struct {
|
||||
let names_let = is_struct.then(|| {
|
||||
let lt_static = Some(cx.lifetime_static(span));
|
||||
let ty_static_ref = cx.ty_ref(span, cx.ty_infer(span), lt_static, ast::Mutability::Not);
|
||||
Some(cx.stmt_let_ty(
|
||||
cx.stmt_let_ty(
|
||||
span,
|
||||
false,
|
||||
Ident::new(sym::names, span),
|
||||
Some(ty_static_ref),
|
||||
cx.expr_array_ref(span, name_exprs),
|
||||
))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
)
|
||||
});
|
||||
|
||||
// `let values: &[&dyn Debug] = &[&&self.field1, &&self.field2];`
|
||||
let path_debug = cx.path_global(span, cx.std_path(&[sym::fmt, sym::Debug]));
|
||||
|
@ -942,13 +942,11 @@ fn extract_arg_details(
|
||||
let mut nonself_arg_tys = Vec::new();
|
||||
let span = trait_.span;
|
||||
|
||||
let explicit_self = if self.explicit_self {
|
||||
let explicit_self = self.explicit_self.then(|| {
|
||||
let (self_expr, explicit_self) = ty::get_explicit_self(cx, span);
|
||||
selflike_args.push(self_expr);
|
||||
Some(explicit_self)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
explicit_self
|
||||
});
|
||||
|
||||
for (ty, name) in self.nonself_args.iter() {
|
||||
let ast_ty = ty.to_ty(cx, span, type_ident, generics);
|
||||
|
@ -248,17 +248,13 @@ fn reuse_workproduct_for_cgu(
|
||||
dwarf_object: None,
|
||||
bytecode: None,
|
||||
},
|
||||
module_global_asm: if has_global_asm {
|
||||
Some(CompiledModule {
|
||||
name: cgu.name().to_string(),
|
||||
kind: ModuleKind::Regular,
|
||||
object: Some(obj_out_global_asm),
|
||||
dwarf_object: None,
|
||||
bytecode: None,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
},
|
||||
module_global_asm: has_global_asm.then(|| CompiledModule {
|
||||
name: cgu.name().to_string(),
|
||||
kind: ModuleKind::Regular,
|
||||
object: Some(obj_out_global_asm),
|
||||
dwarf_object: None,
|
||||
bytecode: None,
|
||||
}),
|
||||
existing_work_product: Some((cgu.work_product_id(), work_product)),
|
||||
})
|
||||
}
|
||||
|
@ -412,11 +412,7 @@ fn get_pgo_sample_use_path(config: &ModuleConfig) -> Option<CString> {
|
||||
}
|
||||
|
||||
fn get_instr_profile_output_path(config: &ModuleConfig) -> Option<CString> {
|
||||
if config.instrument_coverage {
|
||||
Some(CString::new("default_%m_%p.profraw").unwrap())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
config.instrument_coverage.then(|| CString::new("default_%m_%p.profraw").unwrap())
|
||||
}
|
||||
|
||||
pub(crate) unsafe fn llvm_optimize(
|
||||
@ -451,11 +447,10 @@ pub(crate) unsafe fn llvm_optimize(
|
||||
None
|
||||
};
|
||||
|
||||
let mut llvm_profiler = if cgcx.prof.llvm_recording_enabled() {
|
||||
Some(LlvmSelfProfiler::new(cgcx.prof.get_self_profiler().unwrap()))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let mut llvm_profiler = cgcx
|
||||
.prof
|
||||
.llvm_recording_enabled()
|
||||
.then(|| LlvmSelfProfiler::new(cgcx.prof.get_self_profiler().unwrap()));
|
||||
|
||||
let llvm_selfprofiler =
|
||||
llvm_profiler.as_mut().map(|s| s as *mut _ as *mut c_void).unwrap_or(std::ptr::null_mut());
|
||||
|
@ -402,12 +402,8 @@ pub(crate) fn new(
|
||||
|
||||
let (llcx, llmod) = (&*llvm_module.llcx, llvm_module.llmod());
|
||||
|
||||
let coverage_cx = if tcx.sess.instrument_coverage() {
|
||||
let covctx = coverageinfo::CrateCoverageContext::new();
|
||||
Some(covctx)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let coverage_cx =
|
||||
tcx.sess.instrument_coverage().then(coverageinfo::CrateCoverageContext::new);
|
||||
|
||||
let dbg_cx = if tcx.sess.opts.debuginfo != DebugInfo::None {
|
||||
let dctx = debuginfo::CodegenUnitDebugContext::new(llmod);
|
||||
|
@ -154,7 +154,7 @@ fn struct_llfields<'a, 'tcx>(
|
||||
} else {
|
||||
debug!("struct_llfields: offset: {:?} stride: {:?}", offset, layout.size);
|
||||
}
|
||||
let field_remapping = if padding_used { Some(field_remapping) } else { None };
|
||||
let field_remapping = padding_used.then(|| field_remapping);
|
||||
(result, packed, field_remapping)
|
||||
}
|
||||
|
||||
|
@ -579,7 +579,7 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||
}
|
||||
}
|
||||
|
||||
let metadata_module = if need_metadata_module {
|
||||
let metadata_module = need_metadata_module.then(|| {
|
||||
// Emit compressed metadata object.
|
||||
let metadata_cgu_name =
|
||||
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("metadata")).to_string();
|
||||
@ -594,17 +594,15 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
|
||||
if let Err(error) = std::fs::write(&file_name, data) {
|
||||
tcx.sess.emit_fatal(errors::MetadataObjectFileWrite { error });
|
||||
}
|
||||
Some(CompiledModule {
|
||||
CompiledModule {
|
||||
name: metadata_cgu_name,
|
||||
kind: ModuleKind::Metadata,
|
||||
object: Some(file_name),
|
||||
dwarf_object: None,
|
||||
bytecode: None,
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
});
|
||||
|
||||
let ongoing_codegen = start_async_codegen(
|
||||
backend.clone(),
|
||||
|
@ -167,8 +167,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
|
||||
start_bx.set_personality_fn(cx.eh_personality());
|
||||
}
|
||||
|
||||
let cleanup_kinds =
|
||||
if base::wants_msvc_seh(cx.tcx().sess) { Some(analyze::cleanup_kinds(&mir)) } else { None };
|
||||
let cleanup_kinds = base::wants_msvc_seh(cx.tcx().sess).then(|| analyze::cleanup_kinds(&mir));
|
||||
|
||||
let cached_llbbs: IndexVec<mir::BasicBlock, CachedLlbb<Bx::BasicBlock>> =
|
||||
mir.basic_blocks
|
||||
|
@ -207,8 +207,7 @@ fn cold_call<F>(profiler_ref: &SelfProfilerRef, f: F) -> TimingGuard<'_>
|
||||
/// a measureme event, "verbose" generic activities also print a timing entry to
|
||||
/// stderr if the compiler is invoked with -Ztime-passes.
|
||||
pub fn verbose_generic_activity(&self, event_label: &'static str) -> VerboseTimingGuard<'_> {
|
||||
let message =
|
||||
if self.print_verbose_generic_activities { Some(event_label.to_owned()) } else { None };
|
||||
let message = self.print_verbose_generic_activities.then(|| event_label.to_owned());
|
||||
|
||||
VerboseTimingGuard::start(message, self.generic_activity(event_label))
|
||||
}
|
||||
@ -222,11 +221,9 @@ pub fn verbose_generic_activity_with_arg<A>(
|
||||
where
|
||||
A: Borrow<str> + Into<String>,
|
||||
{
|
||||
let message = if self.print_verbose_generic_activities {
|
||||
Some(format!("{}({})", event_label, event_arg.borrow()))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let message = self
|
||||
.print_verbose_generic_activities
|
||||
.then(|| format!("{}({})", event_label, event_arg.borrow()));
|
||||
|
||||
VerboseTimingGuard::start(message, self.generic_activity_with_arg(event_label, event_arg))
|
||||
}
|
||||
|
@ -1066,29 +1066,26 @@ pub fn err_count(&self) -> usize {
|
||||
}
|
||||
|
||||
pub fn has_errors(&self) -> Option<ErrorGuaranteed> {
|
||||
if self.inner.borrow().has_errors() { Some(ErrorGuaranteed(())) } else { None }
|
||||
self.inner.borrow().has_errors().then(ErrorGuaranteed::unchecked_claim_error_was_emitted)
|
||||
}
|
||||
|
||||
pub fn has_errors_or_lint_errors(&self) -> Option<ErrorGuaranteed> {
|
||||
if self.inner.borrow().has_errors_or_lint_errors() {
|
||||
Some(ErrorGuaranteed::unchecked_claim_error_was_emitted())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.inner
|
||||
.borrow()
|
||||
.has_errors_or_lint_errors()
|
||||
.then(ErrorGuaranteed::unchecked_claim_error_was_emitted)
|
||||
}
|
||||
pub fn has_errors_or_delayed_span_bugs(&self) -> Option<ErrorGuaranteed> {
|
||||
if self.inner.borrow().has_errors_or_delayed_span_bugs() {
|
||||
Some(ErrorGuaranteed::unchecked_claim_error_was_emitted())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.inner
|
||||
.borrow()
|
||||
.has_errors_or_delayed_span_bugs()
|
||||
.then(ErrorGuaranteed::unchecked_claim_error_was_emitted)
|
||||
}
|
||||
pub fn is_compilation_going_to_fail(&self) -> Option<ErrorGuaranteed> {
|
||||
if self.inner.borrow().is_compilation_going_to_fail() {
|
||||
Some(ErrorGuaranteed::unchecked_claim_error_was_emitted())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.inner
|
||||
.borrow()
|
||||
.is_compilation_going_to_fail()
|
||||
.then(ErrorGuaranteed::unchecked_claim_error_was_emitted)
|
||||
}
|
||||
|
||||
pub fn print_error_count(&self, registry: &Registry) {
|
||||
|
@ -238,12 +238,10 @@ macro_rules! configure {
|
||||
impl<'a> StripUnconfigured<'a> {
|
||||
pub fn configure<T: HasAttrs + HasTokens>(&self, mut node: T) -> Option<T> {
|
||||
self.process_cfg_attrs(&mut node);
|
||||
if self.in_cfg(node.attrs()) {
|
||||
self.in_cfg(node.attrs()).then(|| {
|
||||
self.try_configure_tokens(&mut node);
|
||||
Some(node)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
node
|
||||
})
|
||||
}
|
||||
|
||||
fn try_configure_tokens<T: HasTokens>(&self, node: &mut T) {
|
||||
@ -257,7 +255,7 @@ fn try_configure_tokens<T: HasTokens>(&self, node: &mut T) {
|
||||
|
||||
fn configure_krate_attrs(&self, mut attrs: ast::AttrVec) -> Option<ast::AttrVec> {
|
||||
attrs.flat_map_in_place(|attr| self.process_cfg_attr(attr));
|
||||
if self.in_cfg(&attrs) { Some(attrs) } else { None }
|
||||
self.in_cfg(&attrs).then(|| attrs)
|
||||
}
|
||||
|
||||
/// Performs cfg-expansion on `stream`, producing a new `AttrTokenStream`.
|
||||
|
@ -574,14 +574,11 @@ pub fn span_for_lifetime_suggestion(&self) -> Option<Span> {
|
||||
|
||||
/// If there are generic parameters, return where to introduce a new one.
|
||||
pub fn span_for_param_suggestion(&self) -> Option<Span> {
|
||||
if self.params.iter().any(|p| self.span.contains(p.span)) {
|
||||
self.params.iter().any(|p| self.span.contains(p.span)).then(|| {
|
||||
// `fn foo<A>(t: impl Trait)`
|
||||
// ^ suggest `, T: Trait` here
|
||||
let span = self.span.with_lo(self.span.hi() - BytePos(1)).shrink_to_lo();
|
||||
Some(span)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.span.with_lo(self.span.hi() - BytePos(1)).shrink_to_lo()
|
||||
})
|
||||
}
|
||||
|
||||
/// `Span` where further predicates would be suggested, accounting for trailing commas, like
|
||||
@ -639,7 +636,7 @@ pub fn bounds_span_for_suggestions(&self, param_def_id: LocalDefId) -> Option<Sp
|
||||
// We include bounds that come from a `#[derive(_)]` but point at the user's code,
|
||||
// as we use this method to get a span appropriate for suggestions.
|
||||
let bs = bound.span();
|
||||
if bs.can_be_used_for_suggestions() { Some(bs.shrink_to_hi()) } else { None }
|
||||
bs.can_be_used_for_suggestions().then(|| bs.shrink_to_hi())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
@ -259,13 +259,8 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
|
||||
}
|
||||
TraitItemKind::Const(ty, body_id) => body_id
|
||||
.and_then(|body_id| {
|
||||
if is_suggestable_infer_ty(ty) {
|
||||
Some(infer_placeholder_type(
|
||||
tcx, def_id, body_id, ty.span, item.ident, "constant",
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
is_suggestable_infer_ty(ty)
|
||||
.then(|| infer_placeholder_type(tcx, def_id, body_id, ty.span, item.ident, "constant",))
|
||||
})
|
||||
.unwrap_or_else(|| icx.to_ty(ty)),
|
||||
TraitItemKind::Type(_, Some(ty)) => icx.to_ty(ty),
|
||||
|
@ -74,15 +74,13 @@ pub(super) fn check_fn<'a, 'tcx>(
|
||||
|
||||
// C-variadic fns also have a `VaList` input that's not listed in `fn_sig`
|
||||
// (as it's created inside the body itself, not passed in from outside).
|
||||
let maybe_va_list = if fn_sig.c_variadic {
|
||||
let maybe_va_list = fn_sig.c_variadic.then(|| {
|
||||
let span = body.params.last().unwrap().span;
|
||||
let va_list_did = tcx.require_lang_item(LangItem::VaList, Some(span));
|
||||
let region = fcx.next_region_var(RegionVariableOrigin::MiscVariable(span));
|
||||
|
||||
Some(tcx.bound_type_of(va_list_did).subst(tcx, &[region.into()]))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
tcx.bound_type_of(va_list_did).subst(tcx, &[region.into()])
|
||||
});
|
||||
|
||||
// Add formal parameters.
|
||||
let inputs_hir = hir.fn_decl_by_hir_id(fn_id).map(|decl| &decl.inputs);
|
||||
|
@ -274,12 +274,10 @@ pub fn resolve_interior<'a, 'tcx>(
|
||||
let r = fcx.tcx.mk_region(ty::ReLateBound(current_depth, br));
|
||||
r
|
||||
});
|
||||
if captured_tys.insert(ty) {
|
||||
captured_tys.insert(ty).then(|| {
|
||||
cause.ty = ty;
|
||||
Some(cause)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
cause
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
@ -90,20 +90,18 @@ pub fn find_param_with_region<'tcx>(
|
||||
r
|
||||
}
|
||||
});
|
||||
if found_anon_region {
|
||||
found_anon_region.then(|| {
|
||||
let ty_hir_id = fn_decl.inputs[index].hir_id;
|
||||
let param_ty_span = hir.span(ty_hir_id);
|
||||
let is_first = index == 0;
|
||||
Some(AnonymousParamInfo {
|
||||
AnonymousParamInfo {
|
||||
param,
|
||||
param_ty: new_param_ty,
|
||||
param_ty_span,
|
||||
bound_region,
|
||||
is_first,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -2308,11 +2308,7 @@ fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
|
||||
.for_each(|(&name, &span)| {
|
||||
let note = rustc_feature::find_feature_issue(name, GateIssue::Language)
|
||||
.map(|n| BuiltinIncompleteFeaturesNote { n });
|
||||
let help = if HAS_MIN_FEATURES.contains(&name) {
|
||||
Some(BuiltinIncompleteFeaturesHelp)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let help = HAS_MIN_FEATURES.contains(&name).then(|| BuiltinIncompleteFeaturesHelp);
|
||||
cx.emit_spanned_lint(
|
||||
INCOMPLETE_FEATURES,
|
||||
span,
|
||||
|
@ -487,7 +487,7 @@ fn no_lint_suggestion(&self, lint_name: &str) -> CheckLintNameResult<'_> {
|
||||
let mut groups: Vec<_> = self
|
||||
.lint_groups
|
||||
.iter()
|
||||
.filter_map(|(k, LintGroup { depr, .. })| if depr.is_none() { Some(k) } else { None })
|
||||
.filter_map(|(k, LintGroup { depr, .. })| depr.is_none().then(|| k))
|
||||
.collect();
|
||||
groups.sort();
|
||||
let groups = groups.iter().map(|k| Symbol::intern(k));
|
||||
@ -1112,11 +1112,9 @@ pub fn qpath_res(&self, qpath: &hir::QPath<'_>, id: hir::HirId) -> Res {
|
||||
.maybe_typeck_results()
|
||||
.filter(|typeck_results| typeck_results.hir_owner == id.owner)
|
||||
.or_else(|| {
|
||||
if self.tcx.has_typeck_results(id.owner.to_def_id()) {
|
||||
Some(self.tcx.typeck(id.owner.def_id))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.tcx
|
||||
.has_typeck_results(id.owner.to_def_id())
|
||||
.then(|| self.tcx.typeck(id.owner.def_id))
|
||||
})
|
||||
.and_then(|typeck_results| typeck_results.type_dependent_def(id))
|
||||
.map_or(Res::Err, |(kind, def_id)| Res::Def(kind, def_id)),
|
||||
|
@ -65,11 +65,8 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
} else {
|
||||
ForLoopsOverFalliblesLoopSub::UseWhileLet { start_span: expr.span.with_hi(pat.span.lo()), end_span: pat.span.between(arg.span), var }
|
||||
} ;
|
||||
let question_mark = if suggest_question_mark(cx, adt, substs, expr.span) {
|
||||
Some(ForLoopsOverFalliblesQuestionMark { suggestion: arg.span.shrink_to_hi() })
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let question_mark = suggest_question_mark(cx, adt, substs, expr.span)
|
||||
.then(|| ForLoopsOverFalliblesQuestionMark { suggestion: arg.span.shrink_to_hi() });
|
||||
let suggestion = ForLoopsOverFalliblesSuggestion {
|
||||
var,
|
||||
start_span: expr.span.with_hi(pat.span.lo()),
|
||||
|
@ -1062,7 +1062,7 @@ pub fn span_with_body(self, hir_id: HirId) -> Span {
|
||||
}
|
||||
|
||||
pub fn span_if_local(self, id: DefId) -> Option<Span> {
|
||||
if id.is_local() { Some(self.tcx.def_span(id)) } else { None }
|
||||
id.is_local().then(|| self.tcx.def_span(id))
|
||||
}
|
||||
|
||||
pub fn res_span(self, res: Res) -> Option<Span> {
|
||||
|
@ -1113,13 +1113,11 @@ pub fn return_type_impl_trait(self, scope_def_id: LocalDefId) -> Option<(Ty<'tcx
|
||||
ty::FnDef(_, _) => {
|
||||
let sig = ret_ty.fn_sig(self);
|
||||
let output = self.erase_late_bound_regions(sig.output());
|
||||
if output.is_impl_trait() {
|
||||
output.is_impl_trait().then(|| {
|
||||
let hir_id = self.hir().local_def_id_to_hir_id(scope_def_id);
|
||||
let fn_decl = self.hir().fn_decl_by_hir_id(hir_id).unwrap();
|
||||
Some((output, fn_decl.output.span()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
(output, fn_decl.output.span())
|
||||
})
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
@ -1225,13 +1223,12 @@ macro_rules! nop_lift {
|
||||
impl<'a, 'tcx> Lift<'tcx> for $ty {
|
||||
type Lifted = $lifted;
|
||||
fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
if tcx.interners.$set.contains_pointer_to(&InternedInSet(&*self.0.0)) {
|
||||
tcx.interners
|
||||
.$set
|
||||
.contains_pointer_to(&InternedInSet(&*self.0.0))
|
||||
// SAFETY: `self` is interned and therefore valid
|
||||
// for the entire lifetime of the `TyCtxt`.
|
||||
Some(unsafe { mem::transmute(self) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
.then(|| unsafe { mem::transmute(self) })
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -1246,13 +1243,13 @@ fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
if self.is_empty() {
|
||||
return Some(List::empty());
|
||||
}
|
||||
if tcx.interners.substs.contains_pointer_to(&InternedInSet(self.as_substs())) {
|
||||
|
||||
tcx.interners
|
||||
.substs
|
||||
.contains_pointer_to(&InternedInSet(self.as_substs()))
|
||||
// SAFETY: `self` is interned and therefore valid
|
||||
// for the entire lifetime of the `TyCtxt`.
|
||||
Some(unsafe { mem::transmute::<&'a List<Ty<'a>>, &'tcx List<Ty<'tcx>>>(self) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
.then(|| unsafe { mem::transmute::<&'a List<Ty<'a>>, &'tcx List<Ty<'tcx>>>(self) })
|
||||
}
|
||||
}
|
||||
|
||||
@ -1264,11 +1261,10 @@ fn lift_to_tcx(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
if self.is_empty() {
|
||||
return Some(List::empty());
|
||||
}
|
||||
if tcx.interners.$set.contains_pointer_to(&InternedInSet(self)) {
|
||||
Some(unsafe { mem::transmute(self) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
tcx.interners
|
||||
.$set
|
||||
.contains_pointer_to(&InternedInSet(self))
|
||||
.then(|| unsafe { mem::transmute(self) })
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -584,7 +584,7 @@ pub fn fn_once_adapter_instance(
|
||||
/// this function returns `None`, then the MIR body does not require substitution during
|
||||
/// codegen.
|
||||
fn substs_for_mir_body(&self) -> Option<SubstsRef<'tcx>> {
|
||||
if self.def.has_polymorphic_mir_body() { Some(self.substs) } else { None }
|
||||
self.def.has_polymorphic_mir_body().then(|| self.substs)
|
||||
}
|
||||
|
||||
pub fn subst_mir<T>(&self, tcx: TyCtxt<'tcx>, v: &T) -> T
|
||||
|
@ -267,13 +267,11 @@ fn decode(d: &mut D) -> GenericArg<'tcx> {
|
||||
impl<'tcx> InternalSubsts<'tcx> {
|
||||
/// Checks whether all elements of this list are types, if so, transmute.
|
||||
pub fn try_as_type_list(&'tcx self) -> Option<&'tcx List<Ty<'tcx>>> {
|
||||
if self.iter().all(|arg| matches!(arg.unpack(), GenericArgKind::Type(_))) {
|
||||
self.iter().all(|arg| matches!(arg.unpack(), GenericArgKind::Type(_))).then(|| {
|
||||
assert_eq!(TYPE_TAG, 0);
|
||||
// SAFETY: All elements are types, see `List<Ty<'tcx>>::as_substs`.
|
||||
Some(unsafe { &*(self as *const List<GenericArg<'tcx>> as *const List<Ty<'tcx>>) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
unsafe { &*(self as *const List<GenericArg<'tcx>> as *const List<Ty<'tcx>>) }
|
||||
})
|
||||
}
|
||||
|
||||
/// Interpret these substitutions as the substitutions of a closure type.
|
||||
|
@ -319,7 +319,7 @@ pub(crate) fn expr_into_dest(
|
||||
// See the notes for `ExprKind::Array` in `as_rvalue` and for
|
||||
// `ExprKind::Borrow` above.
|
||||
let is_union = adt_def.is_union();
|
||||
let active_field_index = if is_union { Some(fields[0].name.index()) } else { None };
|
||||
let active_field_index = is_union.then(|| fields[0].name.index());
|
||||
|
||||
let scope = this.local_scope();
|
||||
|
||||
|
@ -563,14 +563,11 @@ pub(super) fn sort_candidate<'pat>(
|
||||
let not_contained =
|
||||
self.values_not_contained_in_range(&*range, options).unwrap_or(false);
|
||||
|
||||
if not_contained {
|
||||
not_contained.then(|| {
|
||||
// No switch values are contained in the pattern range,
|
||||
// so the pattern can be matched only if this test fails.
|
||||
let otherwise = options.len();
|
||||
Some(otherwise)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
options.len()
|
||||
})
|
||||
}
|
||||
|
||||
(&TestKind::SwitchInt { .. }, _) => None,
|
||||
|
@ -172,7 +172,7 @@ fn from_range<'tcx>(
|
||||
ty: Ty<'tcx>,
|
||||
end: &RangeEnd,
|
||||
) -> Option<IntRange> {
|
||||
if Self::is_integral(ty) {
|
||||
Self::is_integral(ty).then(|| {
|
||||
// Perform a shift if the underlying types are signed,
|
||||
// which makes the interval arithmetic simpler.
|
||||
let bias = IntRange::signed_bias(tcx, ty);
|
||||
@ -182,10 +182,8 @@ fn from_range<'tcx>(
|
||||
// This should have been caught earlier by E0030.
|
||||
bug!("malformed range pattern: {}..={}", lo, (hi - offset));
|
||||
}
|
||||
Some(IntRange { range: lo..=(hi - offset), bias })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
IntRange { range: lo..=(hi - offset), bias }
|
||||
})
|
||||
}
|
||||
|
||||
// The return value of `signed_bias` should be XORed with an endpoint to encode/decode it.
|
||||
|
@ -203,11 +203,7 @@ fn lower_pattern_range(
|
||||
if !lower_overflow && !higher_overflow {
|
||||
self.tcx.sess.emit_err(LowerRangeBoundMustBeLessThanOrEqualToUpper {
|
||||
span,
|
||||
teach: if self.tcx.sess.teach(&error_code!(E0030)) {
|
||||
Some(())
|
||||
} else {
|
||||
None
|
||||
},
|
||||
teach: self.tcx.sess.teach(&error_code!(E0030)).then(|| ()),
|
||||
});
|
||||
}
|
||||
PatKind::Wild
|
||||
|
@ -254,13 +254,7 @@ fn apply_statement_effect(
|
||||
) {
|
||||
// Compute the place that we are storing to, if any
|
||||
let destination = match &statement.kind {
|
||||
StatementKind::Assign(assign) => {
|
||||
if assign.1.is_safe_to_remove() {
|
||||
Some(assign.0)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
StatementKind::Assign(assign) => assign.1.is_safe_to_remove().then(|| assign.0),
|
||||
StatementKind::SetDiscriminant { place, .. } | StatementKind::Deinit(place) => {
|
||||
Some(**place)
|
||||
}
|
||||
|
@ -111,11 +111,9 @@ fn check_bound_args(
|
||||
/// If the given predicate is the trait `fmt::Pointer`, returns the bound parameter type.
|
||||
fn is_pointer_trait(&self, bound: &PredicateKind<'tcx>) -> Option<Ty<'tcx>> {
|
||||
if let ty::PredicateKind::Clause(ty::Clause::Trait(predicate)) = bound {
|
||||
if self.tcx.is_diagnostic_item(sym::Pointer, predicate.def_id()) {
|
||||
Some(predicate.trait_ref.self_ty())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
self.tcx
|
||||
.is_diagnostic_item(sym::Pointer, predicate.def_id())
|
||||
.then(|| predicate.trait_ref.self_ty())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
@ -1283,22 +1283,16 @@ fn parse_attr_args(&mut self) -> PResult<'a, AttrArgs> {
|
||||
}
|
||||
|
||||
fn parse_delim_args_inner(&mut self) -> Option<DelimArgs> {
|
||||
if self.check(&token::OpenDelim(Delimiter::Parenthesis))
|
||||
let delimited = self.check(&token::OpenDelim(Delimiter::Parenthesis))
|
||||
|| self.check(&token::OpenDelim(Delimiter::Bracket))
|
||||
|| self.check(&token::OpenDelim(Delimiter::Brace))
|
||||
{
|
||||
match self.parse_token_tree() {
|
||||
// We've confirmed above that there is a delimiter so unwrapping is OK.
|
||||
TokenTree::Delimited(dspan, delim, tokens) => Some(DelimArgs {
|
||||
dspan,
|
||||
delim: MacDelimiter::from_token(delim).unwrap(),
|
||||
tokens,
|
||||
}),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|| self.check(&token::OpenDelim(Delimiter::Brace));
|
||||
|
||||
delimited.then(|| {
|
||||
// We've confirmed above that there is a delimiter so unwrapping is OK.
|
||||
let TokenTree::Delimited(dspan, delim, tokens) = self.parse_token_tree() else { unreachable!() };
|
||||
|
||||
DelimArgs { dspan, delim: MacDelimiter::from_token(delim).unwrap(), tokens }
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_or_use_outer_attributes(
|
||||
|
@ -404,7 +404,7 @@ fn parse_angle_args_with_leading_angle_bracket_recovery(
|
||||
|
||||
let is_first_invocation = style == PathStyle::Expr;
|
||||
// Take a snapshot before attempting to parse - we can restore this later.
|
||||
let snapshot = if is_first_invocation { Some(self.clone()) } else { None };
|
||||
let snapshot = is_first_invocation.then(|| self.clone());
|
||||
|
||||
debug!("parse_generic_args_with_leading_angle_bracket_recovery: (snapshotting)");
|
||||
match self.parse_angle_args(ty_generics) {
|
||||
|
@ -450,8 +450,7 @@ fn parse_array_or_slice_ty(&mut self) -> PResult<'a, TyKind> {
|
||||
|
||||
fn parse_borrowed_pointee(&mut self) -> PResult<'a, TyKind> {
|
||||
let and_span = self.prev_token.span;
|
||||
let mut opt_lifetime =
|
||||
if self.check_lifetime() { Some(self.expect_lifetime()) } else { None };
|
||||
let mut opt_lifetime = self.check_lifetime().then(|| self.expect_lifetime());
|
||||
let mut mutbl = self.parse_mutability();
|
||||
if self.token.is_lifetime() && mutbl == Mutability::Mut && opt_lifetime.is_none() {
|
||||
// A lifetime is invalid here: it would be part of a bare trait bound, which requires
|
||||
@ -871,7 +870,7 @@ fn parse_ty_bound_modifiers(&mut self) -> PResult<'a, BoundModifiers> {
|
||||
None
|
||||
};
|
||||
|
||||
let maybe = if self.eat(&token::Question) { Some(self.prev_token.span) } else { None };
|
||||
let maybe = self.eat(&token::Question).then(|| self.prev_token.span);
|
||||
|
||||
Ok(BoundModifiers { maybe, maybe_const })
|
||||
}
|
||||
|
@ -835,7 +835,7 @@ fn integer(&mut self) -> Option<usize> {
|
||||
);
|
||||
}
|
||||
|
||||
if found { Some(cur) } else { None }
|
||||
found.then(|| cur)
|
||||
}
|
||||
|
||||
fn suggest_format(&mut self) {
|
||||
|
@ -32,11 +32,8 @@ fn collect_item(tcx: TyCtxt<'_>, items: &mut DiagnosticItems, name: Symbol, item
|
||||
if let Some(original_def_id) = items.name_to_id.insert(name, item_def_id) {
|
||||
if original_def_id != item_def_id {
|
||||
let orig_span = tcx.hir().span_if_local(original_def_id);
|
||||
let orig_crate_name = if orig_span.is_some() {
|
||||
None
|
||||
} else {
|
||||
Some(tcx.crate_name(original_def_id.krate))
|
||||
};
|
||||
let orig_crate_name =
|
||||
orig_span.is_none().then(|| tcx.crate_name(original_def_id.krate));
|
||||
match tcx.hir().span_if_local(item_def_id) {
|
||||
Some(span) => tcx.sess.emit_err(DuplicateDiagnosticItem { span, name }),
|
||||
None => tcx.sess.emit_err(DuplicateDiagnosticItemInCrate {
|
||||
|
@ -281,7 +281,7 @@ fn annotate<F>(
|
||||
self.recurse_with_stability_attrs(
|
||||
depr.map(|(d, _)| DeprecationEntry::local(d, def_id)),
|
||||
stab,
|
||||
if inherit_const_stability.yes() { const_stab } else { None },
|
||||
inherit_const_stability.yes().then(|| const_stab).flatten(),
|
||||
visit_children,
|
||||
);
|
||||
}
|
||||
|
@ -242,8 +242,7 @@ pub fn new(
|
||||
record_graph: bool,
|
||||
record_stats: bool,
|
||||
) -> Self {
|
||||
let record_graph =
|
||||
if record_graph { Some(Lock::new(DepGraphQuery::new(prev_node_count))) } else { None };
|
||||
let record_graph = record_graph.then(|| Lock::new(DepGraphQuery::new(prev_node_count)));
|
||||
let status = Lock::new(EncoderState::new(encoder, record_stats));
|
||||
GraphEncoder { status, record_graph }
|
||||
}
|
||||
|
@ -1700,11 +1700,9 @@ fn lookup_typo_candidate(
|
||||
let crate_mod =
|
||||
Res::Def(DefKind::Mod, crate_id.as_def_id());
|
||||
|
||||
if filter_fn(crate_mod) {
|
||||
Some(TypoSuggestion::typo_from_ident(*ident, crate_mod))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
filter_fn(crate_mod).then(|| {
|
||||
TypoSuggestion::typo_from_ident(*ident, crate_mod)
|
||||
})
|
||||
})
|
||||
}));
|
||||
|
||||
|
@ -2544,7 +2544,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
|
||||
}
|
||||
|
||||
// Only use this directory if it has a file we can expect to always find.
|
||||
if candidate.join("library/std/src/lib.rs").is_file() { Some(candidate) } else { None }
|
||||
candidate.join("library/std/src/lib.rs").is_file().then(|| candidate)
|
||||
};
|
||||
|
||||
let working_dir = std::env::current_dir().unwrap_or_else(|e| {
|
||||
|
@ -322,11 +322,7 @@ fn fix_base_capitalisation(prefix: &str, suffix: &str) -> Option<String> {
|
||||
.take_while(|c| *c != 'i' && *c != 'u')
|
||||
.all(|c| c.to_digit(base).is_some());
|
||||
|
||||
if valid {
|
||||
Some(format!("0{}{}", base_char.to_ascii_lowercase(), &suffix[1..]))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
valid.then(|| format!("0{}{}", base_char.to_ascii_lowercase(), &suffix[1..]))
|
||||
}
|
||||
|
||||
let token::Lit { kind, symbol, suffix, .. } = lit;
|
||||
|
@ -217,7 +217,7 @@ fn from_env_args_next() -> Option<PathBuf> {
|
||||
// Look for the target rustlib directory in the suspected sysroot.
|
||||
let mut rustlib_path = rustc_target::target_rustlib_path(&p, "dummy");
|
||||
rustlib_path.pop(); // pop off the dummy target.
|
||||
if rustlib_path.exists() { Some(p) } else { None }
|
||||
rustlib_path.exists().then(|| p)
|
||||
}
|
||||
None => None,
|
||||
}
|
||||
|
@ -809,7 +809,7 @@ pub(crate) fn parse_mir_spanview(slot: &mut Option<MirSpanview>, v: Option<&str>
|
||||
if v.is_some() {
|
||||
let mut bool_arg = None;
|
||||
if parse_opt_bool(&mut bool_arg, v) {
|
||||
*slot = if bool_arg.unwrap() { Some(MirSpanview::Statement) } else { None };
|
||||
*slot = bool_arg.unwrap().then(|| MirSpanview::Statement);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -850,7 +850,7 @@ pub(crate) fn parse_instrument_coverage(
|
||||
if v.is_some() {
|
||||
let mut bool_arg = None;
|
||||
if parse_opt_bool(&mut bool_arg, v) {
|
||||
*slot = if bool_arg.unwrap() { Some(InstrumentCoverage::All) } else { None };
|
||||
*slot = bool_arg.unwrap().then(|| InstrumentCoverage::All);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +299,7 @@ pub fn is_local(self) -> bool {
|
||||
|
||||
#[inline]
|
||||
pub fn as_local(self) -> Option<LocalDefId> {
|
||||
if self.is_local() { Some(LocalDefId { local_def_index: self.index }) } else { None }
|
||||
self.is_local().then(|| LocalDefId { local_def_index: self.index })
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@ -320,7 +320,7 @@ pub fn is_crate_root(self) -> bool {
|
||||
|
||||
#[inline]
|
||||
pub fn as_crate_root(self) -> Option<CrateNum> {
|
||||
if self.is_crate_root() { Some(self.krate) } else { None }
|
||||
self.is_crate_root().then(|| self.krate)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -244,8 +244,7 @@ fn compute_symbol_name<'tcx>(
|
||||
// project.
|
||||
let avoid_cross_crate_conflicts = is_generic(substs) || is_globally_shared_function;
|
||||
|
||||
let instantiating_crate =
|
||||
if avoid_cross_crate_conflicts { Some(compute_instantiating_crate()) } else { None };
|
||||
let instantiating_crate = avoid_cross_crate_conflicts.then(compute_instantiating_crate);
|
||||
|
||||
// Pick the crate responsible for the symbol mangling version, which has to:
|
||||
// 1. be stable for each instance, whether it's being defined or imported
|
||||
|
@ -82,11 +82,8 @@ fn try_get_upvar_span<F>(
|
||||
upvars.iter().find_map(|(upvar_id, upvar)| {
|
||||
let upvar_ty = typeck_results.node_type(*upvar_id);
|
||||
let upvar_ty = infer_context.resolve_vars_if_possible(upvar_ty);
|
||||
if ty_matches(ty::Binder::dummy(upvar_ty)) {
|
||||
Some(GeneratorInteriorOrUpvar::Upvar(upvar.span))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
ty_matches(ty::Binder::dummy(upvar_ty))
|
||||
.then(|| GeneratorInteriorOrUpvar::Upvar(upvar.span))
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -770,15 +767,13 @@ fn suggest_dereferences(
|
||||
obligation.param_env,
|
||||
real_trait_pred_and_ty,
|
||||
);
|
||||
if obligations
|
||||
let may_hold = obligations
|
||||
.iter()
|
||||
.chain([&obligation])
|
||||
.all(|obligation| self.predicate_may_hold(obligation))
|
||||
{
|
||||
Some(steps)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
.then(|| steps);
|
||||
|
||||
may_hold
|
||||
})
|
||||
{
|
||||
if steps > 0 {
|
||||
|
@ -523,16 +523,14 @@ fn visit_const(&mut self, ct: ty::Const<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
|
||||
let mut visitor = ReferencesOnlyParentGenerics { tcx, generics, trait_item_def_id };
|
||||
let predicates_for_trait = predicates.predicates.iter().filter_map(|(pred, span)| {
|
||||
if pred.visit_with(&mut visitor).is_continue() {
|
||||
Some(Obligation::new(
|
||||
pred.visit_with(&mut visitor).is_continue().then(|| {
|
||||
Obligation::new(
|
||||
tcx,
|
||||
ObligationCause::dummy_with_span(*span),
|
||||
param_env,
|
||||
ty::EarlyBinder(*pred).subst(tcx, impl_trait_ref.substs),
|
||||
))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
)
|
||||
})
|
||||
});
|
||||
|
||||
let infcx = tcx.infer_ctxt().ignoring_regions().build();
|
||||
|
@ -307,7 +307,7 @@ fn predicate_references_self<'tcx>(
|
||||
match predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Clause(ty::Clause::Trait(ref data)) => {
|
||||
// In the case of a trait predicate, we can skip the "self" type.
|
||||
if data.trait_ref.substs[1..].iter().any(has_self_ty) { Some(sp) } else { None }
|
||||
data.trait_ref.substs[1..].iter().any(has_self_ty).then(|| sp)
|
||||
}
|
||||
ty::PredicateKind::Clause(ty::Clause::Projection(ref data)) => {
|
||||
// And similarly for projections. This should be redundant with
|
||||
@ -325,7 +325,7 @@ fn predicate_references_self<'tcx>(
|
||||
//
|
||||
// This is ALT2 in issue #56288, see that for discussion of the
|
||||
// possible alternatives.
|
||||
if data.projection_ty.substs[1..].iter().any(has_self_ty) { Some(sp) } else { None }
|
||||
data.projection_ty.substs[1..].iter().any(has_self_ty).then(|| sp)
|
||||
}
|
||||
ty::PredicateKind::AliasEq(..) => bug!("`AliasEq` not allowed as assumption"),
|
||||
|
||||
|
@ -21,11 +21,7 @@ fn try_fast_path(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
key: &ParamEnvAnd<'tcx, Self>,
|
||||
) -> Option<Self::QueryResponse> {
|
||||
if trivial_dropck_outlives(tcx, key.value.dropped_ty) {
|
||||
Some(DropckOutlivesResult::default())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
trivial_dropck_outlives(tcx, key.value.dropped_ty).then(DropckOutlivesResult::default)
|
||||
}
|
||||
|
||||
fn perform_query(
|
||||
|
@ -378,11 +378,8 @@ fn candidate_from_obligation_no_cache<'o>(
|
||||
let self_ty = trait_ref.self_ty();
|
||||
let (trait_desc, self_desc) = with_no_trimmed_paths!({
|
||||
let trait_desc = trait_ref.print_only_trait_path().to_string();
|
||||
let self_desc = if self_ty.has_concrete_skeleton() {
|
||||
Some(self_ty.to_string())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let self_desc =
|
||||
self_ty.has_concrete_skeleton().then(|| self_ty.to_string());
|
||||
(trait_desc, self_desc)
|
||||
});
|
||||
let cause = if let Conflict::Upstream = conflict {
|
||||
|
@ -113,7 +113,7 @@ fn insert(
|
||||
// Only report the `Self` type if it has at least
|
||||
// some outer concrete shell; otherwise, it's
|
||||
// not adding much information.
|
||||
self_ty: if self_ty.has_concrete_skeleton() { Some(self_ty) } else { None },
|
||||
self_ty: self_ty.has_concrete_skeleton().then(|| self_ty),
|
||||
intercrate_ambiguity_causes: overlap.intercrate_ambiguity_causes,
|
||||
involves_placeholder: overlap.involves_placeholder,
|
||||
}
|
||||
|
@ -207,11 +207,8 @@ fn fn_abi_of_instance<'tcx>(
|
||||
|
||||
let sig = fn_sig_for_fn_abi(tcx, instance, param_env);
|
||||
|
||||
let caller_location = if instance.def.requires_caller_location(tcx) {
|
||||
Some(tcx.caller_location_ty())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let caller_location =
|
||||
instance.def.requires_caller_location(tcx).then(|| tcx.caller_location_ty());
|
||||
|
||||
fn_abi_new_uncached(
|
||||
&LayoutCx { tcx, param_env },
|
||||
|
Loading…
Reference in New Issue
Block a user