File tree 4 files changed +42
-0
lines changed
doc/unstable-book/src/language-features
4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -138,3 +138,16 @@ 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 ` , ` any ` or
143
+ ` not ` in the following way:
144
+
145
+ ``` rust,compile_fail
146
+ #[rustc_on_unimplemented(
147
+ on(
148
+ all(_Self="&str", T="std::string::String"),
149
+ note="you can coerce a `{T}` into a `{Self}` by writing `&*variable`"
150
+ )
151
+ )]
152
+ pub trait From<T>: Sized { /* ... */ }
153
+ ```
Original file line number Diff line number Diff line change @@ -363,6 +363,12 @@ pub trait Into<T>: Sized {
363
363
/// [`from`]: trait.From.html#tymethod.from
364
364
/// [book]: ../../book/ch09-00-error-handling.html
365
365
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
366
+ #[ rustc_on_unimplemented(
367
+ on(
368
+ all( _Self="&str" , T ="std::string::String" ) ,
369
+ note="to coerce a `{T}` into a `{Self}`, use `&*` as a prefix" ,
370
+ )
371
+ ) ]
366
372
pub trait From < T > : Sized {
367
373
/// Performs the conversion.
368
374
#[ 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: to coerce a `std::string::String` into a `&str`, use `&*` as a prefix
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