Auto merge of #68254 - Dylan-DPC:rollup-9vhc59u, r=Dylan-DPC

Rollup of 6 pull requests

Successful merges:

 - #68123 (Implement Cursor for linked lists. (RFC 2570).)
 - #68212 (Suggest to shorten temporary lifetime during method call inside generator)
 - #68232 (Optimize size/speed of Unicode datasets)
 - #68236 (Add some regression tests)
 - #68237 (Account for `Path`s in `is_suggestable_infer_ty`)
 - #68252 (remove redundant clones, found by clippy)

Failed merges:

r? @ghost
This commit is contained in:
bors 2020-01-15 19:40:45 +00:00
commit 3291ae3390
37 changed files with 3903 additions and 3294 deletions

View file

@ -1,5 +1,6 @@
// ignore-tidy-linelength
// ignore-wasm32-bare compiled with panic=abort by default
// compile-flags: -Z mir-opt-level=3
#![feature(box_syntax)]
fn main() {

View file

@ -0,0 +1,29 @@
// build-pass
trait AssociatedConstant {
const DATA: ();
}
impl<F, T> AssociatedConstant for F
where
F: FnOnce() -> T,
T: AssociatedConstant,
{
const DATA: () = T::DATA;
}
impl AssociatedConstant for () {
const DATA: () = ();
}
fn foo() -> impl AssociatedConstant {
()
}
fn get_data<T: AssociatedConstant>(_: T) -> &'static () {
&T::DATA
}
fn main() {
get_data(foo);
}

View file

@ -16,6 +16,11 @@ LL | let _x = get().await;
...
LL | }
| - `client` is later dropped here
help: consider moving this method call into a `let` binding to create a shorter lived borrow
--> $DIR/issue-64130-4-async-move.rs:19:15
|
LL | match client.status() {
| ^^^^^^^^^^^^^^^
= note: the return type of a function must have a statically known size
error: aborting due to previous error

View file

@ -20,7 +20,7 @@ LL | fn assert_sync<T: Sync>(_: T) {}
LL | assert_sync(|| {
| ^^^^^^^^^^^ future returned by `main` is not `Sync`
|
= help: within `[generator@$DIR/not-send-sync.rs:9:17: 13:6 {std::cell::Cell<i32>, ()}]`, the trait `std::marker::Sync` is not implemented for `std::cell::Cell<i32>`
= help: within `[generator@$DIR/not-send-sync.rs:9:17: 13:6 {std::cell::Cell<i32>, (), ()}]`, the trait `std::marker::Sync` is not implemented for `std::cell::Cell<i32>`
note: future is not `Sync` as this value is used across an yield
--> $DIR/not-send-sync.rs:12:9
|

View file

@ -76,7 +76,7 @@ error[E0720]: opaque type expands to a recursive type
LL | fn generator_capture() -> impl Sized {
| ^^^^^^^^^^ expands to a recursive type
|
= note: expanded type is `[generator@$DIR/recursive-impl-trait-type-indirect.rs:50:5: 50:26 x:impl Sized {()}]`
= note: expanded type is `[generator@$DIR/recursive-impl-trait-type-indirect.rs:50:5: 50:26 x:impl Sized {(), ()}]`
error[E0720]: opaque type expands to a recursive type
--> $DIR/recursive-impl-trait-type-indirect.rs:53:26
@ -92,7 +92,7 @@ error[E0720]: opaque type expands to a recursive type
LL | fn generator_hold() -> impl Sized {
| ^^^^^^^^^^ expands to a recursive type
|
= note: expanded type is `[generator@$DIR/recursive-impl-trait-type-indirect.rs:58:5: 62:6 {impl Sized, ()}]`
= note: expanded type is `[generator@$DIR/recursive-impl-trait-type-indirect.rs:58:5: 62:6 {impl Sized, (), ()}]`
error[E0720]: opaque type expands to a recursive type
--> $DIR/recursive-impl-trait-type-indirect.rs:69:26

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,49 @@
// build-pass
#![feature(type_alias_impl_trait)]
use std::marker::PhantomData;
/* copied Index and TryFrom for convinience (and simplicity) */
trait MyIndex<T> {
type O;
fn my_index(self) -> Self::O;
}
trait MyFrom<T>: Sized {
type Error;
fn my_from(value: T) -> Result<Self, Self::Error>;
}
/* MCVE starts here */
trait F {}
impl F for () {}
type DummyT<T> = impl F;
fn _dummy_t<T>() -> DummyT<T> {}
struct Phantom1<T>(PhantomData<T>);
struct Phantom2<T>(PhantomData<T>);
struct Scope<T>(Phantom2<DummyT<T>>);
impl<T> Scope<T> {
fn new() -> Self {
unimplemented!()
}
}
impl<T> MyFrom<Phantom2<T>> for Phantom1<T> {
type Error = ();
fn my_from(_: Phantom2<T>) -> Result<Self, Self::Error> {
unimplemented!()
}
}
impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<Phantom1<T>> for Scope<U> {
type O = T;
fn my_index(self) -> Self::O {
MyFrom::my_from(self.0).ok().unwrap()
}
}
fn main() {
let _pos: Phantom1<DummyT<()>> = Scope::new().my_index();
}

View file

@ -68,6 +68,13 @@ struct Test10 {
}
pub fn main() {
static A = 42;
//~^ ERROR missing type for `static` item
static B: _ = 42;
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
static C: Option<_> = Some(42);
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures
fn fn_test() -> _ { 5 }
//~^ ERROR the type placeholder `_` is not allowed within types on item signatures

View file

@ -1,35 +1,35 @@
error: expected identifier, found reserved identifier `_`
--> $DIR/typeck_type_placeholder_item.rs:146:18
--> $DIR/typeck_type_placeholder_item.rs:153:18
|
LL | struct BadStruct<_>(_);
| ^ expected identifier, found reserved identifier
error: expected identifier, found reserved identifier `_`
--> $DIR/typeck_type_placeholder_item.rs:149:16
--> $DIR/typeck_type_placeholder_item.rs:156:16
|
LL | trait BadTrait<_> {}
| ^ expected identifier, found reserved identifier
error: expected identifier, found reserved identifier `_`
--> $DIR/typeck_type_placeholder_item.rs:159:19
--> $DIR/typeck_type_placeholder_item.rs:166:19
|
LL | struct BadStruct1<_, _>(_);
| ^ expected identifier, found reserved identifier
error: expected identifier, found reserved identifier `_`
--> $DIR/typeck_type_placeholder_item.rs:159:22
--> $DIR/typeck_type_placeholder_item.rs:166:22
|
LL | struct BadStruct1<_, _>(_);
| ^ expected identifier, found reserved identifier
error: expected identifier, found reserved identifier `_`
--> $DIR/typeck_type_placeholder_item.rs:164:19
--> $DIR/typeck_type_placeholder_item.rs:171:19
|
LL | struct BadStruct2<_, T>(_, T);
| ^ expected identifier, found reserved identifier
error[E0403]: the name `_` is already used for a generic parameter in this item's generic parameters
--> $DIR/typeck_type_placeholder_item.rs:159:22
--> $DIR/typeck_type_placeholder_item.rs:166:22
|
LL | struct BadStruct1<_, _>(_);
| - ^ already used
@ -177,8 +177,29 @@ LL |
LL | b: (T, T),
|
error: missing type for `static` item
--> $DIR/typeck_type_placeholder_item.rs:71:12
|
LL | static A = 42;
| ^ help: provide a type for the item: `A: i32`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:71:21
--> $DIR/typeck_type_placeholder_item.rs:73:15
|
LL | static B: _ = 42;
| ^
| |
| not allowed in type signatures
| help: replace `_` with the correct type: `i32`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:75:15
|
LL | static C: Option<_> = Some(42);
| ^^^^^^^^^ not allowed in type signatures
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:78:21
|
LL | fn fn_test() -> _ { 5 }
| ^
@ -187,7 +208,7 @@ LL | fn fn_test() -> _ { 5 }
| help: replace with the correct return type: `i32`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:74:23
--> $DIR/typeck_type_placeholder_item.rs:81:23
|
LL | fn fn_test2() -> (_, _) { (5, 5) }
| -^--^-
@ -197,7 +218,7 @@ LL | fn fn_test2() -> (_, _) { (5, 5) }
| help: replace with the correct return type: `(i32, i32)`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:77:22
--> $DIR/typeck_type_placeholder_item.rs:84:22
|
LL | static FN_TEST3: _ = "test";
| ^
@ -206,7 +227,7 @@ LL | static FN_TEST3: _ = "test";
| help: replace `_` with the correct type: `&'static str`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:80:22
--> $DIR/typeck_type_placeholder_item.rs:87:22
|
LL | static FN_TEST4: _ = 145;
| ^
@ -215,13 +236,13 @@ LL | static FN_TEST4: _ = 145;
| help: replace `_` with the correct type: `i32`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:83:22
--> $DIR/typeck_type_placeholder_item.rs:90:22
|
LL | static FN_TEST5: (_, _) = (1, 2);
| ^^^^^^ not allowed in type signatures
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:86:20
--> $DIR/typeck_type_placeholder_item.rs:93:20
|
LL | fn fn_test6(_: _) { }
| ^ not allowed in type signatures
@ -232,7 +253,7 @@ LL | fn fn_test6<T>(_: T) { }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:89:20
--> $DIR/typeck_type_placeholder_item.rs:96:20
|
LL | fn fn_test7(x: _) { let _x: usize = x; }
| ^ not allowed in type signatures
@ -243,13 +264,13 @@ LL | fn fn_test7<T>(x: T) { let _x: usize = x; }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:92:29
--> $DIR/typeck_type_placeholder_item.rs:99:29
|
LL | fn fn_test8(_f: fn() -> _) { }
| ^ not allowed in type signatures
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:92:29
--> $DIR/typeck_type_placeholder_item.rs:99:29
|
LL | fn fn_test8(_f: fn() -> _) { }
| ^ not allowed in type signatures
@ -260,7 +281,7 @@ LL | fn fn_test8<T>(_f: fn() -> T) { }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:115:12
--> $DIR/typeck_type_placeholder_item.rs:122:12
|
LL | a: _,
| ^ not allowed in type signatures
@ -279,13 +300,13 @@ LL | b: (T, T),
|
error[E0282]: type annotations needed
--> $DIR/typeck_type_placeholder_item.rs:120:27
--> $DIR/typeck_type_placeholder_item.rs:127:27
|
LL | fn fn_test11(_: _) -> (_, _) { panic!() }
| ^^^^^^ cannot infer type
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:120:28
--> $DIR/typeck_type_placeholder_item.rs:127:28
|
LL | fn fn_test11(_: _) -> (_, _) { panic!() }
| ^ ^ not allowed in type signatures
@ -293,7 +314,7 @@ LL | fn fn_test11(_: _) -> (_, _) { panic!() }
| not allowed in type signatures
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:124:30
--> $DIR/typeck_type_placeholder_item.rs:131:30
|
LL | fn fn_test12(x: i32) -> (_, _) { (x, x) }
| -^--^-
@ -303,7 +324,7 @@ LL | fn fn_test12(x: i32) -> (_, _) { (x, x) }
| help: replace with the correct return type: `(i32, i32)`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:127:33
--> $DIR/typeck_type_placeholder_item.rs:134:33
|
LL | fn fn_test13(x: _) -> (i32, _) { (x, x) }
| ------^-
@ -312,7 +333,7 @@ LL | fn fn_test13(x: _) -> (i32, _) { (x, x) }
| help: replace with the correct return type: `(i32, i32)`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:146:21
--> $DIR/typeck_type_placeholder_item.rs:153:21
|
LL | struct BadStruct<_>(_);
| ^ not allowed in type signatures
@ -323,7 +344,7 @@ LL | struct BadStruct<T>(T);
| ^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:151:15
--> $DIR/typeck_type_placeholder_item.rs:158:15
|
LL | impl BadTrait<_> for BadStruct<_> {}
| ^ ^ not allowed in type signatures
@ -336,13 +357,13 @@ LL | impl<T> BadTrait<T> for BadStruct<T> {}
| ^^^ ^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:154:34
--> $DIR/typeck_type_placeholder_item.rs:161:34
|
LL | fn impl_trait() -> impl BadTrait<_> {
| ^ not allowed in type signatures
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:159:25
--> $DIR/typeck_type_placeholder_item.rs:166:25
|
LL | struct BadStruct1<_, _>(_);
| ^ not allowed in type signatures
@ -353,7 +374,7 @@ LL | struct BadStruct1<T, _>(T);
| ^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:164:25
--> $DIR/typeck_type_placeholder_item.rs:171:25
|
LL | struct BadStruct2<_, T>(_, T);
| ^ not allowed in type signatures
@ -364,7 +385,7 @@ LL | struct BadStruct2<K, T>(K, T);
| ^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:168:14
--> $DIR/typeck_type_placeholder_item.rs:175:14
|
LL | type X = Box<_>;
| ^ not allowed in type signatures
@ -381,7 +402,7 @@ LL | fn test10<T>(&self, _x : T) { }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:132:31
--> $DIR/typeck_type_placeholder_item.rs:139:31
|
LL | fn method_test1(&self, x: _);
| ^ not allowed in type signatures
@ -392,7 +413,7 @@ LL | fn method_test1<T>(&self, x: T);
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:134:31
--> $DIR/typeck_type_placeholder_item.rs:141:31
|
LL | fn method_test2(&self, x: _) -> _;
| ^ ^ not allowed in type signatures
@ -405,7 +426,7 @@ LL | fn method_test2<T>(&self, x: T) -> T;
| ^^^ ^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:136:31
--> $DIR/typeck_type_placeholder_item.rs:143:31
|
LL | fn method_test3(&self) -> _;
| ^ not allowed in type signatures
@ -416,7 +437,7 @@ LL | fn method_test3<T>(&self) -> T;
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:138:26
--> $DIR/typeck_type_placeholder_item.rs:145:26
|
LL | fn assoc_fn_test1(x: _);
| ^ not allowed in type signatures
@ -427,7 +448,7 @@ LL | fn assoc_fn_test1<T>(x: T);
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:140:26
--> $DIR/typeck_type_placeholder_item.rs:147:26
|
LL | fn assoc_fn_test2(x: _) -> _;
| ^ ^ not allowed in type signatures
@ -440,7 +461,7 @@ LL | fn assoc_fn_test2<T>(x: T) -> T;
| ^^^ ^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:142:28
--> $DIR/typeck_type_placeholder_item.rs:149:28
|
LL | fn assoc_fn_test3() -> _;
| ^ not allowed in type signatures
@ -462,7 +483,7 @@ LL | fn clone_from<T>(&mut self, other: T) { *self = Test9; }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:102:34
--> $DIR/typeck_type_placeholder_item.rs:109:34
|
LL | fn fn_test10(&self, _x : _) { }
| ^ not allowed in type signatures
@ -473,7 +494,7 @@ LL | fn fn_test10<T>(&self, _x : T) { }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:110:41
--> $DIR/typeck_type_placeholder_item.rs:117:41
|
LL | fn clone_from(&mut self, other: _) { *self = FnTest9; }
| ^ not allowed in type signatures
@ -484,7 +505,7 @@ LL | fn clone_from<T>(&mut self, other: T) { *self = FnTest9; }
| ^^^ ^
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:174:21
--> $DIR/typeck_type_placeholder_item.rs:181:21
|
LL | type Y = impl Trait<_>;
| ^ not allowed in type signatures
@ -508,7 +529,7 @@ LL | fn clone(&self) -> _ { Test9 }
| help: replace with the correct return type: `Test9`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:99:31
--> $DIR/typeck_type_placeholder_item.rs:106:31
|
LL | fn fn_test9(&self) -> _ { () }
| ^
@ -517,7 +538,7 @@ LL | fn fn_test9(&self) -> _ { () }
| help: replace with the correct return type: `()`
error[E0121]: the type placeholder `_` is not allowed within types on item signatures
--> $DIR/typeck_type_placeholder_item.rs:107:28
--> $DIR/typeck_type_placeholder_item.rs:114:28
|
LL | fn clone(&self) -> _ { FnTest9 }
| ^
@ -525,7 +546,7 @@ LL | fn clone(&self) -> _ { FnTest9 }
| not allowed in type signatures
| help: replace with the correct return type: `main::FnTest9`
error: aborting due to 55 previous errors
error: aborting due to 58 previous errors
Some errors have detailed explanations: E0121, E0282, E0403.
For more information about an error, try `rustc --explain E0121`.