Skip to content

Instantly share code, notes, and snippets.

#![feature(prelude_import)]
#![no_std]
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed

This is the rough implementation plan:

pick 9ae5db20d2 introduce Universe struct

We want this. =)

pick 1da0b70c57 introduce UniverseIndex into ParamEnv

Instead of adding a universe to the ParamEnv, the plan is now to add this field to the InferenceCtxt. It represents the maxixum

git show HEAD | head -1; head -1 ~/tmp/issue-47267.rs; for i in 1 2 3 4 5 6; do time rustc --emit=metadata ~/tmp/issue-47267.rs; done
commit 205eba83e2373c81ed136997a0af004630853e10
#![feature(nll)]
1> real 0m0.506s
1> user 0m0.464s
1> sys 0m0.040s
1>
1> real 0m0.511s
1> user 0m0.476s
// MIR for `main`
// source = MirSource { def_id: DefId(0/0:15 ~ issue_47267[317d]::main[0]), promoted: None }
// pass_name = nll
// disambiguator = 0
| Free Region Mapping
| '_#0r | Global | ['_#0r, '_#1r]
| '_#1r | Local | ['_#1r]
|
| Inferred Region Values
#!/bin/bash
if [[ "$1" == "" || "$2" == "" ]]; then
echo "Usage: $0 <crate> <version>"
echo ""
echo "e.g. $0 conrod 0.32.0"
exit 1
fi
curl -L https://crates.io/api/v1/crates/$1/$2/download | tar zxf -
error: internal compiler error: librustc_mir/borrow_check/nll/mod.rs:293: region is not an ReVar: ReEarlyBound(1, 'a)
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports
note: rustc 1.25.0-dev running on x86_64-unknown-linux-gnu
note: run with `RUST_BACKTRACE=1` for a backtrace
# Sample TOML configuration file for building Rust.
#
# To configure rustbuild, copy this file to the directory from which you will be
# running the build, and name it config.toml.
#
# All options are commented out by default in this file, and they're commented
# out with their default values. The build system by default looks for
# `config.toml` in the current directory of a build for build configuration, but
# a custom configuration file can also be specified with `--config` to the build
# system.
fn main() {
let mut x = 22;
let p = &x;
x += 1;
println!("{:?}", p);
println!("{:?}", x);
}
// error[E0506]: cannot assign to `x` because it is borrowed
// --> /home/nmatsakis/tmp/spastorino1.rs:4:5
// MIR for `bar`
// source = MirSource { def_id: DefId(0/0:5 ~ spastorino[317d]::bar[0]), promoted: None }
// pass_name = nll
// disambiguator = 0
| '_#0r: {bb0[0], bb0[1], bb0[2], bb0[3], bb0[4], bb0[5], bb0[6], bb0[7], bb0[8], '_#0r, '_#1r, '_#2r}
| '_#1r: {bb0[0], bb0[1], bb0[2], bb0[3], bb0[4], bb0[5], bb0[6], bb0[7], bb0[8], '_#1r}
| '_#2r: {bb0[0], bb0[1], bb0[2], bb0[3], bb0[4], bb0[5], bb0[6], bb0[7], bb0[8], '_#2r}
| '_#3r: {}
| '_#4r: {}

Here are some scenarios to test. Many of the tests include errors. I think I'd prefer to see these as UI tests, so that we can see the error output, though those often work best if we break them up into small files, each of which should either pass or produce one error (at least until the extensions are added to allow //~ ERROR in ui tests).


Within a function.

fn foo(x: &'a u32, y: &u32) -> &'a u32 { x }