diff options
| author | bors <bors@rust-lang.org> | 2017-01-18 02:20:03 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-01-18 02:20:03 +0000 |
| commit | be1daa4a18b6685f42194ea1407f8d5def10b342 (patch) | |
| tree | 1b8a1cf18abe23da64a152c135382ab2ca3bbfa0 | |
| parent | c07a6ae77cd4ceb3cf591d34c5608ca91d1f75d4 (diff) | |
| parent | d82d4b66f24e21dd124e1b4765939b230cec3685 (diff) | |
Auto merge of #39019 - nikomatsakis:issue-38919, r=eddyb
only consider value items when searching for methods, not types Fixes #38919 r? @eddyb
| -rw-r--r-- | src/librustc_typeck/check/method/probe.rs | 11 | ||||
| -rw-r--r-- | src/libsyntax/json.rs | 2 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-38919.rs | 15 |
3 files changed, 25 insertions, 3 deletions
diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index f331c561f0c..aa8f3bef92e 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -1261,10 +1261,17 @@ impl<'a, 'gcx, 'tcx> ProbeContext<'a, 'gcx, 'tcx> { /////////////////////////////////////////////////////////////////////////// // MISCELLANY fn has_applicable_self(&self, item: &ty::AssociatedItem) -> bool { - // "fast track" -- check for usage of sugar + // "Fast track" -- check for usage of sugar when in method call + // mode. + // + // In Path mode (i.e., resolving a value like `T::next`), consider any + // associated value (i.e., methods, constants) but not types. match self.mode { Mode::MethodCall => item.method_has_self_argument, - Mode::Path => true + Mode::Path => match item.kind { + ty::AssociatedKind::Type => false, + ty::AssociatedKind::Method | ty::AssociatedKind::Const => true + }, } // FIXME -- check for types that deref to `Self`, // like `Rc<Self>` and so on. diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index a1c273baeea..adab76309fe 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -296,7 +296,7 @@ impl DiagnosticSpanLine { h_end: usize) -> DiagnosticSpanLine { DiagnosticSpanLine { - text: fm.get_line(index).unwrap().to_owned(), + text: fm.get_line(index).unwrap_or("").to_owned(), highlight_start: h_start, highlight_end: h_end, } diff --git a/src/test/compile-fail/issue-38919.rs b/src/test/compile-fail/issue-38919.rs new file mode 100644 index 00000000000..e6cee4afd59 --- /dev/null +++ b/src/test/compile-fail/issue-38919.rs @@ -0,0 +1,15 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn foo<T: Iterator>() { + T::Item; //~ ERROR no associated item named `Item` found for type `T` in the current scope +} + +fn main() { } |
