From 5236af8c0ff33d60e30fdde367b476a1efa1d09e Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 14 May 2014 15:24:10 +0200 Subject: [PATCH] Added tests checking that changes in type sig are recognized in SVH. (Only after adding the tests did I realize that this is not really a special case at the AST level; as far as the visitor is concerned, `int` and `i32` and `i64` are just idents.) --- src/test/auxiliary/svh-a-change-type-arg.rs | 37 +++++++++++++++++++ src/test/auxiliary/svh-a-change-type-ret.rs | 37 +++++++++++++++++++ .../auxiliary/svh-a-change-type-static.rs | 37 +++++++++++++++++++ src/test/compile-fail/svh-change-type-arg.rs | 24 ++++++++++++ src/test/compile-fail/svh-change-type-ret.rs | 24 ++++++++++++ .../compile-fail/svh-change-type-static.rs | 24 ++++++++++++ 6 files changed, 183 insertions(+) create mode 100644 src/test/auxiliary/svh-a-change-type-arg.rs create mode 100644 src/test/auxiliary/svh-a-change-type-ret.rs create mode 100644 src/test/auxiliary/svh-a-change-type-static.rs create mode 100644 src/test/compile-fail/svh-change-type-arg.rs create mode 100644 src/test/compile-fail/svh-change-type-ret.rs create mode 100644 src/test/compile-fail/svh-change-type-static.rs diff --git a/src/test/auxiliary/svh-a-change-type-arg.rs b/src/test/auxiliary/svh-a-change-type-arg.rs new file mode 100644 index 000000000000..33f2bf862eda --- /dev/null +++ b/src/test/auxiliary/svh-a-change-type-arg.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : int = 2; + +pub fn foo(_: i32) -> int { + 3 +} + +pub fn an_unused_name() -> int { + 4 +} diff --git a/src/test/auxiliary/svh-a-change-type-ret.rs b/src/test/auxiliary/svh-a-change-type-ret.rs new file mode 100644 index 000000000000..3eea77fdb95c --- /dev/null +++ b/src/test/auxiliary/svh-a-change-type-ret.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : int = 2; + +pub fn foo(_: int) -> i64 { + 3 +} + +pub fn an_unused_name() -> i32 { + 4 +} diff --git a/src/test/auxiliary/svh-a-change-type-static.rs b/src/test/auxiliary/svh-a-change-type-static.rs new file mode 100644 index 000000000000..ff8b8d6db4cf --- /dev/null +++ b/src/test/auxiliary/svh-a-change-type-static.rs @@ -0,0 +1,37 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! The `svh-a-*.rs` files are all deviations from the base file +//! svh-a-base.rs with some difference (usually in `fn foo`) that +//! should not affect the strict version hash (SVH) computation +//! (#14132). + +#![feature(macro_rules)] + +#![crate_id = "a"] + +macro_rules! three { + () => { 3 } +} + +pub trait U {} +pub trait V {} +impl U for () {} +impl V for () {} + +static A_CONSTANT : i32 = 2; + +pub fn foo(_: int) -> int { + 3 +} + +pub fn an_unused_name() -> int { + 4 +} diff --git a/src/test/compile-fail/svh-change-type-arg.rs b/src/test/compile-fail/svh-change-type-arg.rs new file mode 100644 index 000000000000..77b0a9211caf --- /dev/null +++ b/src/test/compile-fail/svh-change-type-arg.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note that these aux-build directives must be in this order +// aux-build:svh-a-base.rs +// aux-build:svh-b.rs +// aux-build:svh-a-change-type-arg.rs + +#![feature(macro_rules)] + +extern crate a; +extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on +//~^ NOTE: perhaps this crate needs to be recompiled + +fn main() { + b::foo() +} diff --git a/src/test/compile-fail/svh-change-type-ret.rs b/src/test/compile-fail/svh-change-type-ret.rs new file mode 100644 index 000000000000..13dcfa3b5da5 --- /dev/null +++ b/src/test/compile-fail/svh-change-type-ret.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note that these aux-build directives must be in this order +// aux-build:svh-a-base.rs +// aux-build:svh-b.rs +// aux-build:svh-a-change-type-ret.rs + +#![feature(macro_rules)] + +extern crate a; +extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on +//~^ NOTE: perhaps this crate needs to be recompiled + +fn main() { + b::foo() +} diff --git a/src/test/compile-fail/svh-change-type-static.rs b/src/test/compile-fail/svh-change-type-static.rs new file mode 100644 index 000000000000..7d26bdd15fb2 --- /dev/null +++ b/src/test/compile-fail/svh-change-type-static.rs @@ -0,0 +1,24 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// note that these aux-build directives must be in this order +// aux-build:svh-a-base.rs +// aux-build:svh-b.rs +// aux-build:svh-a-change-type-static.rs + +#![feature(macro_rules)] + +extern crate a; +extern crate b; //~ ERROR: found possibly newer version of crate `a` which `b` depends on +//~^ NOTE: perhaps this crate needs to be recompiled + +fn main() { + b::foo() +}