Skip to content

Commit 578578d

Browse files
committed
remove error suggestion because of span issue of compiletest
1 parent b44a484 commit 578578d

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Diff for: compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1146,6 +1146,12 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
11461146
}
11471147
// don't create labels for compiler-generated spans
11481148
Some(_) => None,
1149+
// don't create labels for the span not from user's code
1150+
None if opt_assignment_rhs_span
1151+
.is_some_and(|span| self.infcx.tcx.sess.source_map().is_imported(span)) =>
1152+
{
1153+
None
1154+
}
11491155
None => {
11501156
let (has_sugg, decl_span, sugg) = if name != kw::SelfLower {
11511157
suggest_ampmut(
@@ -1335,7 +1341,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
13351341
};
13361342
err.span_suggestion_verbose(
13371343
span,
1338-
format!("consider {changing} this binding's type"),
1344+
format!("consider {changing} this binding's type xxx"),
13391345
sugg,
13401346
Applicability::HasPlaceholders,
13411347
);
@@ -1449,6 +1455,11 @@ fn suggest_ampmut<'tcx>(
14491455
// let x: &i32 = &'a 5;
14501456
// ^^ lifetime annotation not allowed
14511457
//
1458+
eprintln!("opt_assignment_rhs_span: {:?}", opt_assignment_rhs_span);
1459+
eprintln!(
1460+
"code result: {:?}",
1461+
tcx.sess.source_map().span_to_snippet(opt_assignment_rhs_span.unwrap())
1462+
);
14521463
if let Some(assignment_rhs_span) = opt_assignment_rhs_span
14531464
&& let Ok(src) = tcx.sess.source_map().span_to_snippet(assignment_rhs_span)
14541465
&& let Some(stripped) = src.strip_prefix('&')

Diff for: tests/ui/suggestions/dont_suggest_raw_pointer_syntax-issue-127562.stderr

-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ error[E0594]: cannot assign to `*ptr`, which is behind a `*const` pointer
33
|
44
LL | *ptr = 3;
55
| ^^^^^^^^ `ptr` is a `*const` pointer, so the data it refers to cannot be written
6-
|
7-
help: consider specifying this binding's type
8-
|
9-
LL | let ptr: *mut i32 = std::ptr::addr_of!(val);
10-
| ++++++++++
116

127
error: aborting due to 1 previous error
138

0 commit comments

Comments
 (0)