@@ -104,6 +104,7 @@ pub(super) fn hints(
104
104
};
105
105
let iter: &mut dyn Iterator<Item = _> = iter.as_mut().either(|it| it as _, |it| it as _);
106
106
107
+ let mut allow_edit = !postfix;
107
108
for Adjustment { source, target, kind } in iter {
108
109
if source == target {
109
110
cov_mark::hit!(same_type_adjustment);
@@ -113,6 +114,7 @@ pub(super) fn hints(
113
114
// FIXME: Add some nicer tooltips to each of these
114
115
let (text, coercion) = match kind {
115
116
Adjust::NeverToAny if config.adjustment_hints == AdjustmentHints::Always => {
117
+ allow_edit = false;
116
118
("<never-to-any>", "never to any")
117
119
}
118
120
Adjust::Deref(None) => ("*", "dereference"),
@@ -133,6 +135,7 @@ pub(super) fn hints(
133
135
// some of these could be represented via `as` casts, but that's not too nice and
134
136
// handling everything as a prefix expr makes the `(` and `)` insertion easier
135
137
Adjust::Pointer(cast) if config.adjustment_hints == AdjustmentHints::Always => {
138
+ allow_edit = false;
136
139
match cast {
137
140
PointerCast::ReifyFnPointer => {
138
141
("<fn-item-to-fn-pointer>", "fn item to fn pointer")
@@ -179,30 +182,32 @@ pub(super) fn hints(
179
182
if pre.is_none() && post.is_none() {
180
183
return None;
181
184
}
182
- let edit = {
183
- let mut b = TextEditBuilder::default();
184
- if let Some(pre) = &pre {
185
- b.insert(
186
- pre.range.start(),
187
- pre.label.parts.iter().map(|part| &*part.text).collect::<String>(),
188
- );
189
- }
190
- if let Some(post) = &post {
191
- b.insert(
192
- post.range.end(),
193
- post.label.parts.iter().map(|part| &*part.text).collect::<String>(),
194
- );
195
- }
196
- b.finish()
197
- };
198
- match (&mut pre, &mut post) {
199
- (Some(pre), Some(post)) => {
200
- pre.text_edit = Some(edit.clone());
201
- post.text_edit = Some(edit);
185
+ if allow_edit {
186
+ let edit = {
187
+ let mut b = TextEditBuilder::default();
188
+ if let Some(pre) = &pre {
189
+ b.insert(
190
+ pre.range.start(),
191
+ pre.label.parts.iter().map(|part| &*part.text).collect::<String>(),
192
+ );
193
+ }
194
+ if let Some(post) = &post {
195
+ b.insert(
196
+ post.range.end(),
197
+ post.label.parts.iter().map(|part| &*part.text).collect::<String>(),
198
+ );
199
+ }
200
+ b.finish()
201
+ };
202
+ match (&mut pre, &mut post) {
203
+ (Some(pre), Some(post)) => {
204
+ pre.text_edit = Some(edit.clone());
205
+ post.text_edit = Some(edit);
206
+ }
207
+ (Some(pre), None) => pre.text_edit = Some(edit),
208
+ (None, Some(post)) => post.text_edit = Some(edit),
209
+ (None, None) => (),
202
210
}
203
- (Some(pre), None) => pre.text_edit = Some(edit),
204
- (None, Some(post)) => post.text_edit = Some(edit),
205
- (None, None) => (),
206
211
}
207
212
acc.extend(pre);
208
213
acc.extend(post);
0 commit comments