]> git.lizzy.rs Git - rust.git/blob - src/test/ui/issues/issue-3753.rs
Rollup merge of #100168 - WaffleLapkin:improve_diagnostics_for_missing_type_in_a_cons...
[rust.git] / src / test / ui / issues / issue-3753.rs
1 // run-pass
2 // Issue #3656
3 // Issue Name: pub method preceded by attribute can't be parsed
4 // Abstract: Visibility parsing failed when compiler parsing
5
6 use std::f64;
7
8 #[derive(Copy, Clone)]
9 pub struct Point {
10     x: f64,
11     y: f64
12 }
13
14 #[derive(Copy, Clone)]
15 pub enum Shape {
16     Circle(Point, f64),
17     Rectangle(Point, Point)
18 }
19
20 impl Shape {
21     pub fn area(&self, sh: Shape) -> f64 {
22         match sh {
23             Shape::Circle(_, size) => f64::consts::PI * size * size,
24             Shape::Rectangle(Point {x, y}, Point {x: x2, y: y2}) => (x2 - x) * (y2 - y)
25         }
26     }
27 }
28
29 pub fn main(){
30     let s = Shape::Circle(Point { x: 1.0, y: 2.0 }, 3.0);
31     println!("{}", s.area(s));
32 }