commit
54bc9c27e4
@ -289,8 +289,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
||||
// Trait must have a method named `m_name` and it should not have
|
||||
// type parameters or early-bound regions.
|
||||
let tcx = self.tcx;
|
||||
let method_item =
|
||||
self.associated_item(trait_def_id, m_name, Namespace::Value).unwrap();
|
||||
let method_item = match self.associated_item(trait_def_id, m_name, Namespace::Value) {
|
||||
Some(method_item) => method_item,
|
||||
None => {
|
||||
tcx.sess.delay_span_bug(span,
|
||||
"operator trait does not have corresponding operator method");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
let def_id = method_item.def_id;
|
||||
let generics = tcx.generics_of(def_id);
|
||||
assert_eq!(generics.params.len(), 0);
|
||||
|
17
src/test/ui/issues/issue-31076.rs
Normal file
17
src/test/ui/issues/issue-31076.rs
Normal file
@ -0,0 +1,17 @@
|
||||
#![feature(no_core, lang_items)]
|
||||
#![no_core]
|
||||
|
||||
#[lang="sized"]
|
||||
trait Sized {}
|
||||
|
||||
#[lang="add"]
|
||||
trait Add<T> {}
|
||||
|
||||
impl Add<i32> for i32 {}
|
||||
|
||||
fn main() {
|
||||
let x = 5 + 6;
|
||||
//~^ ERROR binary operation `+` cannot be applied to type `{integer}`
|
||||
let y = 5i32 + 6i32;
|
||||
//~^ ERROR binary operation `+` cannot be applied to type `i32`
|
||||
}
|
19
src/test/ui/issues/issue-31076.stderr
Normal file
19
src/test/ui/issues/issue-31076.stderr
Normal file
@ -0,0 +1,19 @@
|
||||
error[E0369]: binary operation `+` cannot be applied to type `{integer}`
|
||||
--> $DIR/issue-31076.rs:13:13
|
||||
|
|
||||
LL | let x = 5 + 6;
|
||||
| ^^^^^
|
||||
|
|
||||
= note: an implementation of `std::ops::Add` might be missing for `{integer}`
|
||||
|
||||
error[E0369]: binary operation `+` cannot be applied to type `i32`
|
||||
--> $DIR/issue-31076.rs:15:13
|
||||
|
|
||||
LL | let y = 5i32 + 6i32;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: an implementation of `std::ops::Add` might be missing for `i32`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0369`.
|
Loading…
x
Reference in New Issue
Block a user