Skip to content

Commit 3432c9f

Browse files
authored
Rollup merge of #161329 - jakubadamw:e-needs-test, r=jackh726
Add regression tests for a few fixed issues with E-needs-test Closes #45689. Closes #66805. Closes #82646. Closes #99478. Closes #146398. LLM disclosure: I used an LLM to identify best candidate issues (labelled as E-needs-test, unclaimed, with sensible reproducible examples etc) All the tests have been verified to pass in the current nightly and reproduce in the nightlies in which they were reported to fail in/released around the date of the issues’ creation.
2 parents 5300385 + d448db8 commit 3432c9f

11 files changed

Lines changed: 140 additions & 0 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/45689>.
2+
3+
//@ build-fail
4+
//@ compile-flags: -Clto
5+
//@ normalize-stderr: "error: crate .* required.*\n( .*\n)*\n" -> ""
6+
//@ normalize-stderr: "aborting due to [0-9]+" -> "aborting due to NUMBER"
7+
//@ dont-require-annotations: ERROR
8+
9+
#![feature(rustc_private)]
10+
11+
extern crate rustc_errors;
12+
//~? ERROR crate `rustc_errors` required to be available in rlib format
13+
14+
fn main() {}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
error: aborting due to NUMBER previous errors
2+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/146398>.
2+
3+
// The panic happens while the JSON emitter fills in its `rendered` field, which is the
4+
// path `cargo` takes, so this has to be checked with the default JSON error format.
5+
//@ compile-flags: --diagnostic-width=30
6+
// ignore-tidy-file-tab
7+
8+
fn main() {
9+
let _: &[u8] = [0, 0];
10+
//~^ ERROR mismatched types
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/elided-span-with-hard-tabs.rs:9:20
3+
|
4+
LL | ..._: &[u8] = [0, ... 0];
5+
| ----- ^^^^^^^^...^^^^^^^^ expected `&[u8]`, found `[{integer}; 2]`
6+
| |
7+
| expected due to this
8+
|
9+
help: consider borrowing here
10+
|
11+
LL | let _: &[u8] = &[0, 0];
12+
| +
13+
14+
error: aborting due to 1 previous error
15+
16+
For more information about this error, try `rustc --explain E0308`.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
pub struct ProjectileCreated;
2+
pub struct NotificationChannel<E>(std::marker::PhantomData<E>);
3+
4+
// The inner `macro_rules!` is what later reports a span from this crate while the
5+
// diagnostic is being rendered against the downstream crate's source.
6+
macro_rules! define_trigger_system {
7+
($(( $field:ident, $ty:ident, $channel:ident )),* $(,)?) => {
8+
#[macro_export]
9+
macro_rules! all_trigger_fields {
10+
($submacro:ident) => { $submacro!($( ( $field, $ty, $channel ) ),*) }
11+
}
12+
};
13+
}
14+
15+
define_trigger_system!((projectile_created, ProjectileCreated, NotificationChannel),);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/66805>.
2+
3+
//@ aux-build: nested-macro-rules-definition.rs
4+
5+
extern crate nested_macro_rules_definition;
6+
use nested_macro_rules_definition::*;
7+
8+
macro_rules! make_event_subscription {
9+
($(( $field:ident, $ty:ident, $channel:ident )),*) => {
10+
pub struct EventSubscription($($channel<nested_macro_rules_definition::$ty>::ReaderId),*);
11+
//~^ ERROR ambiguous associated type
12+
};
13+
}
14+
15+
all_trigger_fields!(make_event_subscription);
16+
//~^ ERROR macros that expand to items must be delimited with braces or followed by a semicolon
17+
18+
fn main() {}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error: macros that expand to items must be delimited with braces or followed by a semicolon
2+
--> $DIR/cross-crate-nested-macro-rules-span.rs:15:1
3+
|
4+
LL | all_trigger_fields!(make_event_subscription);
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: this error originates in the macro `all_trigger_fields` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error[E0223]: ambiguous associated type
10+
--> $DIR/cross-crate-nested-macro-rules-span.rs:10:40
11+
|
12+
LL | pub struct EventSubscription($($channel<nested_macro_rules_definition::$ty>::ReaderId),*);
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
14+
...
15+
LL | all_trigger_fields!(make_event_subscription);
16+
| -------------------------------------------- in this macro invocation
17+
|
18+
= note: this error originates in the macro `make_event_subscription` which comes from the expansion of the macro `all_trigger_fields` (in Nightly builds, run with -Z macro-backtrace for more info)
19+
help: if there were a trait named `Example` with associated type `ReaderId` implemented for `nested_macro_rules_definition::NotificationChannel<ProjectileCreated>`, you could use the fully-qualified path
20+
|
21+
LL - pub struct EventSubscription($($channel<nested_macro_rules_definition::$ty>::ReaderId),*);
22+
LL + pub struct EventSubscription($(<nested_macro_rules_definition::NotificationChannel<ProjectileCreated> as Example>::ReaderId),*);
23+
|
24+
25+
error: aborting due to 2 previous errors
26+
27+
For more information about this error, try `rustc --explain E0223`.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/82646>.
2+
3+
//@ run-pass
4+
//@ compile-flags: -Zmir-opt-level=2 -Coverflow-checks=on
5+
6+
fn main() {
7+
assert_eq!(1_u32.wrapping_sub(2), u32::MAX);
8+
assert_eq!(u32::MAX.wrapping_add(2), 1);
9+
assert_eq!(i32::MIN.wrapping_sub(1), i32::MAX);
10+
assert_eq!(2_u32.wrapping_mul(u32::MAX), u32::MAX - 1);
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extern crate proc_macro;
2+
3+
use proc_macro::TokenStream;
4+
5+
#[proc_macro_attribute]
6+
pub fn tester(_: TokenStream, _: TokenStream) -> TokenStream {
7+
panic!();
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//! Regression test for <https://github.com/rust-lang/rust/issues/99478>.
2+
3+
//@ proc-macro: panicking-attribute.rs
4+
//@ compile-flags: --crate-type=lib
5+
6+
#![feature(custom_inner_attributes)]
7+
#![panicking_attribute::tester]
8+
//~^ ERROR custom attribute panicked

0 commit comments

Comments
 (0)