Skip to content

Commit 406b200

Browse files
authored
Rollup merge of #150031 - yaahc:derive-helper-ambig-assert, r=petrochenkov
assert impossible branch is impossible The second half of this boolean or expression should not be possible with the current visitation implementation. Reasoning: - Innermost res will always be the first candidate visited. - the first scopes visited are `derive_helper` candidates, followed by a single step at `derive_helper_compat`: https://github.com/rust-lang/rust/blob/ee447067/compiler/rustc_resolve/src/ident.rs#L180-L192 - if there are candidates for both kinds the derive_helper candidate will always be innermost - there can only be one derive_helper_compat candidate - The first branch handles cases where the first candidate is a `derive_helper_compat` - if the first candidate is not a `derive_helper_compat` (as enforced by the first branch) and it is not a `derive_helper` (as enforced by the end of the second boolean expression) then then the first candidate and all subsequent candidates must be from later scope types, res cannot possibly be a `derive_helper_compat` r? `@petrochenkov`
2 parents 782a01b + 72c84a6 commit 406b200

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

compiler/rustc_resolve/src/ident.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,10 +743,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
743743

744744
let ambiguity_error_kind = if is_builtin(innermost_res) || is_builtin(res) {
745745
Some(AmbiguityKind::BuiltinAttr)
746-
} else if innermost_res == derive_helper_compat
747-
|| res == derive_helper_compat && innermost_res != derive_helper
748-
{
746+
} else if innermost_res == derive_helper_compat {
749747
Some(AmbiguityKind::DeriveHelper)
748+
} else if res == derive_helper_compat && innermost_res != derive_helper {
749+
span_bug!(orig_ident.span, "impossible inner resolution kind")
750750
} else if innermost_flags.contains(Flags::MACRO_RULES)
751751
&& flags.contains(Flags::MODULE)
752752
&& !self.disambiguate_macro_rules_vs_modularized(innermost_binding, binding)

0 commit comments

Comments
 (0)