Skip to content

Commit d491b57

Browse files
authored
Merge pull request #252 from Muscraft/show-group-start-no-path
fix: Render newline if a Message ends with one
2 parents 244bd35 + 82abe26 commit d491b57

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

src/renderer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ impl Renderer {
636636
} else {
637637
(normalize_whitespace(title.text()), title_element_style)
638638
};
639-
for (i, text) in title_str.lines().enumerate() {
639+
for (i, text) in title_str.split('\n').enumerate() {
640640
if i != 0 {
641641
buffer.append(buffer_msg_line_offset + i, &padding, ElementStyle::NoStyle);
642642
if title_style == TitleStyle::Secondary

tests/rustc_tests.rs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3370,3 +3370,78 @@ note: the traits `Iterator` and `ToTokens` must be implemented
33703370
let renderer = renderer.theme(OutputTheme::Unicode);
33713371
assert_data_eq!(renderer.render(input), expected_unicode);
33723372
}
3373+
3374+
#[test]
3375+
fn not_found_self_type_differs_shadowing_trait_item() {
3376+
// tests/ui/associated-inherent-types/not-found-self-type-differs-shadowing-trait-item.rs
3377+
3378+
let source = r#"#![feature(inherent_associated_types)]
3379+
#![allow(incomplete_features)]
3380+
3381+
// Check that it's okay to report “[inherent] associated type […] not found” for inherent associated
3382+
// type candidates that are not applicable (due to unsuitable Self type) even if there exists a
3383+
// “shadowed” associated type from a trait with the same name since its use would be ambiguous
3384+
// anyway if the IAT didn't exist.
3385+
// FIXME(inherent_associated_types): Figure out which error would be more helpful here.
3386+
3387+
//@ revisions: shadowed uncovered
3388+
3389+
struct S<T>(T);
3390+
3391+
trait Tr {
3392+
type Pr;
3393+
}
3394+
3395+
impl<T> Tr for S<T> {
3396+
type Pr = ();
3397+
}
3398+
3399+
#[cfg(shadowed)]
3400+
impl S<()> {
3401+
type Pr = i32;
3402+
}
3403+
3404+
fn main() {
3405+
let _: S::<bool>::Pr = ();
3406+
//[shadowed]~^ ERROR associated type `Pr` not found
3407+
//[uncovered]~^^ ERROR associated type `Pr` not found
3408+
}
3409+
"#;
3410+
3411+
let input = &[Group::with_title(
3412+
Level::ERROR
3413+
.title("associated type `Pr` not found for `S<bool>` in the current scope")
3414+
.id("E0220"),
3415+
)
3416+
.element(
3417+
Snippet::source(source)
3418+
.path("$DIR/not-found-self-type-differs-shadowing-trait-item.rs")
3419+
.annotation(
3420+
AnnotationKind::Primary
3421+
.span(705..707)
3422+
.label("associated item not found in `S<bool>`"),
3423+
)
3424+
.annotation(
3425+
AnnotationKind::Context
3426+
.span(532..543)
3427+
.label("associated type `Pr` not found for this struct"),
3428+
),
3429+
)
3430+
.element(Level::NOTE.title("the associated type was found for\n"))];
3431+
3432+
let expected = str![[r#"
3433+
error[E0220]: associated type `Pr` not found for `S<bool>` in the current scope
3434+
--> $DIR/not-found-self-type-differs-shadowing-trait-item.rs:28:23
3435+
|
3436+
LL | struct S<T>(T);
3437+
| ----------- associated type `Pr` not found for this struct
3438+
...
3439+
LL | let _: S::<bool>::Pr = ();
3440+
| ^^ associated item not found in `S<bool>`
3441+
|
3442+
= note: the associated type was found for
3443+
3444+
"#]];
3445+
let renderer = Renderer::plain().anonymized_line_numbers(true);
3446+
assert_data_eq!(renderer.render(input), expected);
3447+
}

0 commit comments

Comments
 (0)