Auto merge of #149646 - matthiaskrgr:rollup-jbfeow8, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang/rust#147224 (Emscripten: Turn wasm-eh on by default) - rust-lang/rust#149405 (Recover on misspelled item keyword) - rust-lang/rust#149443 (Tidying up UI tests [6/N]) - rust-lang/rust#149524 (Move attribute safety checking to attribute parsing) - rust-lang/rust#149593 (powf, powi: point out SNaN non-determinism) - rust-lang/rust#149605 (Use branch name instead of HEAD when unshallowing) - rust-lang/rust#149612 (Apply the `bors` environment also to the `outcome` job) - rust-lang/rust#149623 (Don't require a normal tool build of clippy/rustfmt when running their test steps) - rust-lang/rust#149627 (Point to the item that is incorrectly annotated with `#[diagnostic::on_const]`) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
3e2dbcdd3a
86 changed files with 645 additions and 447 deletions
|
|
@ -1,4 +1,4 @@
|
|||
//@ compile-flags: -Copt-level=3 --target wasm32-unknown-emscripten
|
||||
//@ compile-flags: -Copt-level=3 --target wasm32-unknown-emscripten -Z emscripten-wasm-eh=false
|
||||
//@ needs-llvm-components: webassembly
|
||||
|
||||
// Emscripten has its own unique implementation of catch_unwind (in `codegen_emcc_try`),
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@ pub fn no_mangle() {}
|
|||
#[rustc_clean(cfg = "cfail3")]
|
||||
#[rustc_clean(cfg = "cfail5")]
|
||||
#[rustc_clean(cfg = "cfail6")]
|
||||
#[no_mangle]
|
||||
#[unsafe(no_mangle)]
|
||||
pub fn no_mangle() {}
|
||||
|
||||
// Linkage ---------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
// and make sure that the hash has changed, then change nothing between rev2 and
|
||||
// rev3 and make sure that the hash has not changed.
|
||||
|
||||
//@ edition: 2024
|
||||
//@ build-pass (FIXME(62277): could be check-pass?)
|
||||
//@ revisions: cfail1 cfail2 cfail3 cfail4 cfail5 cfail6
|
||||
//@ compile-flags: -Z query-dep-graph -O
|
||||
|
|
@ -649,7 +650,7 @@ impl Foo {
|
|||
//--------------------------
|
||||
//--------------------------
|
||||
//--------------------------
|
||||
//----------
|
||||
//------------------
|
||||
pub fn add_no_mangle_to_method(&self) { }
|
||||
}
|
||||
|
||||
|
|
@ -663,7 +664,7 @@ impl Foo {
|
|||
#[rustc_clean(cfg="cfail3")]
|
||||
#[rustc_clean(cfg="cfail5")]
|
||||
#[rustc_clean(cfg="cfail6")]
|
||||
#[no_mangle]
|
||||
#[unsafe(no_mangle)]
|
||||
pub fn add_no_mangle_to_method(&self) { }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ static STATIC_NO_MANGLE: u8 = 0;
|
|||
#[rustc_clean(cfg="cfail3")]
|
||||
#[rustc_clean(cfg="cfail5")]
|
||||
#[rustc_clean(cfg="cfail6")]
|
||||
#[no_mangle]
|
||||
#[unsafe(no_mangle)]
|
||||
static STATIC_NO_MANGLE: u8 = 0;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -569,7 +569,7 @@ impl AddNoMangleToMethod for Foo {
|
|||
// -------------------------
|
||||
// -------------------------
|
||||
// -------------------------
|
||||
// ---------
|
||||
// -----------------
|
||||
fn add_no_mangle_to_method(&self) { }
|
||||
}
|
||||
|
||||
|
|
@ -583,7 +583,7 @@ impl AddNoMangleToMethod for Foo {
|
|||
#[rustc_clean(cfg="cfail3")]
|
||||
#[rustc_clean(cfg="cfail5")]
|
||||
#[rustc_clean(cfg="cfail6")]
|
||||
#[no_mangle]
|
||||
#[unsafe(no_mangle)]
|
||||
fn add_no_mangle_to_method(&self) { }
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -573,12 +573,6 @@ Exercises the `format!` macro.
|
|||
|
||||
A broad category of tests on functions.
|
||||
|
||||
## `tests/ui/for/`: `for` keyword
|
||||
|
||||
Tests on the `for` keyword and some of its associated errors, such as attempting to write the faulty pattern `for _ in 0..1 {} else {}`.
|
||||
|
||||
**FIXME**: Should be merged with `ui/for-loop-while`.
|
||||
|
||||
## `tests/ui/force-inlining/`: `#[rustc_force_inline]`
|
||||
|
||||
Tests for `#[rustc_force_inline]`, which will force a function to always be labelled as inline by the compiler (it will be inserted at the point of its call instead of being used as a normal function call.) If the compiler is unable to inline the function, an error will be reported. See <https://github.com/rust-lang/rust/pull/134082>.
|
||||
|
|
@ -1521,10 +1515,6 @@ Tests on `enum` variants.
|
|||
|
||||
**FIXME**: Contains a single test described as "Check that rustc accepts various version info flags.", should be rehomed.
|
||||
|
||||
## `tests/ui/warnings/`
|
||||
|
||||
**FIXME**: Contains a single test on non-explicit paths (`::one()`). Should be rehomed probably to `tests/ui/resolve/`.
|
||||
|
||||
## `tests/ui/wasm/`
|
||||
|
||||
These tests target the `wasm32` architecture specifically. They are usually regression tests for WASM-specific bugs which were observed in the past.
|
||||
|
|
|
|||
|
|
@ -9,6 +9,12 @@ help: escape `unsafe` to use it as an identifier
|
|||
LL | #[unsafe(r#unsafe(no_mangle))]
|
||||
| ++
|
||||
|
||||
error: cannot find attribute `r#unsafe` in this scope
|
||||
--> $DIR/double-unsafe-attributes.rs:1:10
|
||||
|
|
||||
LL | #[unsafe(unsafe(no_mangle))]
|
||||
| ^^^^^^
|
||||
|
||||
error: `r#unsafe` is not an unsafe attribute
|
||||
--> $DIR/double-unsafe-attributes.rs:1:3
|
||||
|
|
||||
|
|
@ -17,11 +23,5 @@ LL | #[unsafe(unsafe(no_mangle))]
|
|||
|
|
||||
= note: extraneous unsafe is not allowed in attributes
|
||||
|
||||
error: cannot find attribute `r#unsafe` in this scope
|
||||
--> $DIR/double-unsafe-attributes.rs:1:10
|
||||
|
|
||||
LL | #[unsafe(unsafe(no_mangle))]
|
||||
| ^^^^^^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -12,46 +12,6 @@ LL | #[unsafe(allow(unsafe(dead_code)))]
|
|||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `proc_macro` is not an unsafe attribute
|
||||
--> $DIR/proc-unsafe-attributes.rs:1:3
|
||||
|
|
||||
LL | #[unsafe(proc_macro)]
|
||||
| ^^^^^^ this is not an unsafe attribute
|
||||
|
|
||||
= note: extraneous unsafe is not allowed in attributes
|
||||
|
||||
error: `proc_macro_derive` is not an unsafe attribute
|
||||
--> $DIR/proc-unsafe-attributes.rs:7:3
|
||||
|
|
||||
LL | #[unsafe(proc_macro_derive(Foo))]
|
||||
| ^^^^^^ this is not an unsafe attribute
|
||||
|
|
||||
= note: extraneous unsafe is not allowed in attributes
|
||||
|
||||
error: `proc_macro_attribute` is not an unsafe attribute
|
||||
--> $DIR/proc-unsafe-attributes.rs:18:3
|
||||
|
|
||||
LL | #[unsafe(proc_macro_attribute)]
|
||||
| ^^^^^^ this is not an unsafe attribute
|
||||
|
|
||||
= note: extraneous unsafe is not allowed in attributes
|
||||
|
||||
error: `allow` is not an unsafe attribute
|
||||
--> $DIR/proc-unsafe-attributes.rs:23:3
|
||||
|
|
||||
LL | #[unsafe(allow(dead_code))]
|
||||
| ^^^^^^ this is not an unsafe attribute
|
||||
|
|
||||
= note: extraneous unsafe is not allowed in attributes
|
||||
|
||||
error: `allow` is not an unsafe attribute
|
||||
--> $DIR/proc-unsafe-attributes.rs:27:3
|
||||
|
|
||||
LL | #[unsafe(allow(unsafe(dead_code)))]
|
||||
| ^^^^^^ this is not an unsafe attribute
|
||||
|
|
||||
= note: extraneous unsafe is not allowed in attributes
|
||||
|
||||
error: expected identifier, found keyword `unsafe`
|
||||
--> $DIR/proc-unsafe-attributes.rs:27:16
|
||||
|
|
||||
|
|
@ -103,6 +63,22 @@ LL | #[unsafe(allow(unsafe(dead_code)))]
|
|||
|
|
||||
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
|
||||
|
||||
error: `proc_macro` is not an unsafe attribute
|
||||
--> $DIR/proc-unsafe-attributes.rs:1:3
|
||||
|
|
||||
LL | #[unsafe(proc_macro)]
|
||||
| ^^^^^^ this is not an unsafe attribute
|
||||
|
|
||||
= note: extraneous unsafe is not allowed in attributes
|
||||
|
||||
error: `proc_macro_derive` is not an unsafe attribute
|
||||
--> $DIR/proc-unsafe-attributes.rs:7:3
|
||||
|
|
||||
LL | #[unsafe(proc_macro_derive(Foo))]
|
||||
| ^^^^^^ this is not an unsafe attribute
|
||||
|
|
||||
= note: extraneous unsafe is not allowed in attributes
|
||||
|
||||
error: expected identifier, found keyword `unsafe`
|
||||
--> $DIR/proc-unsafe-attributes.rs:12:21
|
||||
|
|
||||
|
|
@ -132,6 +108,30 @@ LL - #[proc_macro_derive(unsafe(Foo))]
|
|||
LL + #[proc_macro_derive(TraitName, attributes(name1, name2, ...))]
|
||||
|
|
||||
|
||||
error: `proc_macro_attribute` is not an unsafe attribute
|
||||
--> $DIR/proc-unsafe-attributes.rs:18:3
|
||||
|
|
||||
LL | #[unsafe(proc_macro_attribute)]
|
||||
| ^^^^^^ this is not an unsafe attribute
|
||||
|
|
||||
= note: extraneous unsafe is not allowed in attributes
|
||||
|
||||
error: `allow` is not an unsafe attribute
|
||||
--> $DIR/proc-unsafe-attributes.rs:23:3
|
||||
|
|
||||
LL | #[unsafe(allow(dead_code))]
|
||||
| ^^^^^^ this is not an unsafe attribute
|
||||
|
|
||||
= note: extraneous unsafe is not allowed in attributes
|
||||
|
||||
error: `allow` is not an unsafe attribute
|
||||
--> $DIR/proc-unsafe-attributes.rs:27:3
|
||||
|
|
||||
LL | #[unsafe(allow(unsafe(dead_code)))]
|
||||
| ^^^^^^ this is not an unsafe attribute
|
||||
|
|
||||
= note: extraneous unsafe is not allowed in attributes
|
||||
|
||||
error[E0452]: malformed lint attribute input
|
||||
--> $DIR/proc-unsafe-attributes.rs:27:16
|
||||
|
|
||||
|
|
|
|||
10
tests/ui/attributes/unsafe/unsafe-nonexistent-attribute.rs
Normal file
10
tests/ui/attributes/unsafe/unsafe-nonexistent-attribute.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
// This is a regression test for https://github.com/rust-lang/rust/issues/148453
|
||||
// We want the `cannot find attribute` error to appear before `is not an unsafe attribute`
|
||||
//@ edition: 2024
|
||||
|
||||
#[unsafe(does_not_exist)]
|
||||
//~^ ERROR cannot find attribute
|
||||
//~| ERROR is not an unsafe attribute
|
||||
fn aa() {}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
error: cannot find attribute `does_not_exist` in this scope
|
||||
--> $DIR/unsafe-nonexistent-attribute.rs:5:10
|
||||
|
|
||||
LL | #[unsafe(does_not_exist)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: `does_not_exist` is not an unsafe attribute
|
||||
--> $DIR/unsafe-nonexistent-attribute.rs:5:3
|
||||
|
|
||||
LL | #[unsafe(does_not_exist)]
|
||||
| ^^^^^^ this is not an unsafe attribute
|
||||
|
|
||||
= note: extraneous unsafe is not allowed in attributes
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
|
|
@ -3,6 +3,9 @@ error: `#[diagnostic::on_const]` can only be applied to trait impls
|
|||
|
|
||||
LL | #[diagnostic::on_const(message = "tadaa", note = "boing")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL |
|
||||
LL | pub struct Foo;
|
||||
| -------------- not a trait impl
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/misplaced_attr.rs:2:9
|
||||
|
|
@ -15,18 +18,27 @@ error: `#[diagnostic::on_const]` can only be applied to trait impls
|
|||
|
|
||||
LL | #[diagnostic::on_const(message = "tadaa", note = "boing")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL |
|
||||
LL | impl const PartialEq for Foo {
|
||||
| ---------------------------- not a trait impl
|
||||
|
||||
error: `#[diagnostic::on_const]` can only be applied to trait impls
|
||||
--> $DIR/misplaced_attr.rs:16:1
|
||||
|
|
||||
LL | #[diagnostic::on_const(message = "tadaa", note = "boing")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL |
|
||||
LL | impl Foo {
|
||||
| -------- not a trait impl
|
||||
|
||||
error: `#[diagnostic::on_const]` can only be applied to trait impls
|
||||
--> $DIR/misplaced_attr.rs:25:5
|
||||
|
|
||||
LL | #[diagnostic::on_const(message = "tadaa", note = "boing")]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
LL |
|
||||
LL | fn partial_cmp(&self, other: &Foo) -> Option<std::cmp::Ordering> {
|
||||
| ---------------------------------------------------------------- not a trait impl
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//@ compile-flags: --check-cfg=cfg(emscripten_wasm_eh)
|
||||
#[cfg(not(emscripten_wasm_eh))]
|
||||
#[cfg(emscripten_wasm_eh)]
|
||||
//~^ ERROR `cfg(emscripten_wasm_eh)` is experimental
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error[E0658]: `cfg(emscripten_wasm_eh)` is experimental and subject to change
|
||||
--> $DIR/feature-gate-cfg-emscripten-wasm-eh.rs:2:11
|
||||
--> $DIR/feature-gate-cfg-emscripten-wasm-eh.rs:2:7
|
||||
|
|
||||
LL | #[cfg(not(emscripten_wasm_eh))]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
LL | #[cfg(emscripten_wasm_eh)]
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= help: add `#![feature(cfg_emscripten_wasm_eh)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
|
|
|||
|
|
@ -1,14 +1,3 @@
|
|||
error: unsafe attribute used without unsafe
|
||||
--> $DIR/ffi_const.rs:16:7
|
||||
|
|
||||
LL | #[ffi_const]
|
||||
| ^^^^^^^^^ usage of unsafe attribute
|
||||
|
|
||||
help: wrap the attribute in `unsafe(...)`
|
||||
|
|
||||
LL | #[unsafe(ffi_const)]
|
||||
| +++++++ +
|
||||
|
||||
error: `#[ffi_const]` attribute cannot be used on functions
|
||||
--> $DIR/ffi_const.rs:4:1
|
||||
|
|
||||
|
|
@ -33,5 +22,16 @@ LL | #[unsafe(ffi_const)]
|
|||
|
|
||||
= help: `#[ffi_const]` can only be applied to foreign functions
|
||||
|
||||
error: unsafe attribute used without unsafe
|
||||
--> $DIR/ffi_const.rs:16:7
|
||||
|
|
||||
LL | #[ffi_const]
|
||||
| ^^^^^^^^^ usage of unsafe attribute
|
||||
|
|
||||
help: wrap the attribute in `unsafe(...)`
|
||||
|
|
||||
LL | #[unsafe(ffi_const)]
|
||||
| +++++++ +
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,3 @@
|
|||
error: unsafe attribute used without unsafe
|
||||
--> $DIR/ffi_pure.rs:16:7
|
||||
|
|
||||
LL | #[ffi_pure]
|
||||
| ^^^^^^^^ usage of unsafe attribute
|
||||
|
|
||||
help: wrap the attribute in `unsafe(...)`
|
||||
|
|
||||
LL | #[unsafe(ffi_pure)]
|
||||
| +++++++ +
|
||||
|
||||
error: `#[ffi_pure]` attribute cannot be used on functions
|
||||
--> $DIR/ffi_pure.rs:4:1
|
||||
|
|
||||
|
|
@ -33,5 +22,16 @@ LL | #[unsafe(ffi_pure)]
|
|||
|
|
||||
= help: `#[ffi_pure]` can only be applied to foreign functions
|
||||
|
||||
error: unsafe attribute used without unsafe
|
||||
--> $DIR/ffi_pure.rs:16:7
|
||||
|
|
||||
LL | #[ffi_pure]
|
||||
| ^^^^^^^^ usage of unsafe attribute
|
||||
|
|
||||
help: wrap the attribute in `unsafe(...)`
|
||||
|
|
||||
LL | #[unsafe(ffi_pure)]
|
||||
| +++++++ +
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
// E0277 should point exclusively at line 6, not the entire for loop span
|
||||
//! Tests that the E0277 error span, generated by the `for` loop desugaring,
|
||||
//! points exclusively to the loop header expression and not the full loop block.
|
||||
|
||||
fn main() {
|
||||
for c in "asdf" {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0277]: `&str` is not an iterator
|
||||
--> $DIR/for-c-in-str.rs:4:14
|
||||
--> $DIR/for-c-in-str.rs:5:14
|
||||
|
|
||||
LL | for c in "asdf" {
|
||||
| ^^^^^^ `&str` is not an iterator; try calling `.chars()` or `.bytes()`
|
||||
21
tests/ui/for-loop-while/for-loop-bogosity.rs
Normal file
21
tests/ui/for-loop-while/for-loop-bogosity.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//! Tests that a struct with a `next` method but without the `Iterator` trait
|
||||
//! implementation yields an error in a `for` loop.
|
||||
|
||||
struct MyStruct {
|
||||
x: isize,
|
||||
y: isize,
|
||||
}
|
||||
|
||||
impl MyStruct {
|
||||
fn next(&mut self) -> Option<isize> {
|
||||
Some(self.x)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let mut bogus = MyStruct { x: 1, y: 2 };
|
||||
for x in bogus {
|
||||
//~^ ERROR `MyStruct` is not an iterator
|
||||
drop(x);
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ LL | for x in bogus {
|
|||
| ^^^^^ `MyStruct` is not an iterator
|
||||
|
|
||||
help: the trait `Iterator` is not implemented for `MyStruct`
|
||||
--> $DIR/for-loop-bogosity.rs:1:1
|
||||
--> $DIR/for-loop-bogosity.rs:4:1
|
||||
|
|
||||
LL | struct MyStruct {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0425]: cannot find value `foo` in this scope
|
||||
--> $DIR/for-expn.rs:6:7
|
||||
--> $DIR/for-loop-diagnostic-span.rs:6:7
|
||||
|
|
||||
LL | foo
|
||||
| ^^^ not found in this scope
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
//! regression test for issue <https://github.com/rust-lang/rust/issues/16042>
|
||||
|
||||
pub fn main() {
|
||||
let x = () + (); //~ ERROR cannot add `()` to `()`
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0369]: cannot add `()` to `()`
|
||||
--> $DIR/for-loop-type-error.rs:2:16
|
||||
--> $DIR/for-loop-type-error.rs:4:16
|
||||
|
|
||||
LL | let x = () + ();
|
||||
| -- ^ -- ()
|
||||
|
|
@ -3,7 +3,8 @@
|
|||
// Subtle changes in the desugaring can cause the
|
||||
// type of elements in the vector to (incorrectly)
|
||||
// fallback to `!` or `()`.
|
||||
// regression test for issue <https://github.com/rust-lang/rust/issues/42618>
|
||||
|
||||
fn main() {
|
||||
for i in Vec::new() { } //~ ERROR type annotations needed
|
||||
for i in Vec::new() {} //~ ERROR type annotations needed
|
||||
}
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
error[E0282]: type annotations needed
|
||||
--> $DIR/for-loop-unconstrained-element-type.rs:8:14
|
||||
--> $DIR/for-loop-unconstrained-element-type.rs:9:14
|
||||
|
|
||||
LL | for i in Vec::new() { }
|
||||
LL | for i in Vec::new() {}
|
||||
| ^^^^^^^^ cannot infer type of the type parameter `T` declared on the struct `Vec`
|
||||
|
|
||||
help: consider specifying the generic argument
|
||||
|
|
||||
LL | for i in Vec::<T>::new() { }
|
||||
LL | for i in Vec::<T>::new() {}
|
||||
| +++++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
29
tests/ui/for-loop-while/iter-from-mac-call.rs
Normal file
29
tests/ui/for-loop-while/iter-from-mac-call.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
//! Tests for trait/type errors when dereferencing via macro in a for loop.
|
||||
|
||||
macro_rules! deref {
|
||||
($e:expr) => {
|
||||
*$e
|
||||
};
|
||||
}
|
||||
|
||||
fn f1(x: &mut i32) {
|
||||
for _item in deref!(x) {}
|
||||
//~^ ERROR `i32` is not an iterator
|
||||
}
|
||||
|
||||
struct Wrapped(i32);
|
||||
|
||||
macro_rules! borrow_deref {
|
||||
($e:expr) => {
|
||||
&mut *$e
|
||||
};
|
||||
}
|
||||
|
||||
fn f2<'a>(mut iter: Box<dyn Iterator<Item = &'a mut i32>>) {
|
||||
for Wrapped(item) in borrow_deref!(iter) {
|
||||
//~^ ERROR mismatched types
|
||||
*item = 0
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
22
tests/ui/for-loop-while/iter-from-mac-call.stderr
Normal file
22
tests/ui/for-loop-while/iter-from-mac-call.stderr
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
error[E0277]: `i32` is not an iterator
|
||||
--> $DIR/iter-from-mac-call.rs:10:18
|
||||
|
|
||||
LL | for _item in deref!(x) {}
|
||||
| ^^^^^^^^^ `i32` is not an iterator
|
||||
|
|
||||
= help: the trait `Iterator` is not implemented for `i32`
|
||||
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
|
||||
= note: required for `i32` to implement `IntoIterator`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/iter-from-mac-call.rs:23:9
|
||||
|
|
||||
LL | for Wrapped(item) in borrow_deref!(iter) {
|
||||
| ^^^^^^^^^^^^^ ------------------- this is an iterator with items of type `&mut i32`
|
||||
| |
|
||||
| expected `i32`, found `Wrapped`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0308.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
struct MyStruct {
|
||||
x: isize,
|
||||
y: isize,
|
||||
}
|
||||
|
||||
impl MyStruct {
|
||||
fn next(&mut self) -> Option<isize> {
|
||||
Some(self.x)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let mut bogus = MyStruct {
|
||||
x: 1,
|
||||
y: 2,
|
||||
};
|
||||
for x in bogus {
|
||||
//~^ ERROR `MyStruct` is not an iterator
|
||||
drop(x);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
fn changer<'a>(mut things: Box<dyn Iterator<Item=&'a mut u8>>) {
|
||||
for item in *things { *item = 0 }
|
||||
//~^ ERROR `dyn Iterator<Item = &'a mut u8>` is not an iterator
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
macro_rules! deref {
|
||||
($e:expr) => { *$e };
|
||||
}
|
||||
|
||||
fn f1<'a>(mut iter: Box<dyn Iterator<Item=&'a mut u8>>) {
|
||||
for item in deref!(iter) { *item = 0 }
|
||||
//~^ ERROR `dyn Iterator<Item = &'a mut u8>` is not an iterator
|
||||
}
|
||||
|
||||
fn f2(x: &mut i32) {
|
||||
for _item in deref!(x) {}
|
||||
//~^ ERROR `i32` is not an iterator
|
||||
}
|
||||
|
||||
struct Wrapped(i32);
|
||||
|
||||
macro_rules! borrow_deref {
|
||||
($e:expr) => { &mut *$e };
|
||||
}
|
||||
|
||||
fn f3<'a>(mut iter: Box<dyn Iterator<Item=&'a mut i32>>) {
|
||||
for Wrapped(item) in borrow_deref!(iter) { *item = 0 }
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
error[E0277]: `dyn Iterator<Item = &'a mut u8>` is not an iterator
|
||||
--> $DIR/iter_from_mac_call.rs:6:17
|
||||
|
|
||||
LL | for item in deref!(iter) { *item = 0 }
|
||||
| ^^^^^^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
|
||||
|
|
||||
= note: the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
|
||||
= note: required for `dyn Iterator<Item = &'a mut u8>` to implement `IntoIterator`
|
||||
help: consider mutably borrowing here
|
||||
|
|
||||
LL | for item in &mut deref!(iter) { *item = 0 }
|
||||
| ++++
|
||||
|
||||
error[E0277]: `i32` is not an iterator
|
||||
--> $DIR/iter_from_mac_call.rs:11:18
|
||||
|
|
||||
LL | for _item in deref!(x) {}
|
||||
| ^^^^^^^^^ `i32` is not an iterator
|
||||
|
|
||||
= help: the trait `Iterator` is not implemented for `i32`
|
||||
= note: if you want to iterate between `start` until a value `end`, use the exclusive range syntax `start..end` or the inclusive range syntax `start..=end`
|
||||
= note: required for `i32` to implement `IntoIterator`
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/iter_from_mac_call.rs:22:9
|
||||
|
|
||||
LL | for Wrapped(item) in borrow_deref!(iter) { *item = 0 }
|
||||
| ^^^^^^^^^^^^^ ------------------- this is an iterator with items of type `&mut i32`
|
||||
| |
|
||||
| expected `i32`, found `Wrapped`
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0277, E0308.
|
||||
For more information about an error, try `rustc --explain E0277`.
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
#![feature(associated_type_defaults)]
|
||||
|
||||
trait Animal {
|
||||
Type Result = u8;
|
||||
//~^ ERROR expected one of
|
||||
//~^ ERROR keyword `type` is written in the wrong case
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,10 @@
|
|||
error: expected one of `!` or `::`, found `Result`
|
||||
--> $DIR/assoc-type.rs:2:10
|
||||
error: keyword `type` is written in the wrong case
|
||||
--> $DIR/assoc-type.rs:4:5
|
||||
|
|
||||
LL | trait Animal {
|
||||
| - while parsing this item list starting here
|
||||
LL | Type Result = u8;
|
||||
| ^^^^^^ expected one of `!` or `::`
|
||||
LL |
|
||||
LL | }
|
||||
| - the item list ends here
|
||||
| ^^^^
|
||||
|
|
||||
help: write keyword `type` in lowercase
|
||||
help: write it in lowercase
|
||||
|
|
||||
LL - Type Result = u8;
|
||||
LL + type Result = u8;
|
||||
|
|
|
|||
27
tests/ui/parser/misspelled-keywords/recovery.rs
Normal file
27
tests/ui/parser/misspelled-keywords/recovery.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
// Shows that we perform recovery on misspelled item keyword.
|
||||
|
||||
#![feature(associated_type_defaults)]
|
||||
|
||||
trait Animal {
|
||||
Type Result = u8;
|
||||
//~^ ERROR keyword `type` is written in the wrong case
|
||||
}
|
||||
|
||||
Struct Foor {
|
||||
//~^ ERROR keyword `struct` is written in the wrong case
|
||||
hello: String,
|
||||
}
|
||||
|
||||
Const A: u8 = 10;
|
||||
//~^ ERROR keyword `const` is written in the wrong case
|
||||
|
||||
Fn code() {}
|
||||
//~^ ERROR keyword `fn` is written in the wrong case
|
||||
|
||||
Static a: u8 = 0;
|
||||
//~^ ERROR keyword `static` is written in the wrong case
|
||||
|
||||
usee a::b;
|
||||
//~^ ERROR expected one of
|
||||
|
||||
fn main() {}
|
||||
74
tests/ui/parser/misspelled-keywords/recovery.stderr
Normal file
74
tests/ui/parser/misspelled-keywords/recovery.stderr
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
error: keyword `type` is written in the wrong case
|
||||
--> $DIR/recovery.rs:6:5
|
||||
|
|
||||
LL | Type Result = u8;
|
||||
| ^^^^
|
||||
|
|
||||
help: write it in lowercase
|
||||
|
|
||||
LL - Type Result = u8;
|
||||
LL + type Result = u8;
|
||||
|
|
||||
|
||||
error: keyword `struct` is written in the wrong case
|
||||
--> $DIR/recovery.rs:10:1
|
||||
|
|
||||
LL | Struct Foor {
|
||||
| ^^^^^^
|
||||
|
|
||||
help: write it in lowercase (notice the capitalization)
|
||||
|
|
||||
LL - Struct Foor {
|
||||
LL + struct Foor {
|
||||
|
|
||||
|
||||
error: keyword `const` is written in the wrong case
|
||||
--> $DIR/recovery.rs:15:1
|
||||
|
|
||||
LL | Const A: u8 = 10;
|
||||
| ^^^^^
|
||||
|
|
||||
help: write it in lowercase (notice the capitalization)
|
||||
|
|
||||
LL - Const A: u8 = 10;
|
||||
LL + const A: u8 = 10;
|
||||
|
|
||||
|
||||
error: keyword `fn` is written in the wrong case
|
||||
--> $DIR/recovery.rs:18:1
|
||||
|
|
||||
LL | Fn code() {}
|
||||
| ^^
|
||||
|
|
||||
help: write it in lowercase (notice the capitalization)
|
||||
|
|
||||
LL - Fn code() {}
|
||||
LL + fn code() {}
|
||||
|
|
||||
|
||||
error: keyword `static` is written in the wrong case
|
||||
--> $DIR/recovery.rs:21:1
|
||||
|
|
||||
LL | Static a: u8 = 0;
|
||||
| ^^^^^^
|
||||
|
|
||||
help: write it in lowercase (notice the capitalization)
|
||||
|
|
||||
LL - Static a: u8 = 0;
|
||||
LL + static a: u8 = 0;
|
||||
|
|
||||
|
||||
error: expected one of `!` or `::`, found `a`
|
||||
--> $DIR/recovery.rs:24:6
|
||||
|
|
||||
LL | usee a::b;
|
||||
| ^ expected one of `!` or `::`
|
||||
|
|
||||
help: there is a keyword `use` with a similar name
|
||||
|
|
||||
LL - usee a::b;
|
||||
LL + use a::b;
|
||||
|
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
|
|
@ -1,4 +1,3 @@
|
|||
Static a = 0;
|
||||
//~^ ERROR expected one of
|
||||
|
||||
Static a: u32 = 0;
|
||||
//~^ ERROR keyword `static` is written in the wrong case
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
error: expected one of `!` or `::`, found `a`
|
||||
--> $DIR/static.rs:1:8
|
||||
error: keyword `static` is written in the wrong case
|
||||
--> $DIR/static.rs:1:1
|
||||
|
|
||||
LL | Static a = 0;
|
||||
| ^ expected one of `!` or `::`
|
||||
LL | Static a: u32 = 0;
|
||||
| ^^^^^^
|
||||
|
|
||||
help: write keyword `static` in lowercase (notice the capitalization)
|
||||
help: write it in lowercase (notice the capitalization)
|
||||
|
|
||||
LL - Static a = 0;
|
||||
LL + static a = 0;
|
||||
LL - Static a: u32 = 0;
|
||||
LL + static a: u32 = 0;
|
||||
|
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
Struct Foor {
|
||||
//~^ ERROR expected one of
|
||||
//~^ ERROR keyword `struct` is written in the wrong case
|
||||
hello: String,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
error: expected one of `!` or `::`, found `Foor`
|
||||
--> $DIR/struct.rs:1:8
|
||||
error: keyword `struct` is written in the wrong case
|
||||
--> $DIR/struct.rs:1:1
|
||||
|
|
||||
LL | Struct Foor {
|
||||
| ^^^^ expected one of `!` or `::`
|
||||
| ^^^^^^
|
||||
|
|
||||
help: write keyword `struct` in lowercase (notice the capitalization)
|
||||
help: write it in lowercase (notice the capitalization)
|
||||
|
|
||||
LL - Struct Foor {
|
||||
LL + struct Foor {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
//! regression test for issue <https://github.com/rust-lang/rust/issues/122509>
|
||||
//@ build-pass
|
||||
//@ compile-flags: -C codegen-units=2 --emit asm
|
||||
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
error[E0277]: `dyn Iterator<Item = &'a mut u8>` is not an iterator
|
||||
--> $DIR/issue-20605.rs:6:17
|
||||
--> $DIR/dyn-iterator-deref-in-for-loop.rs:9:17
|
||||
|
|
||||
LL | for item in *things { *item = 0 }
|
||||
LL | for item in *things {
|
||||
| ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
|
||||
|
|
||||
= note: the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
|
||||
= note: required for `dyn Iterator<Item = &'a mut u8>` to implement `IntoIterator`
|
||||
help: consider mutably borrowing here
|
||||
|
|
||||
LL | for item in &mut *things { *item = 0 }
|
||||
LL | for item in &mut *things {
|
||||
| ++++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
|
@ -1,14 +1,14 @@
|
|||
error[E0277]: `dyn Iterator<Item = &'a mut u8>` is not an iterator
|
||||
--> $DIR/issue-20605.rs:6:17
|
||||
--> $DIR/dyn-iterator-deref-in-for-loop.rs:9:17
|
||||
|
|
||||
LL | for item in *things { *item = 0 }
|
||||
LL | for item in *things {
|
||||
| ^^^^^^^ the trait `IntoIterator` is not implemented for `dyn Iterator<Item = &'a mut u8>`
|
||||
|
|
||||
= note: the trait bound `dyn Iterator<Item = &'a mut u8>: IntoIterator` is not satisfied
|
||||
= note: required for `dyn Iterator<Item = &'a mut u8>` to implement `IntoIterator`
|
||||
help: consider mutably borrowing here
|
||||
|
|
||||
LL | for item in &mut *things { *item = 0 }
|
||||
LL | for item in &mut *things {
|
||||
| ++++
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
15
tests/ui/traits/dyn-iterator-deref-in-for-loop.rs
Normal file
15
tests/ui/traits/dyn-iterator-deref-in-for-loop.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
//! Tests that dereferencing a Box<dyn Iterator> in a for loop correctly yields an error,
|
||||
//! as the unsized trait object does not implement IntoIterator.
|
||||
//! regression test for <https://github.com/rust-lang/rust/issues/20605>
|
||||
//@ revisions: current next
|
||||
//@ ignore-compare-mode-next-solver (explicit revisions)
|
||||
//@[next] compile-flags: -Znext-solver
|
||||
|
||||
fn changer<'a>(mut things: Box<dyn Iterator<Item = &'a mut u8>>) {
|
||||
for item in *things {
|
||||
//~^ ERROR `dyn Iterator<Item = &'a mut u8>` is not an iterator
|
||||
*item = 0
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue