Skip to content

Rust incorrectly accepts unbalanced parentheses #58886

Closed
@mjbshaw

Description

@mjbshaw

Rust incorrectly accepts the following code (which is missing a )):

pub struct Value {
}

pub fn new() -> Result<Value, ()> {
    Ok(Value {
    } // Look ma, no `)`!
}

So far this seems to only happen if the code is inside a submodule. Shell script to reproduce:

#!/bin/bash

cargo new --lib this_should_not_build
mkdir this_should_not_build/src/foo

cat >> this_should_not_build/src/lib.rs <<-'EOF'
    pub mod foo;
EOF

cat > this_should_not_build/src/foo/mod.rs <<-'EOF'
    pub struct Value {
    }

    pub fn new() -> Result<Value, ()> {
        Ok(Value {
        }
    }
EOF

cd this_should_not_build
cargo build

My compiler version: rustc 1.34.0-nightly (0ea22717a 2019-03-02)

Metadata

Metadata

Assignees

Labels

A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.P-highHigh priorityregression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions