2016-01-06 10:29:00 -06:00
|
|
|
// Test cases where a changing struct appears in the signature of fns
|
|
|
|
// and methods.
|
|
|
|
|
2021-09-19 11:57:19 -05:00
|
|
|
// incremental
|
|
|
|
// compile-flags: -Z query-dep-graph
|
2015-12-22 16:17:27 -06:00
|
|
|
|
|
|
|
#![feature(rustc_attrs)]
|
|
|
|
#![allow(dead_code)]
|
|
|
|
#![allow(unused_variables)]
|
|
|
|
|
|
|
|
fn main() { }
|
|
|
|
|
|
|
|
#[rustc_if_this_changed]
|
|
|
|
struct WillChange {
|
|
|
|
x: u32,
|
|
|
|
y: u32
|
|
|
|
}
|
|
|
|
|
|
|
|
struct WontChange {
|
|
|
|
x: u32,
|
|
|
|
y: u32
|
|
|
|
}
|
|
|
|
|
|
|
|
// these are valid dependencies
|
|
|
|
mod signatures {
|
|
|
|
use WillChange;
|
|
|
|
|
2019-03-17 01:00:46 -05:00
|
|
|
#[rustc_then_this_would_need(type_of)] //~ ERROR no path
|
2019-03-29 11:05:40 -05:00
|
|
|
#[rustc_then_this_would_need(associated_item)] //~ ERROR no path
|
|
|
|
#[rustc_then_this_would_need(trait_def)] //~ ERROR no path
|
2015-12-22 16:17:27 -06:00
|
|
|
trait Bar {
|
2019-03-29 11:05:40 -05:00
|
|
|
#[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
|
2015-12-22 16:17:27 -06:00
|
|
|
fn do_something(x: WillChange);
|
|
|
|
}
|
|
|
|
|
2019-03-29 11:05:40 -05:00
|
|
|
#[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
|
2020-07-17 03:47:04 -05:00
|
|
|
#[rustc_then_this_would_need(typeck)] //~ ERROR OK
|
2015-12-22 16:17:27 -06:00
|
|
|
fn some_fn(x: WillChange) { }
|
|
|
|
|
2019-03-29 11:05:40 -05:00
|
|
|
#[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
|
2020-07-17 03:47:04 -05:00
|
|
|
#[rustc_then_this_would_need(typeck)] //~ ERROR OK
|
2015-12-22 16:17:27 -06:00
|
|
|
fn new_foo(x: u32, y: u32) -> WillChange {
|
|
|
|
WillChange { x: x, y: y }
|
|
|
|
}
|
|
|
|
|
2019-03-17 01:00:46 -05:00
|
|
|
#[rustc_then_this_would_need(type_of)] //~ ERROR OK
|
2015-12-22 16:17:27 -06:00
|
|
|
impl WillChange {
|
2019-03-29 11:05:40 -05:00
|
|
|
#[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
|
2020-07-17 03:47:04 -05:00
|
|
|
#[rustc_then_this_would_need(typeck)] //~ ERROR OK
|
2015-12-22 16:17:27 -06:00
|
|
|
fn new(x: u32, y: u32) -> WillChange { loop { } }
|
|
|
|
}
|
|
|
|
|
2019-03-17 01:00:46 -05:00
|
|
|
#[rustc_then_this_would_need(type_of)] //~ ERROR OK
|
2015-12-22 16:17:27 -06:00
|
|
|
impl WillChange {
|
2019-03-29 11:05:40 -05:00
|
|
|
#[rustc_then_this_would_need(fn_sig)] //~ ERROR OK
|
2020-07-17 03:47:04 -05:00
|
|
|
#[rustc_then_this_would_need(typeck)] //~ ERROR OK
|
2015-12-22 16:17:27 -06:00
|
|
|
fn method(&self, x: u32) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
struct WillChanges {
|
2019-03-17 01:00:46 -05:00
|
|
|
#[rustc_then_this_would_need(type_of)] //~ ERROR OK
|
2015-12-22 16:17:27 -06:00
|
|
|
x: WillChange,
|
2019-03-17 01:00:46 -05:00
|
|
|
#[rustc_then_this_would_need(type_of)] //~ ERROR OK
|
2015-12-22 16:17:27 -06:00
|
|
|
y: WillChange
|
|
|
|
}
|
|
|
|
|
2017-05-02 16:47:38 -05:00
|
|
|
// The fields change, not the type itself.
|
2019-03-17 01:00:46 -05:00
|
|
|
#[rustc_then_this_would_need(type_of)] //~ ERROR no path
|
2016-01-06 10:29:00 -06:00
|
|
|
fn indirect(x: WillChanges) { }
|
2015-12-22 16:17:27 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
mod invalid_signatures {
|
|
|
|
use WontChange;
|
|
|
|
|
2019-03-17 01:00:46 -05:00
|
|
|
#[rustc_then_this_would_need(type_of)] //~ ERROR no path
|
2015-12-22 16:17:27 -06:00
|
|
|
trait A {
|
2019-03-29 11:05:40 -05:00
|
|
|
#[rustc_then_this_would_need(fn_sig)] //~ ERROR no path
|
2015-12-22 16:17:27 -06:00
|
|
|
fn do_something_else_twice(x: WontChange);
|
|
|
|
}
|
|
|
|
|
2019-03-29 11:05:40 -05:00
|
|
|
#[rustc_then_this_would_need(fn_sig)] //~ ERROR no path
|
2015-12-22 16:17:27 -06:00
|
|
|
fn b(x: WontChange) { }
|
|
|
|
|
2019-03-29 11:05:40 -05:00
|
|
|
#[rustc_then_this_would_need(fn_sig)] //~ ERROR no path from `WillChange`
|
2020-07-17 03:47:04 -05:00
|
|
|
#[rustc_then_this_would_need(typeck)] //~ ERROR no path from `WillChange`
|
2015-12-22 16:17:27 -06:00
|
|
|
fn c(x: u32) { }
|
|
|
|
}
|