Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion compiler/rustc_errors/src/annotate_snippet_emitter_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ impl AnnotateSnippetEmitter {
file_ann.swap(0, pos);
}

let file_ann_len = file_ann.len();
for (file_idx, (file, annotations)) in file_ann.into_iter().enumerate() {
if should_show_source_code(&self.ignored_directories_in_source_blocks, sm, &file) {
if let Some(snippet) = self.annotated_snippet(annotations, &file.name, sm) {
Expand Down Expand Up @@ -240,6 +241,7 @@ impl AnnotateSnippetEmitter {
// ╰ warning: this was previously accepted
if let Some(c) = children.first()
&& (!c.span.has_primary_spans() && !c.span.has_span_labels())
&& file_idx == file_ann_len - 1
{
group = group.element(Padding);
}
Expand Down Expand Up @@ -631,7 +633,7 @@ impl AnnotateSnippetEmitter {
report.push(std::mem::replace(&mut group, Group::with_level(level.clone())));
}

if !line_tracker.contains(&lo.line) {
if !line_tracker.contains(&lo.line) && (i == 0 || hi.line <= lo.line) {
line_tracker.push(lo.line);
// ╭▸ $SRC_DIR/core/src/option.rs:594:0 (<- It adds *this*)
// ⸬ $SRC_DIR/core/src/option.rs:602:4
Expand Down Expand Up @@ -740,6 +742,14 @@ fn collect_annotations(
}
}
}

// Sort annotations within each file by line number
for (_, ann) in output.iter_mut() {
ann.sort_by_key(|a| {
let lo = sm.lookup_char_pos(a.span.lo());
lo.line
});
}
output
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ LL | println!();
error: macro expansion ignores `{` and any tokens following
--> $SRC_DIR/std/src/macros.rs:LL:COL
|
|
::: $DIR/main-alongside-macro-calls.rs:30:1
|
LL | println!();
Expand All @@ -42,7 +41,6 @@ LL | println!();
error: macro expansion ignores `{` and any tokens following
--> $SRC_DIR/std/src/macros.rs:LL:COL
|
|
::: $DIR/main-alongside-macro-calls.rs:34:1
|
LL | println!();
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/statics/check-values-constraints.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ LL | field2: SafeEnum::Variant4("str".to_string()),
note: method `to_string` is not const because trait `ToString` is not const
--> $SRC_DIR/alloc/src/string.rs:LL:COL
|
= note: this method is not const
= note: this trait is not const
::: $SRC_DIR/alloc/src/string.rs:LL:COL
|
= note: this trait is not const
= note: this method is not const
= note: calls in statics are limited to constant functions, tuple structs and tuple variants
= note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`

Expand Down
10 changes: 4 additions & 6 deletions tests/ui/typeck/typeck_type_placeholder_item.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -686,12 +686,11 @@ LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
|
note: method `filter` is not const because trait `Iterator` is not const
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
= note: this method is not const
= note: this trait is not const
::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
= note: this trait is not const
= note: this method is not const
= note: calls in constants are limited to constant functions, tuple structs and tuple variants

error[E0015]: cannot call non-const method `<Filter<std::ops::Range<i32>, {closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}> as Iterator>::map::<i32, {closure@$DIR/typeck_type_placeholder_item.rs:240:49: 240:52}>` in constants
Expand All @@ -702,12 +701,11 @@ LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x);
|
note: method `map` is not const because trait `Iterator` is not const
--> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
= note: this method is not const
= note: this trait is not const
::: $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
|
= note: this trait is not const
= note: this method is not const
= note: calls in constants are limited to constant functions, tuple structs and tuple variants

error: aborting due to 83 previous errors
Expand Down
Loading