-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICE: unexpected resolution for an identifier in pattern
#135614
Comments
mvce I think use A::b;
trait A {
fn b() {}
}
fn main() {
let b: ();
} |
bisects to #134754 @frank-king can you make it so that we don't ICE when the feature is not enabled with a feature gate for now? |
I think we should just let the associated functions be silently shadowed here, just like non-associated functions rust/compiler/rustc_resolve/src/late.rs Line 4008 in 6067b36
And a similar issue I found is the associated constants: use Num::{ZERO, one};
trait Num {
const ZERO: Self;
}
impl Num for u32 {
const ZERO: u32 = 0;
}
fn foo(x: u32) -> u32 {
// AssocConst in patterns and expressions
if let ZERO = x { ZERO } else { 1 }
}
fn main() {} |
@matthiaskrgr The original code example you provided is syntactically incorrect (but no ICE if #135663 is applied), could you please have a check? Code// Check that more complex receivers work:
// terminator of the MIR, which has had the PostAnalysisNormalize pass performed on it.
//@ error-pattern: Uninitialized value was created by an allocation
//@ revisions: cfi kcfi
//@ only-linux
//@ [cfi] needs-sanitizer-cfi
//@ [kcfi] needs-sanitizer-kcfi
//@ compile-flags: -C target-feature=-crt-static
//@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zsanitizer=cfi
//@ [cfi] compile-flags: -Z sanitizer=cfi
//@ [kcfi] compile-flags: -Z sanitizer=kcfi
//@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off
//@ run-pass
use Bar::foo;
trait Foo {
fn foo(self: Arc<Self>)(&self)
}
struct FooImpl;
impl Foo for C {
fn rpit_fn(self: Iter<Self>) {}
}
trait Bar {
fn foo(&self) {}
}
struct BarImpl;
impl Bar for BarImpl {
type T = i32;
fn bar(&self) -> Self::T { 7 }
}
fn main() {
let foo: Arc<dyn Foo> = propagate2(&j);
foo.as_ptr();
let bar: &dyn Yprintln!("p1")T=i32> = &BarImpl
assert_eq!(use_closure_once.bar(), 3);
} compiler stderr
|
…errors Fix ICE in resolving associated items as non-bindings Fixes rust-lang#135614 so that imported associated functions of traits can be shadowed by local bindings and associated constants of traits can be used in patterns.
Rollup merge of rust-lang#135663 - frank-king:fix/135614, r=compiler-errors Fix ICE in resolving associated items as non-bindings Fixes rust-lang#135614 so that imported associated functions of traits can be shadowed by local bindings and associated constants of traits can be used in patterns.
auto-reduced (treereduce-rust):
original code
original:
Version information
Possibly related line of code:
rust/compiler/rustc_resolve/src/late.rs
Lines 4015 to 4027 in bb3fa4b
Command:
/home/matthias/.rustup/toolchains/master/bin/rustc
Program output
The text was updated successfully, but these errors were encountered: