Auto merge of #119879 - matthiaskrgr:rollup-y710der, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #119781 (fix typo) - #119865 (Set `c_str_literals` stabilization version back to `CURRENT_RUSTC_VERSION`) - #119866 (Convert `effects` description to doc comment) - #119868 (Register even erroneous impls) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
bfd799f1a5
12 changed files with 190 additions and 54 deletions
|
@ -113,6 +113,7 @@ macro_rules! arena_types {
|
|||
[] stripped_cfg_items: rustc_ast::expand::StrippedCfgItem,
|
||||
[] mod_child: rustc_middle::metadata::ModChild,
|
||||
[] features: rustc_feature::Features,
|
||||
[decode] specialization_graph: rustc_middle::traits::specialization_graph::Graph,
|
||||
]);
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1294,8 +1294,7 @@ rustc_queries! {
|
|||
desc { |tcx| "finding trait impls of `{}`", tcx.def_path_str(trait_id) }
|
||||
}
|
||||
|
||||
query specialization_graph_of(trait_id: DefId) -> &'tcx specialization_graph::Graph {
|
||||
arena_cache
|
||||
query specialization_graph_of(trait_id: DefId) -> Result<&'tcx specialization_graph::Graph, ErrorGuaranteed> {
|
||||
desc { |tcx| "building specialization graph of trait `{}`", tcx.def_path_str(trait_id) }
|
||||
cache_on_disk_if { true }
|
||||
}
|
||||
|
|
|
@ -786,6 +786,15 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for &'tcx [rustc_ast::InlineAsm
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>>
|
||||
for &'tcx crate::traits::specialization_graph::Graph
|
||||
{
|
||||
#[inline]
|
||||
fn decode(d: &mut CacheDecoder<'a, 'tcx>) -> Self {
|
||||
RefDecodable::decode(d)
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! impl_ref_decoder {
|
||||
(<$tcx:tt> $($ty:ty,)*) => {
|
||||
$(impl<'a, $tcx> Decodable<CacheDecoder<'a, $tcx>> for &$tcx [$ty] {
|
||||
|
|
|
@ -30,18 +30,16 @@ pub struct Graph {
|
|||
|
||||
/// The "root" impls are found by looking up the trait's def_id.
|
||||
pub children: DefIdMap<Children>,
|
||||
|
||||
/// Whether an error was emitted while constructing the graph.
|
||||
pub has_errored: Option<ErrorGuaranteed>,
|
||||
}
|
||||
|
||||
impl Graph {
|
||||
pub fn new() -> Graph {
|
||||
Graph { parent: Default::default(), children: Default::default(), has_errored: None }
|
||||
Graph { parent: Default::default(), children: Default::default() }
|
||||
}
|
||||
|
||||
/// The parent of a given impl, which is the `DefId` of the trait when the
|
||||
/// impl is a "specialization root".
|
||||
#[track_caller]
|
||||
pub fn parent(&self, child: DefId) -> DefId {
|
||||
*self.parent.get(&child).unwrap_or_else(|| panic!("Failed to get parent for {child:?}"))
|
||||
}
|
||||
|
@ -255,13 +253,9 @@ pub fn ancestors(
|
|||
trait_def_id: DefId,
|
||||
start_from_impl: DefId,
|
||||
) -> Result<Ancestors<'_>, ErrorGuaranteed> {
|
||||
let specialization_graph = tcx.specialization_graph_of(trait_def_id);
|
||||
let specialization_graph = tcx.specialization_graph_of(trait_def_id)?;
|
||||
|
||||
if let Some(reported) = specialization_graph.has_errored {
|
||||
Err(reported)
|
||||
} else if let Err(reported) =
|
||||
tcx.type_of(start_from_impl).instantiate_identity().error_reported()
|
||||
{
|
||||
if let Err(reported) = tcx.type_of(start_from_impl).instantiate_identity().error_reported() {
|
||||
Err(reported)
|
||||
} else {
|
||||
Ok(Ancestors {
|
||||
|
|
|
@ -32,6 +32,7 @@ pub enum SimplifiedType {
|
|||
CoroutineWitness(DefId),
|
||||
Function(usize),
|
||||
Placeholder,
|
||||
Error,
|
||||
}
|
||||
|
||||
/// Generic parameters are pretty much just bound variables, e.g.
|
||||
|
@ -153,7 +154,8 @@ pub fn simplify_type<'tcx>(
|
|||
TreatParams::ForLookup | TreatParams::AsCandidateKey => None,
|
||||
},
|
||||
ty::Foreign(def_id) => Some(SimplifiedType::Foreign(def_id)),
|
||||
ty::Bound(..) | ty::Infer(_) | ty::Error(_) => None,
|
||||
ty::Error(_) => Some(SimplifiedType::Error),
|
||||
ty::Bound(..) | ty::Infer(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use crate::traits::specialization_graph;
|
||||
use crate::ty::fast_reject::{self, SimplifiedType, TreatParams, TreatProjections};
|
||||
use crate::ty::visit::TypeVisitableExt;
|
||||
use crate::ty::{Ident, Ty, TyCtxt};
|
||||
use hir::def_id::LOCAL_CRATE;
|
||||
use rustc_hir as hir;
|
||||
|
@ -241,9 +240,6 @@ pub(super) fn trait_impls_of_provider(tcx: TyCtxt<'_>, trait_id: DefId) -> Trait
|
|||
let impl_def_id = impl_def_id.to_def_id();
|
||||
|
||||
let impl_self_ty = tcx.type_of(impl_def_id).instantiate_identity();
|
||||
if impl_self_ty.references_error() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if let Some(simplified_self_ty) =
|
||||
fast_reject::simplify_type(tcx, impl_self_ty, TreatParams::AsCandidateKey)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue