@@ -46,7 +46,7 @@ impl<'a> Sugg<'a> {
46
46
pub fn hir_opt ( cx : & LateContext < ' _ , ' _ > , expr : & hir:: Expr ) -> Option < Self > {
47
47
snippet_opt ( cx, expr. span ) . map ( |snippet| {
48
48
let snippet = Cow :: Owned ( snippet) ;
49
- Self :: hir_from_snippet ( expr, snippet)
49
+ Self :: hir_from_snippet ( cx , expr, snippet)
50
50
} )
51
51
}
52
52
@@ -84,12 +84,20 @@ impl<'a> Sugg<'a> {
84
84
pub fn hir_with_macro_callsite ( cx : & LateContext < ' _ , ' _ > , expr : & hir:: Expr , default : & ' a str ) -> Self {
85
85
let snippet = snippet_with_macro_callsite ( cx, expr. span , default) ;
86
86
87
- Self :: hir_from_snippet ( expr, snippet)
87
+ Self :: hir_from_snippet ( cx , expr, snippet)
88
88
}
89
89
90
90
/// Generate a suggestion for an expression with the given snippet. This is used by the `hir_*`
91
91
/// function variants of `Sugg`, since these use different snippet functions.
92
- fn hir_from_snippet ( expr : & hir:: Expr , snippet : Cow < ' a , str > ) -> Self {
92
+ fn hir_from_snippet ( cx : & LateContext < ' _ , ' _ > , expr : & hir:: Expr , snippet : Cow < ' a , str > ) -> Self {
93
+ if let Some ( range) = higher:: range ( cx, expr) {
94
+ let op = match range. limits {
95
+ ast:: RangeLimits :: HalfOpen => AssocOp :: DotDot ,
96
+ ast:: RangeLimits :: Closed => AssocOp :: DotDotEq ,
97
+ } ;
98
+ return Sugg :: BinOp ( op, snippet) ;
99
+ }
100
+
93
101
match expr. kind {
94
102
hir:: ExprKind :: AddrOf ( ..)
95
103
| hir:: ExprKind :: Box ( ..)
0 commit comments