https://hackmd.io/hcl2qyr_T_qWb6hWd_NUxg
FCP for disabling candidate in candidate selection
proposal:
||
constraints to region constraintsweird example:
for<'a> T: Trait<'a, ?U>
T: Trait<'static, i32>
for<'a, V> T: Trait<'a, V>
?U = i32
)original example:
for<'a> T: Trait<'a>
T: Trait<'static>
for<'a> T: Trait<'a> where WC
'a = 'static
'a = 'static || #t
Deferred: implications
Conclusion:
opaque types: mostly the same as inference variables, but only mostly
For candidate selection they are treated as rigid types, which involves one special case
Trying to match if an opaque type implements a trait, also go through all the where-bounds, if a where-bound happens to have something that matches, we'll constrain the opaque type. Happens way too early.
e.g. impl Trait: Default
in fn foo<T: Default>()
. WIP PR: https://github.com/rust-lang/rust/pull/127034
https://github.com/rust-lang/rust/pull/127034
fn filter_fold<T, Acc>(
mut predicate: impl FnMut(&T) -> bool,
mut fold: impl FnMut(Acc, T) -> Acc,
) -> impl FnMut(Acc, T) -> Acc {
move |acc, item| if predicate(&item) { fold(acc, item) } else { acc }
}
trait Trait {}
impl<T> Trait for T {}
fn foo<T: Trait>() -> impl Trait {
1u8
}
behavior with only DefineOpaqueTypes::Yes
impl Trait: Trait
where
-bounds, see a T: Trait
candidateimpl Trait
with T
@lcnr assumption: replace opaque self types with hidden type:
impl Trait: Trait
impl Trait
with its hidden type: ?hidden: Trait
just skip if opaque type is definable
pub(crate) struct NeverShortCircuit<T>(pub T);
impl<T> NeverShortCircuit<T> {
pub fn wrap_mut_1<A, F: FnMut(A) -> T>(
mut f: F
) -> impl FnMut(A) -> NeverShortCircuit<T> {
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for opaque type `impl FnMut(A) -> NeverShortCircuit<T>`
move |a| NeverShortCircuit(f(a))
}
}
failing in collect_unused_stmts_for_coerce_return_ty
or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing