Auto merge of #91549 - fee1-dead:const_env, r=spastorino
Eliminate ConstnessAnd again Closes #91489. Closes #89432. Reverts #91491. Reverts #89450. r? `@spastorino`
This commit is contained in:
commit
22f8bde876
69 changed files with 622 additions and 458 deletions
|
|
@ -1,9 +0,0 @@
|
|||
// run-pass
|
||||
|
||||
const _FOO: fn() -> String = || "foo".into();
|
||||
|
||||
pub fn bar() -> fn() -> String {
|
||||
|| "bar".into()
|
||||
}
|
||||
|
||||
fn main(){}
|
||||
23
src/test/ui/consts/try-operator.rs
Normal file
23
src/test/ui/consts/try-operator.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// run-pass
|
||||
|
||||
#![feature(try_trait_v2)]
|
||||
#![feature(const_trait_impl)]
|
||||
#![feature(const_try)]
|
||||
#![feature(const_convert)]
|
||||
|
||||
fn main() {
|
||||
const fn result() -> Result<bool, ()> {
|
||||
Err(())?;
|
||||
Ok(true)
|
||||
}
|
||||
|
||||
const FOO: Result<bool, ()> = result();
|
||||
assert_eq!(Err(()), FOO);
|
||||
|
||||
const fn option() -> Option<()> {
|
||||
None?;
|
||||
Some(())
|
||||
}
|
||||
const BAR: Option<()> = option();
|
||||
assert_eq!(None, BAR);
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ LL | struct Take(Take);
|
|||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: ...which immediately requires computing drop-check constraints for `Take` again
|
||||
= note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: Take } }`
|
||||
= note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing, constness: NotConst }, value: Take } }`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ LL | enum MList { Cons(isize, MList), Nil }
|
|||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: ...which immediately requires computing drop-check constraints for `MList` again
|
||||
= note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing }, value: MList } }`
|
||||
= note: cycle used when computing dropck types for `Canonical { max_universe: U0, variables: [], value: ParamEnvAnd { param_env: ParamEnv { caller_bounds: [], reveal: UserFacing, constness: NotConst }, value: MList } }`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
|
|||
40
src/test/ui/issues/issue-91489.rs
Normal file
40
src/test/ui/issues/issue-91489.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// check-pass
|
||||
|
||||
// regression test for #91489
|
||||
|
||||
use std::borrow::Borrow;
|
||||
use std::borrow::Cow;
|
||||
|
||||
pub struct VariantType {}
|
||||
pub struct VariantTy {}
|
||||
|
||||
impl Borrow<VariantTy> for VariantType {
|
||||
fn borrow(&self) -> &VariantTy {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl ToOwned for VariantTy {
|
||||
type Owned = VariantType;
|
||||
fn to_owned(&self) -> VariantType {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl VariantTy {
|
||||
pub fn as_str(&self) -> () {}
|
||||
}
|
||||
|
||||
// the presence of this was causing all attempts to call `as_str` on
|
||||
// `Cow<'_, VariantTy>, including in itself, to not find the method
|
||||
static _TYP: () = {
|
||||
let _ = || {
|
||||
// should be found
|
||||
Cow::Borrowed(&VariantTy {}).as_str();
|
||||
};
|
||||
};
|
||||
|
||||
fn main() {
|
||||
// should be found
|
||||
Cow::Borrowed(&VariantTy {}).as_str()
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
// FIXME(fee1-dead): this should have a better error message
|
||||
#![feature(const_trait_impl)]
|
||||
|
||||
struct NonConstAdd(i32);
|
||||
|
||||
impl std::ops::Add for NonConstAdd {
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
error[E0277]: cannot add `NonConstAdd` to `NonConstAdd`
|
||||
--> $DIR/assoc-type.rs:19:16
|
||||
--> $DIR/assoc-type.rs:18:16
|
||||
|
|
||||
LL | type Bar = NonConstAdd;
|
||||
| ^^^^^^^^^^^ no implementation for `NonConstAdd + NonConstAdd`
|
||||
|
|
||||
= help: the trait `Add` is not implemented for `NonConstAdd`
|
||||
note: required by a bound in `Foo::Bar`
|
||||
--> $DIR/assoc-type.rs:15:15
|
||||
--> $DIR/assoc-type.rs:14:15
|
||||
|
|
||||
LL | type Bar: ~const std::ops::Add;
|
||||
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Foo::Bar`
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(const_trait_impl)]
|
||||
#![feature(const_fn_trait_bound)]
|
||||
|
||||
trait Convert<T> {
|
||||
fn to(self) -> T;
|
||||
}
|
||||
|
||||
impl<A, B> const Convert<B> for A where B: ~const From<A> {
|
||||
fn to(self) -> B {
|
||||
B::from(self)
|
||||
}
|
||||
}
|
||||
|
||||
const FOO: fn() -> String = || "foo".to();
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue