Skip to content
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
28 changes: 19 additions & 9 deletions src/tools/compiletest/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,11 @@ impl Config {
}

fn parse_pp_exact(&self, line: &DirectiveLine<'_>) -> Option<Utf8PathBuf> {
if let Some(s) = self.parse_name_value_directive(line, "pp-exact") {
// Unusually, `//@ pp-exact` can be used with or without a colon, so to avoid a panic
// in the parse method we need to make sure there is a colon before calling it.
if line.value_after_colon().is_some()
&& let Some(s) = self.parse_name_value_directive(line, "pp-exact")
{
Some(Utf8PathBuf::from(&s))
} else if self.parse_name_directive(line, "pp-exact") {
line.file_path.file_name().map(Utf8PathBuf::from)
Expand Down Expand Up @@ -648,10 +652,17 @@ impl Config {
}

fn parse_name_directive(&self, line: &DirectiveLine<'_>, directive: &str) -> bool {
// FIXME(Zalathar): Ideally, this should raise an error if a name-only
// directive is followed by a colon, since that's the wrong syntax.
// But we would need to fix tests that rely on the current behaviour.
line.name == directive
if line.name != directive {
return false;
}

if line.value_after_colon().is_some() {
let &DirectiveLine { file_path, line_number, .. } = line;
panic!(
"{file_path}:{line_number}: directive `{directive}` must not be followed by a colon"
);
}
true
}

fn parse_name_value_directive(
Expand All @@ -665,10 +676,9 @@ impl Config {
return None;
};

// FIXME(Zalathar): This silently discards directives with a matching
// name but no colon. Unfortunately, some directives (e.g. "pp-exact")
// currently rely on _not_ panicking here.
let value = line.value_after_colon()?;
let value = line.value_after_colon().unwrap_or_else(|| {
panic!("{file_path}:{line_number}: directive `{directive}` must be followed by a colon and value");
});
debug!("{}: {}", directive, value);
let value = expand_variables(value.to_owned(), self);

Expand Down
1 change: 0 additions & 1 deletion src/tools/compiletest/src/directives/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1153,7 +1153,6 @@ fn edition_order() {
#[test]
fn test_parse_edition_range() {
assert_eq!(None, parse_edition_range("hello-world"));
assert_eq!(None, parse_edition_range("edition"));

assert_eq!(Some(EditionRange::Exact(2018.into())), parse_edition_range("edition: 2018"));
assert_eq!(Some(EditionRange::Exact(2021.into())), parse_edition_range("edition:2021"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Regression test for <https://github.com/rust-lang/rust/issues/150354>
//@ edition 2024
//@ edition: 2024

#![allow(incomplete_features)]
#![feature(min_generic_const_args, adt_const_params)]
Expand Down
1 change: 0 additions & 1 deletion tests/ui/consts/issue-miri-1910.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ ignore-backends: gcc
//@ error-pattern unable to turn pointer into raw bytes
//@ normalize-stderr: "alloc[0-9]+\+0x[a-z0-9]+" -> "ALLOC"

const C: () = unsafe {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/issue-miri-1910.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0080]: unable to turn pointer into integer
--> $DIR/issue-miri-1910.rs:8:5
--> $DIR/issue-miri-1910.rs:7:5
|
LL | (&foo as *const _ as *const u8).add(one_and_a_half_pointers).read();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `C` failed here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//@ edition: 2015

// Non-regression test for issue #89699, where a proc-macro emitting syntax only available in
//@ edition 2018 and up (`async move`) is used on edition 2015
// edition 2018 and up (`async move`) is used on edition 2015

extern crate edition_gated_async_move_syntax;

Expand Down
3 changes: 1 addition & 2 deletions tests/ui/rust-2021/generic-type-collision.fixed
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ edition:2015
//@ check-pass
//@ run-rustfix
//@ edition 2018
//@ edition: 2018
#![warn(rust_2021_prelude_collisions)]

trait MyTrait<A> {
Expand Down
3 changes: 1 addition & 2 deletions tests/ui/rust-2021/generic-type-collision.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//@ edition:2015
//@ check-pass
//@ run-rustfix
//@ edition 2018
//@ edition: 2018
#![warn(rust_2021_prelude_collisions)]

trait MyTrait<A> {
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/rust-2021/generic-type-collision.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
warning: trait-associated function `from_iter` will become ambiguous in Rust 2021
--> $DIR/generic-type-collision.rs:16:5
--> $DIR/generic-type-collision.rs:15:5
|
LL | <Vec<i32>>::from_iter(None);
| ^^^^^^^^^^^^^^^^^^^^^ help: disambiguate the associated function: `<Vec<i32> as MyTrait<_>>::from_iter`
|
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
= warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
= note: for more information, see <https://doc.rust-lang.org/edition-guide/rust-2021/prelude.html>
note: the lint level is defined here
--> $DIR/generic-type-collision.rs:5:9
--> $DIR/generic-type-collision.rs:4:9
|
LL | #![warn(rust_2021_prelude_collisions)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
Loading