Skip to content

Commit 3ea0d10

Browse files
committed
hack to avoid incorrect suggestion
1 parent d201e27 commit 3ea0d10

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/librustc/traits/error_reporting.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1055,6 +1055,13 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
10551055
.filter(|c| !c.is_whitespace())
10561056
.take_while(|c| *c == '&')
10571057
.count();
1058+
if let Some('\'') = snippet.chars()
1059+
.filter(|c| !c.is_whitespace())
1060+
.skip(refs_number)
1061+
.next()
1062+
{ // Do not suggest removal of borrow from type arguments.
1063+
return;
1064+
}
10581065

10591066
let mut trait_type = trait_ref.self_ty();
10601067

src/test/ui/kindck/kindck-copy.stderr

+2-8
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ LL | fn assert_copy<T:Copy>() { }
55
| ----------- ---- required by this bound in `assert_copy`
66
...
77
LL | assert_copy::<&'static mut isize>();
8-
| -^^^^^^^^^^^^^^^^^
9-
| |
10-
| the trait `std::marker::Copy` is not implemented for `&'static mut isize`
11-
| help: consider removing 1 leading `&`-references
8+
| ^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'static mut isize`
129
|
1310
= help: the following implementations were found:
1411
<isize as std::marker::Copy>
@@ -20,10 +17,7 @@ LL | fn assert_copy<T:Copy>() { }
2017
| ----------- ---- required by this bound in `assert_copy`
2118
...
2219
LL | assert_copy::<&'a mut isize>();
23-
| -^^^^^^^^^^^^
24-
| |
25-
| the trait `std::marker::Copy` is not implemented for `&'a mut isize`
26-
| help: consider removing 1 leading `&`-references
20+
| ^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `&'a mut isize`
2721
|
2822
= help: the following implementations were found:
2923
<isize as std::marker::Copy>

0 commit comments

Comments
 (0)