diff options
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ast_lowering/src/item.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_driver_impl/src/lib.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/flags.rs | 89 | ||||
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 7 | ||||
| -rw-r--r-- | compiler/rustc_type_ir/src/flags.rs | 16 | ||||
| -rw-r--r-- | compiler/rustc_type_ir/src/visit.rs | 4 |
6 files changed, 44 insertions, 90 deletions
diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index bd011d59aaa..518349343b3 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1724,8 +1724,8 @@ impl<'hir> LoweringContext<'_, 'hir> { return; }; let define_opaque = define_opaque.iter().filter_map(|(id, path)| { - let res = self.resolver.get_partial_res(*id).unwrap(); - let Some(did) = res.expect_full_res().opt_def_id() else { + let res = self.resolver.get_partial_res(*id); + let Some(did) = res.and_then(|res| res.expect_full_res().opt_def_id()) else { self.dcx().span_delayed_bug(path.span, "should have errored in resolve"); return None; }; diff --git a/compiler/rustc_driver_impl/src/lib.rs b/compiler/rustc_driver_impl/src/lib.rs index 4ba076c64e1..37755e7d61d 100644 --- a/compiler/rustc_driver_impl/src/lib.rs +++ b/compiler/rustc_driver_impl/src/lib.rs @@ -20,7 +20,7 @@ // tidy-alphabetical-end use std::cmp::max; -use std::collections::BTreeMap; +use std::collections::{BTreeMap, BTreeSet}; use std::ffi::OsString; use std::fmt::Write as _; use std::fs::{self, File}; @@ -61,7 +61,7 @@ use rustc_session::config::{ }; use rustc_session::getopts::{self, Matches}; use rustc_session::lint::{Lint, LintId}; -use rustc_session::output::collect_crate_types; +use rustc_session::output::{CRATE_TYPES, collect_crate_types, invalid_output_for_target}; use rustc_session::{EarlyDiagCtxt, Session, config, filesearch}; use rustc_span::FileName; use rustc_target::json::ToJson; @@ -790,6 +790,16 @@ fn print_crate_info( sess.dcx().fatal("only Apple targets currently support deployment version info") } } + SupportedCrateTypes => { + let supported_crate_types = CRATE_TYPES + .iter() + .filter(|(_, crate_type)| !invalid_output_for_target(&sess, *crate_type)) + .map(|(crate_type_sym, _)| *crate_type_sym) + .collect::<BTreeSet<_>>(); + for supported_crate_type in supported_crate_types { + println_info!("{}", supported_crate_type.as_str()); + } + } } req.out.overwrite(&crate_info, sess); diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index 0b8f0e8cd41..b0c442d28f0 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -101,63 +101,13 @@ impl FlagComputation { &ty::Param(_) => { self.add_flags(TypeFlags::HAS_TY_PARAM); - self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE); } - ty::Coroutine(_, args) => { - let args = args.as_coroutine(); - let should_remove_further_specializable = - !self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE); - self.add_args(args.parent_args()); - if should_remove_further_specializable { - self.flags -= TypeFlags::STILL_FURTHER_SPECIALIZABLE; - } - - self.add_ty(args.resume_ty()); - self.add_ty(args.return_ty()); - self.add_ty(args.witness()); - self.add_ty(args.yield_ty()); - self.add_ty(args.tupled_upvars_ty()); - } - - ty::CoroutineWitness(_, args) => { - let should_remove_further_specializable = - !self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE); + &ty::Closure(_, args) + | &ty::Coroutine(_, args) + | &ty::CoroutineClosure(_, args) + | &ty::CoroutineWitness(_, args) => { self.add_args(args); - if should_remove_further_specializable { - self.flags -= TypeFlags::STILL_FURTHER_SPECIALIZABLE; - } - self.add_flags(TypeFlags::HAS_TY_COROUTINE); - } - - &ty::Closure(_, args) => { - let args = args.as_closure(); - let should_remove_further_specializable = - !self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE); - self.add_args(args.parent_args()); - if should_remove_further_specializable { - self.flags -= TypeFlags::STILL_FURTHER_SPECIALIZABLE; - } - - self.add_ty(args.sig_as_fn_ptr_ty()); - self.add_ty(args.kind_ty()); - self.add_ty(args.tupled_upvars_ty()); - } - - &ty::CoroutineClosure(_, args) => { - let args = args.as_coroutine_closure(); - let should_remove_further_specializable = - !self.flags.contains(TypeFlags::STILL_FURTHER_SPECIALIZABLE); - self.add_args(args.parent_args()); - if should_remove_further_specializable { - self.flags -= TypeFlags::STILL_FURTHER_SPECIALIZABLE; - } - - self.add_ty(args.kind_ty()); - self.add_ty(args.signature_parts_ty()); - self.add_ty(args.tupled_upvars_ty()); - self.add_ty(args.coroutine_captures_by_ref_ty()); - self.add_ty(args.coroutine_witness_ty()); } &ty::Bound(debruijn, _) => { @@ -167,21 +117,17 @@ impl FlagComputation { &ty::Placeholder(..) => { self.add_flags(TypeFlags::HAS_TY_PLACEHOLDER); - self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE); } - &ty::Infer(infer) => { - self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE); - match infer { - ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => { - self.add_flags(TypeFlags::HAS_TY_FRESH) - } + &ty::Infer(infer) => match infer { + ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_) => { + self.add_flags(TypeFlags::HAS_TY_FRESH) + } - ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => { - self.add_flags(TypeFlags::HAS_TY_INFER) - } + ty::TyVar(_) | ty::IntVar(_) | ty::FloatVar(_) => { + self.add_flags(TypeFlags::HAS_TY_INFER) } - } + }, &ty::Adt(_, args) => { self.add_args(args); @@ -358,24 +304,19 @@ impl FlagComputation { self.add_args(uv.args); self.add_flags(TypeFlags::HAS_CT_PROJECTION); } - ty::ConstKind::Infer(infer) => { - self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE); - match infer { - InferConst::Fresh(_) => self.add_flags(TypeFlags::HAS_CT_FRESH), - InferConst::Var(_) => self.add_flags(TypeFlags::HAS_CT_INFER), - } - } + ty::ConstKind::Infer(infer) => match infer { + InferConst::Fresh(_) => self.add_flags(TypeFlags::HAS_CT_FRESH), + InferConst::Var(_) => self.add_flags(TypeFlags::HAS_CT_INFER), + }, ty::ConstKind::Bound(debruijn, _) => { self.add_bound_var(debruijn); self.add_flags(TypeFlags::HAS_CT_BOUND); } ty::ConstKind::Param(_) => { self.add_flags(TypeFlags::HAS_CT_PARAM); - self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE); } ty::ConstKind::Placeholder(_) => { self.add_flags(TypeFlags::HAS_CT_PLACEHOLDER); - self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE); } ty::ConstKind::Value(cv) => self.add_ty(cv.ty), ty::ConstKind::Expr(e) => self.add_args(e.args()), diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 43b78423c72..ed336cc5596 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -58,6 +58,7 @@ pub const PRINT_KINDS: &[(&str, PrintKind)] = &[ ("relocation-models", PrintKind::RelocationModels), ("split-debuginfo", PrintKind::SplitDebuginfo), ("stack-protector-strategies", PrintKind::StackProtectorStrategies), + ("supported-crate-types", PrintKind::SupportedCrateTypes), ("sysroot", PrintKind::Sysroot), ("target-cpus", PrintKind::TargetCPUs), ("target-features", PrintKind::TargetFeatures), @@ -888,6 +889,7 @@ pub enum PrintKind { RelocationModels, SplitDebuginfo, StackProtectorStrategies, + SupportedCrateTypes, Sysroot, TargetCPUs, TargetFeatures, @@ -2063,7 +2065,10 @@ fn check_print_request_stability( (print_name, print_kind): (&str, PrintKind), ) { match print_kind { - PrintKind::AllTargetSpecsJson | PrintKind::CheckCfg | PrintKind::TargetSpecJson + PrintKind::AllTargetSpecsJson + | PrintKind::CheckCfg + | PrintKind::SupportedCrateTypes + | PrintKind::TargetSpecJson if !unstable_opts.unstable_options => { early_dcx.early_fatal(format!( diff --git a/compiler/rustc_type_ir/src/flags.rs b/compiler/rustc_type_ir/src/flags.rs index 81aa4a1f19e..6a2498242fe 100644 --- a/compiler/rustc_type_ir/src/flags.rs +++ b/compiler/rustc_type_ir/src/flags.rs @@ -111,18 +111,20 @@ bitflags::bitflags! { /// Does this value have parameters/placeholders/inference variables which could be /// replaced later, in a way that would change the results of `impl` specialization? - const STILL_FURTHER_SPECIALIZABLE = 1 << 21; + const STILL_FURTHER_SPECIALIZABLE = TypeFlags::HAS_TY_PARAM.bits() + | TypeFlags::HAS_TY_PLACEHOLDER.bits() + | TypeFlags::HAS_TY_INFER.bits() + | TypeFlags::HAS_CT_PARAM.bits() + | TypeFlags::HAS_CT_PLACEHOLDER.bits() + | TypeFlags::HAS_CT_INFER.bits(); /// Does this value have `InferTy::FreshTy/FreshIntTy/FreshFloatTy`? - const HAS_TY_FRESH = 1 << 22; + const HAS_TY_FRESH = 1 << 21; /// Does this value have `InferConst::Fresh`? - const HAS_CT_FRESH = 1 << 23; - - /// Does this have `Coroutine` or `CoroutineWitness`? - const HAS_TY_COROUTINE = 1 << 24; + const HAS_CT_FRESH = 1 << 22; /// Does this have any binders with bound vars (e.g. that need to be anonymized)? - const HAS_BINDER_VARS = 1 << 25; + const HAS_BINDER_VARS = 1 << 23; } } diff --git a/compiler/rustc_type_ir/src/visit.rs b/compiler/rustc_type_ir/src/visit.rs index 119b658a2bf..2285e0e75de 100644 --- a/compiler/rustc_type_ir/src/visit.rs +++ b/compiler/rustc_type_ir/src/visit.rs @@ -269,10 +269,6 @@ pub trait TypeVisitableExt<I: Interner>: TypeVisitable<I> { self.has_type_flags(TypeFlags::HAS_TY_OPAQUE) } - fn has_coroutines(&self) -> bool { - self.has_type_flags(TypeFlags::HAS_TY_COROUTINE) - } - fn references_error(&self) -> bool { self.has_type_flags(TypeFlags::HAS_ERROR) } |
