Rollup merge of #144864 - Muscraft:no-source-fixes, r=jieyouxu

No source fixes

This PR started as a fix for a rendering bug that [got noticed in #143661](https://github.com/rust-lang/rust/pull/143661#discussion_r2199109530), but turned into a fix for any rendering bugs related to files with no source.
- Don't add an end column separator after a file with no source
- Add column separator before secondary messages with no source
- Render continuation between no source labels

Before
```
error[E0423]: expected function, tuple struct or tuple variant, found struct `std::collections::HashMap`
   ╭▸ $DIR/multi-suggestion.rs:17:13
   │
LL │     let _ = std::collections::HashMap();
   │             ━━━━━━━━━━━━━━━━━━━━━━━━━━━
   ╭▸ $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
   │
   ╰ note: `std::collections::HashMap` defined here
   ╰╴
note: constructor is not visible here due to private fields
   ╭▸ $SRC_DIR/alloc/src/boxed.rs:LL:COL
   │
   ╰ note: private field
   │
   ╰ note: private field
```

After
```
error[E0423]: expected function, tuple struct or tuple variant, found struct `std::collections::HashMap`
   ╭▸ $DIR/multi-suggestion.rs:17:13
   │
LL │     let _ = std::collections::HashMap();
   │             ━━━━━━━━━━━━━━━━━━━━━━━━━━━
   ╰╴
   ╭▸ $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
   │
   ╰ note: `std::collections::HashMap` defined here
note: constructor is not visible here due to private fields
   ╭▸ $SRC_DIR/alloc/src/boxed.rs:LL:COL
   │
   ├ note: private field
   │
   ╰ note: private field
```

Note: This PR also makes it so `rustc` and `annotate-snippets` match in these cases
This commit is contained in:
Stuart Cook 2025-08-28 23:10:34 +10:00 committed by GitHub
commit 2fae59ac96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
40 changed files with 128 additions and 43 deletions

View file

@ -1462,7 +1462,7 @@ impl HumanEmitter {
max_line_num_len: usize,
is_secondary: bool,
is_cont: bool,
) -> io::Result<()> {
) -> io::Result<CodeWindowStatus> {
let mut buffer = StyledBuffer::new();
if !msp.has_primary_spans() && !msp.has_span_labels() && is_secondary && !self.short_message
@ -1575,12 +1575,14 @@ impl HumanEmitter {
}
let mut annotated_files = FileWithAnnotatedLines::collect_annotations(self, args, msp);
trace!("{annotated_files:#?}");
let mut code_window_status = CodeWindowStatus::Open;
// Make sure our primary file comes first
let primary_span = msp.primary_span().unwrap_or_default();
let (Some(sm), false) = (self.sm.as_ref(), primary_span.is_dummy()) else {
// If we don't have span information, emit and exit
return emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message);
return emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)
.map(|_| code_window_status);
};
let primary_lo = sm.lookup_char_pos(primary_span.lo());
if let Ok(pos) =
@ -1589,6 +1591,9 @@ impl HumanEmitter {
annotated_files.swap(0, pos);
}
// An end column separator should be emitted when a file with with a
// source, is followed by one without a source
let mut col_sep_before_no_show_source = false;
let annotated_files_len = annotated_files.len();
// Print out the annotate source lines that correspond with the error
for (file_idx, annotated_file) in annotated_files.into_iter().enumerate() {
@ -1599,6 +1604,26 @@ impl HumanEmitter {
&annotated_file.file,
) {
if !self.short_message {
// Add an end column separator when a file without a source
// comes after one with a source
// ╭▸ $DIR/deriving-meta-unknown-trait.rs:1:10
// │
// LL │ #[derive(Eqr)]
// │ ━━━
// ╰╴ (<- It prints *this* line)
// ╭▸ $SRC_DIR/core/src/cmp.rs:356:0
// │
// ╰╴note: similarly named derive macro `Eq` defined here
if col_sep_before_no_show_source {
let buffer_msg_line_offset = buffer.num_lines();
self.draw_col_separator_end(
&mut buffer,
buffer_msg_line_offset,
max_line_num_len + 1,
);
}
col_sep_before_no_show_source = false;
// We'll just print an unannotated message.
for (annotation_id, line) in annotated_file.lines.iter().enumerate() {
let mut annotations = line.annotations.clone();
@ -1639,29 +1664,42 @@ impl HumanEmitter {
}
line_idx += 1;
}
for (label, is_primary) in labels.into_iter() {
if is_cont
&& file_idx == annotated_files_len - 1
&& annotation_id == annotated_file.lines.len() - 1
&& !labels.is_empty()
{
code_window_status = CodeWindowStatus::Closed;
}
let labels_len = labels.len();
for (label_idx, (label, is_primary)) in labels.into_iter().enumerate() {
let style = if is_primary {
Style::LabelPrimary
} else {
Style::LabelSecondary
};
let pipe = self.col_separator();
buffer.prepend(line_idx, &format!(" {pipe}"), Style::LineNumber);
for _ in 0..max_line_num_len {
buffer.prepend(line_idx, " ", Style::NoStyle);
}
self.draw_col_separator_no_space(
&mut buffer,
line_idx,
max_line_num_len + 1,
);
line_idx += 1;
let chr = self.note_separator();
buffer.append(line_idx, &format!(" {chr} note: "), style);
for _ in 0..max_line_num_len {
buffer.prepend(line_idx, " ", Style::NoStyle);
}
self.draw_note_separator(
&mut buffer,
line_idx,
max_line_num_len + 1,
label_idx != labels_len - 1,
);
buffer.append(line_idx, "note", Style::MainHeaderMsg);
buffer.append(line_idx, ": ", Style::NoStyle);
buffer.append(line_idx, label, style);
line_idx += 1;
}
}
}
continue;
} else {
col_sep_before_no_show_source = true;
}
// print out the span location and spacer before we print the annotated source
@ -1976,7 +2014,7 @@ impl HumanEmitter {
// final step: take our styled buffer, render it, then output it
emit_to_destination(&buffer.render(), level, &mut self.dst, self.short_message)?;
Ok(())
Ok(code_window_status)
}
fn column_width(&self, code_offset: usize) -> usize {
@ -2491,7 +2529,7 @@ impl HumanEmitter {
!children.is_empty()
|| suggestions.iter().any(|s| s.style != SuggestionStyle::CompletelyHidden),
) {
Ok(()) => {
Ok(code_window_status) => {
if !children.is_empty()
|| suggestions.iter().any(|s| s.style != SuggestionStyle::CompletelyHidden)
{
@ -2502,7 +2540,7 @@ impl HumanEmitter {
{
// We'll continue the vertical bar to point into the next note.
self.draw_col_separator_no_space(&mut buffer, 0, max_line_num_len + 1);
} else {
} else if matches!(code_window_status, CodeWindowStatus::Open) {
// We'll close the vertical bar to visually end the code window.
self.draw_col_separator_end(&mut buffer, 0, max_line_num_len + 1);
}
@ -2829,10 +2867,11 @@ impl HumanEmitter {
}
}
fn note_separator(&self) -> char {
fn note_separator(&self, is_cont: bool) -> &'static str {
match self.theme {
OutputTheme::Ascii => '=',
OutputTheme::Unicode => '╰',
OutputTheme::Ascii => "= ",
OutputTheme::Unicode if is_cont => "",
OutputTheme::Unicode => "",
}
}
@ -2945,11 +2984,7 @@ impl HumanEmitter {
col: usize,
is_cont: bool,
) {
let chr = match self.theme {
OutputTheme::Ascii => "= ",
OutputTheme::Unicode if is_cont => "",
OutputTheme::Unicode => "",
};
let chr = self.note_separator(is_cont);
buffer.puts(line, col, chr, Style::LineNumber);
}
@ -3050,6 +3085,12 @@ enum DisplaySuggestion {
Add,
}
#[derive(Clone, Copy, Debug)]
enum CodeWindowStatus {
Closed,
Open,
}
impl FileWithAnnotatedLines {
/// Preprocess all the annotations so that they are grouped by file and by line number
/// This helps us quickly iterate over the whole message (including secondary file spans)

View file

@ -25,6 +25,7 @@ error[E0599]: no method named `poll` found for struct `Pin<&mut impl Future<Outp
|
LL | match fut.as_mut().poll(ctx) {
| ^^^^ method not found in `Pin<&mut impl Future<Output = ()>>`
|
--> $SRC_DIR/core/src/future/future.rs:LL:COL
|
= note: the method is available for `Pin<&mut impl Future<Output = ()>>` here

View file

@ -57,10 +57,10 @@ error[E0412]: cannot find type `F` in this scope
|
LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) {
| ^
|
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here
|
help: a trait with a similar name exists
|
LL | self , ... , self , self , ... ) where Fn : FnOnce ( & 'a & 'b usize ) {

View file

@ -9,10 +9,10 @@ error[E0412]: cannot find type `F` in this scope
|
LL | _func: F,
| ^
|
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here
|
help: a trait with a similar name exists
|
LL | _func: Fn,

View file

@ -3,6 +3,7 @@ error[E0412]: cannot find type `n` in this scope
|
LL | type_ascribe!(2, n([u8; || 1]))
| ^ help: a trait with a similar name exists: `Fn`
|
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here

View file

@ -3,10 +3,10 @@ error[E0412]: cannot find type `F` in this scope
|
LL | let f: F = async { 1 };
| ^
|
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here
|
help: a trait with a similar name exists
|
LL | let f: Fn = async { 1 };

View file

@ -6,6 +6,7 @@ LL | const FOO: &A = &A::Field(Cow::Borrowed("foo"));
...
LL | FOO => todo!(),
| ^^^ constant of non-structural type
|
--> $SRC_DIR/alloc/src/borrow.rs:LL:COL
|
= note: `Cow<'_, str>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns

View file

@ -3,6 +3,7 @@ error: cannot find derive macro `Eqr` in this scope
|
LL | #[derive(Eqr)]
| ^^^ help: a derive macro with a similar name exists: `Eq`
|
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: similarly named derive macro `Eq` defined here
@ -12,6 +13,7 @@ error: cannot find derive macro `Eqr` in this scope
|
LL | #[derive(Eqr)]
| ^^^ help: a derive macro with a similar name exists: `Eq`
|
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: similarly named derive macro `Eq` defined here

View file

@ -3,6 +3,7 @@ error: cannot find macro `prinltn` in this scope
|
LL | prinltn!();
| ^^^^^^^ help: a macro with a similar name exists: `println`
|
--> $SRC_DIR/std/src/macros.rs:LL:COL
|
= note: similarly named macro `println` defined here

View file

@ -3,6 +3,7 @@ error[E0599]: no method named `fmt` found for opaque type `impl Debug` in the cu
|
LL | x.fmt(f);
| ^^^ method not found in `impl Debug`
|
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
= note: the method is available for `impl Debug` here

View file

@ -48,6 +48,7 @@ error[E0643]: method `hash` has incompatible signature for trait
|
LL | fn hash(&self, hasher: &mut impl Hasher) {}
| ^^^^^^^^^^^ expected generic parameter, found `impl Trait`
|
--> $SRC_DIR/core/src/hash/mod.rs:LL:COL
|
= note: declaration in trait here

View file

@ -3,10 +3,10 @@ error: the item `TryFrom` is imported redundantly
|
LL | use std::convert::TryFrom;
| ^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `TryFrom` is already defined here
|
note: the lint level is defined here
--> $DIR/suggest-remove-issue-121315.rs:2:25
|
@ -18,6 +18,7 @@ error: the item `TryFrom` is imported redundantly
|
LL | use std::convert::{TryFrom, TryInto};
| ^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `TryFrom` is already defined here
@ -27,6 +28,7 @@ error: the item `TryInto` is imported redundantly
|
LL | use std::convert::{TryFrom, TryInto};
| ^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `TryInto` is already defined here
@ -48,6 +50,7 @@ error: the item `Into` is imported redundantly
|
LL | use std::convert::{AsMut, Into};
| ^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `Into` is already defined here

View file

@ -3,10 +3,10 @@ error[E0573]: expected type, found variant `NoResult`
|
LL | fn new() -> NoResult<MyEnum, String> {
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/core/src/result.rs:LL:COL
|
= note: similarly named enum `Result` defined here
|
help: try using the variant's enum
|
LL - fn new() -> NoResult<MyEnum, String> {
@ -57,10 +57,10 @@ error[E0573]: expected type, found variant `NoResult`
|
LL | fn newer() -> NoResult<foo::MyEnum, String> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/core/src/result.rs:LL:COL
|
= note: similarly named enum `Result` defined here
|
help: try using the variant's enum
|
LL - fn newer() -> NoResult<foo::MyEnum, String> {

View file

@ -3,6 +3,7 @@ error[E0530]: match bindings cannot shadow unit variants
|
LL | None @ _ => {}
| ^^^^ cannot be named the same as a unit variant
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the unit variant `None` is defined here

View file

@ -3,10 +3,10 @@ warning: the item `String` is imported redundantly
|
LL | use std::string::String;
| ^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `String` is already defined here
|
note: the lint level is defined here
--> $DIR/use-redundant-issue-71450.rs:3:9
|

View file

@ -3,10 +3,10 @@ warning: the item `Some` is imported redundantly
|
LL | use std::option::Option::Some;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `Some` is already defined here
|
note: the lint level is defined here
--> $DIR/use-redundant-prelude-rust-2015.rs:3:9
|
@ -18,6 +18,7 @@ warning: the item `None` is imported redundantly
|
LL | use std::option::Option::None;
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `None` is already defined here
@ -27,6 +28,7 @@ warning: the item `Ok` is imported redundantly
|
LL | use std::result::Result::Ok;
| ^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `Ok` is already defined here
@ -36,6 +38,7 @@ warning: the item `Err` is imported redundantly
|
LL | use std::result::Result::Err;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `Err` is already defined here

View file

@ -3,10 +3,10 @@ warning: the item `TryFrom` is imported redundantly
|
LL | use std::convert::TryFrom;
| ^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `TryFrom` is already defined here
|
note: the lint level is defined here
--> $DIR/use-redundant-prelude-rust-2021.rs:3:9
|
@ -18,6 +18,7 @@ warning: the item `TryInto` is imported redundantly
|
LL | use std::convert::TryInto;
| ^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/prelude/mod.rs:LL:COL
|
= note: the item `TryInto` is already defined here

View file

@ -3,6 +3,7 @@ error: cannot find macro `printlx` in this scope
|
LL | printlx!("oh noes!");
| ^^^^^^^ help: a macro with a similar name exists: `println`
|
--> $SRC_DIR/std/src/macros.rs:LL:COL
|
= note: similarly named macro `println` defined here

View file

@ -3,6 +3,7 @@ error: cannot find macro `inline` in this scope
|
LL | inline!();
| ^^^^^^ help: a macro with a similar name exists: `line`
|
--> $SRC_DIR/core/src/macros/mod.rs:LL:COL
|
= note: similarly named macro `line` defined here

View file

@ -3,10 +3,10 @@ error[E0599]: cannot write into `String`
|
LL | let _ = write!(buf, "foo");
| ^^^
|
--> $SRC_DIR/core/src/fmt/mod.rs:LL:COL
|
= note: the method is available for `String` here
|
note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method
--> $DIR/missing-writer-issue-139830.rs:7:20
|

View file

@ -14,6 +14,7 @@ warning: cannot specify lifetime arguments explicitly if late bound lifetime par
|
LL | 0.clone::<'a>();
| ^^
|
--> $SRC_DIR/core/src/clone.rs:LL:COL
|
= note: the late bound lifetime parameter is introduced here

View file

@ -15,6 +15,7 @@ error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has
|
LL | Some(refe list) => println!("{list:?}"),
| ^^^^ ^^^^ expected 1 field, found 2
|
--> $SRC_DIR/core/src/option.rs:LL:COL
|
= note: tuple variant has 1 field

View file

@ -690,6 +690,7 @@ error: expected one of `)`, `,`, `@`, `if`, or `|`, found `*`
|
LL | let b = matches!(x, (x * x | x.f()) | x[0]);
| ^ expected one of `)`, `,`, `@`, `if`, or `|`
|
--> $SRC_DIR/core/src/macros/mod.rs:LL:COL
|
= note: while parsing argument for this `pat` macro fragment

View file

@ -6,6 +6,7 @@ LL | const EMPTY: Vec<()> = Vec::new();
...
LL | EMPTY => {}
| ^^^^^ constant of non-structural type
|
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
|
= note: `Vec<()>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns

View file

@ -6,6 +6,7 @@ LL | const CONST_STRING: String = String::new();
...
LL | if let CONST_STRING = empty_str {}
| ^^^^^^^^^^^^ constant of non-structural type
|
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
|
= note: `Vec<u8>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns

View file

@ -3,10 +3,10 @@ error[E0423]: expected function, tuple struct or tuple variant, found struct `st
|
LL | let _ = std::collections::HashMap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
|
= note: `std::collections::HashMap` defined here
|
help: you might have meant to use an associated function to build this type
|
LL | let _ = std::collections::HashMap::new();

View file

@ -144,6 +144,7 @@ LL | parent_source_spans!($($tokens)*);
...
LL | one!("hello", "world");
| ---------------------- in this macro invocation
|
--> $SRC_DIR/core/src/result.rs:LL:COL
|
= note: similarly named tuple variant `Ok` defined here
@ -158,6 +159,7 @@ LL | parent_source_spans!($($tokens)*);
...
LL | two!("yay", "rust");
| ------------------- in this macro invocation
|
--> $SRC_DIR/core/src/result.rs:LL:COL
|
= note: similarly named tuple variant `Ok` defined here
@ -172,6 +174,7 @@ LL | parent_source_spans!($($tokens)*);
...
LL | three!("hip", "hop");
| -------------------- in this macro invocation
|
--> $SRC_DIR/core/src/result.rs:LL:COL
|
= note: similarly named tuple variant `Ok` defined here

View file

@ -76,6 +76,7 @@ error: cannot find derive macro `Dlone` in this scope
|
LL | #[derive(Dlone)]
| ^^^^^ help: a derive macro with a similar name exists: `Clone`
|
--> $SRC_DIR/core/src/clone.rs:LL:COL
|
= note: similarly named derive macro `Clone` defined here
@ -85,6 +86,7 @@ error: cannot find derive macro `Dlone` in this scope
|
LL | #[derive(Dlone)]
| ^^^^^ help: a derive macro with a similar name exists: `Clone`
|
--> $SRC_DIR/core/src/clone.rs:LL:COL
|
= note: similarly named derive macro `Clone` defined here

View file

@ -18,6 +18,7 @@ error[E0412]: cannot find type `Opiton` in this scope
|
LL | type B = Opiton<u8>; // Misspelled type name from the prelude.
| ^^^^^^ help: an enum with a similar name exists: `Option`
|
--> $SRC_DIR/core/src/option.rs:LL:COL
|
= note: similarly named enum `Option` defined here

View file

@ -15,6 +15,7 @@ error: cannot find attribute `tests` in this scope
|
LL | #[tests]
| ^^^^^ help: an attribute macro with a similar name exists: `test`
|
--> $SRC_DIR/core/src/macros/mod.rs:LL:COL
|
= note: similarly named attribute macro `test` defined here

View file

@ -3,6 +3,7 @@ error[E0573]: expected type, found module `result`
|
LL | impl result {
| ^^^^^^ help: an enum with a similar name exists: `Result`
|
--> $SRC_DIR/core/src/result.rs:LL:COL
|
= note: similarly named enum `Result` defined here

View file

@ -99,10 +99,10 @@ error[E0624]: method `len` is private
|
LL | res.len();
| ^^^ private method
|
--> $SRC_DIR/core/src/option.rs:LL:COL
|
= note: private method defined here
|
note: the method `len` exists on the type `Vec<{integer}>`
--> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
help: consider using `Option::expect` to unwrap the `Vec<{integer}>` value, panicking if the value is an `Option::None`

View file

@ -3,6 +3,7 @@ error[E0599]: no method named `finish` found for struct `DefaultHasher` in the c
|
LL | h.finish()
| ^^^^^^ method not found in `DefaultHasher`
|
--> $SRC_DIR/core/src/hash/mod.rs:LL:COL
|
= note: the method is available for `DefaultHasher` here

View file

@ -3,10 +3,10 @@ error[E0423]: expected function, tuple struct or tuple variant, found struct `st
|
LL | let _ = std::collections::HashMap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
|
= note: `std::collections::HashMap` defined here
|
help: you might have meant to use an associated function to build this type
|
LL | let _ = std::collections::HashMap::new();

View file

@ -3,10 +3,10 @@ error[E0423]: expected function, tuple struct or tuple variant, found struct `st
LL │ let _ = std::collections::HashMap();
│ ━━━━━━━━━━━━━━━━━━━━━━━━━━━
╰╴
╭▸ $SRC_DIR/std/src/collections/hash/map.rs:LL:COL
╰ note: `std::collections::HashMap` defined here
╰╴
help: you might have meant to use an associated function to build this type
╭╴
LL │ let _ = std::collections::HashMap::new();
@ -34,7 +34,7 @@ LL │ wtf: Some(Box(U {
note: constructor is not visible here due to private fields
╭▸ $SRC_DIR/alloc/src/boxed.rs:LL:COL
note: private field
note: private field
╰ note: private field
help: you might have meant to use an associated function to build this type

View file

@ -44,6 +44,7 @@ error[E0599]: no method named `try_into` found for type `i32` in the current sco
|
LL | let _i: i16 = 0_i32.try_into().unwrap();
| ^^^^^^^^
|
--> $SRC_DIR/core/src/convert/mod.rs:LL:COL
|
= note: the method is available for `i32` here

View file

@ -3,10 +3,10 @@ error[E0404]: expected trait, found struct `String`
|
LL | struct Foo<T> where T: Bar, <T as Bar>::Baz: String {
| ^^^^^^ not a trait
|
--> $SRC_DIR/alloc/src/string.rs:LL:COL
|
= note: similarly named trait `ToString` defined here
|
help: constrain the associated type to `String`
|
LL - struct Foo<T> where T: Bar, <T as Bar>::Baz: String {
@ -22,10 +22,10 @@ error[E0404]: expected trait, found struct `String`
|
LL | struct Qux<'a, T> where T: Bar, <&'a T as Bar>::Baz: String {
| ^^^^^^ not a trait
|
--> $SRC_DIR/alloc/src/string.rs:LL:COL
|
= note: similarly named trait `ToString` defined here
|
help: constrain the associated type to `String`
|
LL - struct Qux<'a, T> where T: Bar, <&'a T as Bar>::Baz: String {
@ -41,10 +41,10 @@ error[E0404]: expected trait, found struct `String`
|
LL | fn foo<T: Bar>(_: T) where <T as Bar>::Baz: String {
| ^^^^^^ not a trait
|
--> $SRC_DIR/alloc/src/string.rs:LL:COL
|
= note: similarly named trait `ToString` defined here
|
help: constrain the associated type to `String`
|
LL - fn foo<T: Bar>(_: T) where <T as Bar>::Baz: String {
@ -60,10 +60,10 @@ error[E0404]: expected trait, found struct `String`
|
LL | fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: String {
| ^^^^^^ not a trait
|
--> $SRC_DIR/alloc/src/string.rs:LL:COL
|
= note: similarly named trait `ToString` defined here
|
help: constrain the associated type to `String`
|
LL - fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: String {
@ -85,6 +85,7 @@ error[E0404]: expected trait, found struct `String`
|
LL | fn issue_95327() where <u8 as Unresolved>::Assoc: String {}
| ^^^^^^ help: a trait with a similar name exists: `ToString`
|
--> $SRC_DIR/alloc/src/string.rs:LL:COL
|
= note: similarly named trait `ToString` defined here

View file

@ -3,6 +3,7 @@ error[E0412]: cannot find type `Fo` in this scope
|
LL | impl Fo {
| ^^ help: a trait with a similar name exists: `Fn`
|
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here

View file

@ -3,6 +3,7 @@ error[E0412]: cannot find type `F` in this scope
|
LL | impl F {
| ^ help: a trait with a similar name exists: `Fn`
|
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
|
= note: similarly named trait `Fn` defined here

View file

@ -12,6 +12,7 @@ error[E0404]: expected trait, found enum `E`
|
LL | let _: <u8 as E>::N;
| ^ help: a trait with a similar name exists: `Eq`
|
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: similarly named trait `Eq` defined here
@ -42,6 +43,7 @@ error[E0404]: expected trait, found enum `E`
|
LL | <u8 as E>::N;
| ^ help: a trait with a similar name exists: `Eq`
|
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: similarly named trait `Eq` defined here
@ -63,6 +65,7 @@ error[E0404]: expected trait, found enum `E`
|
LL | let _: <u8 as E>::Y;
| ^ help: a trait with a similar name exists: `Eq`
|
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: similarly named trait `Eq` defined here
@ -72,6 +75,7 @@ error[E0404]: expected trait, found enum `E`
|
LL | <u8 as E>::Y;
| ^ help: a trait with a similar name exists: `Eq`
|
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: similarly named trait `Eq` defined here
@ -90,6 +94,7 @@ error[E0404]: expected trait, found enum `E`
|
LL | let _: <u8 as E>::N::NN;
| ^ help: a trait with a similar name exists: `Eq`
|
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: similarly named trait `Eq` defined here
@ -120,6 +125,7 @@ error[E0404]: expected trait, found enum `E`
|
LL | <u8 as E>::N::NN;
| ^ help: a trait with a similar name exists: `Eq`
|
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: similarly named trait `Eq` defined here
@ -141,6 +147,7 @@ error[E0404]: expected trait, found enum `E`
|
LL | let _: <u8 as E>::Y::NN;
| ^ help: a trait with a similar name exists: `Eq`
|
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: similarly named trait `Eq` defined here
@ -150,6 +157,7 @@ error[E0404]: expected trait, found enum `E`
|
LL | <u8 as E>::Y::NN;
| ^ help: a trait with a similar name exists: `Eq`
|
--> $SRC_DIR/core/src/cmp.rs:LL:COL
|
= note: similarly named trait `Eq` defined here