From 34ca33d86fd47ca912751bd8578e66f449639a7c Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Tue, 25 Mar 2025 10:59:30 +1300 Subject: Don't print original source in redefinition errors The source context of the original definition of a redefined symbol was being printed when reporting a redefinition error. Since only the source code containing the redefinition was available, if the original definition was in a different file then the source context of the original definition would just pull from this source code and the context shown would be completely nonsensical. --- src/reports/resolver_error.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/reports') diff --git a/src/reports/resolver_error.rs b/src/reports/resolver_error.rs index 0fce3c4..81bec1b 100644 --- a/src/reports/resolver_error.rs +++ b/src/reports/resolver_error.rs @@ -14,12 +14,10 @@ impl<'a> ResolverError<'a> { } for redefinition in &self.resolver.redefinitions { let definition = &self.resolver.definitions[redefinition.definition]; - let message = format!("Redefined symbol '{}'", definition.tracked.symbol.name); + let name = &definition.tracked.symbol.name; + let location = definition.tracked.symbol.source.location(); + let message = format!("Redefined symbol '{name}' (defined at {location})", ); let context = redefinition.tracked.context(&self.resolver); - let context = Context { - source_code: context.source_code, - source: &context.source.wrap(&definition.tracked.symbol.source) - }; report_source_issue(LogLevel::Error, &context, &message); } } -- cgit v1.2.3-70-g09d2