Skip to content

Commit 776544f

Browse files
committed
Add message to rustc_on_unimplemented attributes in core
1 parent b3a1d56 commit 776544f

File tree

112 files changed

+394
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+394
-318
lines changed

src/liballoc/vec.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,7 +1693,10 @@ impl<T: Hash> Hash for Vec<T> {
16931693
}
16941694

16951695
#[stable(feature = "rust1", since = "1.0.0")]
1696-
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
1696+
#[rustc_on_unimplemented(
1697+
message="vector indices are of type `usize` or ranges of `usize`",
1698+
label="vector indices are of type `usize` or ranges of `usize`",
1699+
)]
16971700
impl<T, I> Index<I> for Vec<T>
16981701
where
16991702
I: ::core::slice::SliceIndex<[T]>,
@@ -1707,7 +1710,10 @@ where
17071710
}
17081711

17091712
#[stable(feature = "rust1", since = "1.0.0")]
1710-
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
1713+
#[rustc_on_unimplemented(
1714+
message="vector indices are of type `usize` or ranges of `usize`",
1715+
label="vector indices are of type `usize` or ranges of `usize`",
1716+
)]
17111717
impl<T, I> IndexMut<I> for Vec<T>
17121718
where
17131719
I: ::core::slice::SliceIndex<[T]>,

src/libcore/cmp.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ use self::Ordering::*;
108108
#[stable(feature = "rust1", since = "1.0.0")]
109109
#[doc(alias = "==")]
110110
#[doc(alias = "!=")]
111-
#[rustc_on_unimplemented = "can't compare `{Self}` with `{Rhs}`"]
111+
#[rustc_on_unimplemented(
112+
message="can't compare `{Self}` with `{Rhs}`",
113+
label="no implementation for `{Self} == {Rhs}`",
114+
)]
112115
pub trait PartialEq<Rhs: ?Sized = Self> {
113116
/// This method tests for `self` and `other` values to be equal, and is used
114117
/// by `==`.
@@ -611,7 +614,10 @@ impl PartialOrd for Ordering {
611614
#[doc(alias = "<")]
612615
#[doc(alias = "<=")]
613616
#[doc(alias = ">=")]
614-
#[rustc_on_unimplemented = "can't compare `{Self}` with `{Rhs}`"]
617+
#[rustc_on_unimplemented(
618+
message="can't compare `{Self}` with `{Rhs}`",
619+
label="no implementation for `{Self} < {Rhs}` and `{Self} > {Rhs}`",
620+
)]
615621
pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
616622
/// This method returns an ordering between `self` and `other` values if one exists.
617623
///

src/libcore/iter/traits.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,11 @@ use super::LoopState;
104104
/// assert_eq!(c.0, vec![0, 1, 2, 3, 4]);
105105
/// ```
106106
#[stable(feature = "rust1", since = "1.0.0")]
107-
#[rustc_on_unimplemented="a collection of type `{Self}` cannot be \
108-
built from an iterator over elements of type `{A}`"]
107+
#[rustc_on_unimplemented(
108+
message="a collection of type `{Self}` cannot be built from an iterator \
109+
over elements of type `{A}`",
110+
label="a collection of type `{Self}` cannot be built from `std::iter::Iterator<Item={A}>`",
111+
)]
109112
pub trait FromIterator<A>: Sized {
110113
/// Creates a value from an iterator.
111114
///

src/libcore/marker.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ use hash::Hasher;
3939
/// [arc]: ../../std/sync/struct.Arc.html
4040
/// [ub]: ../../reference/behavior-considered-undefined.html
4141
#[stable(feature = "rust1", since = "1.0.0")]
42-
#[rustc_on_unimplemented = "`{Self}` cannot be sent between threads safely"]
42+
#[rustc_on_unimplemented(
43+
message="`{Self}` cannot be sent between threads safely",
44+
label="`{Self}` cannot be sent between threads safely"
45+
)]
4346
pub unsafe auto trait Send {
4447
// empty.
4548
}
@@ -88,7 +91,10 @@ impl<T: ?Sized> !Send for *mut T { }
8891
/// [trait object]: ../../book/first-edition/trait-objects.html
8992
#[stable(feature = "rust1", since = "1.0.0")]
9093
#[lang = "sized"]
91-
#[rustc_on_unimplemented = "`{Self}` does not have a constant size known at compile-time"]
94+
#[rustc_on_unimplemented(
95+
message="`{Self}` does not have a constant size known at compile-time",
96+
label="`{Self}` does not have a constant size known at compile-time"
97+
)]
9298
#[fundamental] // for Default, for example, which requires that `[T]: !Default` be evaluatable
9399
pub trait Sized {
94100
// Empty.

src/libcore/ops/index.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@
6060
/// assert_eq!(nucleotide_count[Nucleotide::T], 12);
6161
/// ```
6262
#[lang = "index"]
63-
#[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"]
63+
#[rustc_on_unimplemented(
64+
message="the type `{Self}` cannot be indexed by `{Idx}`",
65+
label="`{Self}` cannot be indexed by `{Idx}`",
66+
)]
6467
#[stable(feature = "rust1", since = "1.0.0")]
6568
#[doc(alias = "]")]
6669
#[doc(alias = "[")]
@@ -147,7 +150,10 @@ pub trait Index<Idx: ?Sized> {
147150
/// balance[Side::Left] = Weight::Kilogram(3.0);
148151
/// ```
149152
#[lang = "index_mut"]
150-
#[rustc_on_unimplemented = "the type `{Self}` cannot be mutably indexed by `{Idx}`"]
153+
#[rustc_on_unimplemented(
154+
message="the type `{Self}` cannot be mutably indexed by `{Idx}`",
155+
label="`{Self}` cannot be mutably indexed by `{Idx}`",
156+
)]
151157
#[stable(feature = "rust1", since = "1.0.0")]
152158
#[doc(alias = "[")]
153159
#[doc(alias = "]")]

