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

[nll] teach SCC about 'static #53327

Merged
merged 8 commits into from
Sep 7, 2018
Merged

Conversation

wesleywiser
Copy link
Member

r? @nikomatsakis

I think this is right? I am seeing better performance on the html5ever benchmark but I'd like a perf run to quantify the exact speedup. There's a few ui tests failing due to changes in the error messages. The main issue seems to be that returns aren't being detected correctly?

mir_check_cast_unsize.rs before:

error: unsatisfied lifetime constraints
  --> mir_check_cast_unsize.rs:17:46
   |
17 |   fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
   |  ________--____________________________________^
   | |        |
   | |        lifetime `'a` defined here
18 | |     //~^ ERROR unsatisfied lifetime constraints
19 | |     x
20 | |     //~^ WARNING not reporting region error due to nll
21 | | }
   | |_^ return requires that `'a` must outlive `'static`

mir_check_cast_unsize.rs after:

error: unsatisfied lifetime constraints
  --> mir_check_cast_unsize.rs:19:5
   |
17 | fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
   |        -- lifetime `'a` defined here
18 |     //~^ ERROR unsatisfied lifetime constraints
19 |     x
   |     ^ cast requires that `'a` must outlive `'static`

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 14, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:48:32] ....................................................................................................
[00:48:35] ....................................................................................................
[00:48:38] ....................................................................................................
[00:48:41] ....................................................................................................
[00:48:45] .........................i..............................FF...............................F..........
[00:48:48] .....FFF............................i...............................................................
[00:48:55] ....................................................................................................
no-bound/auxiliary" "-A" "unused"
[00:49:01] stdout:
[00:49:01] ------------------------------------------
[00:49:01] ------------------------------------------
[00:49:01] 
[00:49:01] ------------------------------------------
[00:49:01] stderr:
[00:49:01] ------------------------------------------
[00:49:01] {"message":"not reporting region error due to nll","code":null,"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs","byte_start":1609,"byte_end":1632,"line_start":49,"line_end":49,"column_start":9,"column_end":32,"is_primary":true,"text":[{"text":"        demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll","highlight_start":9,"highlight_end":32}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"warning: not reporting region error due to nll\n  --> /checkout/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs:49:9\n   |\nLL |         demand_y(x, y, x.get()) //~ WARNING not reporting region error due to nll\n   |         ^^^^^^^^^^^^^^^^^^^^^^^\n\n"}
[00:49:01] {"message":"External requirements","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs","byte_start":1528,"byte_end":1688,"line_start":45,"line_end":50,"column_start":47,"column_end":6,"is_primary":true,"text":[{"text":"    establish_relationships(&cell_a, &cell_b, |_outlives, x, y| {","highlight_start":47,"highlight_end":66},{"text":"        //~^ ERROR","highlight_start":1,"highlight_end":19},{"texeporting region error due to nll","code":null,"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs","byte_start":1696,"byte_end":1719,"line_start":51,"line_end":51,"column_start":9,"column_end":32,"is_primary":true,"text":[{"text":"        demand_y(x, y, x.get())","highlight_start":9,"highlight_end":32}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"warning: not reporting region error due to nll\n  --> /checkout/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs:51:9\n   |\nLL |         demand_y(x, y, x.get())\n   |         ^^^^^^^^^^^^^^^^^^^^^^^\n\n"}
[00:49:01] {"message":"External requirements","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs","byte_start":1603,"byte_end":1784,"line_start":48,"line_end":53,"column_start":47,"column_end":6,"is_primary":true,"text":[{"text":"    establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {","highlight_start":47,"highlight_end":79},{"text":"        //~^ ERROR","highlight_start":1,"highlight_end":19},{"text":"        // Only works if 'x: 'y:","highlight_start":1,"highlight_end":33},{"text":"        demand_y(x, y, x.get())","highlight_start":1,"highlight_end":32},{"text":"        //~^ WARNING not reporting region error due to nll","highlight_start":1,"highlight_end":59},{"text":"    });","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacemi-testing -Z unstable-options -Z borrowck=mir -Z verbose -C prefer-dynamic -C rpath
[00:49:01] 
[00:49:01] ------------------------------------------
[00:49:01] 
[00:49:01] thread '[ui] ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3149:9
[00:49:01] thread '[ui] ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3149:9
[00:49:01] 
[00:49:01] ---- [ui] ui/nll/issue-50716.rs stdout ----
[00:49:01] 
[00:49:01] error: Error: expected failure status (Some(1)) but received status Some(101).
[00:49:01] status: exit code: 101
[00:49:01] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/issue-50716.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/issue-50716/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/issue-50716/auxiliary" "-A" "unused"
[00:49:01] ------------------------------------------
[00:49:01] 
[00:49:01] ------------------------------------------
[00:49:01] stderr:
[00:49:01] stderr:
[00:49:01] ------------------------------------------
[00:49:01] thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:345:21
[00:49:01] 
[00:49:01] error: internal compiler error: unexpected panic
[00:49:01] 
[00:49:01] 
[00:49:01] note: the compiler unexpectedly panicked. this is a bug.
[00:49ast_reify.stderr
[00:49ast_reify.stderr
[00:49:01] To update references, rerun the tests and pass the `--bless` flag
[00:49:01] To only update this specific test, also pass `--test-args nll/mir_check_cast_reify.rs`
[00:49:01] error: 1 errors occurred comparing output.
[00:49:01] status: exit code: 1
[00:49:01] status: exit code: 1
[00:49:01] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/mir_check_cast_reify.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/mir_check_cast_reify/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Zborrowck=mir" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/mir_check_cast_reify/auxiliary" "-A" "unused"
[00:49:01] ------------------------------------------
[00:49:01] 
[00:49:01] ------------------------------------------
[00:49:01] stderr:
[00:49:01] stderr:
[00:49:01] ------------------------------------------
[00:49:01] {"message":"not reporting region error due to nll","code":null,"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/nll/mir_check_cast_reify.rs","byte_start":1682,"byte_end":1685,"line_start":46,"line_end":46,"column_start":25,"column_end":28,"is_primary":true,"text":[{"text":"    let f: fn(_) -> _ = foo;","highlight_start":25,"highlight_end":28}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"warning: not reporting region error due to nll\n  --> /checkout/src/test/ui/nll/mir_c.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3149:9
[00:49:01] ---- [ui] ui/nll/mir_check_cast_unsize.rs stdout ----
[00:49:01] diff of stderr:
[00:49:01] 
[00:49:01] 5    |     ^
[00:49:01] 5    |     ^
[00:49:01] 6 
[00:49:01] 7 error: unsatisfied lifetime constraints
[00:49:01] -   --> $DIR/mir_check_cast_unsize.rs:17:46
[00:49:01] +   --> $DIR/mir_check_cast_unsize.rs:19:5
[00:49:01] 9    |
[00:49:01] - LL |   fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
[00:49:01] -    |  ________--____________________________________^
[00:49:01] -    | |        lifetime `'a` defined here
[00:49:01] -    | |        lifetime `'a` defined here
[00:49:01] - LL | |     //~^ ERROR unsatisfied lifetime constraints
[00:49:01] - LL | |     x
[00:49:01] - LL | |     //~^ WARNING not reporting region error due to nll
[00:49:01] - LL | | }
[00:49:01] -    | |_^ return requires that `'a` must outlive `'static`
[00:49:01] + LL | fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
[00:49:01] +    |        -- lifetime `'a` defined here
[00:49:01] + LL |     //~^ ERROR unsatisfied lifetime constraints
[00:49:01] + LL |     x
[00:49:01] +    |     ^ cast requires that `'a` must outlive `'static`
[00:49:01] 20 error: aborting due to previous error
[00:49:01] 21 
[00:49:01] 
[00:49:01] 
[00:49:01] 
[00:49:01] The actual stderr differed from the expected stderr.
[00:49:01] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/mir_check_cast_unsize/mir_check_cast_unsize.stderr
[00:49:01] To update references, rerun the tests and pass the `--bless` flag
[00:49:01] To only update this specific test, also pass `--tes22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000]   DMA32    [mem 0x0000000001000000-0x00000000ffffffff]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000]   Normal   [mem 0x0000000100000000-0x00000003ffffffff]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000]   Device   empty
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] Movable zone start for each node
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] Early memory node ranges
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000]   node   0: [mem 0x0000000000001000-0x000000000009efff]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000]   node   0: [mem 0x0000000000100000-0x00000000bfff2fff]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000]   node   0: [mem 0x0000000100000000-0x00000003ffffffff]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] Initmem setup node 0 [mem 0x0000000000001000-0x00000003ffffffff]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] On node 0 totalpages: 3932049
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000]   DMA zone: 64 pages used for memmap
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000]   DMA zone: 21 pages reserved
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000]   DMA03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] PM: Registered nosave memory: [mem 0xfffbc000-0xffffffff]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] e820: [mem 0xc0000000-0xfffbbfff] available for PCI devices
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] Booting paravirtualized kernel on KVM
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] clocksource: refined-jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645519600211568 ns
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] setup_percpu: NR_CPUS:512 nr_cpumask_bits:512 nr_cpu_ids:4 nr_node_ids:1
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] PERCPU: Embedded 34 pages/cpu @ffff8803ffc00000 s98392 r8192 d32680 u524288
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] pcpu-alloc: s98392 r8192 d32680 u524288 alloc=1*2097152
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] pcpu-alloc: [0] 0 1 2 3 
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] Built 1 zonelists in Node order, mobility grouping on.  Total pages: 3870588
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] Policy zone: Normal
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.4.0-101-generic root=UUID=752b4ef1-0512-4cae-b541-f03ffd290 kernel: [    0.889847] .... node  #0, CPUs:      #1
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.891837] kvm-clock: cpu 1, msr 3:ffff1041, secondary cpu clock
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.897800]  #2
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.899137] kvm-clock: cpu 2, msr 3:ffff1081, secondary cpu clock
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.904868]  #3
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.906084] kvm-clock: cpu 3, msr 3:ffff10c1, secondary cpu clock
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.911951] x86: Booted up 1 node, 4 CPUs
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.914398] smpboot: Total of 4 processors activated (20800.00 BogoMIPS)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.921484] devtmpfs: initialized
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.927045] evm: security.selinux
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.929271] evm: security.SMACK64
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.930689] evm: security.SMACK64EXEC
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.932641] evm: security.SMACK64TRANSMUTE
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    0.934484] evm: security.SMACK64MMAP
Aug 14 03:22:34 travis-job-505d1e04-a02f-406-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.007866] ACPI: Added _OSI(Module Device)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.009720] ACPI: Added _OSI(Processor Device)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.012016] ACPI: Added _OSI(3.0 _SCP Extensions)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.014331] ACPI: Added _OSI(Processor Aggregator Device)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.019244] ACPI: Executed 2 blocks of module-level executable AML code
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.045321] ACPI: Interpreter enabled
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.048336] ACPI: (supports S0 S3 S4 S5)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.050228] ACPI: Using IOAPIC for interrupt routing
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.053228] PCI: Using host bridge windows from ACPI; if necessary, use "pci=nocrs" and report a bug
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.086708] ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.090264] acpi PNP0A03:00: _OSC: OS supports [ASPM ClockPM Segments MSI]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.094076] acpi PNP0A03:00: _OSC failed (AE_NOT_FOUND); disabling ASPM
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97-6b4ccb169f00 kernel: [    1.179390] pci 0000:00:03.0: [1af4:1004] type 00 class 0x000000
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.189613] pci 0000:00:03.0: reg 0x10: [io  0xc000-0xc03f]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.197828] pci 0000:00:03.0: reg 0x14: [mem 0xfebfe000-0xfebfe07f]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.218762] pci 0000:00:04.0: [1af4:1000] type 00 class 0x020000
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.232229] pci 0000:00:04.0: reg 0x10: [io  0xc040-0xc07f]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.240001] pci 0000:00:04.0: reg 0x14: [mem 0xfebff000-0xfebff0ff]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.259804] ACPI: PCI Interrupt Link [LNKA] (IRQs 5 *10 11)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.264801] ACPI: PCI Interrupt Link [LNKB] (IRQs 5 *10 11)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.270187] ACPI: PCI Interrupt Link [LNKC] (IRQs 5 10 *11)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.276486] ACPI: PCI Interrupt Link [LNKD] (IRQs 5 10 *11)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.280856] ACPI: PCI Interrupt Link [LNKS] (IRQs *9)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    1.303237] ACPI: Enabled 16 GPEs in block 00 to 0F
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb1605d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.524882] input: Sleep Button as /devices/LNXSYSTM:00/LNXSLPBN:00/input/input1
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.527981] ACPI: Sleep Button [SLPF]
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.530160] GHES: HEST is not enabled!
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.534539] ACPI: PCI Interrupt Link [LNKC] enabled at IRQ 11
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.537415] virtio-pci 0000:00:03.0: virtio_pci: leaving for legacy driver
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.545866] ACPI: PCI Interrupt Link [LNKD] enabled at IRQ 10
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.548750] virtio-pci 0000:00:04.0: virtio_pci: leaving for legacy driver
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.560564] Serial: 8250/16550 driver, 32 ports, IRQ sharing enabled
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.585427] 00:03: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 16550A
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.611063] 00:04: ttyS1 at I/O 0x2f8 (irq = 3, base_baud = 115200) is a 16550A
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.637715] 00:05: ttyS2 at I/O 0x3e8 (irq = 6, base_baud = 115200) is a 16550A
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.662817] 00:06: ttyS3 at I 3.788221] ledtrig-cpu: registered to indicate activity on CPUs
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.792595] NET: Registered protocol family 10
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.795013] NET: Registered protocol family 17
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.797247] Key type dns_resolver registered
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.799992] microcode: CPU0 sig=0x206d7, pf=0x1, revision=0x1
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.803803] microcode: CPU1 sig=0x206d7, pf=0x1, revision=0x1
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.806399] microcode: CPU2 sig=0x206d7, pf=0x1, revision=0x1
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.809767] microcode: CPU3 sig=0x206d7, pf=0x1, revision=0x1
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.812670] microcode: Microcode Update Driver: v2.01 <tigran@aivazian.fsnet.co.uk>, Peter Oruba
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.817788] registered taskstats version 1
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.820050] Loading compiled-in X.509 certificates
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    3.822611] Loaded X.509 cert 'Build time autogenerated kernel key: 56232512f0584176d25dbc659499b922e518c1c1'
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 9f00 kernel: [    8.747988] EXT4-fs (sda1): mounted filesystem with ordered data mode. Opts: (null)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    9.011514] random: init: uninitialized urandom read (12 bytes read, 24 bits of entropy available)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    9.159939] random: mountall: uninitialized urandom read (12 bytes read, 28 bits of entropy available)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    9.216011] EXT4-fs (sda1): re-mounted. Opts: (null)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [    9.473662] random: cloud-init: uninitialized urandom read (32 bytes read, 34 bits of entropy available)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [   10.141262] random: cloud-init: uninitialized urandom read (32 bytes read, 42 bits of entropy available)
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [   10.294119] systemd-udevd[702]: starting version 204
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [   10.435872] piix4_smbus 0000:00:01.3: SMBus base address uninitialized - upgrade BIOS or use force_addr=0xaddr
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [   10.503945] intel_rapl: no valid rapl domains found in package 0
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [   10.562382] ppdev: user-space parallel port driver
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 kernel: [   10.709120] random: mktemp: uninitialized urandoing set_multiqueue.
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 instance-setup: INFO Set channels for eth0 to 4.
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 instance-setup: INFO Setting /proc/irq/25/smp_affinity_list to 0 for device virtio1.
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 instance-setup: INFO /proc/irq/25/smp_affinity_list: real affinity 0
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 instance-setup: INFO Setting /proc/irq/26/smp_affinity_list to 0 for device virtio1.
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 instance-setup: INFO /proc/irq/26/smp_affinity_list: real affinity 0
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 instance-setup: INFO Setting /proc/irq/27/smp_affinity_list to 1 for device virtio1.
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 instance-setup: INFO /proc/irq/27/smp_affinity_list: real affinity 1
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 instance-setup: INFO Setting /proc/irq/28/smp_affinity_list to 1 for device virtio1.
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 instance-setup: INFO /proc/irq/28/smp_affinity_list: real affinity 1
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 instance-setup: INFO Setting /proc/irq/29/smp_affinity_list to 2 for device virtio1.
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 instance-setup: INFO /proc/irq/29/smp_affinity_list: real affinity 2
Aug 14 03:22:34 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 instance-setup: INFO Setting /proc00 google-clock-skew: INFO Starting Google Clock Skew daemon.
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 google-clock-skew: INFO Clock drift token has changed: 0.
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 google-accounts: INFO Starting Google Accounts daemon.
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 google-accounts: INFO Creating a new user account for me.
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 google-accounts: INFO Created user account me.
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 google-accounts: INFO Creating a new user account for henrik.
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 google-accounts: INFO Created user account henrik.
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 google-accounts: INFO Creating a new user account for emma.
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 cron[1404]: (CRON) INFO (pidfile fd = 3)
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 cron[1446]: (CRON) STARTUP (fork ok)
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 cron[1446]: (CRON) INFO (Running @reboot jobs)
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 pollinate: system was previously seeded at [2017-12-05 19:31:29.715998981 +0000]
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 pollinate: To re-seed this system again, use the -r|--reseed option
Aug 14 03:22:35 travis-job-505d1e04-a02f-4068-a97e-6b4ccb169f00 google-accounts: INFO Created user account emma.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

None
};

let normal_successors = self.graph.outgoing_regions(node).collect::<Vec<_>>();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to .collect() here to work around a lifetime issue.


impl<'s, 'graph> graph::GraphSuccessors<'graph> for AugmentedRegionGraph<'s> {
type Item = RegionVid;
type Iter = Box<dyn Iterator<Item = Self::Item>>;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out how to name this type so I just boxed it. Should I hand roll a custom Iterator instead?

@nikomatsakis
Copy link
Contributor

cc #53178

@nikomatsakis
Copy link
Contributor

@bors try

@bors
Copy link
Contributor

bors commented Aug 16, 2018

⌛ Trying commit 6e918df9c2afcdd4f71c364c27a0e7d5e3710279 with merge ed285b7a46c0949465c4c1af1d968de39cc1dbbc...

@bors
Copy link
Contributor

bors commented Aug 16, 2018

☀️ Test successful - status-travis
State: approved= try=True

@kennytm
Copy link
Member

kennytm commented Aug 17, 2018

@rust-timer build ed285b7a46c0949465c4c1af1d968de39cc1dbbc

@rust-timer
Copy link
Collaborator

Success: Queued ed285b7a46c0949465c4c1af1d968de39cc1dbbc with parent 5050349, comparison URL.

@kennytm kennytm added S-waiting-on-perf Status: Waiting on a perf run to be completed. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Aug 17, 2018
@kennytm
Copy link
Member

kennytm commented Aug 20, 2018

(FYI perf is ready)

@nikomatsakis
Copy link
Contributor

It seems like the big win here is max-rss:

clean-check 216,940.00 216,748.00 -0.1%
nll-check 1,229,032.00 618,168.00 -49.7%

though instructions win too

clean-check 11,196,975,790.00 11,213,343,029.00 0.1%
nll-check 17,617,306,592.00 17,001,261,662.00 -3.5%

@nikomatsakis nikomatsakis force-pushed the wip_optimize_nll branch 2 times, most recently from f8be3e8 to c2ca559 Compare August 22, 2018 18:05
@nikomatsakis
Copy link
Contributor

OK, I pushed some commits fixing the nits that @wesleywiser was hitting

@nikomatsakis
Copy link
Contributor

@wesleywiser take a look at the changes I pushed; it seems like the only thing holding this up from landing is possible changes to the error messages? Can you run ./x.py test --stage 1 -i --bless src/test/ui (or some such command) and then push the results? It's usually easiest to review the changes that way.

@nikomatsakis nikomatsakis added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 22, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[00:48:04] ....................................................................................................
[00:48:08] ....................................................................................................
[00:48:11] .........................................i..........................................................
[00:48:14] ...........................................................................................i.i..ii..
[00:48:18] ..................................................................FF................................
[00:48:21] ..F......................FF.F..........................................................i............
[00:48:27] ....................................................................................................
[00:48:30] ....................................................................................................
[00:48:30] ....................................................................................................
[00:48:33] ..............F.....................................................................................
[00:48:39] ....................................................................................................
[00:48:42] ....................................................................................................
[00:48:46] ...................................................i................................................
[00:48:50] ....................................................................................................
[00:48:50] ....................................................................................................
[00:48:53] ....................................................................................................
[00:48:55] ..............................................................................................i.....
[00:48:57] .......................................................
[00:48:57] failures:
[00:48:57] 
[00:48:57] ---- [ui] ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs stdout ----
[00:48:57] 
[00:48:57] error: Error: expected failure status (Some(1)) but received status Some(101).
[00:48:57] status: exit code: 101
[00:48:57] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Zborrowck=mir" "-Zverbose" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-eporting region error due to nll","code":null,"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs","byte_start":1696,"byte_end":1719,"line_start":51,"line_end":51,"column_start":9,"column_end":32,"is_primary":true,"text":[{"text":"        demand_y(x, y, x.get())","highlight_start":9,"highlight_end":32}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"warning: not reporting region error due to nll\n  --> /checkout/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs:51:9\n   |\nLL |         demand_y(x, y, x.get())\n   |         ^^^^^^^^^^^^^^^^^^^^^^^\n\n"}
[00:48:57] {"message":"External requirements","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.rs","byte_start":1603,"byte_end":1784,"line_start":48,"line_end":53,"column_start":47,"column_end":6,"is_primary":true,"text":[{"text":"    establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y| {","highlight_start":47,"highlight_end":79},{"text":"        //~^ ERROR","highlight_start":1,"highlight_end":19},{"text":"        // Only works if 'x: 'y:","highlight_start":1,"highlight_end":33},{"text":"        demand_y(x, y, x.get())","highlight_start":1,"highlight_end":32},{"text":"        //~^ WARNING not reporting region error due to nll","highlight_start":1,"highlight_end":59},{"text":"    });","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacem/runtest.rs:3189:9
[00:48:57] ---- [ui] ui/nll/mir_check_cast_unsafe_fn.rs stdout ----
[00:48:57] diff of stderr:
[00:48:57] 
[00:48:57] 5    |                                ^
[00:48:57] 5    |                                ^
[00:48:57] 6 
[00:48:57] 7 error: unsatisfied lifetime constraints
[00:48:57] -   --> $DIR/mir_check_cast_unsafe_fn.rs:20:14
[00:48:57] +   --> $DIR/mir_check_cast_unsafe_fn.rs:18:32
[00:48:57] 9    |
[00:48:57] 10 LL | fn bar<'a>(input: &'a u32, f: fn(&'a u32) -> &'a u32) -> &'static u32 {
[00:48:57] 11    |        -- lifetime `'a` defined here
[00:48:57] 12 ...
[00:48:57] 12 ...
[00:48:57] - LL |     unsafe { g(input) }
[00:48:57] -    |              ^^^^^^^^ returning this value requires that `'a` must outlive `'static`
[00:48:57] + LL |     let g: unsafe fn(_) -> _ = f;
[00:48:57] +    |                                ^ cast requires that `'a` must outlive `'static`
[00:48:57] 16 error: aborting due to previous error
[00:48:57] 17 
[00:48:57] 
[00:48:57] 
[00:48:57] 
[00:48:57] The actual stderr differed from the expected stderr.
[00:48:57] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/mir_check_cast_unsafe_fn/mir_check_cast_unsafe_fn.stderr
[00:48:57] To update references, rerun the tests and pass the `--bless` flag
[00:48:57] To only update this specific test, also pass `--test-args nll/mir_check_cast_unsafe_fn.rs`
[00:48:57] error: 1 errors occurred comparing output.
[00:48:57] status: exit code: 1
[00:48:57] status: exit code: 1
[00:48:57] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/mir_check_cast_unsafe_fn.rs" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/mir_check_cast_unsafe_fn/a" "-Crpath" "-O" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-Zborrowck=mir" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/mir_check_cast_unsafe_fn/auxiliary" "-A" "unused"
[00:48:57] ------------------------------------------
[00:48:57] 
[00:48:57] ------------------------------------------
[00:48:57] stderr:
[00:48:57] stderr:
[00:48:57] ------------------------------------------
[00:48:57] {"message":"not reporting region error due to nll","code":null,"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/nll/mir_check_cast_unsafe_fn.rs","byte_start":761,"byte_end":762,"line_start":18,"line_end":18,"column_start":32,"column_end":33,"is_primary":true,"text":[{"text":"    let g: unsafe fn(_) -> _ = f;","highlight_start":32,"highlight_end":33}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"warning: not reporting region error due to nll\n  --> /checkout/src/test/ui/nll/mir_check_cast_unsafe_fn.rs:18:32\n   |\nLL |     let g: unsafe fn(_) -> _ = f;\n   |                                ^\n\n"}
[00:48:57] {"message":"unsatisfied lifetime constraints","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/mir_check_cast_unsafe_fn.rs","byte_start":530,"byte_end":532,"line_start":15,"line_end":15,"column_start":8,"column_end":10,"is_primary":false,"text":[{"text":"fn bar<'a>(input: &'a u32, s:17:46
[00:48:57] +   --> $DIR/mir_check_cast_unsize.rs:19:5
[00:48:57] 9    |
[00:48:57] - LL |   fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
[00:48:57] -    |  ________--____________________________________^
[00:48:57] -    | |        lifetime `'a` defined here
[00:48:57] -    | |        lifetime `'a` defined here
[00:48:57] - LL | |     //~^ ERROR unsatisfied lifetime constraints
[00:48:57] - LL | |     x
[00:48:57] - LL | |     //~^ WARNING not reporting region error due to nll
[00:48:57] - LL | | }
[00:48:57] -    | |_^ returning this value requires that `'a` must outlive `'static`
[00:48:57] + LL | fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
[00:48:57] +    |        -- lifetime `'a` defined here
[00:48:57] + LL |     //~^ ERROR unsatisfied lifetime constraints
[00:48:57] + LL |     x
[00:48:57] +    |     ^ cast requires that `'a` must outlive `'static`
[00:48:57] 20 error: aborting due to previous error
[00:48:57] 21 
[00:48:57] 
[00:48:57] 
[00:48:57] 
[00:48:57] The actual stderr differed from the expected stderr.
[00:48:57] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/mir_check_cast_unsize/mir_check_cast_unsize.stderr
[00:48:57] To update references, rerun the tests and pass the `--bless` flag
[00:48:57] To only update this specific test, also pass `--test-args nll/mir_check_cast_unsize.rs`
[00:48:57] error: 1 errors occurred comparing output.
[00:48:57] status: exit code: 1
[00:48:57] status: exit code: 1
[00:48:57] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/mir_check_cast_unsize.rs" "--target=x86_64-unknown-linux-gnu" "--error-fohe signature and the body must be made to match. Typically,\nthis is done by updating the function signature. So, in this case, we change\nthe type of `y` to `&'a i32`, like so:\n\n```\nfn foo<'a>(x: &'a i32, y: &'a i32) -> &'a i32 {\n    if x > y { x } else { y }\n}\n```\n\nNow the signature indicates that the function data borrowed from either `x` or\n`y`. Alternatively, you could change the body to not return data from `y`:\n\n```\nfn foo<'a>(x: &'a i32, y: &i32) -> &'a i32 {\n    x\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/regions-static-bound.rs","byte_start":945,"byte_end":958,"line_start":25,"line_end":25,"column_start":5,"column_end":18,"is_primary":true,"text":[{"text":"    static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621]","highlight_start":5,"highlight_end":18}],"label":"lifetime `'static` required","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"add explicit lifetime `'static` to the type of `u`","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/regions/regions-static-bound.rs","byte_start":926,"byte_end":929,"line_start":24,"line_end":24,"column_start":13,"column_end":16,"is_primary":true,"text":[{"text":"fn error(u: &(), v: &()) {","highlight_start":13,"highlight_end":16}],"label":null,"suggested_replacement":"&'static ()","suggestion_applicability":"Unspecified","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0621]: explicit lifetime required in the type of `u`\n  --> /checkout/src/test/ui/regions/regions-static-bound.rs:25:5\n   |\nLL | fn error(u: &(), v: &()) {\n   |             --- help: add explicit lifetime `'static` to the type of `u`: `&'static ()`\nLL |     static_id(&u); //[ll]~ ERROR explicit lifetime required in the type of `u` [E0621]\n   |     ^^^^^^^^^^^^^ lifetime `'static` required\n\n"}
[00:48:57] thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:345:21
[00:48:57] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:48:57] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[00:48:57] {"message":"For more information about this error, try `rustc --explain E0621`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0621`.\n"}
[00:48:57] error: internal compiler error: unexpected panic
[00:48:57] 
[00:48:57] note: the compiler unexpectedly panicked. this is a bug.
[00:48:57] 
[00:48:57] 
[00:48:57] note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
[00:48:57] 
[00:48:57] note: rustc 1.30.0-dev running on x86_64-unknown-linux-gnu
[00:48:57] 
[00:48:57] note: compiler flags: -Z ui-testing -Z unstable-options -Z borrowck=mir -C prefer-dynamic -C rpath
[00:48:57] 
[00:48:57] ------------------------------------------
[00:48:57] 
[00:48:57] thread '[ui] ui/regions/regions-static-bound.rs#nll' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3189:9

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

let static_successors: Range<RegionVid> = if node == self.static_region {
// `'static: 'a` for all regions `'a` -- so add an edge
// from `'static` to every other region.
0.into() .. self.graph.constraint_graph.first_constraints.len().into()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0.into() could just be self.static_region

LL | f(x)
| ^^^^ `x` escapes the function body here
LL | let f: fn(_) -> _ = foo;
| ^^^ cast requires that `'a` must outlive `'static`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, these errors do look less good, but they are also not wrong; I certainly see how they arise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tricky case, but I think if we provide the suggested output in the other comment it would be slightly more understandable. Something closer to the ideal output in my mind would be:

error: unsatisfied lifetime constraints
  --> $DIR/mir_check_cast_reify.rs:46:25
   |
LL | fn foo<'a>(x: &'a u32) -> &'a u32
   | --------------------------------- `foo` is not `'static` due to this definition
...
LL | fn bar<'a>(x: &'a u32) -> &'static u32 {
   |        --     ---         -------- `foo` needs to be `'static` due to this return type
   |        |      |
   |        |      `x` is `'a` due to this
   |        lifetime `'a` defined here
...
LL |     let f: fn(_) -> _ = foo;
   |                         ^^^ this is `'a` but it must outlive `'static`

| -- lifetime `'a` defined here
LL | //~^ ERROR unsatisfied lifetime constraints
LL | x
| ^ cast requires that `'a` must outlive `'static`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case I sort of prefer the error =)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but I suppose it's mostly the crazy span; I think we are labeling the wrong point

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"cast requires..." is not a great label, but the spans are correct in my mind, although I would try and detect this kind of case and point at the return type:

error: unsatisfied lifetime constraints
  --> $DIR/mir_check_cast_unsize.rs:19:5
   |
LL | fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
   |        --     ---         -------- `x` must be `'static` due to this return type
   |        |      |
   |        |      `x` is `'a` due to this type definition
   |        lifetime `'a` defined here
LL |     x
   |     ^ this is `'a` but it must outlive `'static`

@nikomatsakis
Copy link
Contributor

cc @matthewjasper @davidtwco @estebank — expanding the definition of SCC here is messing with our error messages a bit. But then again these have always been heuristics. I am sort of inclined to land this PR "as is" and try to address in follow-up changes to the heuristics -- but I'm curious what y'all think.

I'm not really sure (in any case) what those changes ought to be. The problem here remains that it's hard to separate out the outlives edges that users want to be shown; using the SCC rules seemed to do a decent job of screening out a lot of "junk" at the bottom of the graph, but it's imperfect, and there ought to be a better basis somehow.

@matthewjasper
Copy link
Contributor

All of the cases where we've changed messages are for conflicting files, I'm not sure if there will be any changes after a rebase.

@wesleywiser
Copy link
Member Author

I'll rebase tonight and we can see if that fixes the issues or not.

@estebank
Copy link
Contributor

But then again these have always been heuristics. I am sort of inclined to land this PR "as is" and try to address in follow-up changes to the heuristics -- but I'm curious what y'all think.

@nikomatsakis I agree, lets merge and file tickets. From what I'm seeing there are two cases, and one is a special case of the other, which means that improving the more general case would make both better, and we can take our time to fix the latter.

@nikomatsakis
Copy link
Contributor

Actually, that's wrong.

@nikomatsakis
Copy link
Contributor

error: unsatisfied lifetime constraints
  --> dyn-trait-underscore.rs:18:5
   |
16 | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
   |      -         - let's call the lifetime of this reference `'1`
   |      |
   |      lifetime `T` defined here
17 |     //                      ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
18 |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
   |     ^^^^^^^^^^^^^^^^^^^^^^ requires that `'1` must outlive `T`

It is the a function:

fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
    //                      ^^^^^^^^^^^^^^^^^^^^^ bound *here* defaults to `'static`
    Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
}

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Sep 6, 2018

Ok, I was totally off =) the region is not early-bound here but rather late-bound, and this is the code path that is returning invalid data:

ty::ReFree(free_region) => match free_region.bound_region {
ty::BoundRegion::BrNamed(_, name) => {
self.highlight_named_span(tcx, error_region, &name, diag);
Some(name)
},

@nikomatsakis
Copy link
Contributor

PS @varkor I'm sorry I cited you, your impeccable refactorings are definitely not the problem =)

@nikomatsakis
Copy link
Contributor

OK, so, I'm not sure the best fix, but the problem has to do with this code:

/// Iterates over the late-bound regions defined on fn_def_id and
/// invokes `f` with the liberated form of each one.
fn for_each_late_bound_region_defined_on<'tcx>(
tcx: TyCtxt<'_, '_, 'tcx>,
fn_def_id: DefId,
mut f: impl FnMut(ty::Region<'tcx>)
) {
if let Some(late_bounds) = tcx.is_late_bound_map(fn_def_id.index) {
for late_bound in late_bounds.iter() {
let hir_id = HirId{ owner: fn_def_id.index, local_id: *late_bound };
let region_node_id = tcx.hir.hir_to_node_id(hir_id);
let name = tcx.hir.name(region_node_id).as_interned_str();
let region_def_id = tcx.hir.local_def_id(region_node_id);
let liberated_region = tcx.mk_region(ty::ReFree(ty::FreeRegion {
scope: fn_def_id,
bound_region: ty::BoundRegion::BrNamed(region_def_id, name),
}));
f(liberated_region);
}
}
}

Here we are walking over the hir-id for each late-bound region on the function. We are particularly interested in late-bound regions that are declared but not used -- in fact, we only care here about late-bound regions that have been give names (this code is needed because people may refer to those names elsewhere, and we used to get ICEs if those names were not used somewhere in the function). The problem is that the late-bound region here is anonymous; somehow the node-id we get for it winds up mapping to T, not quite sure why that is.

@wesleywiser
Copy link
Member Author

Thanks for your help @nikomatsakis! I'll rebase tonight and fix the merge conflicts with the tests.

@Mark-Simulacrum
Copy link
Member

@bors p=1 RC milestone

@wesleywiser
Copy link
Member Author

Rebased

@wesleywiser
Copy link
Member Author

This is ready for review.

@kennytm kennytm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 7, 2018
@nikomatsakis
Copy link
Contributor

@bors r+

It would be nice to improve the heuristics, though.

@bors
Copy link
Contributor

bors commented Sep 7, 2018

📌 Commit b1211e8 has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 7, 2018
@bors
Copy link
Contributor

bors commented Sep 7, 2018

⌛ Testing commit b1211e8 with merge fc81e36...

bors added a commit that referenced this pull request Sep 7, 2018
[nll] teach SCC about `'static`

r? @nikomatsakis

I think this is right? I am seeing better performance on the `html5ever` benchmark but I'd like a perf run to quantify the exact speedup. There's a few ui tests failing due to changes in the error messages. The main issue seems to be that returns aren't being detected correctly?

`mir_check_cast_unsize.rs` before:

```
error: unsatisfied lifetime constraints
  --> mir_check_cast_unsize.rs:17:46
   |
17 |   fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
   |  ________--____________________________________^
   | |        |
   | |        lifetime `'a` defined here
18 | |     //~^ ERROR unsatisfied lifetime constraints
19 | |     x
20 | |     //~^ WARNING not reporting region error due to nll
21 | | }
   | |_^ return requires that `'a` must outlive `'static`
```

`mir_check_cast_unsize.rs` after:

```
error: unsatisfied lifetime constraints
  --> mir_check_cast_unsize.rs:19:5
   |
17 | fn bar<'a>(x: &'a u32) -> &'static dyn Debug {
   |        -- lifetime `'a` defined here
18 |     //~^ ERROR unsatisfied lifetime constraints
19 |     x
   |     ^ cast requires that `'a` must outlive `'static`
```
@bors
Copy link
Contributor

bors commented Sep 7, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing fc81e36 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants