Skip to content

Commit b932189

Browse files
authored
Merge pull request #430 from ehuss/update-1.44
Update tests for 1.44.
2 parents 7acf8a9 + 7b86528 commit b932189

13 files changed

+85
-37
lines changed

rust/messages.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,10 @@ def _is_duplicate_message(window, primary_message):
830830
return False
831831

832832

833+
def _is_external_macro(span):
834+
return 'macros>' in span['file_name'] or span['file_name'].startswith('/rustc/')
835+
836+
833837
def _collect_rust_messages(window, base_path, info, target_path,
834838
msg_cb, parent_info,
835839
message):
@@ -851,7 +855,7 @@ def _collect_rust_messages(window, base_path, info, target_path,
851855
852856
- 'file_name': Filename for the message. For spans located in the
853857
'expansion' section, this will be the name of the expanded macro
854-
in the format '<macroname macros>'.
858+
in the format '<macroname macros>'. (No longer true in 1.44)
855859
- 'byte_start':
856860
- 'byte_end':
857861
- 'line_start':
@@ -933,7 +937,7 @@ def add_additional(span, text, level, suggested_replacement=None):
933937
child.suggested_replacement = suggested_replacement
934938
child.level = level_from_str(level)
935939
child.primary = False
936-
if 'macros>' in span['file_name']:
940+
if _is_external_macro(span):
937941
# Nowhere to display this, just send it to the console via msg_cb.
938942
msg_cb(child)
939943
else:
@@ -986,7 +990,7 @@ def find_span_r(span, expansion=None):
986990
return span, expansion
987991

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

1004-
if 'macros>' in span['file_name']:
1008+
if _is_external_macro(span):
10051009
# Macros from extern crates do not have 'expansion', and thus
10061010
# we do not have a location to highlight. Place the result at
10071011
# the bottom of the primary target path.
@@ -1014,20 +1018,22 @@ def find_span_r(span, expansion=None):
10141018
'Errors occurred in macro %s from external crate' % (macro_name,),
10151019
info['level'])
10161020
text = ''.join([x['text'] for x in span['text']])
1017-
add_additional(span,
1018-
'Macro text: %s' % (text,),
1019-
info['level'])
1021+
print('macro text: `%s`' % (text,))
1022+
if text:
1023+
add_additional(span,
1024+
'Macro text: %s' % (text,),
1025+
info['level'])
10201026
else:
10211027
if not expansion or not expansion['def_site_span'] \
1022-
or 'macros>' in expansion['def_site_span']['file_name']:
1028+
or _is_external_macro(expansion['def_site_span']):
10231029
add_additional(span,
10241030
'this error originates in a macro outside of the current crate',
10251031
info['level'])
10261032

10271033
# Add a message for macro invocation site if available in the local
10281034
# crate.
10291035
if span['expansion'] and \
1030-
'macros>' not in span['file_name'] and \
1036+
not _is_external_macro(span) and \
10311037
not span['expansion']['macro_decl_name'].startswith('#['):
10321038
invoke_span, expansion = find_span_r(span)
10331039
add_additional(invoke_span, 'in this macro invocation', 'help')

tests/error-tests/dcrate/src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,28 @@ macro_rules! example {
88
#[macro_export]
99
macro_rules! inner {
1010
($x:expr) => ($x.missing())
11+
// ^^^^^^^ERR(>=1.44.0-beta) no method named `missing`
12+
// ^^^^^^^ERR(>=1.44.0-beta) method not found in
13+
// ^^^^^^^MSG(>=1.44.0-beta) See Also: macro-expansion.rs:7
1114
}
1215

1316
#[macro_export]
1417
macro_rules! example_bad_syntax {
1518
() => {
1619
enum E {
1720
Kind(x: u32)
21+
// ^ERR(>=1.44.0-beta) /expected one of .*, found `:`/
22+
// ^ERR(>=1.44.0-beta) /expected one of .* tokens/
23+
// ^MSG(>=1.44.0-beta) See Also: macro-expansion-outside-1.rs:9
24+
1825
}
1926
}
2027
}
2128

2229
#[macro_export]
2330
macro_rules! example_bad_value {
2431
() => (1i32)
32+
// ^^^^ERR(>=1.44.0-beta) mismatched types
33+
// ^^^^ERR(>=1.44.0-beta) expected `()`, found `i32`
34+
// ^^^^MSG(>=1.44.0-beta) See Also: macro-expansion-outside-2.rs:9
2535
}

tests/error-tests/tests/E0005.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ fn main() {
1414
let Some(y) = x;
1515
// ^^^^^^^ERR pattern `None` not covered
1616
// ^^^^^^^ERR refutable pattern in local binding
17-
// ^^^^^^^MSG(>=1.39.0-beta) See Also: ↑:1
17+
// ^^^^^^^MSG(>=1.39.0-beta,<1.44.0-beta) See Also: ↑:1
18+
// ^^^^^^^MSG(>=1.44.0-beta) See Also: ↓
1819
// ^^^^^^^NOTE(>=1.40.0-beta) `let` bindings require
1920
// ^^^^^^^NOTE(>=1.40.0-beta) for more information
21+
// ^^^^^^^NOTE(>=1.44.0-beta) the matched value
2022
// ^^^^^^^^^^^^^^^^HELP(>=1.40.0-beta) you might want to use `if let`
2123
// ^^^^^^^^^^^^^^^^HELP(>=1.40.0-beta) /Accept Replacement:.*/
2224
}
2325
// Bug: https://github.com/rust-lang/rust/issues/64769
24-
// start-msg: ERR(>=1.39.0-beta) not covered
25-
// start-msg: MSG(>=1.39.0-beta) See Primary: ↓:14
26+
// start-msg: ERR(>=1.39.0-beta,<1.44.0-beta) not covered
27+
// start-msg: MSG(>=1.39.0-beta,<1.44.0-beta) See Primary: ↓:14
28+
// end-msg: ERR(>=1.44.0-beta) Errors occurred in macro
29+
// end-msg: ERR(>=1.44.0-beta) not covered
30+
// end-msg: MSG(>=1.44.0-beta) See Primary: ↑:14

tests/error-tests/tests/arg-count-mismatch.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@
2020
// children without spans, spans with no labels
2121
// Should display error (with link) and a note of expected type.
2222
fn main() { let i: (); i = f(); }
23-
// ^^^ERR this function takes 1 parameter
24-
// ^^^ERR expected 1 parameter
23+
// ^^^ERR(<1.43.0-beta) this function takes 1 parameter
24+
// ^^^ERR(<1.43.0-beta) expected 1 parameter
2525
// ^^^MSG(<1.24.0-beta) See Also: ↑:16
26-
// ^^^MSG(>=1.24.0-beta) See Also: ↑:13
26+
// ^^^MSG(>=1.24.0-beta,<1.43.0-beta) See Also: ↑:13
27+
// ^ERR(>=1.43.0-beta) this function takes 1
28+
// ^^ERR(>=1.43.0-beta) supplied 0
29+
// ^^ERR(>=1.43.0-beta) expected 1
30+
// ^MSG(>=1.43.0-beta) See Also: ↑:13

tests/error-tests/tests/binop-mul-bool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ fn main() { let x = true * false; }
1717
// ^^^^^^^^^^^^NOTE(>=1.19.0,<1.35.0-beta) an implementation of
1818
// ^ERR(>=1.35.0-beta,<1.42.0-beta) binary operation
1919
// ^ERR(>=1.42.0-beta) cannot multiply
20-
// ^NOTE(>=1.35.0-beta) an implementation of
20+
// ^NOTE(>=1.35.0-beta,<1.43.0-beta) an implementation of
2121
// ^^^^ERR(>=1.35.0-beta) bool
2222
// ^^^^^ERR(>=1.35.0-beta) bool

tests/error-tests/tests/error_across_mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ fn test() {
55
// ^ERR(<1.24.0-beta) this function takes 0 parameters but 1
66
// ^ERR(<1.24.0-beta) expected 0 parameters
77
// ^MSG(<1.24.0-beta) See Also: error_across_mod_f.rs:4
8-
// ^^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.24.0-beta) this function takes 0 parameters but 1
9-
// ^^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.24.0-beta) expected 0 parameters
10-
// ^^^^^^^^^^^^^^^^^^^^^^^^MSG(>=1.24.0-beta) See Also: error_across_mod_f.rs:1
8+
// ^^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.24.0-beta,<1.43.0-beta) this function takes 0 parameters but 1
9+
// ^^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.24.0-beta,<1.43.0-beta) expected 0 parameters
10+
// ^^^^^^^^^^^^^^^^^^^^^^^^MSG(>=1.24.0-beta,<1.43.0-beta) See Also: error_across_mod_f.rs:1
11+
// ^^^^^^^^^^^^^^^^^^^^^ERR(>=1.43.0-beta) this function takes 0 arguments but 1
12+
// ^ERR(>=1.43.0-beta) supplied 1 argument
13+
// ^ERR(>=1.43.0-beta) expected 0 arguments
14+
// ^^^^^^^^^^^^^^^^^^^^^MSG(>=1.43.0-beta) See Also: error_across_mod_f.rs:1
1115
}

tests/error-tests/tests/impl-generic-mismatch.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,8 @@ impl Hash for X {
5959
// ^^^^^^^^^^^ERR method `hash` has incompatible signature
6060
// ^^^^^^^^^^^ERR(>=1.28.0-beta) expected generic parameter
6161
// ^^^^^^^^^^^ERR(<1.28.0-beta) annotation in impl
62+
// ^^^^^^^^^^^MSG(>=1.32.0) See Also: ↓
6263
}
64+
// end-msg: ERR(>=1.32.0) Errors occurred in macro
65+
// end-msg: ERR(>=1.32.0) declaration in trait here
66+
// end-msg: MSG(>=1.32.0) See Primary: ↑:58

tests/error-tests/tests/macro-expansion-outside-1.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ extern crate dcrate;
77
// at the bottom of the "root" source file.
88

99
/*BEGIN*/example_bad_syntax!{}/*END*/
10-
// ~ERR(>=1.20.0) /expected one of .*, found `:`/
11-
// ~ERR(>=1.20.0) this error originates in a macro outside of the current crate
10+
// ^^^^^^^^^^^^^^^^^^^^^HELP(>=1.44.0-beta) in this macro invocation
11+
// ^^^^^^^^^^^^^^^^^^^^^MSG(>=1.44.0-beta) See Primary: lib.rs:20
12+
// ~ERR(>=1.20.0,<1.44.0-beta) /expected one of .*, found `:`/
13+
// ~ERR(>=1.20.0,<1.44.0-beta) this error originates in a macro outside of the current crate
1214
// ~ERR(>=1.20.0,<1.41.0-beta) /expected one of .* here/
13-
// ~ERR(>=1.41.0-beta) /expected one of .* tokens/
15+
// ~ERR(>=1.41.0-beta,<1.44.0-beta) /expected one of .* tokens/
1416
// ~ERR(>=1.20.0,<1.24.0-beta) unexpected token
1517
// ~ERR(>=1.20.0,<1.34.0-beta) /expected one of .*, found `:`/
1618
// ~ERR(>=1.20.0,<1.34.0-beta) this error originates in a macro outside of the current crate

tests/error-tests/tests/macro-expansion-outside-2.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ extern crate dcrate;
77

88
fn f() {
99
let x: () = example_bad_value!();
10-
// ^^^^^^^^^^^^^^^^^^^^ERR mismatched types
11-
// ^^^^^^^^^^^^^^^^^^^^ERR this error originates in a macro outside
12-
// ^^^^^^^^^^^^^^^^^^^^ERR(>=1.41.0-beta) expected `()`, found `i32`
10+
// ^^^^^^^^^^^^^^^^^^^^ERR(<1.44.0-beta) mismatched types
11+
// ^^^^^^^^^^^^^^^^^^^^ERR(<1.44.0-beta) this error originates in a macro outside
12+
// ^^^^^^^^^^^^^^^^^^^^ERR(>=1.41.0-beta,<1.44.0-beta) expected `()`, found `i32`
1313
// ^^^^^^^^^^^^^^^^^^^^ERR(<1.41.0-beta) expected (), found i32
1414
// ^^ERR(>=1.41.0-beta) expected due to this
1515
// ^^^^^^^^^^^^^^^^^^^^NOTE(<1.41.0-beta) expected type
1616
// ^^^^^^^^^^^^^^^^^^^^NOTE(<1.16.0) found type
17+
// ^^^^^^^^^^^^^^^^^^^^HELP(>=1.44.0-beta) in this macro invocation
18+
// ^^^^^^^^^^^^^^^^^^^^MSG(>=1.44.0-beta) See Primary: lib.rs:31
1719
}

tests/error-tests/tests/macro-expansion.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ fn main() {
55
// This ensures that the expansion of nested macros works correctly.
66

77
example!(inner!(b" "));
8-
// ^^^^^^^^^^^^^^^^^^^^^^^ERR no method named `missing`
9-
// ^^^^^^^^^^^^^^^^^^^^^^^ERR this error originates in a macro outside of the current crate
10-
// ^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.39.0-beta) method not found
8+
// ^^^^^^^^^^^^^^^^^^^^^^^ERR(<1.44.0-beta) no method named `missing`
9+
// ^^^^^^^^^^^^^^^^^^^^^^^ERR(<1.44.0-beta) this error originates in a macro outside of the current crate
10+
// ^^^^^^^^^^^^^^^^^^^^^^^ERR(>=1.39.0-beta,<1.44.0-beta) method not found
11+
// ^^^^^^^^^^^^^^^^^^^^^^^HELP(>=1.44.0-beta) in this macro invocation
12+
// ^^^^^^^^^^^^^^^^^^^^^^^MSG(>=1.44.0-beta) See Primary: lib.rs:10
1113
}

tests/error-tests/tests/test_multiple_primary_spans.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// ^^^WARN(<1.42.0-beta) conflicting representation hints
77
// ^ERR(>=1.42.0-beta) conflicting representation hints
88
// ^^^ERR(>=1.42.0-beta) conflicting representation hints
9-
// ^NOTE(>=1.43.0-beta) `#[deny(conflicting_repr_hints)]` on by default
10-
// ^WARN(>=1.43.0-beta) this was previously
11-
// ^NOTE(>=1.43.0-beta) for more information
9+
// ^NOTE(>=1.42.0-beta) `#[deny(conflicting_repr_hints)]` on by default
10+
// ^WARN(>=1.42.0-beta) this was previously
11+
// ^NOTE(>=1.42.0-beta) for more information
1212
pub enum C { C }

tests/error-tests/tests/test_unicode.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ fn main() {
66
// ^^^NOTE(>=1.17.0) #[warn(unused_variables)]
77
// ^^^NOTE(>=1.21.0,<1.22.0) to disable this warning
88
// ^^^NOTE(>=1.22.0,<1.25.0-beta) to avoid this warning
9-
// ^^^HELP(>=1.25.0-beta) consider
9+
// ^^^HELP(>=1.25.0-beta,<1.44.0-beta) consider
10+
// ^^^HELP(>=1.44.0-beta) if this is intentional
1011
// ^^^HELP(>=1.25.0-beta) /Accept Replacement:.*_foo/
1112
}

tests/test_syntax_check.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,19 @@ def _collect_expected_regions(self, view):
367367
else:
368368
last_line = row
369369
last_line_offset = 1
370-
try:
371-
actual_region = region_map[row - 1]
372-
except KeyError:
373-
raise AssertionError('Invalid test: %r did not have region on row %r' % (
374-
view.file_name(), row - 1))
370+
# Look upwards to find the most recent BEGIN/END.
371+
region_row = row - 1
372+
while region_row >= 0:
373+
try:
374+
actual_region = region_map[region_row]
375+
except KeyError:
376+
pass
377+
else:
378+
break
379+
region_row -= 1
380+
else:
381+
raise AssertionError('Invalid test: %r did not have region before row %r' % (
382+
view.file_name(), row))
375383
result.append({
376384
'begin': actual_region[0],
377385
'end': actual_region[1],

0 commit comments

Comments
 (0)