File tree Expand file tree Collapse file tree 4 files changed +41
-0
lines changed
doc/unstable-book/src/language-features Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -138,3 +138,15 @@ error[E0277]: `&str` is not an iterator
138
138
= help: the trait `std::iter::Iterator` is not implemented for `&str`
139
139
= note: required by `std::iter::IntoIterator::into_iter`
140
140
```
141
+
142
+ If you need to filter on multiple attributes, you can use ` all ` in the following way:
143
+
144
+ ``` rust,compile_fail
145
+ #[rustc_on_unimplemented(
146
+ on(
147
+ all(_Self="&str", T="std::string::String"),
148
+ note="you can coerce a `{T}` into a `{Self}` by writing `&*variable`"
149
+ )
150
+ )]
151
+ pub trait From<T>: Sized { /* ... */ }
152
+ ```
Original file line number Diff line number Diff line change @@ -352,6 +352,12 @@ pub trait Into<T>: Sized {
352
352
/// [`from`]: trait.From.html#tymethod.from
353
353
/// [book]: ../../book/ch09-00-error-handling.html
354
354
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
355
+ #[ rustc_on_unimplemented(
356
+ on(
357
+ all( _Self="&str" , T ="std::string::String" ) ,
358
+ note="you can coerce a `{T}` into a `{Self}` by writing `&*variable`"
359
+ )
360
+ ) ]
355
361
pub trait From < T > : Sized {
356
362
/// Performs the conversion.
357
363
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
Original file line number Diff line number Diff line change
1
+ fn foo < ' a , T > ( _t : T ) where T : Into < & ' a str > { }
2
+
3
+ fn main ( ) {
4
+ foo ( String :: new ( ) ) ;
5
+ //~^ ERROR the trait bound `&str: std::convert::From<std::string::String>` is not satisfied
6
+ }
Original file line number Diff line number Diff line change
1
+ error[E0277]: the trait bound `&str: std::convert::From<std::string::String>` is not satisfied
2
+ --> $DIR/into-str.rs:4:5
3
+ |
4
+ LL | foo(String::new());
5
+ | ^^^ the trait `std::convert::From<std::string::String>` is not implemented for `&str`
6
+ |
7
+ = note: you can coerce a `std::string::String` into a `&str` by writing `&*variable`
8
+ = note: required because of the requirements on the impl of `std::convert::Into<&str>` for `std::string::String`
9
+ note: required by `foo`
10
+ --> $DIR/into-str.rs:1:1
11
+ |
12
+ LL | fn foo<'a, T>(_t: T) where T: Into<&'a str> {}
13
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14
+
15
+ error: aborting due to previous error
16
+
17
+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments