diff --git a/src/qptr/lift.rs b/src/qptr/lift.rs index 5c65c43..4da3286 100644 --- a/src/qptr/lift.rs +++ b/src/qptr/lift.rs @@ -8,7 +8,7 @@ use crate::qptr::{shapes, QPtrAttr, QPtrMemUsage, QPtrMemUsageKind, QPtrOp, QPtr use crate::transform::{InnerInPlaceTransform, InnerTransform, Transformed, Transformer}; use crate::{ spv, AddrSpace, Attr, AttrSet, AttrSetDef, Const, ConstCtor, ConstDef, Context, ControlNode, - ControlNodeKind, DataInst, DataInstDef, DataInstKind, DeclDef, Diag, EntityDefs, + ControlNodeKind, DataInst, DataInstDef, DataInstKind, DeclDef, Diag, DiagLevel, EntityDefs, EntityOrientedDenseMap, Func, FuncDecl, FxIndexMap, GlobalVar, GlobalVarDecl, Module, Type, TypeCtor, TypeCtorArg, TypeDef, Value, }; @@ -1156,7 +1156,28 @@ impl Transformer for LiftToSpvPtrInstsInFunc<'_> { self.add_value_uses(&data_inst_def.inputs); } Err(LiftError(e)) => { - func_at_inst.def().attrs.push_diag(&self.lifter.cx, e); + let data_inst_def = func_at_inst.def(); + + // HACK(eddyb) do not add redundant errors to `qptr::analyze` bugs. + let has_qptr_analysis_bug_diags = self.lifter.cx[data_inst_def.attrs] + .attrs + .iter() + .any(|attr| match attr { + Attr::Diagnostics(diags) => { + diags.0.iter().any(|diag| match diag.level { + DiagLevel::Bug(loc) => { + loc.file().ends_with("qptr/analyze.rs") + || loc.file().ends_with("qptr\\analyze.rs") + } + _ => false, + }) + } + _ => false, + }); + + if !has_qptr_analysis_bug_diags { + data_inst_def.attrs.push_diag(&self.lifter.cx, e); + } } } }