Skip to content

Update tests for 1.44. #430

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

Merged
merged 1 commit into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 15 additions & 9 deletions rust/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,10 @@ def _is_duplicate_message(window, primary_message):
return False


def _is_external_macro(span):
return 'macros>' in span['file_name'] or span['file_name'].startswith('/rustc/')


def _collect_rust_messages(window, base_path, info, target_path,
msg_cb, parent_info,
message):
Expand All @@ -851,7 +855,7 @@ def _collect_rust_messages(window, base_path, info, target_path,

- 'file_name': Filename for the message. For spans located in the
'expansion' section, this will be the name of the expanded macro
in the format '<macroname macros>'.
in the format '<macroname macros>'. (No longer true in 1.44)
- 'byte_start':
- 'byte_end':
- 'line_start':
Expand Down Expand Up @@ -933,7 +937,7 @@ def add_additional(span, text, level, suggested_replacement=None):
child.suggested_replacement = suggested_replacement
child.level = level_from_str(level)
child.primary = False
if 'macros>' in span['file_name']:
if _is_external_macro(span):
# Nowhere to display this, just send it to the console via msg_cb.
msg_cb(child)
else:
Expand Down Expand Up @@ -986,7 +990,7 @@ def find_span_r(span, expansion=None):
return span, expansion

for span in info['spans']:
if 'macros>' in span['file_name']:
if _is_external_macro(span):
# Rust gives the chain of expansions for the macro, which we don't
# really care about. We want to find the site where the macro was
# invoked. I'm not entirely confident this is the best way to do
Expand All @@ -1001,7 +1005,7 @@ def find_span_r(span, expansion=None):
updated['suggested_replacement'] = span['suggested_replacement']
span = updated

if 'macros>' in span['file_name']:
if _is_external_macro(span):
# Macros from extern crates do not have 'expansion', and thus
# we do not have a location to highlight. Place the result at
# the bottom of the primary target path.
Expand All @@ -1014,20 +1018,22 @@ def find_span_r(span, expansion=None):
'Errors occurred in macro %s from external crate' % (macro_name,),
info['level'])
text = ''.join([x['text'] for x in span['text']])
add_additional(span,
'Macro text: %s' % (text,),
info['level'])
print('macro text: `%s`' % (text,))
if text:
add_additional(span,
'Macro text: %s' % (text,),
info['level'])
else:
if not expansion or not expansion['def_site_span'] \
or 'macros>' in expansion['def_site_span']['file_name']:
or _is_external_macro(expansion['def_site_span']):
add_additional(span,
'this error originates in a macro outside of the current crate',
info['level'])

