Change:
<!-- [31mICE[0m: Rustc '' 'thread 'rustc' panicked at 'range start index 2 out of range for slice of length 1'', 'thread 'rustc' panicked at 'range start index 2 out of range for slice of length 1'' File: --snippet: Version information Command: <!-- Include a backtrace in the code block by setting in your environment. E.g. . --<details<summary<strongProgram output</strong</summary<p</p</details<!-- query stack: [typeck] type-checking [analysis] running analysis passes on this crate --<!-- TRIAGEBOTSTART --<!-- TRIAGEBOTASSIGNSTART --<!-- TRIAGEBOTASSIGNDATASTARTTRIAGEBOTASSIGNDATAEND --<!-- TRIAGEBOTASSIGNEND --<!-- TRIAGEBOT_END --
Regression in cc sjwang05
claim
just to jump start, I just checked the contents of in the case presented: I'm checking what breaks in the test suite if we change the slicing to (which intuitively makes more sense but am still trying to piece things together). Edit: Ah, yeah, that won't work.
Thanks for the help, turns out I could've just used instead of slicing all along . I'll submit the PR once the test suite finishes running locally. As a side note, do you know why some binops seem to have 3 args? Intuitively it'd make sense to only have 2 args for the lhs and rhs tys--my guess is that the "extra" arg is something effects-related, but I'm not familiar at all with that part of the code.

Discussion:
LangItem::PartialEq, LangItem::PartialOrd, ]; <ins> pub static BINARY_OPERATORS: &'static [LangItem] = &[ LangItem::Add, LangItem::Sub, LangItem::Mul, LangItem::Div, LangItem::Rem, LangItem::BitXor, LangItem::BitAnd, LangItem::BitOr, LangItem::Shl, LangItem::Shr, LangItem::AddAssign, LangItem::SubAssign, LangItem::MulAssign, LangItem::DivAssign, LangItem::RemAssign, LangItem::BitXorAssign, LangItem::BitAndAssign, LangItem::BitOrAssign, LangItem::ShlAssign, LangItem::ShrAssign, LangItem::Index, LangItem::IndexMut, LangItem::PartialEq, LangItem::PartialOrd, ]; </ins>

&& let hir::Node::Expr(lhs) = self.tcx.hir_node(*lhs_hir_id) && let hir::Node::Expr(rhs) = self.tcx.hir_node(*rhs_hir_id) && let Some(rhs_ty) = typeck_results.expr_ty_opt(rhs) <ins> && let trait_pred = predicate.unwrap_or(trait_pred) // Only run this code on binary operators && hir::lang_items::BINARY_OPERATORS .iter() .filter_map(|&op| self.tcx.lang_items().get(op)) .any(|op| { op == trait_pred.skip_binder().trait_ref.def_id }) </ins> { // Suggest dereferencing the LHS, RHS, or both terms of a binop if possible

//~^ERROR can't compare `str` with `&String` [E0277] } <ins> fn qux() { // Issue #119352 const FOO: i32 = 42; let _ = FOO & (*"Sized".to_string().into_boxed_str()); //~^ ERROR the size for values of type `str` cannot be known at compilation time //~| ERROR no implementation for `i32 & str` [E0277] } </ins> fn main() {}

LL |     _ = partial[..3] == *string_ref; |                         + <del> error: aborting due to 22 previous errors </del> <ins> error[E0277]: no implementation for `i32 & str` --> $DIR/binary-op-suggest-deref.rs:78:17 | LL |     let _ = FOO & (*"Sized".to_string().into_boxed_str()); |                 ^ no implementation for `i32 & str` | = help: the trait `BitAnd<str>` is not implemented for `i32` = help: the following other types implement trait `BitAnd<Rhs>`: <i32 as BitAnd> <i32 as BitAnd<&i32>> <&'a i32 as BitAnd<i32>> <&i32 as BitAnd<&i32>> error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/binary-op-suggest-deref.rs:78:17 | LL |     let _ = FOO & (*"Sized".to_string().into_boxed_str()); |                 ^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` error: aborting due to 24 previous errors </ins> Some errors have detailed explanations: E0277, E0308, E0369. For more information about an error, try `rustc --explain E0277`.