Format all the let chains in compiler
This commit is contained in:
parent
2763ca50da
commit
b2d2184ede
206 changed files with 3120 additions and 2228 deletions
|
@ -396,11 +396,14 @@ fn verify_ok(tcx: TyCtxt<'_>, list: &[Linkage]) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if let Some(found_strategy) = tcx.required_panic_strategy(cnum) && desired_strategy != found_strategy {
|
||||
if let Some(found_strategy) = tcx.required_panic_strategy(cnum)
|
||||
&& desired_strategy != found_strategy
|
||||
{
|
||||
sess.emit_err(RequiredPanicStrategy {
|
||||
crate_name: tcx.crate_name(cnum),
|
||||
found_strategy,
|
||||
desired_strategy});
|
||||
desired_strategy,
|
||||
});
|
||||
}
|
||||
|
||||
let found_drop_strategy = tcx.panic_in_drop_strategy(cnum);
|
||||
|
|
|
@ -419,7 +419,9 @@ impl<'a> MissingNativeLibrary<'a> {
|
|||
// if it looks like the user has provided a complete filename rather just the bare lib name,
|
||||
// then provide a note that they might want to try trimming the name
|
||||
let suggested_name = if !verbatim {
|
||||
if let Some(libname) = libname.strip_prefix("lib") && let Some(libname) = libname.strip_suffix(".a") {
|
||||
if let Some(libname) = libname.strip_prefix("lib")
|
||||
&& let Some(libname) = libname.strip_suffix(".a")
|
||||
{
|
||||
// this is a unix style filename so trim prefix & suffix
|
||||
Some(libname)
|
||||
} else if let Some(libname) = libname.strip_suffix(".lib") {
|
||||
|
|
|
@ -383,7 +383,9 @@ impl<'tcx> Collector<'tcx> {
|
|||
// First, check for errors
|
||||
let mut renames = FxHashSet::default();
|
||||
for lib in &self.tcx.sess.opts.libs {
|
||||
if let NativeLibKind::Framework { .. } = lib.kind && !self.tcx.sess.target.is_like_osx {
|
||||
if let NativeLibKind::Framework { .. } = lib.kind
|
||||
&& !self.tcx.sess.target.is_like_osx
|
||||
{
|
||||
// Cannot check this when parsing options because the target is not yet available.
|
||||
self.tcx.sess.emit_err(errors::LibFrameworkApple);
|
||||
}
|
||||
|
|
|
@ -1692,17 +1692,22 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
|
|||
// `try_to_translate_virtual_to_real` don't have to worry about how the
|
||||
// compiler is bootstrapped.
|
||||
if let Some(virtual_dir) = &sess.opts.unstable_opts.simulate_remapped_rust_src_base
|
||||
&& let Some(real_dir) = &sess.opts.real_rust_source_base_dir
|
||||
&& let rustc_span::FileName::Real(ref mut old_name) = name {
|
||||
&& let Some(real_dir) = &sess.opts.real_rust_source_base_dir
|
||||
&& let rustc_span::FileName::Real(ref mut old_name) = name
|
||||
{
|
||||
let relative_path = match old_name {
|
||||
rustc_span::RealFileName::LocalPath(local) => local.strip_prefix(real_dir).ok(),
|
||||
rustc_span::RealFileName::LocalPath(local) => {
|
||||
local.strip_prefix(real_dir).ok()
|
||||
}
|
||||
rustc_span::RealFileName::Remapped { virtual_name, .. } => {
|
||||
option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR").and_then(|virtual_dir| virtual_name.strip_prefix(virtual_dir).ok())
|
||||
option_env!("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR")
|
||||
.and_then(|virtual_dir| virtual_name.strip_prefix(virtual_dir).ok())
|
||||
}
|
||||
};
|
||||
debug!(?relative_path, ?virtual_dir, "simulate_remapped_rust_src_base");
|
||||
for subdir in ["library", "compiler"] {
|
||||
if let Some(rest) = relative_path.and_then(|p| p.strip_prefix(subdir).ok()) {
|
||||
if let Some(rest) = relative_path.and_then(|p| p.strip_prefix(subdir).ok())
|
||||
{
|
||||
*old_name = rustc_span::RealFileName::Remapped {
|
||||
local_path: None, // FIXME: maybe we should preserve this?
|
||||
virtual_name: virtual_dir.join(subdir).join(rest),
|
||||
|
|
|
@ -1155,7 +1155,8 @@ fn should_encode_type(tcx: TyCtxt<'_>, def_id: LocalDefId, def_kind: DefKind) ->
|
|||
|
||||
DefKind::OpaqueTy => {
|
||||
let origin = tcx.opaque_type_origin(def_id);
|
||||
if let hir::OpaqueTyOrigin::FnReturn(fn_def_id) | hir::OpaqueTyOrigin::AsyncFn(fn_def_id) = origin
|
||||
if let hir::OpaqueTyOrigin::FnReturn(fn_def_id)
|
||||
| hir::OpaqueTyOrigin::AsyncFn(fn_def_id) = origin
|
||||
&& let hir::Node::TraitItem(trait_item) = tcx.hir().get_by_def_id(fn_def_id)
|
||||
&& let (_, hir::TraitFn::Required(..)) = trait_item.expect_fn()
|
||||
{
|
||||
|
@ -1357,7 +1358,9 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
if should_encode_expn_that_defined(def_kind) {
|
||||
record!(self.tables.expn_that_defined[def_id] <- self.tcx.expn_that_defined(def_id));
|
||||
}
|
||||
if should_encode_span(def_kind) && let Some(ident_span) = tcx.def_ident_span(def_id) {
|
||||
if should_encode_span(def_kind)
|
||||
&& let Some(ident_span) = tcx.def_ident_span(def_id)
|
||||
{
|
||||
record!(self.tables.def_ident_span[def_id] <- ident_span);
|
||||
}
|
||||
if def_kind.has_codegen_attrs() {
|
||||
|
@ -1958,8 +1961,11 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
|
|||
record!(self.tables.impl_trait_ref[def_id] <- trait_ref);
|
||||
|
||||
let trait_ref = trait_ref.instantiate_identity();
|
||||
let simplified_self_ty =
|
||||
fast_reject::simplify_type(self.tcx, trait_ref.self_ty(), TreatParams::AsCandidateKey);
|
||||
let simplified_self_ty = fast_reject::simplify_type(
|
||||
self.tcx,
|
||||
trait_ref.self_ty(),
|
||||
TreatParams::AsCandidateKey,
|
||||
);
|
||||
fx_hash_map
|
||||
.entry(trait_ref.def_id)
|
||||
.or_default()
|
||||
|
@ -2372,8 +2378,9 @@ pub fn rendered_const<'tcx>(tcx: TyCtxt<'tcx>, body: hir::BodyId) -> String {
|
|||
let classification = classify(value);
|
||||
|
||||
if classification == Literal
|
||||
&& !value.span.from_expansion()
|
||||
&& let Ok(snippet) = tcx.sess.source_map().span_to_snippet(value.span) {
|
||||
&& !value.span.from_expansion()
|
||||
&& let Ok(snippet) = tcx.sess.source_map().span_to_snippet(value.span)
|
||||
{
|
||||
// For literals, we avoid invoking the pretty-printer and use the source snippet instead to
|
||||
// preserve certain stylistic choices the user likely made for the sake legibility like
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue