Skip to content
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

[E0412] used type name not in scope #2534

Merged
merged 1 commit into from
Aug 9, 2023
Merged

Conversation

MahadMuhammad
Copy link
Contributor

used type name not in scope - E0412

Code:

struct S<const N: usize>;

pub fn foo<const N: FooBar>() {} // { dg-error "failed to resolve" }
type Foo<const N: FooBar> = S<N>; // { dg-error "failed to resolve" }
struct Foo2<const N: FooBar>; // { dg-error "failed to resolve" }
enum Foo3<const N: FooBar> { // { dg-error "failed to resolve" }
    Foo,
    Bar,
}
union Foo4<const N: FooBar> { // { dg-error "failed to resolve" }
    a: usize,
    b: i32,
}
trait Fooable<const N: FooBar> {} // { dg-error "failed to resolve" }

trait Traitable {}
impl<const N: FooBar> Traitable for Foo2<N> {} // { dg-error "failed to resolve" }

Output:

/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/const_generics_7.rs:3:21: error: failed to resolve TypePath: FooBar in this scope [E0412]
    3 | pub fn foo<const N: FooBar>() {} // { dg-error "failed to resolve" }
      |                     ^~~~~~
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/const_generics_7.rs:4:19: error: failed to resolve TypePath: FooBar in this scope [E0412]
    4 | type Foo<const N: FooBar> = S<N>; // { dg-error "failed to resolve" }
      |                   ^~~~~~
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/const_generics_7.rs:4:31: error: failed to resolve TypePath: N in this scope [E0412]
    4 | type Foo<const N: FooBar> = S<N>; // { dg-error "failed to resolve" }
      |                               ^
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/const_generics_7.rs:5:22: error: failed to resolve TypePath: FooBar in this scope [E0412]
    5 | struct Foo2<const N: FooBar>; // { dg-error "failed to resolve" }
      |                      ^~~~~~
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/const_generics_7.rs:6:20: error: failed to resolve TypePath: FooBar in this scope [E0412]
    6 | enum Foo3<const N: FooBar> { // { dg-error "failed to resolve" }
      |                    ^~~~~~
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/const_generics_7.rs:10:21: error: failed to resolve TypePath: FooBar in this scope [E0412]
   10 | union Foo4<const N: FooBar> { // { dg-error "failed to resolve" }
      |                     ^~~~~~
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/const_generics_7.rs:14:24: error: failed to resolve TypePath: FooBar in this scope [E0412]
   14 | trait Fooable<const N: FooBar> {} // { dg-error "failed to resolve" }
      |                        ^~~~~~
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/const_generics_7.rs:17:15: error: failed to resolve TypePath: FooBar in this scope [E0412]
   17 | impl<const N: FooBar> Traitable for Foo2<N> {} // { dg-error "failed to resolve" }
      |               ^~~~~~
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/const_generics_7.rs:17:42: error: failed to resolve TypePath: N in this scope [E0412]
   17 | impl<const N: FooBar> Traitable for Foo2<N> {} // { dg-error "failed to resolve" }
      |                                          ^
/home/mahad/Desktop/mahad/gccrs/gcc/testsuite/rust/compile/const_generics_7.rs:17:42: error: failed to resolve TypePath: N in this scope [E0412]

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go): Added ErrorCode.

gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-type.cc (ResolveRelativeTypePath::go):
	Added ErrorCode.

Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
@P-E-P P-E-P added enhancement diagnostic diagnostic static analysis labels Aug 7, 2023
@philberty philberty added this pull request to the merge queue Aug 9, 2023
Merged via the queue into Rust-GCC:master with commit 74b8351 Aug 9, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
diagnostic diagnostic static analysis enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants