/src/test/run-pass/import-crate-with-invalid-spans/auxiliary/crate_with_invalid_spans.rs

https://gitlab.com/alx741/rust · Rust · 30 lines · 6 code · 4 blank · 20 comment · 0 complexity · 543d4a732d857466cb64ed7244e7ac53 MD5 · raw file

  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. #![crate_type = "rlib"]
  11. // no-prefer-dynamic
  12. // compile-flags: -g
  13. #[macro_use]
  14. mod crate_with_invalid_spans_macros;
  15. pub fn exported_generic<T>(x: T, y: u32) -> (T, u32) {
  16. // Using the add1 macro will produce an invalid span, because the `y` passed
  17. // to the macro will have a span from this file, but the rest of the code
  18. // generated from the macro will have spans from the macro-defining file.
  19. // The AST node for the (1 + y) expression generated by the macro will then
  20. // take it's `lo` span bound from the `1` literal in the macro-defining file
  21. // and it's `hi` bound from `y` in this file, which should be lower than the
  22. // `lo` and even lower than the lower bound of the FileMap it is supposedly
  23. // contained in because the FileMap for this file was allocated earlier than
  24. // the FileMap of the macro-defining file.
  25. return (x, add1!(y));
  26. }