From 90e941a974e3561efa18c148de24db1f401cd3c4 Mon Sep 17 00:00:00 2001 From: David Wood Date: Wed, 22 Jul 2020 10:31:12 +0100 Subject: [PATCH] mir: improve polymorphic constant bug This commit changes the span and content of the "collection encountered polymorphic constant" bug in monomorphization collection to point to the use of the constant rather than the definition. Signed-off-by: David Wood --- src/librustc_mir/monomorphize/collector.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 0b5f27fc17a..e724180f4d8 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -627,8 +627,9 @@ fn visit_const(&mut self, constant: &&'tcx ty::Const<'tcx>, location: Location) Ok(val) => collect_const_value(self.tcx, val, self.output), Err(ErrorHandled::Reported(ErrorReported) | ErrorHandled::Linted) => {} Err(ErrorHandled::TooGeneric) => span_bug!( - self.tcx.def_span(def.did), - "collection encountered polymorphic constant", + self.body.source_info(location).span, + "collection encountered polymorphic constant: {}", + substituted_constant ), } } -- GitLab