Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f7e1421
Add `TAGS.rustc.emacs`/`TAGS.rustc.vi` make targets, (re-)including r…
pnkfelix Apr 28, 2016
27c01cb
Add process types documentation
GuillaumeGomez Apr 28, 2016
47d9f49
Remove rust flags from doc block
GuillaumeGomez May 1, 2016
e3f1312
dep_graph: avoid panicking in thread when channel closed
birkenfeld May 1, 2016
eba43fb
std::thread docs: spawn() returns not a Thread anymore
birkenfeld May 1, 2016
b75f81c
parser: do not try to continue with `unsafe` on foreign fns
birkenfeld May 2, 2016
fcebf52
typeck: if a private field exists, also check for a public method
birkenfeld May 2, 2016
a11ddb3
Replace copy-pasted variable name with relevant one
shepmaster May 4, 2016
2ca3120
errors in the doc
kindlychung May 4, 2016
16219de
Update iterator.rs
kindlychung May 4, 2016
d1c487e
Add an example to Wrapping's documentation.
fiveop May 5, 2016
a22ca28
[Doc] Default cpu is "generic" (and not "default")
phil-opp May 5, 2016
39eec80
mk: Fix building with --enable-ccache
alexcrichton May 1, 2016
2912bfb
doc: Update reference with better description of target_env
brson May 5, 2016
26eb2be
Fix some some duplicate words.
birkenfeld May 5, 2016
1d18acc
Rollup merge of #33256 - pnkfelix:add-rustc-specific-tags-files, r=ni…
steveklabnik May 5, 2016
5df157b
Rollup merge of #33283 - GuillaumeGomez:process_doc, r=steveklabnik
steveklabnik May 5, 2016
10c34fa
Rollup merge of #33313 - birkenfeld:depgraph-panic, r=nikomatsakis
steveklabnik May 5, 2016
e44162f
Rollup merge of #33314 - alexcrichton:fix-enable-ccache, r=pnkfelix
steveklabnik May 5, 2016
a26f6ba
Rollup merge of #33326 - birkenfeld:issue-33321, r=GuillaumeGomez
steveklabnik May 5, 2016
04097c6
Rollup merge of #33336 - birkenfeld:issue-27361, r=sfackler
steveklabnik May 5, 2016
e94a722
Rollup merge of #33342 - birkenfeld:issue-26472, r=arielb1
steveklabnik May 5, 2016
da36566
Rollup merge of #33402 - shepmaster:copied-variable-name, r=Manishearth
steveklabnik May 5, 2016
9b68372
Rollup merge of #33409 - kindlychung:patch-2, r=steveklabnik
steveklabnik May 5, 2016
7860cc5
Rollup merge of #33410 - GuillaumeGomez:explain, r=Manishearth
steveklabnik May 5, 2016
8842100
Rollup merge of #33428 - fiveop:wrapping_example, r=steveklabnik
steveklabnik May 5, 2016
47b6999
Rollup merge of #33430 - phil-opp:patch-1, r=alexcrichton
steveklabnik May 5, 2016
0af9250
Rollup merge of #33437 - brson:trips, r=Manishearth
steveklabnik May 5, 2016
3ac65ea
Rollup merge of #33438 - birkenfeld:dup-words, r=steveklabnik
steveklabnik May 5, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/librustc_typeck/check/method/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ pub fn exists<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
span: Span,
method_name: ast::Name,
self_ty: ty::Ty<'tcx>,
call_expr_id: ast::NodeId)
call_expr_id: ast::NodeId,
allow_private: bool)
-> bool
{
let mode = probe::Mode::MethodCall;
Expand All @@ -93,7 +94,7 @@ pub fn exists<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
Err(NoMatch(..)) => false,
Err(Ambiguity(..)) => true,
Err(ClosureAmbiguity(..)) => true,
Err(PrivateMatch(..)) => true,
Err(PrivateMatch(..)) => allow_private,
}
}

Expand Down
13 changes: 10 additions & 3 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2943,12 +2943,19 @@ fn check_expr_with_expectation_and_lvalue_pref<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,

if let Some((did, field_ty)) = private_candidate {
let struct_path = fcx.tcx().item_path_str(did);
let msg = format!("field `{}` of struct `{}` is private", field.node, struct_path);
fcx.tcx().sess.span_err(expr.span, &msg);
fcx.write_ty(expr.id, field_ty);
let msg = format!("field `{}` of struct `{}` is private", field.node, struct_path);
let mut err = fcx.tcx().sess.struct_span_err(expr.span, &msg);
// Also check if an accessible method exists, which is often what is meant.
if method::exists(fcx, field.span, field.node, expr_t, expr.id, false) {
err.fileline_note(field.span, &format!("a method called `{}` also exists, \
maybe a `()` to call it is missing?",
field.node));
}
err.emit();
} else if field.node == keywords::Invalid.name() {
fcx.write_error(expr.id);
} else if method::exists(fcx, field.span, field.node, expr_t, expr.id) {
} else if method::exists(fcx, field.span, field.node, expr_t, expr.id, true) {
fcx.type_error_struct(field.span,
|actual| {
format!("attempted to take value of method `{}` on type \
Expand Down
24 changes: 24 additions & 0 deletions src/test/compile-fail/issue-26472.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// 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.

mod sub {
pub struct S { len: usize }
impl S {
pub fn new() -> S { S { len: 0 } }
pub fn len(&self) -> usize { self.len }
}
}

fn main() {
let s = sub::S::new();
let v = s.len;
//~^ ERROR field `len` of struct `sub::S` is private
//~| NOTE a method called `len` also exists, maybe a `()` to call it is missing
}