Skip to content

Commit bd4fe45

Browse files
committed
External spans: Added a test for #38875.
A bug has been discovered and fixed in the process.
1 parent d11973a commit bd4fe45

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

src/librustc_metadata/decoder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ impl<'a, 'tcx> CrateMetadata {
765765
assert!(!self.is_proc_macro(id));
766766
let ast = self.entry(id).ast.unwrap();
767767
let def_id = self.local_def_id(id);
768-
let body = ast.decode(self).body.decode(self);
768+
let body = ast.decode((self, tcx)).body.decode((self, tcx));
769769
tcx.hir.intern_inlined_body(def_id, body)
770770
}
771771

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub const FOO: usize = *&0;
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:issue_38875_b.rs
12+
13+
extern crate issue_38875_b;
14+
15+
fn main() {
16+
let test_x = [0; issue_38875_b::FOO];
17+
}
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0080]: constant evaluation error
2+
--> $DIR/auxiliary/issue_38875_b.rs:11:24
3+
|
4+
11 | pub const FOO: usize = *&0;
5+
| ^^^ unimplemented constant expression: deref operation
6+
|
7+
note: for repeat count here
8+
--> $DIR/issue_38875.rs:16:22
9+
|
10+
16 | let test_x = [0; issue_38875_b::FOO];
11+
| ^^^^^^^^^^^^^^^^^^
12+
13+
error: aborting due to previous error(s)
14+

0 commit comments

Comments
 (0)