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
4 changes: 3 additions & 1 deletion compiler/rustc_hir_typeck/src/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1723,8 +1723,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Don't emit a suggestion if we found an actual method
// that had unsatisfied trait bounds
if unsatisfied_predicates.is_empty()
// ...or if we already suggested that name because of `rustc_confusable` annotation.
// ...or if we already suggested that name because of `rustc_confusable` annotation
&& Some(similar_candidate.name()) != confusable_suggested
// and if the we aren't in an expansion.
&& !span.from_expansion()
{
self.find_likely_intended_associated_item(
&mut err,
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/hygiene/no_implicit_prelude.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ LL | ().clone()
| ^^^^^
|
= help: items from traits can only be used if the trait is in scope
help: there is a method `clone_from` with a similar name, but with different arguments
--> $SRC_DIR/core/src/clone.rs:LL:COL
= note: this error originates in the macro `::bar::m` (in Nightly builds, run with -Z macro-backtrace for more info)
help: trait `Clone` which provides `clone` is implemented but not in scope; perhaps you want to import it
|
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/macros/missing-writer-issue-139830.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Make sure we don't suggest a method change inside the `write!` macro.
//
// See <https://github.com/rust-lang/rust/issues/139830>

fn main() {
let mut buf = String::new();
let _ = write!(buf, "foo");
//~^ ERROR cannot write into `String`
}
23 changes: 23 additions & 0 deletions tests/ui/macros/missing-writer-issue-139830.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error[E0599]: cannot write into `String`
--> $DIR/missing-writer-issue-139830.rs:7:20
|
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
|
LL | let _ = write!(buf, "foo");
| ^^^
= help: items from traits can only be used if the trait is in scope
help: trait `Write` which provides `write_fmt` is implemented but not in scope; perhaps you want to import it
|
LL + use std::fmt::Write;
|

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0599`.
Loading