Skip to content

Commit 7d9ec81

Browse files
committed
normalize_erasing_regions -> try_normalize_erasing_regions
1 parent 7e18f4f commit 7d9ec81

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

tests/ui/needless_borrow.fixed

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ fn main() {
139139
let _ = std::any::Any::type_id(&""); // Don't lint. `Any` is only bound
140140
let _ = Box::new(&""); // Don't lint. Type parameter appears in return type
141141
ref_as_ref_path(&""); // Don't lint. Argument type is not a type parameter
142+
refs_only(&()); // Don't lint. `&T` implements trait, but `T` doesn't
142143
multiple_constraints_normalizes_to_different(&[[""]], &[""]); // Don't lint. Projected type appears in arguments
143144
}
144145

@@ -238,6 +239,20 @@ where
238239
{
239240
}
240241

242+
trait RefsOnly {
243+
type Referent;
244+
}
245+
246+
impl<T> RefsOnly for &T {
247+
type Referent = T;
248+
}
249+
250+
fn refs_only<T>(_: T)
251+
where
252+
T: RefsOnly<Referent = ()>,
253+
{
254+
}
255+
241256
fn multiple_constraints_normalizes_to_different<T, U, V>(_: T, _: U)
242257
where
243258
T: IntoIterator<Item = U>,

tests/ui/needless_borrow.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ fn main() {
139139
let _ = std::any::Any::type_id(&""); // Don't lint. `Any` is only bound
140140
let _ = Box::new(&""); // Don't lint. Type parameter appears in return type
141141
ref_as_ref_path(&""); // Don't lint. Argument type is not a type parameter
142+
refs_only(&()); // Don't lint. `&T` implements trait, but `T` doesn't
142143
multiple_constraints_normalizes_to_different(&[[""]], &[""]); // Don't lint. Projected type appears in arguments
143144
}
144145

@@ -238,6 +239,20 @@ where
238239
{
239240
}
240241

242+
trait RefsOnly {
243+
type Referent;
244+
}
245+
246+
impl<T> RefsOnly for &T {
247+
type Referent = T;
248+
}
249+
250+
fn refs_only<T>(_: T)
251+
where
252+
T: RefsOnly<Referent = ()>,
253+
{
254+
}
255+
241256
fn multiple_constraints_normalizes_to_different<T, U, V>(_: T, _: U)
242257
where
243258
T: IntoIterator<Item = U>,

tests/ui/needless_borrow.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,19 @@ LL | let _ = Some("").unwrap_or(&"");
157157
| ^^^ help: change this to: `""`
158158

159159
error: this expression borrows a value the compiler would automatically borrow
160-
--> $DIR/needless_borrow.rs:186:13
160+
--> $DIR/needless_borrow.rs:187:13
161161
|
162162
LL | (&self.f)()
163163
| ^^^^^^^^^ help: change this to: `(self.f)`
164164

165165
error: this expression borrows a value the compiler would automatically borrow
166-
--> $DIR/needless_borrow.rs:195:13
166+
--> $DIR/needless_borrow.rs:196:13
167167
|
168168
LL | (&mut self.f)()
169169
| ^^^^^^^^^^^^^ help: change this to: `(self.f)`
170170

171171
error: the borrowed expression implements the required traits
172-
--> $DIR/needless_borrow.rs:283:55
172+
--> $DIR/needless_borrow.rs:298:55
173173
|
174174
LL | let _ = std::process::Command::new("ls").args(&["-a", "-l"]).status().unwrap();
175175
| ^^^^^^^^^^^^^ help: change this to: `["-a", "-l"]`

0 commit comments

Comments
 (0)