Skip to content

Commit 28b2bba

Browse files
committed
Specialize future-incompatibility warning for UNSTABLE_NAME_COLLISION.
1 parent 0232744 commit 28b2bba

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

src/librustc/lint/mod.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -498,15 +498,21 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
498498

499499
// Check for future incompatibility lints and issue a stronger warning.
500500
let lints = sess.lint_store.borrow();
501-
if let Some(future_incompatible) = lints.future_incompatible(LintId::of(lint)) {
502-
let future = if let Some(edition) = future_incompatible.edition {
503-
format!("the {} edition", edition)
501+
let lint_id = LintId::of(lint);
502+
if let Some(future_incompatible) = lints.future_incompatible(lint_id) {
503+
const STANDARD_MESSAGE: &str =
504+
"this was previously accepted by the compiler but is being phased out; \
505+
it will become a hard error";
506+
507+
let explanation = if lint_id == LintId::of(::lint::builtin::UNSTABLE_NAME_COLLISION) {
508+
"once this method is added to the standard library, \
509+
there will be ambiguity here, which will cause a hard error!"
510+
.to_owned()
511+
} else if let Some(edition) = future_incompatible.edition {
512+
format!("{} in the {} edition!", STANDARD_MESSAGE, edition)
504513
} else {
505-
"a future release".to_owned()
514+
format!("{} in a future release!", STANDARD_MESSAGE)
506515
};
507-
let explanation = format!("this was previously accepted by the compiler \
508-
but is being phased out; \
509-
it will become a hard error in {}!", future);
510516
let citation = format!("for more information, see {}",
511517
future_incompatible.reference);
512518
err.warn(&explanation);

src/librustc_typeck/check/method/probe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> {
10421042
lint::builtin::UNSTABLE_NAME_COLLISION,
10431043
self.fcx.body_id,
10441044
self.span,
1045-
"a method with this name will be added to the standard library in the future",
1045+
"a method with this name may be added to the standard library in the future",
10461046
);
10471047

10481048
// FIXME: This should be a `span_suggestion` instead of `help`. However `self.span` only

src/test/ui/inference_unstable.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ use inference_unstable_itertools::IpuItertools;
2424

2525
fn main() {
2626
assert_eq!('x'.ipu_flatten(), 1);
27-
//~^ WARN a method with this name will be added to the standard library in the future
28-
//~^^ WARN it will become a hard error in a future release
27+
//~^ WARN a method with this name may be added to the standard library in the future
28+
//~^^ WARN once this method is added to the standard library, there will be ambiguity here
2929
}

src/test/ui/inference_unstable.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
warning: a method with this name will be added to the standard library in the future
1+
warning: a method with this name may be added to the standard library in the future
22
--> $DIR/inference_unstable.rs:26:20
33
|
44
LL | assert_eq!('x'.ipu_flatten(), 1);
55
| ^^^^^^^^^^^
66
|
77
= note: #[warn(unstable_name_collision)] on by default
8-
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
8+
= warning: once this method is added to the standard library, there will be ambiguity here, which will cause a hard error!
99
= note: for more information, see pr #48552 <https://github.com/rust-lang/rust/pull/48552>
1010
= help: call with fully qualified syntax `inference_unstable_itertools::IpuItertools::ipu_flatten(...)` to keep using the current method
1111
= note: add #![feature(ipu_flatten)] to the crate attributes to enable `inference_unstable_iterator::IpuIterator::ipu_flatten`

0 commit comments

Comments
 (0)