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

PERF: Prevent switches to AST when processing array type #4782

Merged
merged 1 commit into from
Jan 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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