Skip to content

Commit

Permalink
PERF: Prevent switches to AST when processing array type
Browse files Browse the repository at this point in the history
  • Loading branch information
mchernyavsky committed Dec 24, 2019
1 parent 7fc0e2a commit e3686eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/main/kotlin/org/rust/lang/core/resolve/NameResolution.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1259,10 +1259,9 @@ private fun processLexicalDeclarations(
is RsFunction -> {
if (Namespace.Types in ns && processAll(scope.typeParameters, processor)) return true
if (Namespace.Values in ns && processAll(scope.constParameters, processor)) return true
// XXX: `cameFrom !is RsValueParameterList` prevents switches to AST in cases like
// `fn foo(a: usize, b: [u8; SIZE])`. Note that rustc really process them and show
// [E0435] on this: `fn foo(a: usize, b: [u8; a])`.
if (Namespace.Values in ns && cameFrom !is RsValueParameterList) {
// XXX: `cameFrom is RsBlock` prevents switches to AST in cases like `fn foo(a: usize, b: [u8; SIZE])`.
// Note that rustc really process them and show [E0435] on this: `fn foo(a: usize, b: [u8; a])`.
if (Namespace.Values in ns && cameFrom is RsBlock) {
val selfParam = scope.selfParameter
if (selfParam != null && processor("self", selfParam)) return true

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class RsStubOnlyTypeInferenceTest : RsTypificationTestBase() {
fun `test const expr`() = stubOnlyTypeInfer("""
//- foo.rs
const COUNT: usize = 2;
pub fn foo() -> [i32; (2 * COUNT + 3) << (4 / 2)] { unimplemented!() }
pub fn foo(a: i32) -> [i32; (2 * COUNT + 3) << (4 / 2)] { unimplemented!() }
//- main.rs
mod foo;
fn main() {
let x = foo::foo();
let x = foo::foo(0);
x;
//^ [i32; 28]
}
Expand Down

0 comments on commit e3686eb

Please sign in to comment.