diff options
Diffstat (limited to 'tests')
13 files changed, 177 insertions, 7 deletions
diff --git a/tests/run-make/metadata-dep-info/dash-separated_something-extra.expected.d b/tests/run-make/metadata-dep-info/dash-separated_something-extra.expected.d index 497d76b4ea1..43e8f9185a3 100644 --- a/tests/run-make/metadata-dep-info/dash-separated_something-extra.expected.d +++ b/tests/run-make/metadata-dep-info/dash-separated_something-extra.expected.d @@ -1,5 +1,5 @@ -libdash_separated_something-extra.rmeta: dash-separated.rs - dash-separated_something-extra.d: dash-separated.rs +libdash_separated_something-extra.rmeta: dash-separated.rs + dash-separated.rs: diff --git a/tests/run-make/rustc-help/help-v.diff b/tests/run-make/rustc-help/help-v.diff index 30703f6424e..0ea79f3e557 100644 --- a/tests/run-make/rustc-help/help-v.diff +++ b/tests/run-make/rustc-help/help-v.diff @@ -1,4 +1,4 @@ -@@ -53,10 +53,27 @@ +@@ -63,10 +63,27 @@ Set a codegen option -V, --version Print version info and exit -v, --verbose Use verbose output diff --git a/tests/run-make/rustc-help/help-v.stdout b/tests/run-make/rustc-help/help-v.stdout index 13af6e21060..744453d6e85 100644 --- a/tests/run-make/rustc-help/help-v.stdout +++ b/tests/run-make/rustc-help/help-v.stdout @@ -26,9 +26,19 @@ Options: Specify which edition of the compiler to use when compiling code. The default is 2015 and the latest stable edition is 2024. - --emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir] + --emit TYPE[=FILE] Comma separated list of types of output for the - compiler to emit + compiler to emit. + Each TYPE has the default FILE name: + * asm - CRATE_NAME.s + * llvm-bc - CRATE_NAME.bc + * dep-info - CRATE_NAME.d + * link - (platform and crate-type dependent) + * llvm-ir - CRATE_NAME.ll + * metadata - libCRATE_NAME.rmeta + * mir - CRATE_NAME.mir + * obj - CRATE_NAME.o + * thin-link-bitcode - CRATE_NAME.indexing.o --print INFO[=FILE] Compiler information to print on stdout (or to a file) INFO may be one of diff --git a/tests/run-make/rustc-help/help.stdout b/tests/run-make/rustc-help/help.stdout index 62757d989eb..3043755207a 100644 --- a/tests/run-make/rustc-help/help.stdout +++ b/tests/run-make/rustc-help/help.stdout @@ -26,9 +26,19 @@ Options: Specify which edition of the compiler to use when compiling code. The default is 2015 and the latest stable edition is 2024. - --emit [asm|llvm-bc|llvm-ir|obj|metadata|link|dep-info|mir] + --emit TYPE[=FILE] Comma separated list of types of output for the - compiler to emit + compiler to emit. + Each TYPE has the default FILE name: + * asm - CRATE_NAME.s + * llvm-bc - CRATE_NAME.bc + * dep-info - CRATE_NAME.d + * link - (platform and crate-type dependent) + * llvm-ir - CRATE_NAME.ll + * metadata - libCRATE_NAME.rmeta + * mir - CRATE_NAME.mir + * obj - CRATE_NAME.o + * thin-link-bitcode - CRATE_NAME.indexing.o --print INFO[=FILE] Compiler information to print on stdout (or to a file) INFO may be one of diff --git a/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.rs b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.rs new file mode 100644 index 00000000000..e8329e3694d --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.rs @@ -0,0 +1,12 @@ +trait Foo { + fn rpitit() -> impl Sized; +} + +// Ensure that we don't try to probe the name of the RPITIT when looking for +// fixes to suggest for the redundant generic below. + +fn test<T: Foo<i32, Assoc = i32>>() {} +//~^ ERROR trait takes 0 generic arguments but 1 generic argument was supplied +//~| ERROR associated type `Assoc` not found for `Foo` + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.stderr b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.stderr new file mode 100644 index 00000000000..1058ef01f32 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.stderr @@ -0,0 +1,24 @@ +error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied + --> $DIR/dont-probe-missing-item-name-2.rs:8:12 + | +LL | fn test<T: Foo<i32, Assoc = i32>>() {} + | ^^^------------------ help: remove the unnecessary generics + | | + | expected 0 generic arguments + | +note: trait defined here, with 0 generic parameters + --> $DIR/dont-probe-missing-item-name-2.rs:1:7 + | +LL | trait Foo { + | ^^^ + +error[E0220]: associated type `Assoc` not found for `Foo` + --> $DIR/dont-probe-missing-item-name-2.rs:8:21 + | +LL | fn test<T: Foo<i32, Assoc = i32>>() {} + | ^^^^^ associated type `Assoc` not found + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0107, E0220. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.rs b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.rs new file mode 100644 index 00000000000..db39bb35437 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.rs @@ -0,0 +1,11 @@ +trait Trait { + fn method() -> impl Sized; +} + +// Ensure that we don't try to probe the name of the RPITIT when looking for +// fixes to suggest for the missing associated type's trait path below. + +fn foo() -> i32::Assoc {} +//~^ ERROR ambiguous associated type + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.stderr b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.stderr new file mode 100644 index 00000000000..f30d0228a3c --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-3.stderr @@ -0,0 +1,15 @@ +error[E0223]: ambiguous associated type + --> $DIR/dont-probe-missing-item-name-3.rs:8:13 + | +LL | fn foo() -> i32::Assoc {} + | ^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated type `Assoc` implemented for `i32`, you could use the fully-qualified path + | +LL - fn foo() -> i32::Assoc {} +LL + fn foo() -> <i32 as Example>::Assoc {} + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0223`. diff --git a/tests/ui/invalid-compile-flags/emit-output-types-without-args.rs b/tests/ui/invalid-compile-flags/emit-output-types-without-args.rs new file mode 100644 index 00000000000..a96eeb0a5ce --- /dev/null +++ b/tests/ui/invalid-compile-flags/emit-output-types-without-args.rs @@ -0,0 +1,2 @@ +//@ compile-flags: --emit +//@ error-pattern: Argument to option 'emit' missing diff --git a/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr b/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr new file mode 100644 index 00000000000..669913b5765 --- /dev/null +++ b/tests/ui/invalid-compile-flags/emit-output-types-without-args.stderr @@ -0,0 +1,15 @@ +error: Argument to option 'emit' missing + Usage: + --emit TYPE[=FILE] Comma separated list of types of output for the + compiler to emit. + Each TYPE has the default FILE name: + * asm - CRATE_NAME.s + * llvm-bc - CRATE_NAME.bc + * dep-info - CRATE_NAME.d + * link - (platform and crate-type dependent) + * llvm-ir - CRATE_NAME.ll + * metadata - libCRATE_NAME.rmeta + * mir - CRATE_NAME.mir + * obj - CRATE_NAME.o + * thin-link-bitcode - CRATE_NAME.indexing.o + diff --git a/tests/ui/typeck/pointer-arith-assign.fixed b/tests/ui/typeck/pointer-arith-assign.fixed new file mode 100644 index 00000000000..907208579e7 --- /dev/null +++ b/tests/ui/typeck/pointer-arith-assign.fixed @@ -0,0 +1,20 @@ +//@ run-rustfix +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_assignments)] + +fn test_add_assign_raw_pointer() { + let mut arr = [0u8; 10]; + let mut _ptr = arr.as_mut_ptr(); + + _ptr = _ptr.wrapping_add(2); //~ ERROR binary assignment operation `+=` cannot be applied to type `*mut u8` [E0368] +} + +fn test_sub_assign_raw_pointer() { + let mut arr = [0u8; 10]; + let mut _ptr = arr.as_mut_ptr(); + + _ptr = _ptr.wrapping_sub(2); //~ ERROR binary assignment operation `-=` cannot be applied to type `*mut u8` [E0368] +} + +fn main() {} diff --git a/tests/ui/typeck/pointer-arith-assign.rs b/tests/ui/typeck/pointer-arith-assign.rs new file mode 100644 index 00000000000..0f4ef6ab74c --- /dev/null +++ b/tests/ui/typeck/pointer-arith-assign.rs @@ -0,0 +1,20 @@ +//@ run-rustfix +#![allow(dead_code)] +#![allow(unused_variables)] +#![allow(unused_assignments)] + +fn test_add_assign_raw_pointer() { + let mut arr = [0u8; 10]; + let mut _ptr = arr.as_mut_ptr(); + + _ptr += 2; //~ ERROR binary assignment operation `+=` cannot be applied to type `*mut u8` [E0368] +} + +fn test_sub_assign_raw_pointer() { + let mut arr = [0u8; 10]; + let mut _ptr = arr.as_mut_ptr(); + + _ptr -= 2; //~ ERROR binary assignment operation `-=` cannot be applied to type `*mut u8` [E0368] +} + +fn main() {} diff --git a/tests/ui/typeck/pointer-arith-assign.stderr b/tests/ui/typeck/pointer-arith-assign.stderr new file mode 100644 index 00000000000..a2bebe5e247 --- /dev/null +++ b/tests/ui/typeck/pointer-arith-assign.stderr @@ -0,0 +1,31 @@ +error[E0368]: binary assignment operation `+=` cannot be applied to type `*mut u8` + --> $DIR/pointer-arith-assign.rs:10:5 + | +LL | _ptr += 2; + | ----^^^^^ + | | + | cannot use `+=` on type `*mut u8` + | +help: consider using `add` or `wrapping_add` to do pointer arithmetic + | +LL - _ptr += 2; +LL + _ptr = _ptr.wrapping_add(2); + | + +error[E0368]: binary assignment operation `-=` cannot be applied to type `*mut u8` + --> $DIR/pointer-arith-assign.rs:17:5 + | +LL | _ptr -= 2; + | ----^^^^^ + | | + | cannot use `-=` on type `*mut u8` + | +help: consider using `sub` or `wrapping_sub` to do pointer arithmetic + | +LL - _ptr -= 2; +LL + _ptr = _ptr.wrapping_sub(2); + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0368`. |
