mirror of
https://gitee.com/openharmony/third_party_rust_codespan
synced 2024-11-23 15:30:26 +00:00
commit
3f8907ce36
@ -113,7 +113,7 @@ impl<FileId> Label<FileId> {
|
||||
/// Represents a diagnostic message that can provide information like errors and
|
||||
/// warnings to the user.
|
||||
///
|
||||
/// The position of a Diagnostic is considered to be the position of the [`Label`] with a style of [`LabelStyle::primary`] that has the smallest start position.
|
||||
/// The position of a Diagnostic is considered to be the position of the [`Label`] that has the earliest starting position and has the highest style which appears in all the labels of the diagnostic.
|
||||
#[derive(Clone, Debug)]
|
||||
#[cfg_attr(feature = "serialization", derive(Serialize, Deserialize))]
|
||||
pub struct Diagnostic<FileId> {
|
||||
|
@ -123,10 +123,11 @@ where
|
||||
{
|
||||
Some(labeled_file) => {
|
||||
// another diagnostic also referenced this file
|
||||
if labeled_file.start > label.range.start
|
||||
&& labeled_file.max_label_style >= label.style
|
||||
if labeled_file.max_label_style > label.style
|
||||
|| (labeled_file.max_label_style == label.style
|
||||
&& labeled_file.start > label.range.start)
|
||||
{
|
||||
// this label indicates an earlier start and has at least the same level of style
|
||||
// this label has a higher style or has the same style but starts earlier
|
||||
labeled_file.start = label.range.start;
|
||||
labeled_file.location = files
|
||||
.location(label.file_id, label.range.start)
|
||||
|
@ -569,9 +569,10 @@ mod multiline_overlapping {
|
||||
.with_message("match arms have incompatible types")
|
||||
.with_code("E0308")
|
||||
.with_labels(vec![
|
||||
// this secondary label is before the primary label to test the locus calculation (see issue #259)
|
||||
Label::secondary((), 89..134).with_message("this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>`"),
|
||||
Label::primary((), 230..351).with_message("expected enum `Result`, found struct `LineIndexOutOfBoundsError`"),
|
||||
Label::secondary((), 8..362).with_message("`match` arms have incompatible types"),
|
||||
Label::secondary((), 89..134).with_message("this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>`"),
|
||||
Label::secondary((), 167..195).with_message("this is found to be of type `Result<ByteIndex, LineIndexOutOfBoundsError>`"),
|
||||
])
|
||||
.with_notes(vec![unindent::unindent(
|
||||
|
Loading…
Reference in New Issue
Block a user