Skip to content

Commit 9709dba

Browse files
authored
Rollup merge of rust-lang#37919 - nikomatsakis:incremental-36168, r=mw
add regression test for rust-lang#36168 Fixes rust-lang#36168 r? @michaelwoerister
2 parents 8de607c + 72fbf9f commit 9709dba

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2014 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 struct Point {
12+
pub x: f32,
13+
pub y: f32,
14+
}
15+
16+
#[cfg(rpass2)]
17+
fn unused_helper() {
18+
}
19+
20+
pub fn distance_squared(this: &Point) -> f32 {
21+
return this.x * this.x + this.y * this.y;
22+
}
23+
24+
impl Point {
25+
pub fn distance_from_origin(&self) -> f32 {
26+
distance_squared(self).sqrt()
27+
}
28+
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Copyright 2014 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+
// Test where we add a private item into the root of an external.
12+
// crate. This should not cause anything we use to be invalidated.
13+
// Regression test for #36168.
14+
15+
// revisions:rpass1 rpass2
16+
// compile-flags: -Z query-dep-graph
17+
// aux-build:point.rs
18+
19+
#![feature(rustc_attrs)]
20+
#![feature(stmt_expr_attributes)]
21+
#![allow(dead_code)]
22+
23+
#![rustc_partition_reused(module="struct_point-fn_calls_methods_in_same_impl", cfg="rpass2")]
24+
#![rustc_partition_reused(module="struct_point-fn_calls_free_fn", cfg="rpass2")]
25+
#![rustc_partition_reused(module="struct_point-fn_read_field", cfg="rpass2")]
26+
#![rustc_partition_reused(module="struct_point-fn_write_field", cfg="rpass2")]
27+
#![rustc_partition_reused(module="struct_point-fn_make_struct", cfg="rpass2")]
28+
29+
extern crate point;
30+
31+
/// A fn item that calls (public) methods on `Point` from the same impl
32+
mod fn_calls_methods_in_same_impl {
33+
use point::Point;
34+
35+
#[rustc_clean(label="TypeckItemBody", cfg="rpass2")]
36+
pub fn check() {
37+
let x = Point { x: 2.0, y: 2.0 };
38+
x.distance_from_origin();
39+
}
40+
}
41+
42+
/// A fn item that calls (public) methods on `Point` from another impl
43+
mod fn_calls_free_fn {
44+
use point::{self, Point};
45+
46+
#[rustc_clean(label="TypeckItemBody", cfg="rpass2")]
47+
pub fn check() {
48+
let x = Point { x: 2.0, y: 2.0 };
49+
point::distance_squared(&x);
50+
}
51+
}
52+
53+
/// A fn item that makes an instance of `Point` but does not invoke methods
54+
mod fn_make_struct {
55+
use point::Point;
56+
57+
#[rustc_clean(label="TypeckItemBody", cfg="rpass2")]
58+
pub fn make_origin() -> Point {
59+
Point { x: 2.0, y: 2.0 }
60+
}
61+
}
62+
63+
/// A fn item that reads fields from `Point` but does not invoke methods
64+
mod fn_read_field {
65+
use point::Point;
66+
67+
#[rustc_clean(label="TypeckItemBody", cfg="rpass2")]
68+
pub fn get_x(p: Point) -> f32 {
69+
p.x
70+
}
71+
}
72+
73+
/// A fn item that writes to a field of `Point` but does not invoke methods
74+
mod fn_write_field {
75+
use point::Point;
76+
77+
#[rustc_clean(label="TypeckItemBody", cfg="rpass2")]
78+
pub fn inc_x(p: &mut Point) {
79+
p.x += 1.0;
80+
}
81+
}
82+
83+
fn main() {
84+
}

0 commit comments

Comments
 (0)