Git Product home page Git Product logo

Comments (8)

matthiaskrgr avatar matthiaskrgr commented on August 19, 2024

#126320 cc @oli-obk :D

from rust.

oli-obk avatar oli-obk commented on August 19, 2024

wtf. why does that wrong comma cause the struct to be different from a struct with no fields

from rust.

matthiaskrgr avatar matthiaskrgr commented on August 19, 2024

minimized

struct X {,}

fn main() {
    || {
        if let X { x: 1,} = (X {}) {}
    };
}

from rust.

chenyukang avatar chenyukang commented on August 19, 2024

wtf. why does that wrong comma cause the struct to be different from a struct with no fields

An extra , is a recovered struct variant, and it is skipped here:

let inexistent_fields_err = if !(inexistent_fields.is_empty() || variant.is_recovered())

so we didn't emit the error like an empty struct:

(Some(err), None) => Err(err.emit()),

error[E0026]: struct `X` does not have a field named `x`
 --> src/main.rs:5:20
  |
5 |         if let X { x: 1,} = (X {}) {}
  |                    ^ struct `X` does not have this field

So the compiler continues until the ICE point.

I think a trivial fix will be ok here?

from rust.

oli-obk avatar oli-obk commented on August 19, 2024

Hmm... I'd look into reporting that error even for recovered structs and figuring out how to avoid it just for the cases that this skip was intended to avoid

from rust.

chenyukang avatar chenyukang commented on August 19, 2024

seems there is nothing else we are trying to avoid:

2ea2bb4

I'd prefer not to report the no-field error, since the first error in parsing will point out the root cause, and there is a case like #126344, which may introduce noise when there are too many type errors, it's also applied to this issue.

from rust.

oli-obk avatar oli-obk commented on August 19, 2024

Oh... we can probably just replace the is_recovered method with a new tainted_by_errors method and return an Result<(), ErrorGuaranteed>. This way we act as if we reported an error, and thus not continue to the ICE

from rust.

oli-obk avatar oli-obk commented on August 19, 2024

Since we cannot encode an ErrorGuaranteed in the flags list, either take a TyCtxt argument on the tainted_by_errors method, or check if replacing the field field with Result<IndexVec<FieldIdx, FieldDef>, ErrorGuaranteed> works out nicely

from rust.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.