Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion src/librustc_errors/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ impl EmitterWriter {
Style::MainHeaderMsg
};

if msp.primary_spans().is_empty() && msp.span_labels().is_empty() && is_secondary
if !msp.has_primary_spans() && !msp.has_span_labels() && is_secondary
&& !self.short_message {
// This is a secondary message with no span info
for _ in 0..max_line_num_len {
Expand Down
14 changes: 5 additions & 9 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5013,11 +5013,7 @@ impl<'a> Resolver<'a> {
))
}

if b.span.is_dummy() {
err.note(&note_msg);
} else {
err.span_note(b.span, &note_msg);
}
err.span_note(b.span, &note_msg);
for (i, help_msg) in help_msgs.iter().enumerate() {
let or = if i == 0 { "" } else { "or " };
err.help(&format!("{}{}", or, help_msg));
Expand Down Expand Up @@ -5132,10 +5128,10 @@ impl<'a> Resolver<'a> {
container));

err.span_label(span, format!("`{}` re{} here", name, new_participle));
if !old_binding.span.is_dummy() {
err.span_label(self.session.source_map().def_span(old_binding.span),
format!("previous {} of the {} `{}` here", old_noun, old_kind, name));
}
err.span_label(
self.session.source_map().def_span(old_binding.span),
format!("previous {} of the {} `{}` here", old_noun, old_kind, name),
);

// See https://github.com/rust-lang/rust/issues/32354
if old_binding.is_import() || new_binding.is_import() {
Expand Down
10 changes: 10 additions & 0 deletions src/libsyntax_pos/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,11 @@ impl MultiSpan {
&self.primary_spans
}

/// Returns wether any of the primary spans is displayable.
pub fn has_primary_spans(&self) -> bool {
self.primary_spans.iter().any(|sp| *sp != DUMMY_SP)
}

/// Returns `true` if this contains only a dummy primary span with any hygienic context.
pub fn is_dummy(&self) -> bool {
let mut is_dummy = true;
Expand Down Expand Up @@ -726,6 +731,11 @@ impl MultiSpan {

span_labels
}

/// Returns wether any of the span labels is displayable.
pub fn has_span_labels(&self) -> bool {
self.span_labels.iter().any(|(sp, _)| *sp != DUMMY_SP)
}
}

impl From<Span> for MultiSpan {
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/consts/const-size_of-cycle.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ note: ...which requires const-evaluating `Foo::bytes::{{constant}}`...
|
LL | intrinsics::size_of::<T>()
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires computing layout of `Foo`...
note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: None }, value: [u8; _] }`...
= note: ...which requires computing layout of `Foo`...
= note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: None }, value: [u8; _] }`...
note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}`...
--> $DIR/const-size_of-cycle.rs:6:17
|
Expand Down
6 changes: 3 additions & 3 deletions src/test/ui/impl-trait/auto-trait-leak.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ note: ...which requires processing `cycle1`...
|
LL | fn cycle1() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`...
= note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`...
note: ...which requires processing `cycle2::{{impl-Trait}}`...
--> $DIR/auto-trait-leak.rs:23:16
|
Expand All @@ -20,7 +20,7 @@ note: ...which requires processing `cycle2`...
|
LL | fn cycle2() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`...
= note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`...
= note: ...which again requires processing `cycle1::{{impl-Trait}}`, completing the cycle
note: cycle used when checking item types in top-level module
--> $DIR/auto-trait-leak.rs:3:1
Expand All @@ -45,7 +45,7 @@ note: ...which requires processing `cycle1`...
|
LL | fn cycle1() -> impl Clone {
| ^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`...
= note: ...which requires evaluating trait selection obligation `impl std::clone::Clone: std::marker::Send`...
note: ...which requires processing `cycle2::{{impl-Trait}}`...
--> $DIR/auto-trait-leak.rs:23:16
|
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-26548.stderr
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
error[E0391]: cycle detected when computing layout of `std::option::Option<S>`
|
note: ...which requires computing layout of `S`...
= note: ...which requires computing layout of `S`...
= note: ...which again requires computing layout of `std::option::Option<S>`, completing the cycle
note: cycle used when processing `main`
--> $DIR/issue-26548.rs:9:1
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issues/issue-44415.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ note: ...which requires const-evaluating `Foo::bytes::{{constant}}`...
|
LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }],
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: ...which requires computing layout of `Foo`...
note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: None }, value: [u8; _] }`...
= note: ...which requires computing layout of `Foo`...
= note: ...which requires normalizing `ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: All, def_id: None }, value: [u8; _] }`...
note: ...which requires const-evaluating + checking `Foo::bytes::{{constant}}`...
--> $DIR/issue-44415.rs:6:17
|
Expand Down