Skip to content

fix #24968 more friend error message for Self in fn args #25096

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 2 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
3c503a5
more friend error message for in fn arg
XuefengWu May 4, 2015
7ec6bd9
change Self type error message
XuefengWu May 10, 2015
f1ab664
rustc_back: Only use archive member filenames
alexcrichton May 9, 2015
e5efea4
Delete `_book` folder if it exists from previous runs
mdinger May 13, 2015
cce30b2
Remove errant line
tamird May 12, 2015
5f932e8
make diagnostic message clearer when called from cargo
mathroc May 13, 2015
4774d5d
Allow `T::C` syntax in match patterns to refer to trait-assosociated …
quantheory May 1, 2015
f548a05
Unignore some tests in stage1
tamird May 12, 2015
809be9b
Fix link to RFC 255 in Reference.
May 14, 2015
b4bbf3a
Fix ICE that occurs when an associated const is ambiguous.
quantheory May 3, 2015
556e76b
std: Redesign Duration, implementing RFC 1040
alexcrichton Apr 28, 2015
a4444aa
Add error explanations for E0066 and E0069.
May 12, 2015
44a5bf1
libstd/env: Add non-Rust synchronization warnings for setenv()
cgwalters Apr 23, 2015
71f7fb2
Fix table syntax.
dreid May 14, 2015
1b5b639
Auto merge of #25065 - quantheory:fix_associated_const_ambiguity_mess…
bors May 14, 2015
f539c41
Fix automatic substitution of task->thread.
dreid May 14, 2015
e77b03d
Auto merge of #25238 - alexcrichton:fix-archive-with-slashes, r=brson
bors May 14, 2015
06aef33
Add error explanations for E0053, E0251, E0252, E0255, E0256, E0368.
May 14, 2015
0a1a53d
Auto merge of #24741 - cgwalters:note-setenv-and-unsetenv-are-not-thr…
bors May 14, 2015
d636b5c
Improve examples in the E0255/E0256 error explanations.
May 14, 2015
588777f
Improve E0053 and E0066 error explanations.
May 14, 2015
b1bd3a3
Auto merge of #25338 - tamird:unignore-stage-tests, r=alexcrichton
bors May 14, 2015
af52207
Auto merge of #25381 - mathroc:patch-1, r=alexcrichton
bors May 14, 2015
62d0ef4
Fix crates.io link.
WiSaGaN May 14, 2015
ca225df
Rollup merge of #25354 - mdinger:delete_book, r=steveklabnik
Manishearth May 14, 2015
ab47005
Rollup merge of #25381 - mathroc:patch-1, r=alexcrichton
Manishearth May 14, 2015
3ce4b99
Rollup merge of #25391 - nham:ref_rfc255_link, r=alexcrichton
Manishearth May 14, 2015
0cbef04
Rollup merge of #25395 - dreid:patch-1, r=alexcrichton
Manishearth May 14, 2015
ff207b7
Rollup merge of #25397 - dreid:patch-2, r=alexcrichton
Manishearth May 14, 2015
1109b6d
Rollup merge of #25398 - nham:E0066_E0069, r=huonw
Manishearth May 14, 2015
2df7ae6
Rollup merge of #25401 - WiSaGaN:bugfix/fix_crates_io_link, r=stevekl…
Manishearth May 14, 2015
b4e1ce5
trpl-docs: Specify correct type of variable binding
dnaeon May 14, 2015
acb5e02
Another thread->task fix.
dreid May 14, 2015
e2bb734
trpl: punctuation fix
durka May 14, 2015
90b9529
Move configuration 1 phase before crate metadata collection
lilyball May 14, 2015
785cbe3
I fixed the typo of the value of e in the memory tables. It is a refe…
May 14, 2015
dd4dad8
Auto merge of #24920 - alexcrichton:duration, r=aturon
bors May 14, 2015
dc6eb78
trpl: fix link from Structs to Traits
durka May 14, 2015
66c0fe0
trpl: fix link from Enums to Traits
durka May 14, 2015
c147ac4
trpl: fix link from Match to If Let
durka May 14, 2015
c8b0689
trpl: punctuation fix in Patterns
durka May 14, 2015
4bdeb31
Add #[inline] to Borrow<str>::borrow for String.
koute May 14, 2015
a1577db
TRPL: Fix Internal Link
killercup May 14, 2015
50fb669
s/Iterater/Iterator/
apasel422 May 14, 2015
571f371
Auto merge of #25403 - Manishearth:rollup, r=Manishearth
bors May 14, 2015
82c7282
trpl: Fix missing internal links
leunggamciu May 14, 2015
140577b
Don't use <Duration as Display>::display() in time passes
nrc May 14, 2015
568f13a
Remove an almost-duplicated sentence.
habnabit May 15, 2015
2792855
Auto merge of #25399 - kballard:crate-attributes-cfg_attr, r=alexcric…
bors May 15, 2015
6e9e76a
Fix error codes E0197-E0200
cactorium May 15, 2015
1f40cde
Rollup merge of #25404 - dnaeon:doc-fixes, r=steveklabnik
steveklabnik May 15, 2015
0028f85
Rollup merge of #25405 - dreid:patch-3, r=nikomatsakis
steveklabnik May 15, 2015
c356211
Rollup merge of #25407 - durka:patch-1, r=alexcrichton
steveklabnik May 15, 2015
765a55e
Rollup merge of #25408 - Nashenas88:rust-book-stack-and-heap-typo, r=…
steveklabnik May 15, 2015
dd60abc
Rollup merge of #25410 - durka:patch-2, r=steveklabnik
steveklabnik May 15, 2015
609b4a1
Rollup merge of #25412 - koute:master, r=alexcrichton
steveklabnik May 15, 2015
aa56011
Rollup merge of #25413 - killercup:patch-11, r=alexcrichton
steveklabnik May 15, 2015
8d52274
Rollup merge of #25414 - apasel422:patch-1, r=alexcrichton
steveklabnik May 15, 2015
5501f07
Rollup merge of #25418 - leunggamciu:patch-trpl, r=steveklabnik
steveklabnik May 15, 2015
6df13d4
Rollup merge of #25420 - habnabit:master, r=steveklabnik
steveklabnik May 15, 2015
507f8b8
Fix merge conflict and also add markdown formatting
cactorium May 15, 2015
0260333
Fix major compile time regression
dotdash May 15, 2015
daabc8a
Auto merge of #25421 - steveklabnik:rollup, r=steveklabnik
bors May 15, 2015
0077ffe
Auto merge of #25419 - nrc:time, r=alexcrichton
bors May 15, 2015
190de69
Add backticks around language keyword
cactorium May 15, 2015
072cba9
Auto merge of #25422 - cactorium:unsafe_errors, r=huonw
bors May 15, 2015
579e319
Auto merge of #25400 - nrc:save-api, r=huonw
bors May 15, 2015
7ebaf1c
Auto merge of #25423 - dotdash:assume, r=huonw
bors May 15, 2015
a1d4648
more friend error message for in fn arg
XuefengWu May 4, 2015
eac661c
add compile test and update error message for Self keyworkd
XuefengWu May 16, 2015
54f0828
Merge branch '24968_err_msg_parse_self_type' of github.com:XuefengWu/…
XuefengWu May 16, 2015
ba89495
fix typo for copyright year and trait capitalise
XuefengWu May 16, 2015
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
14 changes: 12 additions & 2 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2361,8 +2361,18 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
"type name"
};

let msg = format!("use of undeclared {} `{}`", kind,
path_names_to_string(path, 0));
let self_type_name = special_idents::type_self.name;
let is_invalid_self_type_name =
path.segments.len() > 0 &&
maybe_qself.is_none() &&
path.segments[0].identifier.name == self_type_name;
let msg = if is_invalid_self_type_name {
"use of Self outside of an impl".to_string()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Self can also be used in a trait, so the message should include that. Also, you could add backticks around "Self".

} else {
format!("use of undeclared {} `{}`",
kind, path_names_to_string(path, 0))
};

self.resolve_error(ty.span, &msg[..]);
}
}
Expand Down