diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 03f8ac250e9..aff866fa76d 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -1055,6 +1055,13 @@ fn suggest_remove_reference( .filter(|c| !c.is_whitespace()) .take_while(|c| *c == '&') .count(); + if let Some('\'') = snippet.chars() + .filter(|c| !c.is_whitespace()) + .skip(refs_number) + .next() + { // Do not suggest removal of borrow from type arguments. + return; + } let mut trait_type = trait_ref.self_ty(); diff --git a/src/test/ui/kindck/kindck-copy.stderr b/src/test/ui/kindck/kindck-copy.stderr index fee9e2802a6..3ca9cf7e973 100644 --- a/src/test/ui/kindck/kindck-copy.stderr +++ b/src/test/ui/kindck/kindck-copy.stderr @@ -5,10 +5,7 @@ LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'static mut isize>(); - | -^^^^^^^^^^^^^^^^^ - | | - | the trait `std::marker::Copy` is not implemented for `&'static mut isize` - | help: consider removing 1 leading `&`-references + | ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'static mut isize` | = help: the following implementations were found: @@ -20,10 +17,7 @@ LL | fn assert_copy() { } | ----------- ---- required by this bound in `assert_copy` ... LL | assert_copy::<&'a mut isize>(); - | -^^^^^^^^^^^^ - | | - | the trait `std::marker::Copy` is not implemented for `&'a mut isize` - | help: consider removing 1 leading `&`-references + | ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut isize` | = help: the following implementations were found: