Skip to content

Anonymous lifetime inference regression #10396

@sfackler

Description

@sfackler

The following function compiled up to today:

    fn write_messages(&mut self, messages: &[&FrontendMessage]) {
         for &message in messages.iter() {
             self.stream.write_message(message);
         }
         self.stream.flush();
     }

After updating to the from yesterday's Rust nightly to today's, it now fails to compile with the following error:

/home/sfackler/rust/src/rust-postgres/lib.rs:540:13: 540:20 error: in type `&lib::message::FrontendMessage<>`, pointer has a longer lifetime than the data it references
/home/sfackler/rust/src/rust-postgres/lib.rs:540         for &message in messages.iter() {
                                                              ^~~~~~~
/home/sfackler/rust/src/rust-postgres/lib.rs:539:64: 544:5 note: the pointer is valid for the anonymous lifetime #3 defined on the block at 539:64
/home/sfackler/rust/src/rust-postgres/lib.rs:539     fn write_messages(&mut self, messages: &[&FrontendMessage]) {
/home/sfackler/rust/src/rust-postgres/lib.rs:540         for &message in messages.iter() {
/home/sfackler/rust/src/rust-postgres/lib.rs:541             self.stream.write_message(message);
/home/sfackler/rust/src/rust-postgres/lib.rs:542         }
/home/sfackler/rust/src/rust-postgres/lib.rs:543         self.stream.flush();
/home/sfackler/rust/src/rust-postgres/lib.rs:544     }
/home/sfackler/rust/src/rust-postgres/lib.rs:539:64: 544:5 note: but the referenced data is only valid for the anonymous lifetime #4 defined on the block at 539:64
/home/sfackler/rust/src/rust-postgres/lib.rs:539     fn write_messages(&mut self, messages: &[&FrontendMessage]) {
/home/sfackler/rust/src/rust-postgres/lib.rs:540         for &message in messages.iter() {
/home/sfackler/rust/src/rust-postgres/lib.rs:541             self.stream.write_message(message);
/home/sfackler/rust/src/rust-postgres/lib.rs:542         }
/home/sfackler/rust/src/rust-postgres/lib.rs:543         self.stream.flush();
/home/sfackler/rust/src/rust-postgres/lib.rs:544     }
error: aborting due to previous error
task '<unnamed>' failed at 'explicit failure', /build/rust-git/src/rust/src/libsyntax/diagnostic.rs:101
task '<unnamed>' failed at 'receiving on closed channel', /build/rust-git/src/rust/src/libstd/rt/comm.rs:198

Possibly related to #10153?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lifetimesArea: Lifetimes / regionsE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions