File tree Expand file tree Collapse file tree 3 files changed +67
-0
lines changed
Expand file tree Collapse file tree 3 files changed +67
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright 2015 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+ #![ crate_type = "rlib" ]
12+ // no-prefer-dynamic
13+
14+ // compile-flags: -g
15+
16+ #[ macro_use]
17+ mod crate_with_invalid_spans_macros;
18+
19+ pub fn exported_generic < T > ( x : T , y : u32 ) -> ( T , u32 ) {
20+ // Using the add1 macro will produce an invalid span, because the `y` passed
21+ // to the macro will have a span from this file, but the rest of the code
22+ // generated from the macro will have spans from the macro-defining file.
23+ // The AST node for the (1 + y) expression generated by the macro will then
24+ // take it's `lo` span bound from the `1` literal in the macro-defining file
25+ // and it's `hi` bound from `y` in this file, which should be lower than the
26+ // `lo` and even lower than the lower bound of the FileMap it is supposedly
27+ // contained in because the FileMap for this file was allocated earlier than
28+ // the FileMap of the macro-defining file.
29+ return ( x, add1 ! ( y) ) ;
30+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2015 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+ macro_rules! add1 {
12+ ( $e: expr) => ( {
13+ let a = 1 + $e;
14+ let b = $e + 1 ;
15+ a + b - 1
16+ } )
17+ }
Original file line number Diff line number Diff line change 1+ // Copyright 2015 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:crate_with_invalid_spans.rs
12+
13+ extern crate crate_with_invalid_spans;
14+
15+ fn main ( ) {
16+ // The AST of `exported_generic` stored in crate_with_invalid_spans's
17+ // metadata should contain an invalid span where span.lo > span.hi.
18+ // Let's make sure the compiler doesn't crash when encountering this.
19+ let _ = crate_with_invalid_spans:: exported_generic ( 32u32 , 7u32 ) ;
20+ }
You can’t perform that action at this time.
0 commit comments