src/libstd/panic.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,10 @@ pub use core::panic::{PanicInfo, Location};
110110
///
111111
/// [`AssertUnwindSafe`]: ./struct.AssertUnwindSafe.html
112112
#[stable(feature = "catch_unwind", since = "1.9.0")]
113-
#[rustc_on_unimplemented = "the type {Self} may not be safely transferred \
114-
across an unwind boundary"]
113+
#[rustc_on_unimplemented(
114+
message="the type `{Self}` may not be safely transferred across an unwind boundary",
115+
label="`{Self}` may not be safely transferred across an unwind boundary",
116+
)]
115117
pub auto trait UnwindSafe {}
116118

117119
/// A marker trait representing types where a shared reference is considered
@@ -126,9 +128,12 @@ pub auto trait UnwindSafe {}
126128
/// [`UnsafeCell`]: ../cell/struct.UnsafeCell.html
127129
/// [`UnwindSafe`]: ./trait.UnwindSafe.html
128130
#[stable(feature = "catch_unwind", since = "1.9.0")]
129-
#[rustc_on_unimplemented = "the type {Self} may contain interior mutability \
130-
and a reference may not be safely transferrable \
131-
across a catch_unwind boundary"]
131+
#[rustc_on_unimplemented(
132+
message="the type `{Self}` may contain interior mutability and a reference may not be safely \
133+
transferrable across a catch_unwind boundary",
134+
label="`{Self}` may contain interior mutability and a reference may not be safely \
135+
transferrable across a catch_unwind boundary",
136+
)]
132137
pub auto trait RefUnwindSafe {}
133138

134139
/// A simple wrapper around a type to assert that it is unwind safe.

src/libsyntax/parse/parser.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,14 +1204,6 @@ impl<'a> Parser<'a> {
12041204
fn span_fatal_err<S: Into<MultiSpan>>(&self, sp: S, err: Error) -> DiagnosticBuilder<'a> {
12051205
err.span_err(sp, self.diagnostic())
12061206
}
1207-
fn span_fatal_help<S: Into<MultiSpan>>(&self,
1208-
sp: S,
1209-
m: &str,
1210-
help: &str) -> DiagnosticBuilder<'a> {
1211-
let mut err = self.sess.span_diagnostic.struct_span_fatal(sp, m);
1212-
err.help(help);
1213-
err
1214-
}
12151207
fn bug(&self, m: &str) -> ! {
12161208
self.sess.span_diagnostic.span_bug(self.span, m)
12171209
}

src/test/compile-fail/associated-types-unsized.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ trait Get {
1414
}
1515

1616
fn foo<T:Get>(t: T) {
17-
let x = t.get(); //~ ERROR `<T as Get>::Value: std::marker::Sized` is not
17+
let x = t.get(); //~ ERROR `<T as Get>::Value` does not have a constant size known at compile-time
1818
}
1919

2020
fn main() {

src/test/compile-fail/bad-method-typaram-kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
fn foo<T:'static>() {
12-
1.bar::<T>(); //~ ERROR `T: std::marker::Send` is not satisfied
12+
1.bar::<T>(); //~ ERROR `T` cannot be sent between threads safely
1313
}
1414

1515
trait bar {

src/test/compile-fail/bad-sized.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ trait Trait {}
1313
pub fn main() {
1414
let x: Vec<Trait + Sized> = Vec::new();
1515
//~^ ERROR only auto traits can be used as additional traits in a trait object
16-
//~| ERROR the trait bound `Trait: std::marker::Sized` is not satisfied
17-
//~| ERROR the trait bound `Trait: std::marker::Sized` is not satisfied
16+
//~| ERROR `Trait` does not have a constant size known at compile-time
17+
//~| ERROR `Trait` does not have a constant size known at compile-time
1818
}

0 commit comments

Comments
 (0)