@@ -109,7 +109,11 @@ pub enum ResolverError {
109
109
#[ error( "Only `comptime` globals can be mutable" ) ]
110
110
MutableGlobal { location : Location } ,
111
111
#[ error( "Globals must have a specified type" ) ]
112
- UnspecifiedGlobalType { location : Location , expected_type : Type } ,
112
+ UnspecifiedGlobalType {
113
+ pattern_location : Location ,
114
+ expr_location : Location ,
115
+ expected_type : Type ,
116
+ } ,
113
117
#[ error( "Global failed to evaluate" ) ]
114
118
UnevaluatedGlobalType { location : Location } ,
115
119
#[ error( "Globals used in a type position must be non-negative" ) ]
@@ -168,7 +172,7 @@ pub enum ResolverError {
168
172
AttributeFunctionIsNotAPath { function : String , location : Location } ,
169
173
#[ error( "Attribute function `{name}` is not in scope" ) ]
170
174
AttributeFunctionNotInScope { name : String , location : Location } ,
171
- #[ error( "The trait `{missing_trait}` is not implemented for `{type_missing_trait}" ) ]
175
+ #[ error( "The trait `{missing_trait}` is not implemented for `{type_missing_trait}` " ) ]
172
176
TraitNotImplemented {
173
177
impl_trait : String ,
174
178
missing_trait : String ,
@@ -197,7 +201,7 @@ pub enum ResolverError {
197
201
impl ResolverError {
198
202
pub fn location ( & self ) -> Location {
199
203
match self {
200
- ResolverError :: DuplicateDefinition { first_location : location, .. }
204
+ ResolverError :: DuplicateDefinition { second_location : location, .. }
201
205
| ResolverError :: UnconditionalRecursion { location, .. }
202
206
| ResolverError :: PathIsNotIdent { location }
203
207
| ResolverError :: Expected { location, .. }
@@ -233,7 +237,7 @@ impl ResolverError {
233
237
| ResolverError :: WhileInConstrainedFn { location }
234
238
| ResolverError :: JumpOutsideLoop { location, .. }
235
239
| ResolverError :: MutableGlobal { location }
236
- | ResolverError :: UnspecifiedGlobalType { location, .. }
240
+ | ResolverError :: UnspecifiedGlobalType { pattern_location : location, .. }
237
241
| ResolverError :: UnevaluatedGlobalType { location }
238
242
| ResolverError :: NegativeGlobalType { location, .. }
239
243
| ResolverError :: NonIntegralGlobalType { location, .. }
@@ -292,10 +296,10 @@ impl<'a> From<&'a ResolverError> for Diagnostic {
292
296
ResolverError :: DuplicateDefinition { name, first_location, second_location} => {
293
297
let mut diag = Diagnostic :: simple_error (
294
298
format ! ( "duplicate definitions of {name} found" ) ,
295
- "first definition found here" . to_string ( ) ,
296
- * first_location ,
299
+ "second definition found here" . to_string ( ) ,
300
+ * second_location ,
297
301
) ;
298
- diag. add_secondary ( "second definition found here" . to_string ( ) , * second_location ) ;
302
+ diag. add_secondary ( "first definition found here" . to_string ( ) , * first_location ) ;
299
303
diag
300
304
}
301
305
ResolverError :: UnusedVariable { ident } => {
@@ -573,12 +577,14 @@ impl<'a> From<&'a ResolverError> for Diagnostic {
573
577
* location,
574
578
)
575
579
} ,
576
- ResolverError :: UnspecifiedGlobalType { location , expected_type } => {
577
- Diagnostic :: simple_error (
580
+ ResolverError :: UnspecifiedGlobalType { pattern_location , expr_location , expected_type } => {
581
+ let mut diagnostic = Diagnostic :: simple_error (
578
582
"Globals must have a specified type" . to_string ( ) ,
579
- format ! ( "Inferred type is `{expected_type}`" ) ,
580
- * location,
581
- )
583
+ String :: new ( ) ,
584
+ * pattern_location,
585
+ ) ;
586
+ diagnostic. add_secondary ( format ! ( "Inferred type is `{expected_type}`" ) , * expr_location) ;
587
+ diagnostic
582
588
} ,
583
589
ResolverError :: UnevaluatedGlobalType { location } => {
584
590
Diagnostic :: simple_error (
@@ -763,9 +769,9 @@ impl<'a> From<&'a ResolverError> for Diagnostic {
763
769
ResolverError :: TraitNotImplemented { impl_trait, missing_trait : the_trait, type_missing_trait : typ, location, missing_trait_location} => {
764
770
let mut diagnostic = Diagnostic :: simple_error (
765
771
format ! ( "The trait bound `{typ}: {the_trait}` is not satisfied" ) ,
766
- format ! ( "The trait `{the_trait}` is not implemented for `{typ}" )
772
+ format ! ( "The trait `{the_trait}` is not implemented for `{typ}` " )
767
773
, * location) ;
768
- diagnostic. add_secondary ( format ! ( "required by this bound in `{impl_trait}" ) , * missing_trait_location) ;
774
+ diagnostic. add_secondary ( format ! ( "required by this bound in `{impl_trait}` " ) , * missing_trait_location) ;
769
775
diagnostic
770
776
} ,
771
777
ResolverError :: LoopNotYetSupported { location } => {
0 commit comments