@@ -46,7 +46,7 @@ impl<'a> Sugg<'a> {
4646 pub fn hir_opt ( cx : & LateContext < ' _ , ' _ > , expr : & hir:: Expr ) -> Option < Self > {
4747 snippet_opt ( cx, expr. span ) . map ( |snippet| {
4848 let snippet = Cow :: Owned ( snippet) ;
49- Self :: hir_from_snippet ( expr, snippet)
49+ Self :: hir_from_snippet ( cx , expr, snippet)
5050 } )
5151 }
5252
@@ -84,12 +84,20 @@ impl<'a> Sugg<'a> {
8484 pub fn hir_with_macro_callsite ( cx : & LateContext < ' _ , ' _ > , expr : & hir:: Expr , default : & ' a str ) -> Self {
8585 let snippet = snippet_with_macro_callsite ( cx, expr. span , default) ;
8686
87- Self :: hir_from_snippet ( expr, snippet)
87+ Self :: hir_from_snippet ( cx , expr, snippet)
8888 }
8989
9090 /// Generate a suggestion for an expression with the given snippet. This is used by the `hir_*`
9191 /// 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+
93101 match expr. kind {
94102 hir:: ExprKind :: AddrOf ( ..)
95103 | hir:: ExprKind :: Box ( ..)
0 commit comments