Merge remote-tracking branch 'Dretch/prettydocs'
Conflicts: src/compiletest/errors.rs src/libsyntax/parse/attr.rs src/libsyntax/parse/comments.rs src/test/compile-fail/ambig_impl_unify.rs src/test/compile-fail/assign-super.rs src/test/compile-fail/bad-for-loop.rs src/test/compile-fail/bad-var-env-capture-in-block-arg.rs src/test/compile-fail/block-arg-as-stmt-with-value.rs src/test/compile-fail/borrowck-assign-comp-idx.rs src/test/compile-fail/borrowck-lend-flow.rs src/test/compile-fail/borrowck-loan-blocks-move-cc.rs src/test/compile-fail/borrowck-loan-blocks-mut-uniq.rs src/test/compile-fail/borrowck-loan-rcvr.rs src/test/compile-fail/borrowck-loan-vec-content.rs src/test/compile-fail/borrowck-mut-vec-as-imm-slice-bad.rs src/test/compile-fail/cap-clause-with-stack-closure.rs src/test/compile-fail/do1.rs src/test/compile-fail/do2.rs src/test/compile-fail/empty-vec-trailing-comma.rs src/test/compile-fail/evec-subtyping.rs src/test/compile-fail/issue-1896.rs src/test/compile-fail/issue-2149.rs src/test/compile-fail/issue-2150.rs src/test/compile-fail/issue-2487-b.rs src/test/compile-fail/kindck-implicit-close-over-mut-var.rs src/test/compile-fail/liveness-issue-2163.rs src/test/compile-fail/liveness-use-in-index-lvalue.rs src/test/compile-fail/no-reuse-move-arc.rs src/test/compile-fail/no-send-res-ports.rs src/test/compile-fail/non-const.rs src/test/compile-fail/pure-higher-order.rs src/test/compile-fail/pure-loop-body.rs src/test/compile-fail/regions-addr-of-upvar-self.rs src/test/compile-fail/regions-escape-loop-via-vec.rs src/test/compile-fail/regions-scoping.rs src/test/compile-fail/seq-args.rs src/test/compile-fail/tstate-unsat-in-called-fn-expr.rs src/test/compile-fail/tstate-unsat-in-fn-expr.rs src/test/compile-fail/vec-add.rs src/test/compile-fail/vec-concat-bug.rs src/test/compile-fail/vector-no-ann.rs
This commit is contained in:
commit
569467eb0d
268 changed files with 1051 additions and 656 deletions
|
@ -21,14 +21,14 @@ fn load_errors(testfile: str) -> ~[expected_error] {
|
|||
}
|
||||
|
||||
fn parse_expected(line_num: uint, line: str) -> ~[expected_error] unsafe {
|
||||
let error_tag = "//!";
|
||||
let error_tag = "//~";
|
||||
let mut idx;
|
||||
alt str::find_str(line, error_tag) {
|
||||
option::none { ret ~[]; }
|
||||
option::some(nn) { idx = (nn as uint) + str::len(error_tag); }
|
||||
}
|
||||
|
||||
// "//!^^^ kind msg" denotes a message expected
|
||||
// "//~^^^ kind msg" denotes a message expected
|
||||
// three lines above current line:
|
||||
let mut adjust_line = 0u;
|
||||
let len = str::len(line);
|
||||
|
|
82
src/etc/sugarise-doc-comments.py
Executable file
82
src/etc/sugarise-doc-comments.py
Executable file
|
@ -0,0 +1,82 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
#
|
||||
# this script attempts to turn doc comment attributes (#[doc = "..."])
|
||||
# into sugared-doc-comments (/** ... */ and /// ...)
|
||||
#
|
||||
# it sugarises all .rs/.rc files underneath the working directory
|
||||
#
|
||||
|
||||
import sys, os, fnmatch, re
|
||||
|
||||
|
||||
DOC_PATTERN = '^(?P<indent>[\\t ]*)#\\[(\\s*)doc(\\s*)=' + \
|
||||
'(\\s*)"(?P<text>(\\"|[^"])*?)"(\\s*)\\]' + \
|
||||
'(?P<semi>;)?'
|
||||
|
||||
ESCAPES = [("\\'", "'"),
|
||||
('\\"', '"'),
|
||||
("\\n", "\n"),
|
||||
("\\r", "\r"),
|
||||
("\\t", "\t")]
|
||||
|
||||
|
||||
def unescape(s):
|
||||
for (find, repl) in ESCAPES:
|
||||
s = s.replace(find, repl)
|
||||
return s
|
||||
|
||||
|
||||
def block_trim(s):
|
||||
lns = s.splitlines()
|
||||
|
||||
# remove leading/trailing whitespace-lines
|
||||
while lns and not lns[0].strip():
|
||||
lns = lns[1:]
|
||||
while lns and not lns[-1].strip():
|
||||
lns = lns[:-1]
|
||||
|
||||
# remove leading horizontal whitespace
|
||||
n = sys.maxint
|
||||
for ln in lns:
|
||||
if ln.strip():
|
||||
n = min(n, len(re.search('^\s*', ln).group()))
|
||||
if n != sys.maxint:
|
||||
lns = [ln[n:] for ln in lns]
|
||||
|
||||
# strip trailing whitespace
|
||||
lns = [ln.rstrip() for ln in lns]
|
||||
|
||||
return lns
|
||||
|
||||
|
||||
def replace_doc(m):
|
||||
indent = m.group('indent')
|
||||
text = block_trim(unescape(m.group('text')))
|
||||
|
||||
if len(text) > 1:
|
||||
inner = '!' if m.group('semi') else '*'
|
||||
starify = lambda s: indent + ' *' + (' ' + s if s else '')
|
||||
text = '\n'.join(map(starify, text))
|
||||
repl = indent + '/*' + inner + '\n' + text + '\n' + indent + ' */'
|
||||
else:
|
||||
inner = '!' if m.group('semi') else '/'
|
||||
repl = indent + '//' + inner + ' ' + text[0]
|
||||
|
||||
return repl
|
||||
|
||||
|
||||
def sugarise_file(path):
|
||||
s = open(path).read()
|
||||
|
||||
r = re.compile(DOC_PATTERN, re.MULTILINE | re.DOTALL)
|
||||
ns = re.sub(r, replace_doc, s)
|
||||
|
||||
if s != ns:
|
||||
open(path, 'w').write(ns)
|
||||
|
||||
|
||||
for (dirpath, dirnames, filenames) in os.walk('.'):
|
||||
for name in fnmatch.filter(filenames, '*.r[sc]'):
|
||||
sugarise_file(os.path.join(dirpath, name))
|
||||
|
|
@ -58,8 +58,8 @@ export
|
|||
all, any,
|
||||
all_between, any_between,
|
||||
map,
|
||||
each,
|
||||
each_char,
|
||||
each, eachi,
|
||||
each_char, each_chari,
|
||||
bytes_iter,
|
||||
chars_iter,
|
||||
split_char_iter,
|
||||
|
@ -73,7 +73,7 @@ export
|
|||
find_char, find_char_from, find_char_between,
|
||||
rfind_char, rfind_char_from, rfind_char_between,
|
||||
find_str, find_str_from, find_str_between,
|
||||
contains,
|
||||
contains, contains_char,
|
||||
starts_with,
|
||||
ends_with,
|
||||
|
||||
|
@ -672,9 +672,15 @@ pure fn bytes_iter(ss: str/&, it: fn(u8)) {
|
|||
#[doc = "Iterate over the bytes in a string"]
|
||||
#[inline(always)]
|
||||
pure fn each(s: str/&, it: fn(u8) -> bool) {
|
||||
eachi(s, |_i, b| it(b) )
|
||||
}
|
||||
|
||||
#[doc = "Iterate over the bytes in a string, with indices"]
|
||||
#[inline(always)]
|
||||
pure fn eachi(s: str/&, it: fn(uint, u8) -> bool) {
|
||||
let mut i = 0u, l = len(s);
|
||||
while (i < l) {
|
||||
if !it(s[i]) { break; }
|
||||
if !it(i, s[i]) { break; }
|
||||
i += 1u;
|
||||
}
|
||||
}
|
||||
|
@ -682,12 +688,19 @@ pure fn each(s: str/&, it: fn(u8) -> bool) {
|
|||
#[doc = "Iterates over the chars in a string"]
|
||||
#[inline(always)]
|
||||
pure fn each_char(s: str/&, it: fn(char) -> bool) {
|
||||
let mut pos = 0u;
|
||||
each_chari(s, |_i, c| it(c))
|
||||
}
|
||||
|
||||
#[doc = "Iterates over the chars in a string, with indices"]
|
||||
#[inline(always)]
|
||||
pure fn each_chari(s: str/&, it: fn(uint, char) -> bool) {
|
||||
let mut pos = 0u, ch_pos = 0u;
|
||||
let len = len(s);
|
||||
while pos < len {
|
||||
let {ch, next} = char_range_at(s, pos);
|
||||
pos = next;
|
||||
if !it(ch) { break; }
|
||||
if !it(ch_pos, ch) { break; }
|
||||
ch_pos += 1u;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1146,6 +1159,18 @@ pure fn contains(haystack: str/&a, needle: str/&b) -> bool {
|
|||
option::is_some(find_str(haystack, needle))
|
||||
}
|
||||
|
||||
#[doc = "
|
||||
Returns true if a string contains a char.
|
||||
|
||||
# Arguments
|
||||
|
||||
* haystack - The string to look in
|
||||
* needle - The char to look for
|
||||
"]
|
||||
pure fn contains_char(haystack: str/&, needle: char) -> bool {
|
||||
option::is_some(find_char(haystack, needle))
|
||||
}
|
||||
|
||||
#[doc = "
|
||||
Returns true if one string starts with another
|
||||
|
||||
|
@ -1879,12 +1904,21 @@ impl extensions/& for str/& {
|
|||
#[doc = "Returns true if one string contains another"]
|
||||
#[inline]
|
||||
fn contains(needle: str/&a) -> bool { contains(self, needle) }
|
||||
#[doc = "Returns true if a string contains a char"]
|
||||
#[inline]
|
||||
fn contains_char(needle: char) -> bool { contains_char(self, needle) }
|
||||
#[doc = "Iterate over the bytes in a string"]
|
||||
#[inline]
|
||||
fn each(it: fn(u8) -> bool) { each(self, it) }
|
||||
#[doc = "Iterate over the bytes in a string, with indices"]
|
||||
#[inline]
|
||||
fn eachi(it: fn(uint, u8) -> bool) { eachi(self, it) }
|
||||
#[doc = "Iterate over the chars in a string"]
|
||||
#[inline]
|
||||
fn each_char(it: fn(char) -> bool) { each_char(self, it) }
|
||||
#[doc = "Iterate over the chars in a string, with indices"]
|
||||
#[inline]
|
||||
fn each_chari(it: fn(uint, char) -> bool) { each_chari(self, it) }
|
||||
#[doc = "Returns true if one string ends with another"]
|
||||
#[inline]
|
||||
fn ends_with(needle: str/&) -> bool { ends_with(self, needle) }
|
||||
|
@ -2644,6 +2678,14 @@ mod tests {
|
|||
assert !contains(data, "ไท华");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_contains_char() {
|
||||
assert contains_char("abc", 'b');
|
||||
assert contains_char("a", 'a');
|
||||
assert !contains_char("abc", 'd');
|
||||
assert !contains_char("", 'a');
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_chars_iter() {
|
||||
let mut i = 0;
|
||||
|
|
|
@ -652,8 +652,9 @@ type attribute = spanned<attribute_>;
|
|||
#[auto_serialize]
|
||||
enum attr_style { attr_outer, attr_inner, }
|
||||
|
||||
// doc-comments are promoted to attributes that have is_sugared_doc = true
|
||||
#[auto_serialize]
|
||||
type attribute_ = {style: attr_style, value: meta_item};
|
||||
type attribute_ = {style: attr_style, value: meta_item, is_sugared_doc: bool};
|
||||
|
||||
/*
|
||||
iface_refs appear in both impls and in classes that implement ifaces.
|
||||
|
|
|
@ -4,7 +4,8 @@ import std::map;
|
|||
import std::map::hashmap;
|
||||
import either::either;
|
||||
import diagnostic::span_handler;
|
||||
import ast_util::dummy_spanned;
|
||||
import ast_util::{spanned, dummy_spanned};
|
||||
import parse::comments::{doc_comment_style, strip_doc_comment_decoration};
|
||||
|
||||
// Constructors
|
||||
export mk_name_value_item_str;
|
||||
|
@ -12,10 +13,12 @@ export mk_name_value_item;
|
|||
export mk_list_item;
|
||||
export mk_word_item;
|
||||
export mk_attr;
|
||||
export mk_sugared_doc_attr;
|
||||
|
||||
// Conversion
|
||||
export attr_meta;
|
||||
export attr_metas;
|
||||
export desugar_doc_attr;
|
||||
|
||||
// Accessors
|
||||
export get_attr_name;
|
||||
|
@ -66,9 +69,19 @@ fn mk_word_item(+name: ast::ident) -> @ast::meta_item {
|
|||
}
|
||||
|
||||
fn mk_attr(item: @ast::meta_item) -> ast::attribute {
|
||||
ret dummy_spanned({style: ast::attr_inner, value: *item});
|
||||
ret dummy_spanned({style: ast::attr_inner, value: *item,
|
||||
is_sugared_doc: false});
|
||||
}
|
||||
|
||||
fn mk_sugared_doc_attr(text: str, lo: uint, hi: uint) -> ast::attribute {
|
||||
let lit = spanned(lo, hi, ast::lit_str(@text));
|
||||
let attr = {
|
||||
style: doc_comment_style(text),
|
||||
value: spanned(lo, hi, ast::meta_name_value(@"doc", lit)),
|
||||
is_sugared_doc: true
|
||||
};
|
||||
ret spanned(lo, hi, attr);
|
||||
}
|
||||
|
||||
/* Conversion */
|
||||
|
||||
|
@ -81,6 +94,16 @@ fn attr_metas(attrs: ~[ast::attribute]) -> ~[@ast::meta_item] {
|
|||
ret mitems;
|
||||
}
|
||||
|
||||
fn desugar_doc_attr(attr: ast::attribute) -> ast::attribute {
|
||||
if attr.node.is_sugared_doc {
|
||||
let comment = get_meta_item_value_str(@attr.node.value).get();
|
||||
let meta = mk_name_value_item_str(@"doc",
|
||||
strip_doc_comment_decoration(*comment));
|
||||
ret mk_attr(meta);
|
||||
} else {
|
||||
attr
|
||||
}
|
||||
}
|
||||
|
||||
/* Accessors */
|
||||
|
||||
|
|
|
@ -102,7 +102,8 @@ fn fold_meta_item_(&&mi: @meta_item, fld: ast_fold) -> @meta_item {
|
|||
fn fold_attribute_(at: attribute, fld: ast_fold) ->
|
||||
attribute {
|
||||
ret {node: {style: at.node.style,
|
||||
value: *fold_meta_item_(@at.node.value, fld)},
|
||||
value: *fold_meta_item_(@at.node.value, fld),
|
||||
is_sugared_doc: at.node.is_sugared_doc },
|
||||
span: fld.new_span(at.span)};
|
||||
}
|
||||
//used in noop_fold_foreign_item and noop_fold_fn_decl
|
||||
|
|
|
@ -15,7 +15,8 @@ impl parser_attr for parser {
|
|||
-> attr_or_ext
|
||||
{
|
||||
let expect_item_next = vec::is_not_empty(first_item_attrs);
|
||||
if self.token == token::POUND {
|
||||
alt self.token {
|
||||
token::POUND {
|
||||
let lo = self.span.lo;
|
||||
if self.look_ahead(1u) == token::LBRACKET {
|
||||
self.bump();
|
||||
|
@ -30,15 +31,40 @@ impl parser_attr for parser {
|
|||
self.bump();
|
||||
ret some(right(self.parse_syntax_ext_naked(lo)));
|
||||
} else { ret none; }
|
||||
} else { ret none; }
|
||||
}
|
||||
token::DOC_COMMENT(_) {
|
||||
ret some(left(self.parse_outer_attributes()));
|
||||
}
|
||||
_ {
|
||||
ret none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse attributes that appear before an item
|
||||
fn parse_outer_attributes() -> ~[ast::attribute] {
|
||||
let mut attrs: ~[ast::attribute] = ~[];
|
||||
while self.token == token::POUND
|
||||
&& self.look_ahead(1u) == token::LBRACKET {
|
||||
vec::push(attrs, self.parse_attribute(ast::attr_outer));
|
||||
loop {
|
||||
alt copy self.token {
|
||||
token::POUND {
|
||||
if self.look_ahead(1u) != token::LBRACKET {
|
||||
break;
|
||||
}
|
||||
attrs += [self.parse_attribute(ast::attr_outer)]/~;
|
||||
}
|
||||
token::DOC_COMMENT(s) {
|
||||
let attr = ::attr::mk_sugared_doc_attr(
|
||||
*self.get_str(s), self.span.lo, self.span.hi);
|
||||
if attr.node.style != ast::attr_outer {
|
||||
self.fatal("expected outer comment");
|
||||
}
|
||||
attrs += [attr]/~;
|
||||
self.bump();
|
||||
}
|
||||
_ {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ret attrs;
|
||||
}
|
||||
|
@ -55,7 +81,8 @@ impl parser_attr for parser {
|
|||
let meta_item = self.parse_meta_item();
|
||||
self.expect(token::RBRACKET);
|
||||
let mut hi = self.span.hi;
|
||||
ret spanned(lo, hi, {style: style, value: *meta_item});
|
||||
ret spanned(lo, hi, {style: style, value: *meta_item,
|
||||
is_sugared_doc: false});
|
||||
}
|
||||
|
||||
// Parse attributes that appear after the opening of an item, each
|
||||
|
@ -68,22 +95,41 @@ impl parser_attr for parser {
|
|||
{inner: ~[ast::attribute], next: ~[ast::attribute]} {
|
||||
let mut inner_attrs: ~[ast::attribute] = ~[];
|
||||
let mut next_outer_attrs: ~[ast::attribute] = ~[];
|
||||
while self.token == token::POUND {
|
||||
if self.look_ahead(1u) != token::LBRACKET {
|
||||
// This is an extension
|
||||
break;
|
||||
}
|
||||
let attr = self.parse_attribute(ast::attr_inner);
|
||||
if self.token == token::SEMI {
|
||||
loop {
|
||||
alt copy self.token {
|
||||
token::POUND {
|
||||
if self.look_ahead(1u) != token::LBRACKET {
|
||||
// This is an extension
|
||||
break;
|
||||
}
|
||||
let attr = self.parse_attribute(ast::attr_inner);
|
||||
if self.token == token::SEMI {
|
||||
self.bump();
|
||||
inner_attrs += [attr]/~;
|
||||
} else {
|
||||
// It's not really an inner attribute
|
||||
let outer_attr =
|
||||
spanned(attr.span.lo, attr.span.hi,
|
||||
{style: ast::attr_outer, value: attr.node.value,
|
||||
is_sugared_doc: false});
|
||||
next_outer_attrs += [outer_attr]/~;
|
||||
break;
|
||||
}
|
||||
}
|
||||
token::DOC_COMMENT(s) {
|
||||
let attr = ::attr::mk_sugared_doc_attr(
|
||||
*self.get_str(s), self.span.lo, self.span.hi);
|
||||
self.bump();
|
||||
vec::push(inner_attrs, attr);
|
||||
} else {
|
||||
// It's not really an inner attribute
|
||||
let outer_attr =
|
||||
spanned(attr.span.lo, attr.span.hi,
|
||||
{style: ast::attr_outer, value: attr.node.value});
|
||||
vec::push(next_outer_attrs, outer_attr);
|
||||
if attr.node.style == ast::attr_inner {
|
||||
inner_attrs += [attr]/~;
|
||||
} else {
|
||||
next_outer_attrs += [attr]/~;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_ {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
ret {inner: inner_attrs, next: next_outer_attrs};
|
||||
|
|
|
@ -8,6 +8,7 @@ export cmnt;
|
|||
export lit;
|
||||
export cmnt_style;
|
||||
export gather_comments_and_literals;
|
||||
export is_doc_comment, doc_comment_style, strip_doc_comment_decoration;
|
||||
|
||||
enum cmnt_style {
|
||||
isolated, // No code on either side of each line of the comment
|
||||
|
@ -18,6 +19,81 @@ enum cmnt_style {
|
|||
|
||||
type cmnt = {style: cmnt_style, lines: ~[str], pos: uint};
|
||||
|
||||
fn is_doc_comment(s: str) -> bool {
|
||||
s.starts_with("///") ||
|
||||
s.starts_with("//!") ||
|
||||
s.starts_with("/**") ||
|
||||
s.starts_with("/*!")
|
||||
}
|
||||
|
||||
fn doc_comment_style(comment: str) -> ast::attr_style {
|
||||
assert is_doc_comment(comment);
|
||||
if comment.starts_with("//!") || comment.starts_with("/*!") {
|
||||
ast::attr_inner
|
||||
} else {
|
||||
ast::attr_outer
|
||||
}
|
||||
}
|
||||
|
||||
fn strip_doc_comment_decoration(comment: str) -> str {
|
||||
|
||||
/// remove whitespace-only lines from the start/end of lines
|
||||
fn vertical_trim(lines: [str]/~) -> [str]/~ {
|
||||
let mut i = 0u, j = lines.len();
|
||||
while i < j && lines[i].trim().is_empty() {
|
||||
i += 1u;
|
||||
}
|
||||
while j > i && lines[j - 1u].trim().is_empty() {
|
||||
j -= 1u;
|
||||
}
|
||||
ret lines.slice(i, j);
|
||||
}
|
||||
|
||||
// drop leftmost columns that contain only values in chars
|
||||
fn block_trim(lines: [str]/~, chars: str, max: option<uint>) -> [str]/~ {
|
||||
|
||||
let mut i = max.get_default(uint::max_value);
|
||||
for lines.each |line| {
|
||||
if line.trim().is_empty() {
|
||||
cont;
|
||||
}
|
||||
for line.each_chari |j, c| {
|
||||
if j >= i {
|
||||
break;
|
||||
}
|
||||
if !chars.contains_char(c) {
|
||||
i = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ret do lines.map |line| {
|
||||
let chars = str::chars(line);
|
||||
if i > chars.len() {
|
||||
""
|
||||
} else {
|
||||
str::from_chars(chars.slice(i, chars.len()))
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if comment.starts_with("//") {
|
||||
ret comment.slice(3u, comment.len()).trim();
|
||||
}
|
||||
|
||||
if comment.starts_with("/*") {
|
||||
let lines = str::lines_any(comment.slice(3u, comment.len() - 2u));
|
||||
let lines = vertical_trim(lines);
|
||||
let lines = block_trim(lines, "\t ", none);
|
||||
let lines = block_trim(lines, "*", some(1u));
|
||||
let lines = block_trim(lines, "\t ", none);
|
||||
ret str::connect(lines, "\n");
|
||||
}
|
||||
|
||||
fail "not a doc-comment: " + comment;
|
||||
}
|
||||
|
||||
fn read_to_eol(rdr: string_reader) -> str {
|
||||
let mut val = "";
|
||||
while rdr.curr != '\n' && !is_eof(rdr) {
|
||||
|
@ -57,29 +133,41 @@ fn consume_whitespace_counting_blank_lines(rdr: string_reader,
|
|||
}
|
||||
}
|
||||
|
||||
fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool) -> cmnt {
|
||||
|
||||
fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
|
||||
&comments: [cmnt]/~) {
|
||||
#debug(">>> shebang comment");
|
||||
let p = rdr.chpos;
|
||||
#debug("<<< shebang comment");
|
||||
ret {style: if code_to_the_left { trailing } else { isolated },
|
||||
lines: ~[read_one_line_comment(rdr)],
|
||||
pos: p};
|
||||
vec::push(comments, {
|
||||
style: if code_to_the_left { trailing } else { isolated },
|
||||
lines: ~[read_one_line_comment(rdr)],
|
||||
pos: p
|
||||
});
|
||||
}
|
||||
|
||||
fn read_line_comments(rdr: string_reader, code_to_the_left: bool) -> cmnt {
|
||||
fn read_line_comments(rdr: string_reader, code_to_the_left: bool,
|
||||
&comments: [cmnt]/~) {
|
||||
#debug(">>> line comments");
|
||||
let p = rdr.chpos;
|
||||
let mut lines: ~[str] = ~[];
|
||||
while rdr.curr == '/' && nextch(rdr) == '/' {
|
||||
let line = read_one_line_comment(rdr);
|
||||
log(debug, line);
|
||||
if is_doc_comment(line) { // doc-comments are not put in comments
|
||||
break;
|
||||
}
|
||||
vec::push(lines, line);
|
||||
consume_non_eol_whitespace(rdr);
|
||||
}
|
||||
#debug("<<< line comments");
|
||||
ret {style: if code_to_the_left { trailing } else { isolated },
|
||||
lines: lines,
|
||||
pos: p};
|
||||
if !lines.is_empty() {
|
||||
vec::push(comments, {
|
||||
style: if code_to_the_left { trailing } else { isolated },
|
||||
lines: lines,
|
||||
pos: p
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn all_whitespace(s: str, begin: uint, end: uint) -> bool {
|
||||
|
@ -101,13 +189,27 @@ fn trim_whitespace_prefix_and_push_line(&lines: ~[str],
|
|||
vec::push(lines, s1);
|
||||
}
|
||||
|
||||
fn read_block_comment(rdr: string_reader, code_to_the_left: bool) -> cmnt {
|
||||
fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
|
||||
&comments: [cmnt]/~) {
|
||||
#debug(">>> block comment");
|
||||
let p = rdr.chpos;
|
||||
let mut lines: ~[str] = ~[];
|
||||
let mut col: uint = rdr.col;
|
||||
bump(rdr);
|
||||
bump(rdr);
|
||||
|
||||
// doc-comments are not really comments, they are attributes
|
||||
if rdr.curr == '*' || rdr.curr == '!' {
|
||||
while !(rdr.curr == '*' && nextch(rdr) == '/') && !is_eof(rdr) {
|
||||
bump(rdr);
|
||||
}
|
||||
if !is_eof(rdr) {
|
||||
bump(rdr);
|
||||
bump(rdr);
|
||||
}
|
||||
ret;
|
||||
}
|
||||
|
||||
let mut curr_line = "/*";
|
||||
let mut level: int = 1;
|
||||
while level > 0 {
|
||||
|
@ -143,7 +245,7 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool) -> cmnt {
|
|||
style = mixed;
|
||||
}
|
||||
#debug("<<< block comment");
|
||||
ret {style: style, lines: lines, pos: p};
|
||||
vec::push(comments, {style: style, lines: lines, pos: p});
|
||||
}
|
||||
|
||||
fn peeking_at_comment(rdr: string_reader) -> bool {
|
||||
|
@ -156,11 +258,11 @@ fn consume_comment(rdr: string_reader, code_to_the_left: bool,
|
|||
&comments: ~[cmnt]) {
|
||||
#debug(">>> consume comment");
|
||||
if rdr.curr == '/' && nextch(rdr) == '/' {
|
||||
vec::push(comments, read_line_comments(rdr, code_to_the_left));
|
||||
read_line_comments(rdr, code_to_the_left, comments);
|
||||
} else if rdr.curr == '/' && nextch(rdr) == '*' {
|
||||
vec::push(comments, read_block_comment(rdr, code_to_the_left));
|
||||
read_block_comment(rdr, code_to_the_left, comments);
|
||||
} else if rdr.curr == '#' && nextch(rdr) == '!' {
|
||||
vec::push(comments, read_shebang_comment(rdr, code_to_the_left));
|
||||
read_shebang_comment(rdr, code_to_the_left, comments);
|
||||
} else { fail; }
|
||||
#debug("<<< consume comment");
|
||||
}
|
||||
|
|
|
@ -161,7 +161,11 @@ impl tt_reader_as_reader of reader for tt_reader {
|
|||
}
|
||||
|
||||
fn string_advance_token(&&r: string_reader) {
|
||||
consume_whitespace_and_comments(r);
|
||||
for consume_whitespace_and_comments(r).each |comment| {
|
||||
r.peek_tok = comment.tok;
|
||||
r.peek_span = comment.sp;
|
||||
ret;
|
||||
}
|
||||
|
||||
if is_eof(r) {
|
||||
r.peek_tok = token::EOF;
|
||||
|
@ -277,22 +281,41 @@ fn is_hex_digit(c: char) -> bool {
|
|||
|
||||
fn is_bin_digit(c: char) -> bool { ret c == '0' || c == '1'; }
|
||||
|
||||
fn consume_whitespace_and_comments(rdr: string_reader) {
|
||||
// might return a sugared-doc-attr
|
||||
fn consume_whitespace_and_comments(rdr: string_reader)
|
||||
-> option<{tok: token::token, sp: span}> {
|
||||
while is_whitespace(rdr.curr) { bump(rdr); }
|
||||
ret consume_any_line_comment(rdr);
|
||||
}
|
||||
|
||||
fn consume_any_line_comment(rdr: string_reader) {
|
||||
// might return a sugared-doc-attr
|
||||
fn consume_any_line_comment(rdr: string_reader)
|
||||
-> option<{tok: token::token, sp: span}> {
|
||||
if rdr.curr == '/' {
|
||||
alt nextch(rdr) {
|
||||
'/' {
|
||||
while rdr.curr != '\n' && !is_eof(rdr) { bump(rdr); }
|
||||
// Restart whitespace munch.
|
||||
|
||||
ret consume_whitespace_and_comments(rdr);
|
||||
bump(rdr);
|
||||
bump(rdr);
|
||||
// line comments starting with "///" or "//!" are doc-comments
|
||||
if rdr.curr == '/' || rdr.curr == '!' {
|
||||
let start_chpos = rdr.chpos - 2u;
|
||||
let mut acc = "//";
|
||||
while rdr.curr != '\n' && !is_eof(rdr) {
|
||||
str::push_char(acc, rdr.curr);
|
||||
bump(rdr);
|
||||
}
|
||||
ret some({
|
||||
tok: token::DOC_COMMENT(intern(*rdr.interner, @acc)),
|
||||
sp: ast_util::mk_sp(start_chpos, rdr.chpos)
|
||||
});
|
||||
} else {
|
||||
while rdr.curr != '\n' && !is_eof(rdr) { bump(rdr); }
|
||||
// Restart whitespace munch.
|
||||
ret consume_whitespace_and_comments(rdr);
|
||||
}
|
||||
}
|
||||
'*' { bump(rdr); bump(rdr); ret consume_block_comment(rdr); }
|
||||
_ { ret; }
|
||||
_ {}
|
||||
}
|
||||
} else if rdr.curr == '#' {
|
||||
if nextch(rdr) == '!' {
|
||||
|
@ -305,9 +328,34 @@ fn consume_any_line_comment(rdr: string_reader) {
|
|||
}
|
||||
}
|
||||
}
|
||||
ret none;
|
||||
}
|
||||
|
||||
fn consume_block_comment(rdr: string_reader) {
|
||||
// might return a sugared-doc-attr
|
||||
fn consume_block_comment(rdr: string_reader)
|
||||
-> option<{tok: token::token, sp: span}> {
|
||||
|
||||
// block comments starting with "/**" or "/*!" are doc-comments
|
||||
if rdr.curr == '*' || rdr.curr == '!' {
|
||||
let start_chpos = rdr.chpos - 2u;
|
||||
let mut acc = "/*";
|
||||
while !(rdr.curr == '*' && nextch(rdr) == '/') && !is_eof(rdr) {
|
||||
str::push_char(acc, rdr.curr);
|
||||
bump(rdr);
|
||||
}
|
||||
if is_eof(rdr) {
|
||||
rdr.fatal("unterminated block doc-comment");
|
||||
} else {
|
||||
acc += "*/";
|
||||
bump(rdr);
|
||||
bump(rdr);
|
||||
ret some({
|
||||
tok: token::DOC_COMMENT(intern(*rdr.interner, @acc)),
|
||||
sp: ast_util::mk_sp(start_chpos, rdr.chpos)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let mut level: int = 1;
|
||||
while level > 0 {
|
||||
if is_eof(rdr) { rdr.fatal("unterminated block comment"); }
|
||||
|
|
|
@ -80,6 +80,7 @@ enum token {
|
|||
|
||||
//ACTUALLY(whole_nonterminal),
|
||||
|
||||
DOC_COMMENT(str_num),
|
||||
EOF,
|
||||
}
|
||||
|
||||
|
@ -170,11 +171,15 @@ fn to_str(in: interner<@str>, t: token) -> str {
|
|||
+ str::escape_default(*interner::get(in, s))
|
||||
+ "\""
|
||||
}
|
||||
|
||||
/* Name components */
|
||||
IDENT(s, _) {
|
||||
*interner::get(in, s)
|
||||
}
|
||||
UNDERSCORE { "_" }
|
||||
|
||||
/* Other */
|
||||
DOC_COMMENT(s) { *interner::get(in, s) }
|
||||
EOF { "<eof>" }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -647,7 +647,9 @@ fn print_inner_attributes(s: ps, attrs: ~[ast::attribute]) {
|
|||
alt attr.node.style {
|
||||
ast::attr_inner {
|
||||
print_attribute(s, attr);
|
||||
word(s.s, ";");
|
||||
if !attr.node.is_sugared_doc {
|
||||
word(s.s, ";");
|
||||
}
|
||||
count += 1;
|
||||
}
|
||||
_ {/* fallthrough */ }
|
||||
|
@ -659,9 +661,15 @@ fn print_inner_attributes(s: ps, attrs: ~[ast::attribute]) {
|
|||
fn print_attribute(s: ps, attr: ast::attribute) {
|
||||
hardbreak_if_not_bol(s);
|
||||
maybe_print_comment(s, attr.span.lo);
|
||||
word(s.s, "#[");
|
||||
print_meta_item(s, @attr.node.value);
|
||||
word(s.s, "]");
|
||||
if attr.node.is_sugared_doc {
|
||||
let meta = attr::attr_meta(attr);
|
||||
let comment = attr::get_meta_item_value_str(meta).get();
|
||||
word(s.s, *comment);
|
||||
} else {
|
||||
word(s.s, "#[");
|
||||
print_meta_item(s, @attr.node.value);
|
||||
word(s.s, "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -233,7 +233,8 @@ mod test {
|
|||
ast::meta_name_value(
|
||||
@"crate_type",
|
||||
ast_util::respan(ast_util::dummy_sp(),
|
||||
ast::lit_str(@t))))
|
||||
ast::lit_str(@t)))),
|
||||
is_sugared_doc: false
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -613,7 +613,8 @@ fn get_attributes(md: ebml::doc) -> ~[ast::attribute] {
|
|||
assert (vec::len(meta_items) == 1u);
|
||||
let meta_item = meta_items[0];
|
||||
vec::push(attrs,
|
||||
{node: {style: ast::attr_outer, value: *meta_item},
|
||||
{node: {style: ast::attr_outer, value: *meta_item,
|
||||
is_sugared_doc: false},
|
||||
span: ast_util::dummy_sp()});
|
||||
};
|
||||
}
|
||||
|
|
|
@ -44,7 +44,10 @@ fn doc_meta(
|
|||
doc attribute"];
|
||||
|
||||
let doc_attrs = attr::find_attrs_by_name(attrs, "doc");
|
||||
let doc_metas = attr::attr_metas(doc_attrs);
|
||||
let doc_metas = do doc_attrs.map |attr| {
|
||||
attr::attr_meta(attr::desugar_doc_attr(attr))
|
||||
};
|
||||
|
||||
if vec::is_not_empty(doc_metas) {
|
||||
if vec::len(doc_metas) != 1u {
|
||||
#warn("ignoring %u doc attributes", vec::len(doc_metas) - 1u);
|
||||
|
|
|
@ -6,6 +6,6 @@ fn my_fail() -> ! { fail; }
|
|||
fn main() {
|
||||
alt true { false { my_fail(); } true { } }
|
||||
|
||||
log(debug, x); //! ERROR unresolved name: x
|
||||
log(debug, x); //~ ERROR unresolved name: x
|
||||
let x: int;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ fn main() {
|
|||
rgb(_, _, _) { }
|
||||
cmyk(_, _, _, _) { }
|
||||
no_color(_) { }
|
||||
//!^ ERROR this pattern has 1 field, but the corresponding variant has no fields
|
||||
//~^ ERROR this pattern has 1 field, but the corresponding variant has no fields
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ fn main() {
|
|||
fn foo(c: color) {
|
||||
alt c {
|
||||
rgb(_, _) { }
|
||||
//!^ ERROR this pattern has 2 fields, but the corresponding variant has 3 fields
|
||||
//~^ ERROR this pattern has 2 fields, but the corresponding variant has 3 fields
|
||||
cmyk(_, _, _, _) { }
|
||||
no_color { }
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
impl methods1 for uint { fn me() -> uint { self } } //! NOTE candidate #1 is `methods1::me`
|
||||
impl methods2 for uint { fn me() -> uint { self } } //! NOTE candidate #2 is `methods2::me`
|
||||
fn main() { 1u.me(); } //! ERROR multiple applicable methods in scope
|
||||
impl methods1 for uint { fn me() -> uint { self } } //~ NOTE candidate #1 is `methods1::me`
|
||||
impl methods2 for uint { fn me() -> uint { self } } //~ NOTE candidate #2 is `methods2::me`
|
||||
fn main() { 1u.me(); } //~ ERROR multiple applicable methods in scope
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
// aux-build:ambig_impl_2_lib.rs
|
||||
use ambig_impl_2_lib;
|
||||
import ambig_impl_2_lib::methods1;
|
||||
impl methods2 for uint { fn me() -> uint { self } } //! NOTE candidate #2 is `methods2::me`
|
||||
fn main() { 1u.me(); } //! ERROR multiple applicable methods in scope
|
||||
//!^ NOTE candidate #1 is `ambig_impl_2_lib::methods1::me`
|
||||
impl methods2 for uint { fn me() -> uint { self } } //~ NOTE candidate #2 is `methods2::me`
|
||||
fn main() { 1u.me(); } //~ ERROR multiple applicable methods in scope
|
||||
//~^ NOTE candidate #1 is `ambig_impl_2_lib::methods1::me`
|
||||
|
|
|
@ -2,9 +2,9 @@ iface A { fn foo(); }
|
|||
iface B { fn foo(); }
|
||||
|
||||
fn foo<T: A B>(t: T) {
|
||||
t.foo(); //! ERROR multiple applicable methods in scope
|
||||
//!^ NOTE candidate #1 derives from the bound `A`
|
||||
//!^^ NOTE candidate #2 derives from the bound `B`
|
||||
t.foo(); //~ ERROR multiple applicable methods in scope
|
||||
//~^ NOTE candidate #1 derives from the bound `A`
|
||||
//~^^ NOTE candidate #2 derives from the bound `B`
|
||||
}
|
||||
|
||||
fn main() {}
|
|
@ -1,12 +1,12 @@
|
|||
impl methods for ~[uint] {
|
||||
fn foo() -> int {1} //! NOTE candidate #1 is `methods::foo`
|
||||
fn foo() -> int {1} //~ NOTE candidate #1 is `methods::foo`
|
||||
}
|
||||
|
||||
impl methods for ~[int] {
|
||||
fn foo() -> int {2} //! NOTE candidate #2 is `methods::foo`
|
||||
fn foo() -> int {2} //~ NOTE candidate #2 is `methods::foo`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let x = ~[];
|
||||
x.foo(); //! ERROR multiple applicable methods in scope
|
||||
x.foo(); //~ ERROR multiple applicable methods in scope
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
fn test() {
|
||||
let v: int;
|
||||
v = 1; //! NOTE prior assignment occurs here
|
||||
v = 1; //~ NOTE prior assignment occurs here
|
||||
#debug["v=%d", v];
|
||||
v = 2; //! ERROR re-assignment of immutable variable
|
||||
v = 2; //~ ERROR re-assignment of immutable variable
|
||||
#debug["v=%d", v];
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fn main() {
|
||||
let mut x: ~[mut int] = ~[mut 3];
|
||||
let y: ~[int] = ~[3];
|
||||
x = y; //! ERROR values differ in mutability
|
||||
x = y; //~ ERROR values differ in mutability
|
||||
}
|
|
@ -11,5 +11,5 @@ class cat {
|
|||
|
||||
fn main() {
|
||||
let nyan : cat = cat(52u, 99);
|
||||
nyan.speak = fn@() { #debug["meow"]; }; //! ERROR assigning to method
|
||||
nyan.speak = fn@() { #debug["meow"]; }; //~ ERROR assigning to method
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Check that bogus field access is non-fatal
|
||||
fn main() {
|
||||
let x = 0;
|
||||
log(debug, x.foo); //! ERROR attempted access of field
|
||||
log(debug, x.bar); //! ERROR attempted access of field
|
||||
log(debug, x.foo); //~ ERROR attempted access of field
|
||||
log(debug, x.bar); //~ ERROR attempted access of field
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
#[attr]
|
||||
#debug("hi"); //! ERROR expected item
|
||||
#debug("hi"); //~ ERROR expected item
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
#[attr]
|
||||
let _i = 0; //! ERROR expected item
|
||||
let _i = 0; //~ ERROR expected item
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
fn bad_bang(i: uint) -> ! {
|
||||
ret 7u;
|
||||
//!^ ERROR expected `_|_` but found `uint`
|
||||
//~^ ERROR expected `_|_` but found `uint`
|
||||
}
|
||||
|
||||
fn main() { bad_bang(5u); }
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
fn bad_bang(i: uint) -> ! {
|
||||
if i < 0u { } else { fail; }
|
||||
//!^ ERROR expected `_|_` but found `()`
|
||||
//~^ ERROR expected `_|_` but found `()`
|
||||
}
|
||||
|
||||
fn main() { bad_bang(5u); }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
fn baz(_x: fn() -> int) {}
|
||||
for baz |_e| { } //! ERROR should return `bool`
|
||||
for baz |_e| { } //~ ERROR should return `bool`
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fn foo<T>() {
|
||||
1u.bar::<T>(); //! ERROR: missing `copy`
|
||||
1u.bar::<T>(); //~ ERROR: missing `copy`
|
||||
}
|
||||
|
||||
impl methods for uint {
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
fn false() { } //! ERROR found `false` in restricted position
|
||||
fn false() { } //~ ERROR found `false` in restricted position
|
||||
fn main() { }
|
|
@ -1,2 +1,2 @@
|
|||
fn true() { } //! ERROR found `true` in restricted position
|
||||
fn true() { } //~ ERROR found `true` in restricted position
|
||||
fn main() { }
|
|
@ -2,6 +2,6 @@ fn main() {
|
|||
let x = 3;
|
||||
fn blah(_a: native fn()) {}
|
||||
blah(|| {
|
||||
log(debug, x); //! ERROR attempted dynamic environment capture
|
||||
log(debug, x); //~ ERROR attempted dynamic environment capture
|
||||
});
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
fn f() -> ! {
|
||||
3i //! ERROR expected `_|_` but found `int`
|
||||
3i //~ ERROR expected `_|_` but found `int`
|
||||
}
|
||||
fn main() { }
|
||||
|
|
|
@ -4,5 +4,5 @@ fn main() {
|
|||
let x = true;
|
||||
let y = 1;
|
||||
let z = x + y;
|
||||
//!^ ERROR binary operation + cannot be applied to type `bool`
|
||||
//~^ ERROR binary operation + cannot be applied to type `bool`
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ fn compute1() -> float {
|
|||
let v = ~[0f, 1f, 2f, 3f];
|
||||
|
||||
do vec::foldl(0f, v) |x, y| { x + y } - 10f
|
||||
//!^ ERROR mismatched types: expected `()`
|
||||
//~^ ERROR mismatched types: expected `()`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -9,5 +9,5 @@ fn main() {
|
|||
}
|
||||
|
||||
f(g);
|
||||
//!^ ERROR mismatched types: expected `extern fn(extern fn(extern fn()))`
|
||||
//~^ ERROR mismatched types: expected `extern fn(extern fn(extern fn()))`
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ fn coerce(b: fn()) -> native fn() {
|
|||
g: fn()) -> native fn() { ret f(g); }
|
||||
fn fn_id(f: native fn()) -> native fn() { ret f }
|
||||
ret lol(fn_id, b);
|
||||
//!^ ERROR mismatched types: expected `extern fn(fn()) -> extern fn()`
|
||||
//~^ ERROR mismatched types: expected `extern fn(fn()) -> extern fn()`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -4,9 +4,9 @@ fn a() {
|
|||
let mut p = ~[mut 1];
|
||||
|
||||
// Create an immutable pointer into p's contents:
|
||||
let _q: &int = &p[0]; //! NOTE loan of mutable vec content granted here
|
||||
let _q: &int = &p[0]; //~ NOTE loan of mutable vec content granted here
|
||||
|
||||
p[0] = 5; //! ERROR assigning to mutable vec content prohibited due to outstanding loan
|
||||
p[0] = 5; //~ ERROR assigning to mutable vec content prohibited due to outstanding loan
|
||||
}
|
||||
|
||||
fn borrow(_x: &[int], _f: fn()) {}
|
||||
|
@ -17,8 +17,8 @@ fn b() {
|
|||
|
||||
let mut p = ~[mut 1];
|
||||
|
||||
do borrow(p) || { //! NOTE loan of mutable vec content granted here
|
||||
p[0] = 5; //! ERROR assigning to mutable vec content prohibited due to outstanding loan
|
||||
do borrow(p) || { //~ NOTE loan of mutable vec content granted here
|
||||
p[0] = 5; //~ ERROR assigning to mutable vec content prohibited due to outstanding loan
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,12 @@ type point = { x: int, y: int };
|
|||
|
||||
fn a() {
|
||||
let mut p = {x: 3, y: 4};
|
||||
let _q = &p; //! NOTE loan of mutable local variable granted here
|
||||
let _q = &p; //~ NOTE loan of mutable local variable granted here
|
||||
|
||||
// This assignment is illegal because the field x is not
|
||||
// inherently mutable; since `p` was made immutable, `p.x` is now
|
||||
// immutable. Otherwise the type of &_q.x (&int) would be wrong.
|
||||
p.x = 5; //! ERROR assigning to mutable field prohibited due to outstanding loan
|
||||
p.x = 5; //~ ERROR assigning to mutable field prohibited due to outstanding loan
|
||||
}
|
||||
|
||||
fn b() {
|
||||
|
@ -24,8 +24,8 @@ fn c() {
|
|||
// and then try to overwrite `p` as a whole.
|
||||
|
||||
let mut p = {x: 3, mut y: 4};
|
||||
let _q = &p.y; //! NOTE loan of mutable local variable granted here
|
||||
p = {x: 5, mut y: 7};//! ERROR assigning to mutable local variable prohibited due to outstanding loan
|
||||
let _q = &p.y; //~ NOTE loan of mutable local variable granted here
|
||||
p = {x: 5, mut y: 7};//~ ERROR assigning to mutable local variable prohibited due to outstanding loan
|
||||
copy p;
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,8 @@ fn d() {
|
|||
// address of a subcomponent and then modify that subcomponent:
|
||||
|
||||
let mut p = {x: 3, mut y: 4};
|
||||
let _q = &p.y; //! NOTE loan of mutable field granted here
|
||||
p.y = 5; //! ERROR assigning to mutable field prohibited due to outstanding loan
|
||||
let _q = &p.y; //~ NOTE loan of mutable field granted here
|
||||
p.y = 5; //~ ERROR assigning to mutable field prohibited due to outstanding loan
|
||||
copy p;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@ const foo: int = 5;
|
|||
|
||||
fn main() {
|
||||
// assigning to various global constants
|
||||
none = some(3); //! ERROR assigning to static item
|
||||
foo = 6; //! ERROR assigning to static item
|
||||
none = some(3); //~ ERROR assigning to static item
|
||||
foo = 6; //~ ERROR assigning to static item
|
||||
}
|
|
@ -2,5 +2,5 @@ enum foo = int;
|
|||
|
||||
fn main() {
|
||||
let x = foo(3);
|
||||
*x = 4; //! ERROR assigning to enum content
|
||||
*x = 4; //~ ERROR assigning to enum content
|
||||
}
|
|
@ -14,7 +14,7 @@ fn main() {
|
|||
|
||||
// in these cases we pass through a box, so the mut
|
||||
// of the box is dominant
|
||||
p.x.a = 2; //! ERROR assigning to immutable field
|
||||
p.y.a = 2; //! ERROR assigning to const field
|
||||
p.x.a = 2; //~ ERROR assigning to immutable field
|
||||
p.y.a = 2; //~ ERROR assigning to const field
|
||||
p.z.a = 2;
|
||||
}
|
|
@ -6,8 +6,8 @@ fn main() {
|
|||
|
||||
alt x {
|
||||
{f: v} => {
|
||||
impure(v); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
impure(v); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
fn main() {
|
||||
let x = some(~1);
|
||||
alt x { //! NOTE loan of immutable local variable granted here
|
||||
alt x { //~ NOTE loan of immutable local variable granted here
|
||||
some(y) {
|
||||
let _a <- x; //! ERROR moving out of immutable local variable prohibited due to outstanding loan
|
||||
let _a <- x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
|
||||
}
|
||||
_ {}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ fn main() {
|
|||
let x = some(~1);
|
||||
alt x {
|
||||
some(y) {
|
||||
let _b <- y; //! ERROR moving out of pattern binding
|
||||
let _b <- y; //~ ERROR moving out of pattern binding
|
||||
}
|
||||
_ {}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ fn borrow_from_arg_imm_ref(&&v: ~int) {
|
|||
}
|
||||
|
||||
fn borrow_from_arg_mut_ref(&v: ~int) {
|
||||
borrow(v); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn borrow_from_arg_move(-v: ~int) {
|
||||
|
|
|
@ -19,23 +19,23 @@ fn post_aliased_const() {
|
|||
fn post_aliased_mut() {
|
||||
// SPURIOUS--flow
|
||||
let mut v = ~3;
|
||||
borrow(v); //! ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
let _w = &mut v; //! NOTE prior loan as mutable granted here
|
||||
borrow(v); //~ ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
let _w = &mut v; //~ NOTE prior loan as mutable granted here
|
||||
}
|
||||
|
||||
fn post_aliased_scope(cond: bool) {
|
||||
// NDM--scope of &
|
||||
let mut v = ~3;
|
||||
borrow(v); //! ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
if cond { inc(&mut v); } //! NOTE prior loan as mutable granted here
|
||||
borrow(v); //~ ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
if cond { inc(&mut v); } //~ NOTE prior loan as mutable granted here
|
||||
}
|
||||
|
||||
fn loop_aliased_mut() {
|
||||
let mut v = ~3, w = ~4;
|
||||
let mut _x = &mut w;
|
||||
loop {
|
||||
borrow(v); //! ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
_x = &mut v; //! NOTE prior loan as mutable granted here
|
||||
borrow(v); //~ ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
_x = &mut v; //~ NOTE prior loan as mutable granted here
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,8 @@ fn while_aliased_mut(cond: bool) {
|
|||
let mut v = ~3, w = ~4;
|
||||
let mut _x = &mut w;
|
||||
while cond {
|
||||
borrow(v); //! ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
_x = &mut v; //! NOTE prior loan as mutable granted here
|
||||
borrow(v); //~ ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
_x = &mut v; //~ NOTE prior loan as mutable granted here
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,9 +52,9 @@ fn while_aliased_mut_cond(cond: bool, cond2: bool) {
|
|||
let mut v = ~3, w = ~4;
|
||||
let mut _x = &mut w;
|
||||
while cond {
|
||||
borrow(v); //! ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
borrow(v); //~ ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
if cond2 {
|
||||
_x = &mut v; //! NOTE prior loan as mutable granted here
|
||||
_x = &mut v; //~ NOTE prior loan as mutable granted here
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ fn loop_in_block() {
|
|||
let mut v = ~3, w = ~4;
|
||||
let mut _x = &mut w;
|
||||
for uint::range(0u, 10u) |_i| {
|
||||
borrow(v); //! ERROR loan of mutable variable declared in an outer block as immutable conflicts with prior loan
|
||||
_x = &mut v; //! NOTE prior loan as mutable granted here
|
||||
borrow(v); //~ ERROR loan of mutable variable declared in an outer block as immutable conflicts with prior loan
|
||||
_x = &mut v; //~ NOTE prior loan as mutable granted here
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,8 @@ fn at_most_once_block() {
|
|||
let mut v = ~3, w = ~4;
|
||||
let mut _x = &mut w;
|
||||
do at_most_once || {
|
||||
borrow(v); //! ERROR loan of mutable variable declared in an outer block as immutable conflicts with prior loan
|
||||
_x = &mut v; //! NOTE prior loan as mutable granted here
|
||||
borrow(v); //~ ERROR loan of mutable variable declared in an outer block as immutable conflicts with prior loan
|
||||
_x = &mut v; //~ NOTE prior loan as mutable granted here
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,16 +4,16 @@ fn borrow(v: &int, f: fn(x: &int)) {
|
|||
|
||||
fn box_imm() {
|
||||
let mut v = ~3;
|
||||
let _w = &mut v; //! NOTE loan of mutable local variable granted here
|
||||
let _w = &mut v; //~ NOTE loan of mutable local variable granted here
|
||||
do task::spawn |move v| {
|
||||
//!^ ERROR moving out of mutable local variable prohibited due to outstanding loan
|
||||
//~^ ERROR moving out of mutable local variable prohibited due to outstanding loan
|
||||
#debug["v=%d", *v];
|
||||
}
|
||||
|
||||
let mut v = ~3;
|
||||
let _w = &mut v; //! NOTE loan of mutable local variable granted here
|
||||
let _w = &mut v; //~ NOTE loan of mutable local variable granted here
|
||||
task::spawn(fn~(move v) {
|
||||
//!^ ERROR moving out of mutable local variable prohibited due to outstanding loan
|
||||
//~^ ERROR moving out of mutable local variable prohibited due to outstanding loan
|
||||
#debug["v=%d", *v];
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ fn take(-_v: ~int) {
|
|||
|
||||
fn box_imm() {
|
||||
let v = ~3;
|
||||
let _w = &v; //! NOTE loan of immutable local variable granted here
|
||||
take(v); //! ERROR moving out of immutable local variable prohibited due to outstanding loan
|
||||
let _w = &v; //~ NOTE loan of immutable local variable granted here
|
||||
take(v); //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -4,8 +4,8 @@ fn borrow(v: &int, f: fn(x: &int)) {
|
|||
|
||||
fn box_imm() {
|
||||
let mut v = ~3;
|
||||
do borrow(v) |w| { //! NOTE loan of mutable local variable granted here
|
||||
v = ~4; //! ERROR assigning to mutable variable declared in an outer block prohibited due to outstanding loan
|
||||
do borrow(v) |w| { //~ NOTE loan of mutable local variable granted here
|
||||
v = ~4; //~ ERROR assigning to mutable variable declared in an outer block prohibited due to outstanding loan
|
||||
assert *v == 3;
|
||||
assert *w == 4;
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ fn b() {
|
|||
|
||||
// Here I create an outstanding loan and check that we get conflicts:
|
||||
|
||||
&mut p; //! NOTE prior loan as mutable granted here
|
||||
//!^ NOTE prior loan as mutable granted here
|
||||
&mut p; //~ NOTE prior loan as mutable granted here
|
||||
//~^ NOTE prior loan as mutable granted here
|
||||
|
||||
p + 3; //! ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
p * 3; //! ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
p + 3; //~ ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
p * 3; //~ ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
}
|
||||
|
||||
fn c() {
|
||||
|
@ -35,8 +35,8 @@ fn c() {
|
|||
|
||||
|
||||
// ...but not impure fns
|
||||
*q * 3; //! ERROR illegal borrow unless pure: creating immutable alias to aliasable, mutable memory
|
||||
//!^ NOTE impure due to access to impure function
|
||||
*q * 3; //~ ERROR illegal borrow unless pure: creating immutable alias to aliasable, mutable memory
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -19,8 +19,8 @@ fn a() {
|
|||
p.impurem();
|
||||
|
||||
// But in this case we do not honor the loan:
|
||||
do p.blockm || { //! NOTE loan of mutable local variable granted here
|
||||
p.x = 10; //! ERROR assigning to mutable field prohibited due to outstanding loan
|
||||
do p.blockm || { //~ NOTE loan of mutable local variable granted here
|
||||
p.x = 10; //~ ERROR assigning to mutable field prohibited due to outstanding loan
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,11 +29,11 @@ fn b() {
|
|||
|
||||
// Here I create an outstanding loan and check that we get conflicts:
|
||||
|
||||
&mut p; //! NOTE prior loan as mutable granted here
|
||||
//!^ NOTE prior loan as mutable granted here
|
||||
&mut p; //~ NOTE prior loan as mutable granted here
|
||||
//~^ NOTE prior loan as mutable granted here
|
||||
|
||||
p.purem(); //! ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
p.impurem(); //! ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
p.purem(); //~ ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
p.impurem(); //~ ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
}
|
||||
|
||||
fn c() {
|
||||
|
@ -45,8 +45,8 @@ fn c() {
|
|||
(*q).purem();
|
||||
|
||||
// ...but not impure fns
|
||||
(*q).impurem(); //! ERROR illegal borrow unless pure: creating immutable alias to aliasable, mutable memory
|
||||
//!^ NOTE impure due to access to impure function
|
||||
(*q).impurem(); //~ ERROR illegal borrow unless pure: creating immutable alias to aliasable, mutable memory
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -14,8 +14,8 @@ fn has_mut_vec_and_does_not_try_to_change_it() {
|
|||
|
||||
fn has_mut_vec_but_tries_to_change_it() {
|
||||
let v = ~[mut 1, 2, 3];
|
||||
do takes_imm_elt(&v[0]) || { //! NOTE loan of mutable vec content granted here
|
||||
v[1] = 4; //! ERROR assigning to mutable vec content prohibited due to outstanding loan
|
||||
do takes_imm_elt(&v[0]) || { //~ NOTE loan of mutable vec content granted here
|
||||
v[1] = 4; //~ ERROR assigning to mutable vec content prohibited due to outstanding loan
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fn foo(x: *~int) -> ~int {
|
||||
let y <- *x; //! ERROR dereference of unsafe pointer requires unsafe function or block
|
||||
let y <- *x; //~ ERROR dereference of unsafe pointer requires unsafe function or block
|
||||
ret y;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
fn main() {
|
||||
let x: int = 3;
|
||||
let y: &mut int = &mut x; //! ERROR taking mut reference to immutable local variable
|
||||
let y: &mut int = &mut x; //~ ERROR taking mut reference to immutable local variable
|
||||
*y = 5;
|
||||
log (debug, *y);
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ fn want_slice(v: &[int]) -> int {
|
|||
}
|
||||
|
||||
fn has_mut_vec(+v: @~[mut int]) -> int {
|
||||
want_slice(*v) //! ERROR illegal borrow unless pure: creating immutable alias to aliasable, mutable memory
|
||||
//!^ NOTE impure due to access to impure function
|
||||
want_slice(*v) //~ ERROR illegal borrow unless pure: creating immutable alias to aliasable, mutable memory
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -5,9 +5,9 @@ enum cycle {
|
|||
fn main() {
|
||||
let x = ~node({mut a: ~empty});
|
||||
// Create a cycle!
|
||||
alt check *x { //! NOTE loan of immutable local variable granted here
|
||||
alt check *x { //~ NOTE loan of immutable local variable granted here
|
||||
node(y) {
|
||||
y.a <- x; //! ERROR moving out of immutable local variable prohibited due to outstanding loan
|
||||
y.a <- x; //~ ERROR moving out of immutable local variable prohibited due to outstanding loan
|
||||
}
|
||||
};
|
||||
}
|
|
@ -27,8 +27,8 @@ fn process(_i: int) {}
|
|||
|
||||
fn match_const_box_and_do_bad_things(v: &const @const option<int>) {
|
||||
alt *v {
|
||||
@some(i) { //! ERROR illegal borrow unless pure: enum variant in aliasable, mutable location
|
||||
process(i) //! NOTE impure due to access to impure function
|
||||
@some(i) { //~ ERROR illegal borrow unless pure: enum variant in aliasable, mutable location
|
||||
process(i) //~ NOTE impure due to access to impure function
|
||||
}
|
||||
@none {}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ fn match_const_reg_unused(v: &const option<int>) {
|
|||
|
||||
fn match_const_reg_impure(v: &const option<int>) {
|
||||
alt *v {
|
||||
some(i) {impure(i)} //! ERROR illegal borrow unless pure: enum variant in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
some(i) {impure(i)} //~ ERROR illegal borrow unless pure: enum variant in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
none {}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
fn main() {
|
||||
let mut x: option<int> = none;
|
||||
alt x { //! NOTE loan of mutable local variable granted here
|
||||
alt x { //~ NOTE loan of mutable local variable granted here
|
||||
none {}
|
||||
some(i) {
|
||||
// Not ok: i is an outstanding ptr into x.
|
||||
x = some(i+1); //! ERROR assigning to mutable local variable prohibited due to outstanding loan
|
||||
x = some(i+1); //~ ERROR assigning to mutable local variable prohibited due to outstanding loan
|
||||
}
|
||||
}
|
||||
copy x; // just to prevent liveness warnings
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
fn main() {
|
||||
let mut x = none;
|
||||
alt x { //! NOTE loan of mutable local variable granted here
|
||||
alt x { //~ NOTE loan of mutable local variable granted here
|
||||
none {
|
||||
// It is ok to reassign x here, because there is in
|
||||
// fact no outstanding loan of x!
|
||||
x = some(0);
|
||||
}
|
||||
some(i) {
|
||||
x = some(1); //! ERROR assigning to mutable local variable prohibited due to outstanding loan
|
||||
x = some(1); //~ ERROR assigning to mutable local variable prohibited due to outstanding loan
|
||||
}
|
||||
}
|
||||
copy x; // just to prevent liveness warnings
|
||||
|
|
|
@ -4,8 +4,8 @@ fn test1(x: @mut ~int) {
|
|||
// Here, evaluating the second argument actually invalidates the
|
||||
// first borrow, even though it occurs outside of the scope of the
|
||||
// borrow!
|
||||
pure_borrow(*x, *x = ~5); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to assigning to dereference of mutable @ pointer
|
||||
pure_borrow(*x, *x = ~5); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to assigning to dereference of mutable @ pointer
|
||||
}
|
||||
|
||||
fn test2() {
|
||||
|
@ -13,8 +13,8 @@ fn test2() {
|
|||
|
||||
// Same, but for loanable data:
|
||||
|
||||
pure_borrow(x, x = ~5); //! ERROR assigning to mutable local variable prohibited due to outstanding loan
|
||||
//!^ NOTE loan of mutable local variable granted here
|
||||
pure_borrow(x, x = ~5); //~ ERROR assigning to mutable local variable prohibited due to outstanding loan
|
||||
//~^ NOTE loan of mutable local variable granted here
|
||||
|
||||
copy x;
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ fn impure(_i: int) {}
|
|||
fn foo(v: &const option<int>) {
|
||||
alt *v {
|
||||
some(i) {
|
||||
//!^ ERROR illegal borrow unless pure: enum variant in aliasable, mutable location
|
||||
//~^ ERROR illegal borrow unless pure: enum variant in aliasable, mutable location
|
||||
unchecked {
|
||||
impure(i); //! NOTE impure due to access to impure function
|
||||
impure(i); //~ NOTE impure due to access to impure function
|
||||
}
|
||||
}
|
||||
none {
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
fn borrow(_v: &int) {}
|
||||
|
||||
fn box_mut(v: @mut ~int) {
|
||||
borrow(*v); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(*v); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_rec_mut(v: @{mut f: ~int}) {
|
||||
borrow(v.f); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_mut_rec(v: @mut {f: ~int}) {
|
||||
borrow(v.f); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_mut_recs(v: @mut {f: {g: {h: ~int}}}) {
|
||||
borrow(v.f.g.h); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f.g.h); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_imm(v: @~int) {
|
||||
|
@ -33,28 +33,28 @@ fn box_imm_recs(v: @{f: {g: {h: ~int}}}) {
|
|||
}
|
||||
|
||||
fn box_const(v: @const ~int) {
|
||||
borrow(*v); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(*v); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_rec_const(v: @{const f: ~int}) {
|
||||
borrow(v.f); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_recs_const(v: @{f: {g: {const h: ~int}}}) {
|
||||
borrow(v.f.g.h); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f.g.h); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_const_rec(v: @const {f: ~int}) {
|
||||
borrow(v.f); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_const_recs(v: @const {f: {g: {h: ~int}}}) {
|
||||
borrow(v.f.g.h); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f.g.h); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -29,8 +29,8 @@ fn aliased_const() {
|
|||
|
||||
fn aliased_mut() {
|
||||
let mut v = ~3;
|
||||
let _w = &mut v; //! NOTE prior loan as mutable granted here
|
||||
borrow(v); //! ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
let _w = &mut v; //~ NOTE prior loan as mutable granted here
|
||||
borrow(v); //~ ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
}
|
||||
|
||||
fn aliased_other() {
|
||||
|
@ -42,8 +42,8 @@ fn aliased_other() {
|
|||
fn aliased_other_reassign() {
|
||||
let mut v = ~3, w = ~4;
|
||||
let mut _x = &mut w;
|
||||
_x = &mut v; //! NOTE prior loan as mutable granted here
|
||||
borrow(v); //! ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
_x = &mut v; //~ NOTE prior loan as mutable granted here
|
||||
borrow(v); //~ ERROR loan of mutable local variable as immutable conflicts with prior loan
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
fn borrow(_v: &int) {}
|
||||
|
||||
fn box_mut(v: &mut ~int) {
|
||||
borrow(*v); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(*v); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_rec_mut(v: &{mut f: ~int}) {
|
||||
borrow(v.f); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_mut_rec(v: &mut {f: ~int}) {
|
||||
borrow(v.f); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_mut_recs(v: &mut {f: {g: {h: ~int}}}) {
|
||||
borrow(v.f.g.h); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f.g.h); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_imm(v: &~int) {
|
||||
|
@ -33,28 +33,28 @@ fn box_imm_recs(v: &{f: {g: {h: ~int}}}) {
|
|||
}
|
||||
|
||||
fn box_const(v: &const ~int) {
|
||||
borrow(*v); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(*v); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_rec_const(v: &{const f: ~int}) {
|
||||
borrow(v.f); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_recs_const(v: &{f: {g: {const h: ~int}}}) {
|
||||
borrow(v.f.g.h); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f.g.h); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_const_rec(v: &const {f: ~int}) {
|
||||
borrow(v.f); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn box_const_recs(v: &const {f: {g: {h: ~int}}}) {
|
||||
borrow(v.f.g.h); //! ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//!^ NOTE impure due to access to impure function
|
||||
borrow(v.f.g.h); //~ ERROR illegal borrow unless pure: unique value in aliasable, mutable location
|
||||
//~^ NOTE impure due to access to impure function
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
fn main() {
|
||||
let x = 5;
|
||||
let _y = fn~(move x) -> int {
|
||||
let _z = fn~(move x) -> int { x }; //! ERROR moving out of variable declared in an outer block
|
||||
let _z = fn~(move x) -> int { x }; //~ ERROR moving out of variable declared in an outer block
|
||||
22
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ fn main() {
|
|||
foo(|| bar(x) );
|
||||
|
||||
let x = @3;
|
||||
foo(|copy x| bar(x) ); //! ERROR cannot capture values explicitly with a block closure
|
||||
foo(|copy x| bar(x) ); //~ ERROR cannot capture values explicitly with a block closure
|
||||
|
||||
let x = @3;
|
||||
foo(|move x| bar(x) ); //! ERROR cannot capture values explicitly with a block closure
|
||||
foo(|move x| bar(x) ); //~ ERROR cannot capture values explicitly with a block closure
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class cat : int { //! ERROR can only implement interface types
|
||||
class cat : int { //~ ERROR can only implement interface types
|
||||
let meows: uint;
|
||||
new(in_x : uint) { self.meows = in_x; }
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ class cat {
|
|||
fn sleep() { loop{} }
|
||||
fn meow() {
|
||||
#error("Meow");
|
||||
meows += 1u; //! ERROR unresolved name
|
||||
sleep(); //! ERROR unresolved name
|
||||
meows += 1u; //~ ERROR unresolved name
|
||||
sleep(); //~ ERROR unresolved name
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fn main() {
|
||||
do something
|
||||
|x| do somethingelse //! ERROR: expecting '{' but found 'do'
|
||||
|x| do somethingelse //~ ERROR: expecting '{' but found 'do'
|
||||
|y| say(x, y)
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
let x = do y; //! ERROR: expecting '{' but found
|
||||
let x = do y; //~ ERROR: expecting '{' but found
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
fn f(f: fn@(int) -> bool) -> bool { f(10i) }
|
||||
|
||||
fn main() {
|
||||
assert do f() |i| { i == 10i } == 10i; //! ERROR: expected `bool` but found `int`
|
||||
assert do f() |i| { i == 10i } == 10i; //~ ERROR: expected `bool` but found `int`
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
fn main() {
|
||||
let v = ~[,]; //! ERROR unexpected token: ','
|
||||
let v = ~[,]; //~ ERROR unexpected token: ','
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
enum hello = int;
|
||||
|
||||
fn main() {
|
||||
let hello = 0; //!ERROR declaration of `hello` shadows an enum that's in
|
||||
let hello = 0; //~ERROR declaration of `hello` shadows an enum that's in
|
||||
}
|
|
@ -4,26 +4,26 @@ fn wants_three(x: str/3) { }
|
|||
|
||||
fn has_box(x: str/@) {
|
||||
wants_box(x);
|
||||
wants_uniq(x); //! ERROR str storage differs: expected ~ but found @
|
||||
wants_three(x); //! ERROR str storage differs: expected 3 but found @
|
||||
wants_uniq(x); //~ ERROR str storage differs: expected ~ but found @
|
||||
wants_three(x); //~ ERROR str storage differs: expected 3 but found @
|
||||
}
|
||||
|
||||
fn has_uniq(x: str/~) {
|
||||
wants_box(x); //! ERROR str storage differs: expected @ but found ~
|
||||
wants_box(x); //~ ERROR str storage differs: expected @ but found ~
|
||||
wants_uniq(x);
|
||||
wants_three(x); //! ERROR str storage differs: expected 3 but found ~
|
||||
wants_three(x); //~ ERROR str storage differs: expected 3 but found ~
|
||||
}
|
||||
|
||||
fn has_three(x: str/3) {
|
||||
wants_box(x); //! ERROR str storage differs: expected @ but found 3
|
||||
wants_uniq(x); //! ERROR str storage differs: expected ~ but found 3
|
||||
wants_box(x); //~ ERROR str storage differs: expected @ but found 3
|
||||
wants_uniq(x); //~ ERROR str storage differs: expected ~ but found 3
|
||||
wants_three(x);
|
||||
}
|
||||
|
||||
fn has_four(x: str/4) {
|
||||
wants_box(x); //! ERROR str storage differs: expected @ but found 4
|
||||
wants_uniq(x); //! ERROR str storage differs: expected ~ but found 4
|
||||
wants_three(x); //! ERROR str storage differs: expected 3 but found 4
|
||||
wants_box(x); //~ ERROR str storage differs: expected @ but found 4
|
||||
wants_uniq(x); //~ ERROR str storage differs: expected ~ but found 4
|
||||
wants_three(x); //~ ERROR str storage differs: expected 3 but found 4
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -4,26 +4,26 @@ fn wants_three(x: [uint]/3) { }
|
|||
|
||||
fn has_box(x: @[uint]) {
|
||||
wants_box(x);
|
||||
wants_uniq(x); //! ERROR [] storage differs: expected ~ but found @
|
||||
wants_three(x); //! ERROR [] storage differs: expected 3 but found @
|
||||
wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found @
|
||||
wants_three(x); //~ ERROR [] storage differs: expected 3 but found @
|
||||
}
|
||||
|
||||
fn has_uniq(x: ~[uint]) {
|
||||
wants_box(x); //! ERROR [] storage differs: expected @ but found ~
|
||||
wants_box(x); //~ ERROR [] storage differs: expected @ but found ~
|
||||
wants_uniq(x);
|
||||
wants_three(x); //! ERROR [] storage differs: expected 3 but found ~
|
||||
wants_three(x); //~ ERROR [] storage differs: expected 3 but found ~
|
||||
}
|
||||
|
||||
fn has_three(x: [uint]/3) {
|
||||
wants_box(x); //! ERROR [] storage differs: expected @ but found 3
|
||||
wants_uniq(x); //! ERROR [] storage differs: expected ~ but found 3
|
||||
wants_box(x); //~ ERROR [] storage differs: expected @ but found 3
|
||||
wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found 3
|
||||
wants_three(x);
|
||||
}
|
||||
|
||||
fn has_four(x: [uint]/4) {
|
||||
wants_box(x); //! ERROR [] storage differs: expected @ but found 4
|
||||
wants_uniq(x); //! ERROR [] storage differs: expected ~ but found 4
|
||||
wants_three(x); //! ERROR [] storage differs: expected 3 but found 4
|
||||
wants_box(x); //~ ERROR [] storage differs: expected @ but found 4
|
||||
wants_uniq(x); //~ ERROR [] storage differs: expected ~ but found 4
|
||||
wants_three(x); //~ ERROR [] storage differs: expected 3 but found 4
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -2,5 +2,5 @@ fn main() {
|
|||
fn f() { }
|
||||
fn g(i: int) { }
|
||||
let x = f == g;
|
||||
//!^ ERROR expected `extern fn()` but found `extern fn(int)`
|
||||
//~^ ERROR expected `extern fn()` but found `extern fn(int)`
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ fn apply<T>(t: T, f: fn(T)) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
apply(@3, takes_mut); //! ERROR (values differ in mutability)
|
||||
apply(@3, takes_mut); //~ ERROR (values differ in mutability)
|
||||
apply(@3, takes_const);
|
||||
apply(@3, takes_imm);
|
||||
|
||||
apply(@mut 3, takes_mut);
|
||||
apply(@mut 3, takes_const);
|
||||
apply(@mut 3, takes_imm); //! ERROR (values differ in mutability)
|
||||
apply(@mut 3, takes_imm); //~ ERROR (values differ in mutability)
|
||||
}
|
||||
|
|
|
@ -18,5 +18,5 @@ fn main() {
|
|||
let g: @const int = r();
|
||||
|
||||
// Bad.
|
||||
let h: @int = r(); //! ERROR (values differ in mutability)
|
||||
let h: @int = r(); //~ ERROR (values differ in mutability)
|
||||
}
|
||||
|
|
|
@ -20,5 +20,5 @@ fn main() {
|
|||
// mutability check will fail, because the
|
||||
// type of r has been inferred to be
|
||||
// fn(@const int) -> @const int
|
||||
*r(@mut 3) = 4; //! ERROR assigning to dereference of const @ pointer
|
||||
*r(@mut 3) = 4; //~ ERROR assigning to dereference of const @ pointer
|
||||
}
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
fn main() {
|
||||
let x: option<uint>;
|
||||
x = 5;
|
||||
//!^ ERROR mismatched types: expected `core::option::option<uint>`
|
||||
//~^ ERROR mismatched types: expected `core::option::option<uint>`
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ mod y {
|
|||
|
||||
fn bar(x: x::foo) -> y::foo {
|
||||
ret x;
|
||||
//!^ ERROR mismatched types: expected `y::foo` but found `x::foo`
|
||||
//~^ ERROR mismatched types: expected `y::foo` but found `x::foo`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -5,7 +5,7 @@ type T2 = int;
|
|||
|
||||
fn bar(x: T1) -> T2 {
|
||||
ret x;
|
||||
//!^ ERROR mismatched types: expected `T2` but found `T1`
|
||||
//~^ ERROR mismatched types: expected `T2` but found `T1`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -4,7 +4,7 @@ import core::task::task;
|
|||
|
||||
fn bar(x: uint) -> task {
|
||||
ret x;
|
||||
//!^ ERROR mismatched types: expected `core::task::task`
|
||||
//~^ ERROR mismatched types: expected `core::task::task`
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -2,7 +2,7 @@ iface foo<T> { }
|
|||
|
||||
fn bar(x: foo<uint>) -> foo<int> {
|
||||
ret (x as foo::<int>);
|
||||
//!^ ERROR mismatched types: expected `foo<int>` but found `foo<uint>`
|
||||
//~^ ERROR mismatched types: expected `foo<int>` but found `foo<uint>`
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -3,7 +3,7 @@ iface foo {
|
|||
}
|
||||
impl of foo for int {
|
||||
fn bar() -> int {
|
||||
//!^ ERROR method `bar` has 0 parameters but the iface has 1
|
||||
//~^ ERROR method `bar` has 0 parameters but the iface has 1
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ impl of bar for uint { fn dup() -> uint { self } fn blah<X>() {} }
|
|||
impl of bar for uint { fn dup() -> uint { self } fn blah<X>() {} }
|
||||
|
||||
fn main() {
|
||||
10.dup::<int>(); //! ERROR does not take type parameters
|
||||
10.blah::<int, int>(); //! ERROR incorrect number of type parameters
|
||||
10u.dup(); //! ERROR multiple applicable methods
|
||||
(10 as bar).dup(); //! ERROR contains a self type
|
||||
10.dup::<int>(); //~ ERROR does not take type parameters
|
||||
10.blah::<int, int>(); //~ ERROR incorrect number of type parameters
|
||||
10u.dup(); //~ ERROR multiple applicable methods
|
||||
(10 as bar).dup(); //~ ERROR contains a self type
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
iface foo { fn foo(); }
|
||||
|
||||
impl of foo for uint {} //! ERROR missing method `foo`
|
||||
impl of foo for uint {} //~ ERROR missing method `foo`
|
||||
|
||||
impl of foo for uint { fn foo() -> int {} } //! ERROR incompatible type
|
||||
impl of foo for uint { fn foo() -> int {} } //~ ERROR incompatible type
|
||||
|
||||
impl of int for uint { fn foo() {} } //! ERROR can only implement interface
|
||||
impl of int for uint { fn foo() {} } //~ ERROR can only implement interface
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
fn g() { }
|
||||
|
||||
pure fn f(_q: int) -> bool {
|
||||
g(); //! ERROR access to impure function prohibited in pure context
|
||||
g(); //~ ERROR access to impure function prohibited in pure context
|
||||
ret true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
fn main() {
|
||||
let z = ();
|
||||
log(debug, z[0]); //! ERROR cannot index a value of type `()`
|
||||
log(debug, z[0]); //~ ERROR cannot index a value of type `()`
|
||||
}
|
||||
|
|
|
@ -29,62 +29,62 @@ fn main() {
|
|||
fn id_u64(n: u64) -> u64 { n }
|
||||
|
||||
id_i8(a8); // ok
|
||||
id_i8(a16); //! ERROR mismatched types: expected `i8` but found `i16`
|
||||
id_i8(a32); //! ERROR mismatched types: expected `i8` but found `i32`
|
||||
id_i8(a64); //! ERROR mismatched types: expected `i8` but found `i64`
|
||||
id_i8(a16); //~ ERROR mismatched types: expected `i8` but found `i16`
|
||||
id_i8(a32); //~ ERROR mismatched types: expected `i8` but found `i32`
|
||||
id_i8(a64); //~ ERROR mismatched types: expected `i8` but found `i64`
|
||||
|
||||
id_i16(a8); //! ERROR mismatched types: expected `i16` but found `i8`
|
||||
id_i16(a8); //~ ERROR mismatched types: expected `i16` but found `i8`
|
||||
id_i16(a16); // ok
|
||||
id_i16(a32); //! ERROR mismatched types: expected `i16` but found `i32`
|
||||
id_i16(a64); //! ERROR mismatched types: expected `i16` but found `i64`
|
||||
id_i16(a32); //~ ERROR mismatched types: expected `i16` but found `i32`
|
||||
id_i16(a64); //~ ERROR mismatched types: expected `i16` but found `i64`
|
||||
|
||||
id_i32(a8); //! ERROR mismatched types: expected `i32` but found `i8`
|
||||
id_i32(a16); //! ERROR mismatched types: expected `i32` but found `i16`
|
||||
id_i32(a8); //~ ERROR mismatched types: expected `i32` but found `i8`
|
||||
id_i32(a16); //~ ERROR mismatched types: expected `i32` but found `i16`
|
||||
id_i32(a32); // ok
|
||||
id_i32(a64); //! ERROR mismatched types: expected `i32` but found `i64`
|
||||
id_i32(a64); //~ ERROR mismatched types: expected `i32` but found `i64`
|
||||
|
||||
id_i64(a8); //! ERROR mismatched types: expected `i64` but found `i8`
|
||||
id_i64(a16); //! ERROR mismatched types: expected `i64` but found `i16`
|
||||
id_i64(a32); //! ERROR mismatched types: expected `i64` but found `i32`
|
||||
id_i64(a8); //~ ERROR mismatched types: expected `i64` but found `i8`
|
||||
id_i64(a16); //~ ERROR mismatched types: expected `i64` but found `i16`
|
||||
id_i64(a32); //~ ERROR mismatched types: expected `i64` but found `i32`
|
||||
id_i64(a64); // ok
|
||||
|
||||
id_i8(c8); // ok
|
||||
id_i8(c16); //! ERROR mismatched types: expected `i8` but found `i16`
|
||||
id_i8(c32); //! ERROR mismatched types: expected `i8` but found `i32`
|
||||
id_i8(c64); //! ERROR mismatched types: expected `i8` but found `i64`
|
||||
id_i8(c16); //~ ERROR mismatched types: expected `i8` but found `i16`
|
||||
id_i8(c32); //~ ERROR mismatched types: expected `i8` but found `i32`
|
||||
id_i8(c64); //~ ERROR mismatched types: expected `i8` but found `i64`
|
||||
|
||||
id_i16(c8); //! ERROR mismatched types: expected `i16` but found `i8`
|
||||
id_i16(c8); //~ ERROR mismatched types: expected `i16` but found `i8`
|
||||
id_i16(c16); // ok
|
||||
id_i16(c32); //! ERROR mismatched types: expected `i16` but found `i32`
|
||||
id_i16(c64); //! ERROR mismatched types: expected `i16` but found `i64`
|
||||
id_i16(c32); //~ ERROR mismatched types: expected `i16` but found `i32`
|
||||
id_i16(c64); //~ ERROR mismatched types: expected `i16` but found `i64`
|
||||
|
||||
id_i32(c8); //! ERROR mismatched types: expected `i32` but found `i8`
|
||||
id_i32(c16); //! ERROR mismatched types: expected `i32` but found `i16`
|
||||
id_i32(c8); //~ ERROR mismatched types: expected `i32` but found `i8`
|
||||
id_i32(c16); //~ ERROR mismatched types: expected `i32` but found `i16`
|
||||
id_i32(c32); // ok
|
||||
id_i32(c64); //! ERROR mismatched types: expected `i32` but found `i64`
|
||||
id_i32(c64); //~ ERROR mismatched types: expected `i32` but found `i64`
|
||||
|
||||
id_i64(a8); //! ERROR mismatched types: expected `i64` but found `i8`
|
||||
id_i64(a16); //! ERROR mismatched types: expected `i64` but found `i16`
|
||||
id_i64(a32); //! ERROR mismatched types: expected `i64` but found `i32`
|
||||
id_i64(a8); //~ ERROR mismatched types: expected `i64` but found `i8`
|
||||
id_i64(a16); //~ ERROR mismatched types: expected `i64` but found `i16`
|
||||
id_i64(a32); //~ ERROR mismatched types: expected `i64` but found `i32`
|
||||
id_i64(a64); // ok
|
||||
|
||||
id_u8(b8); // ok
|
||||
id_u8(b16); //! ERROR mismatched types: expected `u8` but found `u16`
|
||||
id_u8(b32); //! ERROR mismatched types: expected `u8` but found `u32`
|
||||
id_u8(b64); //! ERROR mismatched types: expected `u8` but found `u64`
|
||||
id_u8(b16); //~ ERROR mismatched types: expected `u8` but found `u16`
|
||||
id_u8(b32); //~ ERROR mismatched types: expected `u8` but found `u32`
|
||||
id_u8(b64); //~ ERROR mismatched types: expected `u8` but found `u64`
|
||||
|
||||
id_u16(b8); //! ERROR mismatched types: expected `u16` but found `u8`
|
||||
id_u16(b8); //~ ERROR mismatched types: expected `u16` but found `u8`
|
||||
id_u16(b16); // ok
|
||||
id_u16(b32); //! ERROR mismatched types: expected `u16` but found `u32`
|
||||
id_u16(b64); //! ERROR mismatched types: expected `u16` but found `u64`
|
||||
id_u16(b32); //~ ERROR mismatched types: expected `u16` but found `u32`
|
||||
id_u16(b64); //~ ERROR mismatched types: expected `u16` but found `u64`
|
||||
|
||||
id_u32(b8); //! ERROR mismatched types: expected `u32` but found `u8`
|
||||
id_u32(b16); //! ERROR mismatched types: expected `u32` but found `u16`
|
||||
id_u32(b8); //~ ERROR mismatched types: expected `u32` but found `u8`
|
||||
id_u32(b16); //~ ERROR mismatched types: expected `u32` but found `u16`
|
||||
id_u32(b32); // ok
|
||||
id_u32(b64); //! ERROR mismatched types: expected `u32` but found `u64`
|
||||
id_u32(b64); //~ ERROR mismatched types: expected `u32` but found `u64`
|
||||
|
||||
id_u64(b8); //! ERROR mismatched types: expected `u64` but found `u8`
|
||||
id_u64(b16); //! ERROR mismatched types: expected `u64` but found `u16`
|
||||
id_u64(b32); //! ERROR mismatched types: expected `u64` but found `u32`
|
||||
id_u64(b8); //~ ERROR mismatched types: expected `u64` but found `u8`
|
||||
id_u64(b16); //~ ERROR mismatched types: expected `u64` but found `u16`
|
||||
id_u64(b32); //~ ERROR mismatched types: expected `u64` but found `u32`
|
||||
id_u64(b64); // ok
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Regression test for issue #1362 - without that fix the span will be bogus
|
||||
// no-reformat
|
||||
fn main() {
|
||||
let x: uint = 20i; //! ERROR mismatched types
|
||||
let x: uint = 20i; //~ ERROR mismatched types
|
||||
}
|
||||
// NOTE: Do not add any extra lines as the line number the error is
|
||||
// on is significant; an error later in the source file might not
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
fn main() {
|
||||
#macro[[#apply[f, [x, ...]], f(x, ...)]];
|
||||
fn add(a: int, b: int) -> int { ret a + b; }
|
||||
assert (#apply[add, [y, 15]] == 16); //! ERROR unresolved name: y
|
||||
assert (#apply[add, [y, 15]] == 16); //~ ERROR unresolved name: y
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Regresion test for issue #1448 and #1386
|
||||
|
||||
fn main() {
|
||||
#debug["%u", 10i]; //! ERROR mismatched types
|
||||
#debug["%u", 10i]; //~ ERROR mismatched types
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// Testing that we don't fail abnormally after hitting the errors
|
||||
|
||||
import unresolved::*; //! ERROR unresolved modulename
|
||||
//!^ ERROR unresolved does not name a module
|
||||
import unresolved::*; //~ ERROR unresolved modulename
|
||||
//~^ ERROR unresolved does not name a module
|
||||
|
||||
fn main() {
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
// Issue #1763 - infer types correctly
|
||||
|
||||
type actor<T> = { //! ERROR type parameter `T` is unused
|
||||
type actor<T> = { //~ ERROR type parameter `T` is unused
|
||||
unused: bool
|
||||
};
|
||||
|
||||
|
|
|
@ -3,6 +3,6 @@ type t<T> = { f: fn() -> T };
|
|||
fn f<T>(_x: t<T>) {}
|
||||
|
||||
fn main() {
|
||||
let x: t<()> = { f: || () }; //! ERROR expressions with stack closure
|
||||
let x: t<()> = { f: || () }; //~ ERROR expressions with stack closure
|
||||
f(x);
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue