tint/resolver: Shuffle validation code

Restructure the logic so there's less, pointless dynamic casting, and the complexity is reduced.

This alters the order in which variables are validated, hence the change of test.

Change-Id: I9a3120c0278faa5ac9f1db65eeb71a8e4a705596
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/95948
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/src/tint/resolver/variable_validation_test.cc b/src/tint/resolver/variable_validation_test.cc
index b538db0..5625f00 100644
--- a/src/tint/resolver/variable_validation_test.cc
+++ b/src/tint/resolver/variable_validation_test.cc
@@ -59,18 +59,16 @@
     EXPECT_EQ(r()->error(), "12:34 error: override declaration requires a type or initializer");
 }
 
-TEST_F(ResolverVariableValidationTest, VarTypeNotStorable) {
+TEST_F(ResolverVariableValidationTest, VarTypeNotConstructible) {
     // var i : i32;
     // var p : pointer<function, i32> = &v;
     auto* i = Var("i", ty.i32(), ast::StorageClass::kNone);
-    auto* p = Var(Source{{56, 78}}, "a", ty.pointer<i32>(ast::StorageClass::kFunction),
+    auto* p = Var("a", ty.pointer<i32>(Source{{56, 78}}, ast::StorageClass::kFunction),
                   ast::StorageClass::kNone, AddressOf(Source{{12, 34}}, "i"));
     WrapInFunction(i, p);
 
     EXPECT_FALSE(r()->Resolve());
-    EXPECT_EQ(r()->error(),
-              "56:78 error: ptr<function, i32, read_write> cannot be used as the "
-              "type of a var");
+    EXPECT_EQ(r()->error(), "56:78 error: function-scope 'var' must have a constructible type");
 }
 
 TEST_F(ResolverVariableValidationTest, LetTypeNotConstructible) {