@@ -84,7 +84,7 @@ pub(super) fn cargo(
84
84
85
85
let ( manifest_path, manifest_error_range) = {
86
86
let mae = error. downcast_ref :: < ManifestAwareError > ( ) ;
87
- ( mae. map ( |e| e. manifest_path ( ) . clone ( ) ) , mae. map ( |e| e. manifest_error_range ( ) ) )
87
+ ( mae. map ( |e| e. manifest_path ( ) . clone ( ) ) , mae. and_then ( |e| e. manifest_error_range ( ) ) )
88
88
} ;
89
89
BuildResult :: CargoError { error, stdout, manifest_path, manifest_error_range }
90
90
}
@@ -805,15 +805,15 @@ pub struct ManifestAwareError {
805
805
cause : anyhow:: Error ,
806
806
/// The path to a manifest file within the project that seems the closest to the error's origin.
807
807
nearest_project_manifest : PathBuf ,
808
- manifest_error_range : Range ,
808
+ manifest_error_range : Option < Range > ,
809
809
}
810
810
811
811
impl ManifestAwareError {
812
812
fn new ( cause : anyhow:: Error , root_manifest : & Path , ws : Option < & Workspace < ' _ > > ) -> Self {
813
813
let project_dir = root_manifest. parent ( ) . unwrap ( ) ;
814
814
let mut err_path = root_manifest;
815
815
// Cover whole manifest if we haven't any better idea.
816
- let mut err_range = Range { start : Position :: new ( 0 , 0 ) , end : Position :: new ( 9999 , 0 ) } ;
816
+ let mut err_range = None ;
817
817
818
818
if let Some ( manifest_err) = cause. downcast_ref :: < ManifestError > ( ) {
819
819
// Scan through any manifest errors to pin the error more precisely.
@@ -834,9 +834,14 @@ impl ManifestAwareError {
834
834
}
835
835
}
836
836
if let Some ( ( line, col) ) = find_toml_error ( last_cause) {
837
+ let line = line as _ ;
838
+ let start_col = col as _ ;
839
+ let end_col = start_col + 1 ;
837
840
// Use TOML deserializiation error position.
838
- err_range. start = Position :: new ( line as _ , col as _ ) ;
839
- err_range. end = Position :: new ( line as _ , col as u64 + 1 ) ;
841
+ err_range = Some ( Range {
842
+ start : Position :: new ( line, start_col) ,
843
+ end : Position :: new ( line, end_col) ,
844
+ } ) ;
840
845
}
841
846
} else {
842
847
let nearest_cause = manifest_err
@@ -868,7 +873,7 @@ impl ManifestAwareError {
868
873
& self . nearest_project_manifest
869
874
}
870
875
871
- pub fn manifest_error_range ( & self ) -> Range {
876
+ pub fn manifest_error_range ( & self ) -> Option < Range > {
872
877
self . manifest_error_range
873
878
}
874
879
}
0 commit comments