forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#107941 - compiler-errors:str-has-u8-slice-f…
…or-auto, r=lcnr Treat `str` as containing `[u8]` for auto trait purposes Wanted to gauge `@rust-lang/lang` and `@rust-lang/types` teams' thoughts on treating `str` as "containing" a `[u8]` slice for auto-trait purposes. `@dtolnay` brought this up in rust-lang#13231 (comment) as a blocker for future `str` type librarification, and I think it's both a valid concern and very easy to fix. I'm interested in actually doing that `str` type librarification (rust-lang#107939), but this probably should be considered in the mean time regardless of that PR. r? types for the impl, though this definitely needs an FCP.
- Loading branch information
Showing
5 changed files
with
36 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#![feature(negative_impls)] | ||
#![feature(auto_traits)] | ||
|
||
auto trait AutoTrait {} | ||
|
||
impl<T> !AutoTrait for [T] {} | ||
|
||
fn needs_auto_trait<T: AutoTrait + ?Sized>() {} | ||
|
||
fn main() { | ||
needs_auto_trait::<str>(); | ||
//~^ ERROR the trait bound `[u8]: AutoTrait` is not satisfied in `str` | ||
} |
16 changes: 16 additions & 0 deletions
16
tests/ui/auto-traits/str-contains-slice-conceptually.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
error[E0277]: the trait bound `[u8]: AutoTrait` is not satisfied in `str` | ||
--> $DIR/str-contains-slice-conceptually.rs:11:22 | ||
| | ||
LL | needs_auto_trait::<str>(); | ||
| ^^^ within `str`, the trait `AutoTrait` is not implemented for `[u8]` | ||
| | ||
= note: `str` is considered to contain a `[u8]` slice for auto trait purposes | ||
note: required by a bound in `needs_auto_trait` | ||
--> $DIR/str-contains-slice-conceptually.rs:8:24 | ||
| | ||
LL | fn needs_auto_trait<T: AutoTrait + ?Sized>() {} | ||
| ^^^^^^^^^ required by this bound in `needs_auto_trait` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |