Rollup merge of #133850 - oli-obk:push-xryukktpyooq, r=compiler-errors
Avoid `opaque type not constrained` errors in the presence of other errors pulled out of https://github.com/rust-lang/rust/pull/128440 These errors carry no new information if the opaque type was actually used in a constraining (but erroneous) way somewhere.
This commit is contained in:
commit
ea4e7192ac
24 changed files with 56 additions and 138 deletions
|
@ -226,13 +226,18 @@ impl TaitConstraintLocator<'_> {
|
|||
constrained = true;
|
||||
|
||||
if !opaque_types_defined_by.contains(&self.def_id) {
|
||||
self.tcx.dcx().emit_err(TaitForwardCompat {
|
||||
let guar = self.tcx.dcx().emit_err(TaitForwardCompat {
|
||||
span: hidden_type.span,
|
||||
item_span: self
|
||||
.tcx
|
||||
.def_ident_span(item_def_id)
|
||||
.unwrap_or_else(|| self.tcx.def_span(item_def_id)),
|
||||
});
|
||||
// Avoid "opaque type not constrained" errors on the opaque itself.
|
||||
self.found = Some(ty::OpaqueHiddenType {
|
||||
span: DUMMY_SP,
|
||||
ty: Ty::new_error(self.tcx, guar),
|
||||
});
|
||||
}
|
||||
let concrete_type =
|
||||
self.tcx.erase_regions(hidden_type.remap_generic_params_to_declaration_params(
|
||||
|
@ -248,7 +253,7 @@ impl TaitConstraintLocator<'_> {
|
|||
if !constrained {
|
||||
debug!("no constraints in typeck results");
|
||||
if opaque_types_defined_by.contains(&self.def_id) {
|
||||
self.tcx.dcx().emit_err(TaitForwardCompat2 {
|
||||
let guar = self.tcx.dcx().emit_err(TaitForwardCompat2 {
|
||||
span: self
|
||||
.tcx
|
||||
.def_ident_span(item_def_id)
|
||||
|
@ -256,6 +261,11 @@ impl TaitConstraintLocator<'_> {
|
|||
opaque_type_span: self.tcx.def_span(self.def_id),
|
||||
opaque_type: self.tcx.def_path_str(self.def_id),
|
||||
});
|
||||
// Avoid "opaque type not constrained" errors on the opaque itself.
|
||||
self.found = Some(ty::OpaqueHiddenType {
|
||||
span: DUMMY_SP,
|
||||
ty: Ty::new_error(self.tcx, guar),
|
||||
});
|
||||
}
|
||||
return;
|
||||
};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use rustc_hir::def::CtorOf;
|
||||
use rustc_index::Idx;
|
||||
use tracing::trace;
|
||||
|
||||
use crate::rmeta::*;
|
||||
|
||||
|
@ -530,8 +529,6 @@ where
|
|||
{
|
||||
/// Given the metadata, extract out the value at a particular index (if any).
|
||||
pub(super) fn get<'a, 'tcx, M: Metadata<'a, 'tcx>>(&self, metadata: M, i: I) -> T::Value<'tcx> {
|
||||
trace!("LazyTable::lookup: index={:?} len={:?}", i, self.len);
|
||||
|
||||
// Access past the end of the table returns a Default
|
||||
if i.index() >= self.len {
|
||||
return Default::default();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue