diff options
Diffstat (limited to 'src/test')
12 files changed, 133 insertions, 14 deletions
diff --git a/src/test/ui/associated-consts/associated-const-ambiguity-report.stderr b/src/test/ui/associated-consts/associated-const-ambiguity-report.stderr index c5e32afbbce..fc94ef2ff88 100644 --- a/src/test/ui/associated-consts/associated-const-ambiguity-report.stderr +++ b/src/test/ui/associated-consts/associated-const-ambiguity-report.stderr @@ -17,11 +17,11 @@ LL | const ID: i32 = 3; help: disambiguate the associated constant for candidate #1 | LL | const X: i32 = Foo::ID; - | ^^^^^^^ + | ^^^^^ help: disambiguate the associated constant for candidate #2 | LL | const X: i32 = Bar::ID; - | ^^^^^^^ + | ^^^^^ error: aborting due to previous error diff --git a/src/test/ui/const-generics/enum-variants.rs b/src/test/ui/const-generics/enum-variants.rs new file mode 100644 index 00000000000..5c6c4a8efac --- /dev/null +++ b/src/test/ui/const-generics/enum-variants.rs @@ -0,0 +1,24 @@ +// check-pass +enum Foo<const N: usize> { + Variant, + Variant2(), + Variant3{}, +} + +struct Bar<const N: usize>; +struct Bar2<const N: usize>(); +struct Bar3<const N: usize> {} + +fn main() { + let _ = Foo::Variant::<1>; + let _ = Foo::Variant2::<1>(); + let _ = Foo::Variant3::<1>{}; + + let _ = Foo::<1>::Variant; + let _ = Foo::<1>::Variant2(); + let _ = Foo::<1>::Variant3{}; + + let _ = Bar::<1>; + let _ = Bar2::<1>(); + let _ = Bar3::<1>{}; +} diff --git a/src/test/ui/error-codes/E0034.stderr b/src/test/ui/error-codes/E0034.stderr index 471512ca8f7..55119857d8f 100644 --- a/src/test/ui/error-codes/E0034.stderr +++ b/src/test/ui/error-codes/E0034.stderr @@ -17,11 +17,11 @@ LL | fn foo() {} help: disambiguate the associated function for candidate #1 | LL | Trait1::foo() - | ^^^^^^^^^^^ + | ^^^^^^^^ help: disambiguate the associated function for candidate #2 | LL | Trait2::foo() - | ^^^^^^^^^^^ + | ^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/issues/issue-18446.stderr b/src/test/ui/issues/issue-18446.stderr index 11c8cfdcf66..33cf76d777b 100644 --- a/src/test/ui/issues/issue-18446.stderr +++ b/src/test/ui/issues/issue-18446.stderr @@ -2,10 +2,7 @@ error[E0034]: multiple applicable items in scope --> $DIR/issue-18446.rs:18:7 | LL | x.foo(); - | --^^^-- - | | | - | | multiple `foo` found - | help: disambiguate the associated function for candidate #2: `T::foo(&x)` + | ^^^ multiple `foo` found | note: candidate #1 is defined in an impl for the type `(dyn T + 'a)` --> $DIR/issue-18446.rs:9:5 @@ -17,6 +14,10 @@ note: candidate #2 is defined in the trait `T` | LL | fn foo(&self); | ^^^^^^^^^^^^^^ +help: disambiguate the associated function for candidate #2 + | +LL | T::foo(&x); + | ^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/methods/method-ambig-two-traits-from-impls2.stderr b/src/test/ui/methods/method-ambig-two-traits-from-impls2.stderr index 85b39647885..7bfb8baa0c6 100644 --- a/src/test/ui/methods/method-ambig-two-traits-from-impls2.stderr +++ b/src/test/ui/methods/method-ambig-two-traits-from-impls2.stderr @@ -17,11 +17,11 @@ LL | fn foo() {} help: disambiguate the associated function for candidate #1 | LL | A::foo(); - | ^^^^^^ + | ^^^ help: disambiguate the associated function for candidate #2 | LL | B::foo(); - | ^^^^^^ + | ^^^ error: aborting due to previous error diff --git a/src/test/ui/span/issue-7575.stderr b/src/test/ui/span/issue-7575.stderr index 16a1ac6d718..f789441378f 100644 --- a/src/test/ui/span/issue-7575.stderr +++ b/src/test/ui/span/issue-7575.stderr @@ -61,10 +61,7 @@ error[E0599]: no method named `is_str` found for type parameter `T` in the curre --> $DIR/issue-7575.rs:70:7 | LL | t.is_str() - | --^^^^^^-- - | | | - | | this is an associated function, not a method - | help: disambiguate the associated function for the candidate: `ManyImplTrait::is_str(t)` + | ^^^^^^ this is an associated function, not a method | = note: found the following associated functions; to be used as methods, functions must have a `self` parameter note: the candidate is defined in the trait `ManyImplTrait` @@ -73,6 +70,10 @@ note: the candidate is defined in the trait `ManyImplTrait` LL | fn is_str() -> bool { | ^^^^^^^^^^^^^^^^^^^ = help: items from traits can only be used if the type parameter is bounded by the trait +help: disambiguate the associated function for the candidate + | +LL | ManyImplTrait::is_str(t) + | error: aborting due to 3 previous errors diff --git a/src/test/ui/typeck/issue-87872-missing-inaccessible-field-literal.rs b/src/test/ui/typeck/issue-87872-missing-inaccessible-field-literal.rs new file mode 100644 index 00000000000..31761441337 --- /dev/null +++ b/src/test/ui/typeck/issue-87872-missing-inaccessible-field-literal.rs @@ -0,0 +1,11 @@ +pub mod foo { + pub struct Foo { + pub you_can_use_this_field: bool, + you_cant_use_this_field: bool, + } +} + +fn main() { + foo::Foo {}; + //~^ ERROR cannot construct `Foo` with struct literal syntax due to inaccessible fields +} diff --git a/src/test/ui/typeck/issue-87872-missing-inaccessible-field-literal.stderr b/src/test/ui/typeck/issue-87872-missing-inaccessible-field-literal.stderr new file mode 100644 index 00000000000..81b73c00e86 --- /dev/null +++ b/src/test/ui/typeck/issue-87872-missing-inaccessible-field-literal.stderr @@ -0,0 +1,8 @@ +error: cannot construct `Foo` with struct literal syntax due to inaccessible fields + --> $DIR/issue-87872-missing-inaccessible-field-literal.rs:9:5 + | +LL | foo::Foo {}; + | ^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/typeck/issue-87872-missing-inaccessible-field-pattern.rs b/src/test/ui/typeck/issue-87872-missing-inaccessible-field-pattern.rs new file mode 100644 index 00000000000..d28e17559d8 --- /dev/null +++ b/src/test/ui/typeck/issue-87872-missing-inaccessible-field-pattern.rs @@ -0,0 +1,11 @@ +#![allow(dead_code, unused_variables)] + +pub mod foo { + #[derive(Default)] + pub struct Foo { pub visible: bool, invisible: bool, } +} + +fn main() { + let foo::Foo {} = foo::Foo::default(); + //~^ ERROR pattern does not mention field `visible` and inaccessible fields +} diff --git a/src/test/ui/typeck/issue-87872-missing-inaccessible-field-pattern.stderr b/src/test/ui/typeck/issue-87872-missing-inaccessible-field-pattern.stderr new file mode 100644 index 00000000000..51b8e39b101 --- /dev/null +++ b/src/test/ui/typeck/issue-87872-missing-inaccessible-field-pattern.stderr @@ -0,0 +1,18 @@ +error[E0027]: pattern does not mention field `visible` and inaccessible fields + --> $DIR/issue-87872-missing-inaccessible-field-pattern.rs:9:9 + | +LL | let foo::Foo {} = foo::Foo::default(); + | ^^^^^^^^^^^ missing field `visible` and inaccessible fields + | +help: include the missing field in the pattern and ignore the inaccessible fields + | +LL | let foo::Foo { visible, .. } = foo::Foo::default(); + | ^^^^^^^^^^^^^^^ +help: if you don't care about this missing field, you can explicitly ignore it + | +LL | let foo::Foo { .. } = foo::Foo::default(); + | ^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0027`. diff --git a/src/test/ui/wf/hir-wf-check-erase-regions.rs b/src/test/ui/wf/hir-wf-check-erase-regions.rs new file mode 100644 index 00000000000..bb398e5698a --- /dev/null +++ b/src/test/ui/wf/hir-wf-check-erase-regions.rs @@ -0,0 +1,14 @@ +// Regression test for #87549. +// compile-flags: -C incremental=tmp/wf/hir-wf-check-erase-regions + +pub struct Table<T, const N: usize>([Option<T>; N]); + +impl<'a, T, const N: usize> IntoIterator for &'a Table<T, N> { + type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; //~ ERROR `&T` is not an iterator + type Item = &'a T; + + fn into_iter(self) -> Self::IntoIter { //~ ERROR `&T` is not an iterator + unimplemented!() + } +} +fn main() {} diff --git a/src/test/ui/wf/hir-wf-check-erase-regions.stderr b/src/test/ui/wf/hir-wf-check-erase-regions.stderr new file mode 100644 index 00000000000..a704754e82a --- /dev/null +++ b/src/test/ui/wf/hir-wf-check-erase-regions.stderr @@ -0,0 +1,31 @@ +error[E0277]: `&T` is not an iterator + --> $DIR/hir-wf-check-erase-regions.rs:7:5 + | +LL | type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&T` is not an iterator + | + ::: $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL + | +LL | pub struct Flatten<I: Iterator<Item: IntoIterator>> { + | ------------ required by this bound in `Flatten` + | + = help: the trait `Iterator` is not implemented for `&T` + = note: required because of the requirements on the impl of `IntoIterator` for `&T` + +error[E0277]: `&T` is not an iterator + --> $DIR/hir-wf-check-erase-regions.rs:10:27 + | +LL | fn into_iter(self) -> Self::IntoIter { + | ^^^^^^^^^^^^^^ `&T` is not an iterator + | + ::: $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL + | +LL | pub struct Flatten<I: Iterator<Item: IntoIterator>> { + | ------------ required by this bound in `Flatten` + | + = help: the trait `Iterator` is not implemented for `&T` + = note: required because of the requirements on the impl of `IntoIterator` for `&T` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. |
