Repository navigation
Conversation
|
HIR ty lowering was modified cc @fmease |
This comment has been minimized.
This comment has been minimized.
023ccc0 to
75f36b4
Compare
| | | ||
| LL + #![feature(unstable_value)] | ||
| | | ||
| help: add `#![feature(unstable_value)]` to the crate attributes to enable `value` | ||
| | | ||
| LL + #![feature(unstable_value)] | ||
| | |
There was a problem hiding this comment.
why is this emitted 3 times. maybe it shouldn't xd
There was a problem hiding this comment.
That seems to be a pre-existing bug. I added a commit which deduplicates the diagnostic.
|
lgtm, minor nit which might be worth fixing, otherwise r=me. does the following start to warn because of this PR? trait Local<T> {
fn call_once(&self) -> T;
}
impl Local<u8> for fn() {
fn call_once(&self) -> u8 { 8 }
}
impl Local<u16> for fn() {
fn call_once(&self) -> u16 { 16 }
}
fn example<T: FnOnce() + Local<u8> + Local<u16>>(f: T) -> u8 {
f.call_once()
}
fn main() {
assert_eq!(example((|| {}) as fn()), 8);
} |
|
Yes, your example now warns with: |
This comment has been minimized.
This comment has been minimized.
adedd2b to
bc321f9
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| this.unstable_candidates.iter().map(|(candidate, feature)| { | ||
| (format!(" `{}`", tcx.def_path_str(candidate.item.def_id)), *feature) | ||
| }), | ||
| this.unstable_candidates |
There was a problem hiding this comment.
does this filtering make more sense in disabled_nightly_features? I feel like that may also help other callers 🤔
r=me either way
This PR fixes the associated item resolution logic for both value-level and type-level resolution. In both cases, this starts from a set of possible candidates matching the item name, which we then attempt to filter down to a single candidate.
Value-level resolution
pick_methodcallsconsider_candidatestwice: first for "inherent candidates" and then for "extension candidates". The second set is only considered ifconsider_candidatesreturns no candidates for the first set.Previously the logic for
consider_candidateswas:Add<u8> + Add<u16>) then pick one and return that. Only the trait is needed, type inference will later fill in the generics. If one candidate is ambiguously imported from a glob import, that candidate is returned for the ambiguous trait import lint.This had several bugs:
unstable-same-trait.rs).ambiguous-glob-imported-subtrait.rs)The new logic fixes both issues:
Type-level resolution
Type-level resolution is much simpler: if there are multiple candidates, then supertrait shadowing is used to select a subtrait candidate if it shadows all other candidates. But if there were multiple subtrait candidates with different generic arguments, it would return the first one instead of emitting an ambiguity error. (
ambiguous-instantiations.rs)The new logic fixes this by making supertrait shadowing preserve multiple instantiations of the same trait. If multiple candidates remain then this results in an ambiguity error.
unique_subtraithelperThe logic for supertrait shadowing has been moved to a shared helper and drastically simplified.
r? lcnr