# Add a message for macro invocation site if available in the local
# crate.
if span['expansion'] and \
'macros>' not in span['file_name'] and \
not _is_external_macro(span) and \
not span['expansion']['macro_decl_name'].startswith('#['):
invoke_span, expansion = find_span_r(span)
add_additional(invoke_span, 'in this macro invocation', 'help')
Expand Down
10 changes: 10 additions & 0 deletions tests/error-tests/dcrate/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,28 @@ macro_rules! example {
#[macro_export]
macro_rules! inner {
($x:expr) => ($x.missing())
// ^^^^^^^ERR(>=1.44.0-beta) no method named `missing`
// ^^^^^^^ERR(>=1.44.0-beta) method not found in
// ^^^^^^^MSG(>=1.44.0-beta) See Also: macro-expansion.rs:7
}

#[macro_export]
macro_rules! example_bad_syntax {
() => {
enum E {
Kind(x: u32)
// ^ERR(>=1.44.0-beta) /expected one of .*, found `:`/
// ^ERR(>=1.44.0-beta) /expected one of .* tokens/
// ^MSG(>=1.44.0-beta) See Also: macro-expansion-outside-1.rs:9

}
}
}

#[macro_export]
macro_rules! example_bad_value {
() => (1i32)
// ^^^^ERR(>=1.44.0-beta) mismatched types
// ^^^^ERR(>=1.44.0-beta) expected `()`, found `i32`
// ^^^^MSG(>=1.44.0-beta) See Also: macro-expansion-outside-2.rs:9
}
11 changes: 8 additions & 3 deletions tests/error-tests/tests/E0005.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ fn main() {
let Some(y) = x;
// ^^^^^^^ERR pattern `None` not covered
// ^^^^^^^ERR refutable pattern in local binding
// ^^^^^^^MSG(>=1.39.0-beta) See Also: ↑:1
// ^^^^^^^MSG(>=1.39.0-beta,<1.44.0-beta) See Also: ↑:1
// ^^^^^^^MSG(>=1.44.0-beta) See Also: ↓
// ^^^^^^^NOTE(>=1.40.0-beta) `let` bindings require
// ^^^^^^^NOTE(>=1.40.0-beta) for more information
// ^^^^^^^NOTE(>=1.44.0-beta) the matched value
// ^^^^^^^^^^^^^^^^HELP(>=1.40.0-beta) you might want to use `if let`
// ^^^^^^^^^^^^^^^^HELP(>=1.40.0-beta) /Accept Replacement:.*/
}
// Bug: https://github.com/rust-lang/rust/issues/64769
// start-msg: ERR(>=1.39.0-beta) not covered
// start-msg: MSG(>=1.39.0-beta) See Primary: ↓:14
// start-msg: ERR(>=1.39.0-beta,<1.44.0-beta) not covered
// start-msg: MSG(>=1.39.0-beta,<1.44.0-beta) See Primary: ↓:14
// end-msg: ERR(>=1.44.0-beta) Errors occurred in macro
// end-msg: ERR(>=1.44.0-beta) not covered
// end-msg: MSG(>=1.44.0-beta) See Primary: ↑:14
10 changes: 7 additions & 3 deletions tests/error-tests/tests/arg-count-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
// children without spans, spans with no labels
// Should display error (with link) and a note of expected type.
fn main() { let i: (); i = f(); }
// ^^^ERR this function takes 1 parameter
// ^^^ERR expected 1 parameter
// ^^^ERR(<1.43.0-beta) this function takes 1 parameter
// ^^^ERR(<1.43.0-beta) expected 1 parameter
// ^^^MSG(<1.24.0-beta) See Also: ↑:16
// ^^^MSG(>=1.24.0-beta) See Also: ↑:13
// ^^^MSG(>=1.24.0-beta,<1.43.0-beta) See Also: ↑:13
// ^ERR(>=1.43.0-beta) this function takes 1
// ^^ERR(>=1.43.0-beta) supplied 0
// ^^ERR(>=1.43.0-beta) expected 1
// ^MSG(>=1.43.0-beta) See Also: ↑:13
2 changes: 1 addition & 1 deletion tests/error-tests/tests/binop-mul-bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ fn main() { let x = true * false; }
// ^^^^^^^^^^^^NOTE(>=1.19.0,<1.35.0-beta) an implementation of
// ^ERR(>=1.35.0-beta,<1.42.0-beta) binary operation
// ^ERR(>=1.42.0-beta) cannot multiply
// ^NOTE(>=1.35.0-beta) an implementation of
// ^NOTE(>=1.35.0-beta,<1.43.0-beta) an implementation of
// ^^^^ERR(>=1.35.0-beta) bool
// ^^^^^ERR(>=1.35.0-beta) bool
10 changes: 7 additions & 3 deletions tests/error-tests/tests/error_across_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ fn test() {
// ^ERR(<1.24.0-beta) this function takes 0 parameters but 1
// ^ERR(<1.24.0-beta) expected 0 parameters
// ^MSG(<1.24.0-beta) See Also: error_across_mod_f.rs:4
// ^^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.24.0-beta) this function takes 0 parameters but 1
// ^^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.24.0-beta) expected 0 parameters
// ^^^^^^^^^^^^^^^^^^^^^^^^MSG(>=1.24.0-beta) See Also: error_across_mod_f.rs:1
// ^^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.24.0-beta,<1.43.0-beta) this function takes 0 parameters but 1
// ^^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.24.0-beta,<1.43.0-beta) expected 0 parameters
// ^^^^^^^^^^^^^^^^^^^^^^^^MSG(>=1.24.0-beta,<1.43.0-beta) See Also: error_across_mod_f.rs:1
// ^^^^^^^^^^^^^^^^^^^^^ERR(>=1.43.0-beta) this function takes 0 arguments but 1
// ^ERR(>=1.43.0-beta) supplied 1 argument
// ^ERR(>=1.43.0-beta) expected 0 arguments
// ^^^^^^^^^^^^^^^^^^^^^MSG(>=1.43.0-beta) See Also: error_across_mod_f.rs:1
}
4 changes: 4 additions & 0 deletions tests/error-tests/tests/impl-generic-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ impl Hash for X {
// ^^^^^^^^^^^ERR method `hash` has incompatible signature
// ^^^^^^^^^^^ERR(>=1.28.0-beta) expected generic parameter
// ^^^^^^^^^^^ERR(<1.28.0-beta) annotation in impl
// ^^^^^^^^^^^MSG(>=1.32.0) See Also: ↓
}
// end-msg: ERR(>=1.32.0) Errors occurred in macro
// end-msg: ERR(>=1.32.0) declaration in trait here
// end-msg: MSG(>=1.32.0) See Primary: ↑:58
8 changes: 5 additions & 3 deletions tests/error-tests/tests/macro-expansion-outside-1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ extern crate dcrate;
// at the bottom of the "root" source file.

/*BEGIN*/example_bad_syntax!{}/*END*/
// ~ERR(>=1.20.0) /expected one of .*, found `:`/
// ~ERR(>=1.20.0) this error originates in a macro outside of the current crate
// ^^^^^^^^^^^^^^^^^^^^^HELP(>=1.44.0-beta) in this macro invocation
// ^^^^^^^^^^^^^^^^^^^^^MSG(>=1.44.0-beta) See Primary: lib.rs:20
// ~ERR(>=1.20.0,<1.44.0-beta) /expected one of .*, found `:`/
// ~ERR(>=1.20.0,<1.44.0-beta) this error originates in a macro outside of the current crate
// ~ERR(>=1.20.0,<1.41.0-beta) /expected one of .* here/
// ~ERR(>=1.41.0-beta) /expected one of .* tokens/
// ~ERR(>=1.41.0-beta,<1.44.0-beta) /expected one of .* tokens/
// ~ERR(>=1.20.0,<1.24.0-beta) unexpected token
// ~ERR(>=1.20.0,<1.34.0-beta) /expected one of .*, found `:`/
// ~ERR(>=1.20.0,<1.34.0-beta) this error originates in a macro outside of the current crate
Expand Down
8 changes: 5 additions & 3 deletions tests/error-tests/tests/macro-expansion-outside-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ extern crate dcrate;

fn f() {
let x: () = example_bad_value!();
// ^^^^^^^^^^^^^^^^^^^^ERR mismatched types
// ^^^^^^^^^^^^^^^^^^^^ERR this error originates in a macro outside
// ^^^^^^^^^^^^^^^^^^^^ERR(>=1.41.0-beta) expected `()`, found `i32`
// ^^^^^^^^^^^^^^^^^^^^ERR(<1.44.0-beta) mismatched types
// ^^^^^^^^^^^^^^^^^^^^ERR(<1.44.0-beta) this error originates in a macro outside
// ^^^^^^^^^^^^^^^^^^^^ERR(>=1.41.0-beta,<1.44.0-beta) expected `()`, found `i32`
// ^^^^^^^^^^^^^^^^^^^^ERR(<1.41.0-beta) expected (), found i32
// ^^ERR(>=1.41.0-beta) expected due to this
// ^^^^^^^^^^^^^^^^^^^^NOTE(<1.41.0-beta) expected type
// ^^^^^^^^^^^^^^^^^^^^NOTE(<1.16.0) found type
// ^^^^^^^^^^^^^^^^^^^^HELP(>=1.44.0-beta) in this macro invocation
// ^^^^^^^^^^^^^^^^^^^^MSG(>=1.44.0-beta) See Primary: lib.rs:31
}
8 changes: 5 additions & 3 deletions tests/error-tests/tests/macro-expansion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ fn main() {
// This ensures that the expansion of nested macros works correctly.

example!(inner!(b" "));
// ^^^^^^^^^^^^^^^^^^^^^^^ERR no method named `missing`
// ^^^^^^^^^^^^^^^^^^^^^^^ERR this error originates in a macro outside of the current crate
// ^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.39.0-beta) method not found
// ^^^^^^^^^^^^^^^^^^^^^^^ERR(<1.44.0-beta) no method named `missing`
// ^^^^^^^^^^^^^^^^^^^^^^^ERR(<1.44.0-beta) this error originates in a macro outside of the current crate
// ^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.39.0-beta,<1.44.0-beta) method not found
// ^^^^^^^^^^^^^^^^^^^^^^^HELP(>=1.44.0-beta) in this macro invocation
// ^^^^^^^^^^^^^^^^^^^^^^^MSG(>=1.44.0-beta) See Primary: lib.rs:10
}
6 changes: 3 additions & 3 deletions tests/error-tests/tests/test_multiple_primary_spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// ^^^WARN(<1.42.0-beta) conflicting representation hints
// ^ERR(>=1.42.0-beta) conflicting representation hints
// ^^^ERR(>=1.42.0-beta) conflicting representation hints
// ^NOTE(>=1.43.0-beta) `#[deny(conflicting_repr_hints)]` on by default
// ^WARN(>=1.43.0-beta) this was previously
// ^NOTE(>=1.43.0-beta) for more information
// ^NOTE(>=1.42.0-beta) `#[deny(conflicting_repr_hints)]` on by default
// ^WARN(>=1.42.0-beta) this was previously
// ^NOTE(>=1.42.0-beta) for more information
pub enum C { C }
3 changes: 2 additions & 1 deletion tests/error-tests/tests/test_unicode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ fn main() {
// ^^^NOTE(>=1.17.0) #[warn(unused_variables)]
// ^^^NOTE(>=1.21.0,<1.22.0) to disable this warning
// ^^^NOTE(>=1.22.0,<1.25.0-beta) to avoid this warning
// ^^^HELP(>=1.25.0-beta) consider
// ^^^HELP(>=1.25.0-beta,<1.44.0-beta) consider
// ^^^HELP(>=1.44.0-beta) if this is intentional
// ^^^HELP(>=1.25.0-beta) /Accept Replacement:.*_foo/
}
18 changes: 13 additions & 5 deletions tests/test_syntax_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,11 +367,19 @@ def _collect_expected_regions(self, view):
else:
last_line = row
last_line_offset = 1
try:
actual_region = region_map[row - 1]
except KeyError:
raise AssertionError('Invalid test: %r did not have region on row %r' % (
view.file_name(), row - 1))
# Look upwards to find the most recent BEGIN/END.
region_row = row - 1
while region_row >= 0:
try:
actual_region = region_map[region_row]
except KeyError:
pass
else:
break
region_row -= 1
else:
raise AssertionError('Invalid test: %r did not have region before row %r' % (
view.file_name(), row))
result.append({
'begin': actual_region[0],
'end': actual_region[1],
Expand Down