Skip to content

Commit 97d8d04

Browse files
committed
Remove index type check (review comment)
1 parent cde0023 commit 97d8d04

File tree

3 files changed

+6
-29
lines changed

3 files changed

+6
-29
lines changed

src/librustc/hir/mod.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -244,23 +244,6 @@ impl Path {
244244
pub fn is_global(&self) -> bool {
245245
!self.segments.is_empty() && self.segments[0].name == keywords::CrateRoot.name()
246246
}
247-
248-
/// Wether this path is any of `::std::ops::{Range, RangeTo, RangeFrom}`.
249-
pub fn is_range(&self) -> bool {
250-
let mut base = ["{{root}}", "std", "ops"].iter().map(|p| p.to_string()).collect::<Vec<_>>();
251-
let range_paths = ["Range", "RangeTo", "RangeFrom"];
252-
let segments = self.segments.iter()
253-
.map(|segment| format!("{}", segment.name))
254-
.collect::<Vec<String>>();
255-
for path in &range_paths {
256-
base.push(path.to_string());
257-
if base == segments {
258-
return true;
259-
}
260-
base.pop();
261-
}
262-
false
263-
}
264247
}
265248

266249
impl fmt::Debug for Path {

src/librustc/traits/error_reporting.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -832,17 +832,11 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
832832
let parent_node = self.tcx.hir.get_parent_node(node_id);
833833
if let Some(hir::map::NodeLocal(ref local)) = self.tcx.hir.find(parent_node) {
834834
if let Some(ref expr) = local.init {
835-
if let hir::ExprIndex(_, ref index) = expr.node {
836-
if let hir::ExprStruct(hir::QPath::Resolved(None, ref path),
837-
..) = index.node {
838-
if let (Ok(snippet), true) = (
839-
self.tcx.sess.codemap().span_to_snippet(expr.span),
840-
path.is_range()
841-
) {
842-
err.span_suggestion(expr.span,
843-
"consider a slice instead",
844-
format!("&{}", snippet));
845-
}
835+
if let hir::ExprIndex(_, _) = expr.node {
836+
if let Ok(snippet) = self.tcx.sess.codemap().span_to_snippet(expr.span) {
837+
err.span_suggestion(expr.span,
838+
"consider a slice instead",
839+
format!("&{}", snippet));
846840
}
847841
}
848842
}

src/test/ui/suggestions/str-array-assignment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ fn main() { //~ NOTE expected `()` because of default return type
2020
//~| NOTE expected type
2121
let v = s[..2];
2222
//~^ ERROR the trait bound `str: std::marker::Sized` is not satisfied
23-
//~| NOTE consider a slice instead
23+
//~| HELP consider a slice instead
2424
//~| NOTE `str` does not have a constant size known at compile-time
2525
//~| HELP the trait `std::marker::Sized` is not implemented for `str`
2626
//~| NOTE all local variables must have a statically known size

0 commit comments

Comments
 (0)