-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpaths.rs
145 lines (123 loc) · 3.79 KB
/
paths.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#![allow(warnings)]
// Testing uniform paths in 2018.
// I expect to see consistency between imports and expressions
// in all locations.
mod a {
pub struct A1;
pub struct A2;
pub struct A3;
pub struct A4;
}
use a::A1; // "a" is in scope
#[cfg(feature = "rust-2015")]
use ::a::A2; // :: is only for crates in 2018
use self::a::A3;
use crate::a::A4;
fn f1() {
let _ = a::A1;
#[cfg(feature = "rust-2015")]
let _ = ::a::A2;
let _ = self::a::A3;
let _ = crate::a::A4;
}
extern crate pandoc_types;
use pandoc_types::definition::Alignment;
use ::pandoc_types::definition::Block;
use self::pandoc_types::definition::Inline;
use crate::pandoc_types::definition::MathType;
fn f2() {
let _ = pandoc_types::definition::Alignment::AlignLeft;
let _ = ::pandoc_types::definition::Block::Null;
let _ = self::pandoc_types::definition::Inline::Space;
let _ = crate::pandoc_types::definition::MathType::DisplayMath;
}
struct B1;
struct B2;
struct B3;
struct B4;
struct B5;
mod c {
#[cfg(feature = "rust-2015")]
use B1; // root in 2015, out of scope in 2018
#[cfg(feature = "rust-2015")]
use ::B2; // root in 2015, not a crate in 2018
use self::super::B3;
use super::B4;
use crate::B5;
fn f1() {
#[cfg(feature = "rust-2015")]
let _ = B1;
#[cfg(feature = "rust-2015")]
let _ = ::B2;
let _ = self::super::B3;
let _ = super::B4;
let _ = crate::B5;
}
pub mod d {
pub struct D1;
pub struct D2;
pub struct D3;
pub struct D4;
pub struct D5;
}
#[cfg(feature = "rust-2015")]
use c::d::D1;
#[cfg(feature = "rust-2015")]
use ::c::d::D2;
use self::d::D3;
use super::c::d::D4;
use crate::c::d::D5;
fn f2() {
// works in neither edition
// inconsistent with 'use' in 2015, consistent in 2018
// let _ = c::d::D1;
#[cfg(feature = "rust-2015")]
let _ = ::c::d::D2;
let _ = self::d::D3;
let _ = super::c::d::D4;
let _ = crate::c::d::D5;
}
use pandoc_types::definition::Alignment;
use ::pandoc_types::definition::Block;
use self::super::pandoc_types::definition::Inline;
use super::pandoc_types::definition::QuoteType;
use crate::pandoc_types::definition::MathType;
fn f3() {
let _ = pandoc_types::definition::Alignment::AlignLeft;
let _ = ::pandoc_types::definition::Block::Null;
let _ = self::super::pandoc_types::definition::Inline::Space;
let _ = super::pandoc_types::definition::QuoteType::SingleQuote;
let _ = crate::pandoc_types::definition::MathType::DisplayMath;
}
}
use c::d;
use d::D1; // "d" is in scope
// This just shows that resolution isn't in lexical (?) order
use f::F1;
use e::f;
mod e { pub mod f { pub struct F1; } }
// resolution of name conflicts
mod g {
mod pandoc_types { pub mod definition {
pub enum Alignment { AlignLeft, Blah }
pub enum MyAlignment1 { AlignLeft, Blah }
pub enum MyAlignment2 { AlignLeft, Blah }
} }
// root takes precedence in 2015;
// ambiguous in 2018
#[cfg(feature = "rust-2015")]
use pandoc_types::definition::Alignment;
// failed crate-root resolution in 2015, ambiguous in 2018
//use pandoc_types::definition::MyAlignment1;
use self::pandoc_types::definition::MyAlignment2;
fn f1() {
// _local scope_ takes precedence, 2015 & 2018
// inconsistent with 'use' in 2018
// https://github.com/rust-lang/rust/issues/57853
let _ = pandoc_types::definition::Alignment::Blah;
// local scope again, 2015 & 2018, inconsistent
let _ = pandoc_types::definition::MyAlignment1::AlignLeft;
let _ = self::pandoc_types::definition::MyAlignment2::AlignLeft;
}
}
fn main() { }