Issue 1:
Just playing with higher-order functions and structs with function fields.

I tried this code:

// the main function
fn main() {

let funcs = Funcs {
a: Box::new( |x| { 1 + x } ),
b: Box::new( |x| { x * 2 } )
};

let composed = compose(&funcs.a, &funcs.b);

let r1: i32 = composed(3);
let r2: i32 = composed(10);

println!("r1 is {}", r1);
println!("r2 is {}", r2);

}

// a higher order function
fn compose<'a, T, F: 'a, G: 'a>(f: &'a F, g: &'a G) -> Box<Fn(T) -> T + 'a>
where
F: Fn(T) -> T,
G: Fn(T) -> T {

Box::new(move |x| { f(g(x)) })
}

struct Funcs {
a: Box<Fn(i32) -> i32>,
b: Box<Fn(i32) -> i32>,
}

I expected to see this happen:

Compiling rust_hello v0.0.1 (file:///home/mike/source/rust_hello)
Running `target/debug/rust_hello`
r1 is 7
r2 is 21

Instead, this happened:

Compiling rust_hello v0.0.1 (file:///home/mike/source/rust_hello)
src/main.rs:10:20: 10:47 error: internal compiler error: cat_expr Errd
src/main.rs:10 let composed = compose(&funcs.a, &funcs.b);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:130

Meta

rustc --version --verbose
rustc 1.0.0-nightly (30e1f9a1c 2015-03-14) (built 2015-03-15)
binary: rustc
commit-hash: 30e1f9a1c2bf7134135800bc9afd082773defadc
commit-date: 2015-03-14
build-date: 2015-03-15
host: x86_64-unknown-linux-gnu
release: 1.0.0-nightly

Backtrace:

RUST_BACKTRACE=1 rustc src/main.rs
src/main.rs:10:20: 10:47 error: internal compiler error: cat_expr Errd
src/main.rs:10 let composed = compose(&funcs.a, &funcs.b);
^~~~~~~~~~~~~~~~~~~~~~~~~~~
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /home/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-linux/build/src/libsyntax/diagnostic.rs:130

stack backtrace:
1: 0x7fb896007fd4 - sys::backtrace::write::hc598c94e8fe3368fYyC
2: 0x7fb89602dd98 - panicking::on_panic::he6f0d5fd56790ce4OGI
3: 0x7fb895f64faa - rt::unwind::begin_unwind_inner::h0de67d11bf40bff3mnI
4: 0x7fb8933e140d - rt::unwind::begin_unwind::h1003680148821460282
5: 0x7fb8933e13b3 - diagnostic::SpanHandler::span_bug::h1c5c4bceba1974e2FaB
6: 0x7fb893c98523 - session::Session::span_bug::h04e509cfca0af677Qvn
7: 0x7fb894cc60e1 - check::regionck::visit_expr::h6d73f9ea96a73481dCd
8: 0x7fb894cc69fa - check::regionck::visit_local::h94f330bbd6249aa8izd
9: 0x7fb894cc18a5 - check::regionck::Rcx<'a, 'tcx>::visit_fn_body::h91c2ca9bef55fb39qed
10: 0x7fb894d4c566 - check::check_bare_fn::ha0fa7770160c8d54b8m
11: 0x7fb894d44681 - check::check_item::h289f0c28a59d81b7Pqn
12: 0x7fb894e18a03 - check_crate::closure.35785
13: 0x7fb894e1373a - check_crate::h77f9ea673c087f80O3B
14: 0x7fb89662fbf8 - driver::phase_3_run_analysis_passes::h716709d467e74aabqGa
15: 0x7fb896616f59 - driver::compile_input::h56dbe0e66fe8a956Rba
16: 0x7fb8966cea42 - run_compiler::hbbbe30f1ad654d0ex2b
17: 0x7fb8966cc88c - thunk::F.Invoke<A, R>::invoke::h9510793753674638958
18: 0x7fb8966cb910 - rt::unwind::try::try_fn::h15118916039308917284
19: 0x7fb89609ef58 - rust_try_inner
20: 0x7fb89609ef45 - rust_try
21: 0x7fb8966cbdb6 - thunk::F.Invoke<A, R>::invoke::h8595907971712275588
22: 0x7fb89601c995 - sys::thread::thread_start::h9f0c06661d546448B1G
23: 0x7fb88fec2181 - start_thread
24: 0x7fb895bd647c - __clone
25: 0x0 - <unknown>

Issue 2:
Hello folks,

I'm dutifully reporting this as the compiler told me to so. The bug is the same reported already by #24504 and #22897, although it appeared on a different circumstance. I have this simple program (I'm a Rust newbie so It's very likely I'm doing things terribly wrong):

use std::io::*;

const initial_height: u32 = 1;

fn summer_growth(h: u32) -> u32 {
h + 1
}

fn spring_growth(h: u32) -> u32 {
h * 2
}

fn utopian_tree(cycles: u32) -> u32 {
(0..cycles).fold(|acc, x| grow(acc,x), initial_height);
}

fn grow(acc: u32, cycle: u32) -> u32 {
match cycle % 2 == 0 {
true => spring_growth(acc),
false => summer_growth(acc)
}
}

fn main () {
let mut buf = String::new();
stdin().read_line(&mut buf).unwrap();
let test_cases: u32 = buf.trim().parse().unwrap();
for _ in 0..test_cases {
stdin().read_line(&mut buf).unwrap();
let cycle: u32 = buf.trim().parse().unwrap();
println!("{}", utopian_tree(cycle));
}
}

Expected outcome:

The compile to tell me how wrong I am

Actual outcome:

☁ algorithms rustc utopian_tree.rs -o utopian_tree
utopian_tree.rs:14:5: 14:59 error: internal compiler error: cat_expr Errd
utopian_tree.rs:14 (0..cycles).fold(|acc, x| grow(acc,x), initial_height);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/m
aster/CONTRIBUTING.md#bug-reports
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/
beta-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:149

Meta

☁ algorithms rustc --version --verbose
rustc 1.0.0-beta.2 (e9080ec39 2015-04-16) (built 2015-04-16)
binary: rustc
commit-hash: e9080ec39d9a44eb0773d648b348575b19f655e5
commit-date: 2015-04-16
build-date: 2015-04-16
host: x86_64-apple-darwin
release: 1.0.0-beta.2
☁ algorithms

Shows up with latest beta as well:

☁ algorithms rustc utopian_tree.rs -o utopian_tree
utopian_tree.rs:14:5: 14:59 error: internal compiler error: cat_expr Errd
utopian_tree.rs:14 (0..cycles).fold(|acc, x| grow(acc,x), initial_height);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/beta-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:149

☁ algorithms rustc --verbose --version
rustc 1.0.0-beta.4 (850151a75 2015-04-30) (built 2015-04-30)
binary: rustc
commit-hash: 850151a75709f146addd30bbbf1f23d384f0b381
commit-date: 2015-04-30
build-date: 2015-04-30
host: x86_64-apple-darwin
release: 1.0.0-beta.4
☁ algorithms