Change:
// can't have destructors. let scopes = mem::replace(&mut *bcx.fcx.scopes.borrow_mut(), vec![]); <del> bcx = trans_into(bcx, expr, dest); </del> <ins> // Lock emitted debug locations to the location of // the constant reference expression. debuginfo::with_source_location_override(bcx.fcx, expr.debug_loc(), || { bcx = trans_into(bcx, const_expr, dest) }); </ins> let scopes = mem::replace(&mut *bcx.fcx.scopes.borrow_mut(), scopes); assert!(scopes.is_empty());

Discussion:
Rust version: OS: Gentoo Linux AMD64
cc
The same thing happens with openssl-sys 0.4.1:
For anyone running into this, you can disable debug info to work around the issue until it's fixed:
Same problem here. Rust version: rustc 1.0.0-nightly ( 2015-02-17) (built 2015-02-18) Operating System: OS X Yosemite 10.10.2
It looks like I have the same problem: Compiling mio v0.2.1 () Running 1:1 error: internal compiler error: debuginfo: Could not find scope info for node NodeExpr(Expr { id: 5326, node: ExprStruct(Path { span: Span { lo: BytePos(0), hi: BytePos(0), expnid: ExpnId() }, global: false, segments: [PathSegment { identifier: StaticMutex, parameters: AngleBracketedParameters(AngleBracketedParameterData { lifetimes: [], types: [], bindings: [] }) }] }, [Field { ident: Spanned { node: lock, span: Span { lo: BytePos(0), hi: BytePos(0), expnid: ExpnId() } }, expr: Expr { id: 5327, node: ExprPath(Path { span: Span { lo: BytePos(0), hi: BytePos(0), expnid: ExpnId() }, global: false, segments: [PathSegment { identifier: sys, parameters: AngleBracketedParameters(AngleBracketedParameterData { lifetimes: [], types: [], bindings: [] }) }, PathSegment { identifier: MUTEXINIT, parameters: AngleBracketedParameters(AngleBracketedParameterData { lifetimes: [], types: [], bindings: [] }) }] }), span: Span { lo: BytePos(0), hi: BytePos(0), expnid: ExpnId() } }, span: Span { lo: BytePos(0), hi: BytePos(0), expnid: ExpnId() } }, Field { ident: Spanned { node: poison, span: Span { lo: BytePos(0), hi: BytePos(0), expnid: ExpnId() } }, expr: Expr { id: 5328, node: ExprPath(Path { span: Span { lo: BytePos(0),

hi: BytePos(0), expnid: ExpnId() }, global: false, segments: [PathSegment { identifier: poison, parameters: AngleBracketedParameters(AngleBracketedParameterData { lifetimes: [], types: [], bindings: [] }) }, PathSegment { identifier: FLAGINIT, parameters: AngleBracketedParameters(AngleBracketedParameterData { lifetimes: [], types: [], bindings: [] }) }] }), span: Span { lo: BytePos(0), hi: BytePos(0), expnid: ExpnId() } }, span: Span { lo: BytePos(0), hi: BytePos(0), expnid: ExpnId() } }], None), span: Span { lo: BytePos(0), hi: BytePos(0), expnid: ExpnId() } }) #![allow(noncamelcasetypes, nonuppercaseglobals, nonsnakecase)] ^ Rust version: rustc 1.0.0-nightly ( 2015-02-17) (built 2015-02-18) OS: 3.13.0-24-generic -Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x8664 x8664 x86_64 GNU/Linux
A minimized version:
Minimized a bit further actually, perhaps you could publish a version which uses instead of on the vector of ?
Er, nevermind, I have against rust-openssl to temporarily fix this.
I encountered a similar problem with constants in match patterns. This very probably has the same root cause, which is that the AST of constants gets substituted for the constant-reference during trans, but then we suddenly have a bunch of unrelated AST node ids in there. I'll try to fix this this week.
My minimal case: