summaryrefslogtreecommitdiffstats
path: root/src/test/ui/type
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr2
-rw-r--r--src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr2
-rw-r--r--src/test/ui/type-alias-impl-trait/closure_args.rs16
-rw-r--r--src/test/ui/type-alias-impl-trait/closure_args2.rs23
-rw-r--r--src/test/ui/type-alias-impl-trait/closure_parent_substs.rs65
-rw-r--r--src/test/ui/type-alias-impl-trait/closure_wf_outlives.rs65
-rw-r--r--src/test/ui/type-alias-impl-trait/closure_wf_outlives.stderr64
-rw-r--r--src/test/ui/type-alias-impl-trait/constrain_inputs.rs24
-rw-r--r--src/test/ui/type-alias-impl-trait/constrain_inputs.stderr58
-rw-r--r--src/test/ui/type-alias-impl-trait/constrain_inputs_unsound.rs31
-rw-r--r--src/test/ui/type-alias-impl-trait/constrain_inputs_unsound.stderr9
-rw-r--r--src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs3
-rw-r--r--src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.stderr10
-rw-r--r--src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.rs6
-rw-r--r--src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.stderr10
-rw-r--r--src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.rs4
-rw-r--r--src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr14
-rw-r--r--src/test/ui/type-alias-impl-trait/different_defining_uses_never_type3.rs12
-rw-r--r--src/test/ui/type-alias-impl-trait/different_defining_uses_never_type3.stderr14
-rw-r--r--src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs6
-rw-r--r--src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr4
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs5
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr6
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs7
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr12
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.stderr8
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.stderr6
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.stderr4
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr8
-rw-r--r--src/test/ui/type-alias-impl-trait/generic_lifetime_param.rs5
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_bounds.rs51
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_bounds.stderr16
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_bounds2.rs10
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_bounds3.rs18
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_bounds_closure.rs31
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_bounds_closure.stderr11
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_bounds_from_types.rs51
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_bounds_from_types.stderr16
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check.rs27
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs43
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr58
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.rs11
-rw-r--r--src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr14
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-101750.rs37
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr3
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr2
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-57961.rs2
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-57961.stderr2
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs2
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-58662-simplified.rs20
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-60371.stderr2
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-74280.stderr2
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-89686.rs2
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-89686.stderr2
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-90400-1.rs1
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-90400-1.stderr4
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-90400-2.rs1
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-90400-2.stderr6
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.rs10
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.stderr15
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-96572-unconstrained.rs92
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-98604.rs6
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-98604.stderr6
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-98608.rs6
-rw-r--r--src/test/ui/type-alias-impl-trait/issue-98608.stderr6
-rw-r--r--src/test/ui/type-alias-impl-trait/missing_lifetime_bound.rs7
-rw-r--r--src/test/ui/type-alias-impl-trait/missing_lifetime_bound.stderr8
-rw-r--r--src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs6
-rw-r--r--src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr2
-rw-r--r--src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs6
-rw-r--r--src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr2
-rw-r--r--src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr4
-rw-r--r--src/test/ui/type-alias-impl-trait/unbounded_opaque_type.rs14
-rw-r--r--src/test/ui/type-alias-impl-trait/underconstrained_generic.stderr2
-rw-r--r--src/test/ui/type/issue-100584.rs15
-rw-r--r--src/test/ui/type/issue-100584.stderr44
-rw-r--r--src/test/ui/type/issue-101866.rs15
-rw-r--r--src/test/ui/type/issue-101866.stderr18
-rw-r--r--src/test/ui/type/issue-94187-verbose-type-name.rs13
-rw-r--r--src/test/ui/type/type-alias-bounds.rs2
-rw-r--r--src/test/ui/type/type-arg-out-of-scope.stderr12
-rw-r--r--src/test/ui/type/type-ascription-instead-of-initializer.stderr2
-rw-r--r--src/test/ui/type/type-check-defaults.stderr8
-rw-r--r--src/test/ui/type/type-check/assignment-expected-bool.stderr22
-rw-r--r--src/test/ui/type/type-check/assignment-in-if.rs19
-rw-r--r--src/test/ui/type/type-check/assignment-in-if.stderr71
-rw-r--r--src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr16
-rw-r--r--src/test/ui/type/type-mismatch-same-crate-name.stderr11
-rw-r--r--src/test/ui/type/type-params-in-different-spaces-2.stderr12
-rw-r--r--src/test/ui/type/type-recursive-box-shadowed.stderr4
-rw-r--r--src/test/ui/type/type-recursive.stderr42
-rw-r--r--src/test/ui/type_length_limit.stderr4
-rw-r--r--src/test/ui/typeck/assign-non-lval-derefmut.stderr4
-rw-r--r--src/test/ui/typeck/assign-non-lval-mut-ref.stderr4
-rw-r--r--src/test/ui/typeck/assign-non-lval-needs-deref.rs19
-rw-r--r--src/test/ui/typeck/assign-non-lval-needs-deref.stderr16
-rw-r--r--src/test/ui/typeck/do-not-suggest-placeholder-to-const-static-without-type.rs8
-rw-r--r--src/test/ui/typeck/do-not-suggest-placeholder-to-const-static-without-type.stderr20
-rw-r--r--src/test/ui/typeck/issue-100164.fixed9
-rw-r--r--src/test/ui/typeck/issue-100164.rs9
-rw-r--r--src/test/ui/typeck/issue-100164.stderr14
-rw-r--r--src/test/ui/typeck/issue-100246.rs30
-rw-r--r--src/test/ui/typeck/issue-100246.stderr13
-rw-r--r--src/test/ui/typeck/issue-100285.rs22
-rw-r--r--src/test/ui/typeck/issue-100285.stderr34
-rw-r--r--src/test/ui/typeck/issue-29124.stderr8
-rw-r--r--src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.stderr4
-rw-r--r--src/test/ui/typeck/issue-79040.stderr4
-rw-r--r--src/test/ui/typeck/issue-87181/empty-tuple-method.rs2
-rw-r--r--src/test/ui/typeck/issue-87181/empty-tuple-method.stderr6
-rw-r--r--src/test/ui/typeck/issue-87181/enum-variant.rs2
-rw-r--r--src/test/ui/typeck/issue-87181/enum-variant.stderr6
-rw-r--r--src/test/ui/typeck/issue-87181/tuple-field.stderr10
-rw-r--r--src/test/ui/typeck/issue-87181/tuple-method.stderr9
-rw-r--r--src/test/ui/typeck/issue-90101.stderr2
-rw-r--r--src/test/ui/typeck/issue-91210-ptr-method.stderr9
-rw-r--r--src/test/ui/typeck/issue-91633.rs8
-rw-r--r--src/test/ui/typeck/issue-96738.stderr18
-rw-r--r--src/test/ui/typeck/issue-98982.rs9
-rw-r--r--src/test/ui/typeck/issue-98982.stderr24
-rw-r--r--src/test/ui/typeck/point-at-type-param-in-path-expr.rs6
-rw-r--r--src/test/ui/typeck/point-at-type-param-in-path-expr.stderr17
-rw-r--r--src/test/ui/typeck/remove-extra-argument.stderr2
-rw-r--r--src/test/ui/typeck/slow-lhs-suggestion.rs26
-rw-r--r--src/test/ui/typeck/slow-lhs-suggestion.stderr187
-rw-r--r--src/test/ui/typeck/struct-enum-wrong-args.stderr16
-rw-r--r--src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.stderr14
-rw-r--r--src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr8
-rw-r--r--src/test/ui/typeck/typeck_type_placeholder_item.stderr4
-rw-r--r--src/test/ui/typeof/issue-100183.rs6
-rw-r--r--src/test/ui/typeof/issue-100183.stderr14
131 files changed, 1850 insertions, 243 deletions
diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr b/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr
index 006253f84..eb58ee73c 100644
--- a/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr
+++ b/src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr
@@ -12,7 +12,7 @@ LL | V(u8)
help: provide the argument
|
LL | <E>::V(/* u8 */);
- | ~~~~~~~~~~~~~~~~
+ | ~~~~~~~~~~
error[E0308]: mismatched types
--> $DIR/enum-variant-priority-higher-than-other-inherent.rs:22:17
diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr b/src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr
index aaa3159e0..0202a2fea 100644
--- a/src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr
+++ b/src/test/ui/type-alias-enum-variants/enum-variant-priority-lint-ambiguous_associated_items.stderr
@@ -4,7 +4,6 @@ error: ambiguous associated item
LL | fn f() -> Self::V { 0 }
| ^^^^^^^ help: use fully-qualified syntax: `<E as Tr>::V`
|
- = note: `#[deny(ambiguous_associated_items)]` on by default
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #57644 <https://github.com/rust-lang/rust/issues/57644>
note: `V` could refer to the variant defined here
@@ -17,6 +16,7 @@ note: `V` could also refer to the associated type defined here
|
LL | type V;
| ^^^^^^
+ = note: `#[deny(ambiguous_associated_items)]` on by default
error: ambiguous associated item
--> $DIR/enum-variant-priority-lint-ambiguous_associated_items.rs:32:15
diff --git a/src/test/ui/type-alias-impl-trait/closure_args.rs b/src/test/ui/type-alias-impl-trait/closure_args.rs
new file mode 100644
index 000000000..c5e7af81d
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/closure_args.rs
@@ -0,0 +1,16 @@
+// check-pass
+
+// regression test for https://github.com/rust-lang/rust/issues/100800
+
+#![feature(type_alias_impl_trait)]
+
+trait Anything {}
+impl<T> Anything for T {}
+type Input = impl Anything;
+fn run<F: FnOnce(Input) -> ()>(f: F, i: Input) {
+ f(i);
+}
+
+fn main() {
+ run(|x: u32| {println!("{x}");}, 0);
+}
diff --git a/src/test/ui/type-alias-impl-trait/closure_args2.rs b/src/test/ui/type-alias-impl-trait/closure_args2.rs
new file mode 100644
index 000000000..82386c280
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/closure_args2.rs
@@ -0,0 +1,23 @@
+// run-pass
+
+#![feature(type_alias_impl_trait)]
+
+trait Foo {
+ // This was reachable in https://github.com/rust-lang/rust/issues/100800
+ fn foo(&self) { unreachable!() }
+}
+impl<T> Foo for T {}
+
+struct B;
+impl B {
+ fn foo(&self) {}
+}
+
+type Input = impl Foo;
+fn run1<F: FnOnce(Input)>(f: F, i: Input) {f(i)}
+fn run2<F: FnOnce(B)>(f: F, i: B) {f(i)}
+
+fn main() {
+ run1(|x: B| {x.foo()}, B);
+ run2(|x: B| {x.foo()}, B);
+}
diff --git a/src/test/ui/type-alias-impl-trait/closure_parent_substs.rs b/src/test/ui/type-alias-impl-trait/closure_parent_substs.rs
new file mode 100644
index 000000000..475f4724f
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/closure_parent_substs.rs
@@ -0,0 +1,65 @@
+// When WF checking the hidden type in the ParamEnv of the opaque type,
+// one complication arises when the hidden type is a closure/generator:
+// the "parent_substs" of the type may reference lifetime parameters
+// not present in the opaque type.
+// These region parameters are not really useful in this check.
+// So here we ignore them and replace them with fresh region variables.
+
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+// Basic test
+mod test1 {
+ // Hidden type = Closure['_#0r]
+ type Opaque = impl Sized;
+
+ fn define<'a: 'a>() -> Opaque {
+ || {}
+ }
+}
+
+// the region vars cannot both be equal to `'static` or `'empty`
+mod test2 {
+ trait Trait {}
+
+ // Hidden type = Closure['a, '_#0r, '_#1r]
+ // Constraints = [('_#0r: 'a), ('a: '_#1r)]
+ type Opaque<'a>
+ where
+ &'a (): Trait,
+ = impl Sized + 'a;
+
+ fn define<'a, 'x, 'y>() -> Opaque<'a>
+ where
+ &'a (): Trait,
+ 'x: 'a,
+ 'a: 'y,
+ {
+ || {}
+ }
+}
+
+// the region var cannot be equal to `'a` or `'b`
+mod test3 {
+ trait Trait {}
+
+ // Hidden type = Closure['a, 'b, '_#0r]
+ // Constraints = [('_#0r: 'a), ('_#0r: 'b)]
+ type Opaque<'a, 'b>
+ where
+ (&'a (), &'b ()): Trait,
+ = impl Sized + 'a + 'b;
+
+ fn define<'a, 'b, 'x>() -> Opaque<'a, 'b>
+ where
+ (&'a (), &'b ()): Trait,
+ 'x: 'a,
+ 'x: 'b,
+ {
+ || {}
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/closure_wf_outlives.rs b/src/test/ui/type-alias-impl-trait/closure_wf_outlives.rs
new file mode 100644
index 000000000..53974dbb3
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/closure_wf_outlives.rs
@@ -0,0 +1,65 @@
+// If the hidden type is a closure, we require the "outlives" bounds that appear on the
+// defining site to also appear on the opaque type.
+//
+// It's not clear if this is the desired behavior but at least
+// it's consistent and has no back-compat risk.
+
+// check-fail
+
+#![feature(type_alias_impl_trait)]
+#![allow(dead_code)]
+
+// requires `'a: 'b` bound
+mod test1 {
+ type Opaque<'a, 'b> = impl Sized + 'a + 'b;
+ //~^ ERROR lifetime bound not satisfied
+
+ fn define<'a, 'b>() -> Opaque<'a, 'b>
+ where
+ 'a: 'b,
+ {
+ || {}
+ }
+}
+
+// Same as the above but through indirection `'x`
+mod test2 {
+ type Opaque<'a, 'b> = impl Sized + 'a + 'b;
+ //~^ ERROR cannot infer an appropriate lifetime
+
+ fn define<'a, 'b, 'x>() -> Opaque<'a, 'b>
+ where
+ 'a: 'x,
+ 'x: 'b,
+ {
+ || {}
+ }
+}
+
+// fixed version of the above
+mod test2_fixed {
+ type Opaque<'a: 'b, 'b> = impl Sized + 'a + 'b;
+
+ fn define<'a, 'b, 'x>() -> Opaque<'a, 'b>
+ where
+ 'a: 'x,
+ 'x: 'b,
+ {
+ || {}
+ }
+}
+
+// requires `T: 'static`
+mod test3 {
+ type Opaque<T> = impl Sized;
+ //~^ ERROR the parameter type `T` may not live long enough
+
+ fn define<T>() -> Opaque<T>
+ where
+ T: 'static,
+ {
+ || {}
+ }
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/closure_wf_outlives.stderr b/src/test/ui/type-alias-impl-trait/closure_wf_outlives.stderr
new file mode 100644
index 000000000..ae6462bb6
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/closure_wf_outlives.stderr
@@ -0,0 +1,64 @@
+error[E0478]: lifetime bound not satisfied
+ --> $DIR/closure_wf_outlives.rs:14:27
+ |
+LL | type Opaque<'a, 'b> = impl Sized + 'a + 'b;
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+note: lifetime parameter instantiated with the lifetime `'a` as defined here
+ --> $DIR/closure_wf_outlives.rs:14:17
+ |
+LL | type Opaque<'a, 'b> = impl Sized + 'a + 'b;
+ | ^^
+note: but lifetime parameter must outlive the lifetime `'b` as defined here
+ --> $DIR/closure_wf_outlives.rs:14:21
+ |
+LL | type Opaque<'a, 'b> = impl Sized + 'a + 'b;
+ | ^^
+
+error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements
+ --> $DIR/closure_wf_outlives.rs:27:27
+ |
+LL | type Opaque<'a, 'b> = impl Sized + 'a + 'b;
+ | ^^^^^^^^^^^^^^^^^^^^
+ |
+note: first, the lifetime cannot outlive the lifetime `'a` as defined here...
+ --> $DIR/closure_wf_outlives.rs:27:17
+ |
+LL | type Opaque<'a, 'b> = impl Sized + 'a + 'b;
+ | ^^
+note: ...so that the declared lifetime parameter bounds are satisfied
+ --> $DIR/closure_wf_outlives.rs:27:27
+ |
+LL | type Opaque<'a, 'b> = impl Sized + 'a + 'b;
+ | ^^^^^^^^^^^^^^^^^^^^
+note: but, the lifetime must be valid for the lifetime `'b` as defined here...
+ --> $DIR/closure_wf_outlives.rs:27:21
+ |
+LL | type Opaque<'a, 'b> = impl Sized + 'a + 'b;
+ | ^^
+note: ...so that the declared lifetime parameter bounds are satisfied
+ --> $DIR/closure_wf_outlives.rs:27:27
+ |
+LL | type Opaque<'a, 'b> = impl Sized + 'a + 'b;
+ | ^^^^^^^^^^^^^^^^^^^^
+
+error[E0310]: the parameter type `T` may not live long enough
+ --> $DIR/closure_wf_outlives.rs:54:22
+ |
+LL | type Opaque<T> = impl Sized;
+ | ^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds...
+ |
+note: ...that is required by this bound
+ --> $DIR/closure_wf_outlives.rs:59:12
+ |
+LL | T: 'static,
+ | ^^^^^^^
+help: consider adding an explicit lifetime bound...
+ |
+LL | type Opaque<T: 'static> = impl Sized;
+ | +++++++++
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0310, E0478, E0495.
+For more information about an error, try `rustc --explain E0310`.
diff --git a/src/test/ui/type-alias-impl-trait/constrain_inputs.rs b/src/test/ui/type-alias-impl-trait/constrain_inputs.rs
index c32174288..03fb64b7b 100644
--- a/src/test/ui/type-alias-impl-trait/constrain_inputs.rs
+++ b/src/test/ui/type-alias-impl-trait/constrain_inputs.rs
@@ -1,17 +1,33 @@
-// check-pass
-
#![feature(type_alias_impl_trait)]
-mod foo {
+mod lifetime_params {
type Ty<'a> = impl Sized;
fn defining(s: &str) -> Ty<'_> { s }
fn execute(ty: Ty<'_>) -> &str { todo!() }
+ //~^ ERROR return type references an anonymous lifetime, which is not constrained by the fn input types
+
+ type BadFnSig = fn(Ty<'_>) -> &str;
+ //~^ ERROR return type references an anonymous lifetime, which is not constrained by the fn input types
+ type BadTraitRef = dyn Fn(Ty<'_>) -> &str;
+ //~^ ERROR binding for associated type `Output` references an anonymous lifetime
}
-mod bar {
+mod lifetime_params_2 {
type Ty<'a> = impl FnOnce() -> &'a str;
fn defining(s: &str) -> Ty<'_> { move || s }
fn execute(ty: Ty<'_>) -> &str { ty() }
+ //~^ ERROR return type references an anonymous lifetime, which is not constrained by the fn input types
+}
+
+// regression test for https://github.com/rust-lang/rust/issues/97104
+mod type_params {
+ type Ty<T> = impl Sized;
+ fn define<T>(s: T) -> Ty<T> { s }
+
+ type BadFnSig = fn(Ty<&str>) -> &str;
+ //~^ ERROR return type references an anonymous lifetime, which is not constrained by the fn input types
+ type BadTraitRef = dyn Fn(Ty<&str>) -> &str;
+ //~^ ERROR binding for associated type `Output` references an anonymous lifetime
}
fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/constrain_inputs.stderr b/src/test/ui/type-alias-impl-trait/constrain_inputs.stderr
new file mode 100644
index 000000000..93953fd06
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/constrain_inputs.stderr
@@ -0,0 +1,58 @@
+error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
+ --> $DIR/constrain_inputs.rs:6:31
+ |
+LL | fn execute(ty: Ty<'_>) -> &str { todo!() }
+ | ^^^^
+ |
+ = note: lifetimes appearing in an associated or opaque type are not considered constrained
+ = note: consider introducing a named lifetime parameter
+
+error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
+ --> $DIR/constrain_inputs.rs:9:35
+ |
+LL | type BadFnSig = fn(Ty<'_>) -> &str;
+ | ^^^^
+ |
+ = note: lifetimes appearing in an associated or opaque type are not considered constrained
+ = note: consider introducing a named lifetime parameter
+
+error[E0582]: binding for associated type `Output` references an anonymous lifetime, which does not appear in the trait input types
+ --> $DIR/constrain_inputs.rs:11:42
+ |
+LL | type BadTraitRef = dyn Fn(Ty<'_>) -> &str;
+ | ^^^^
+ |
+ = note: lifetimes appearing in an associated or opaque type are not considered constrained
+ = note: consider introducing a named lifetime parameter
+
+error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
+ --> $DIR/constrain_inputs.rs:18:31
+ |
+LL | fn execute(ty: Ty<'_>) -> &str { ty() }
+ | ^^^^
+ |
+ = note: lifetimes appearing in an associated or opaque type are not considered constrained
+ = note: consider introducing a named lifetime parameter
+
+error[E0581]: return type references an anonymous lifetime, which is not constrained by the fn input types
+ --> $DIR/constrain_inputs.rs:27:37
+ |
+LL | type BadFnSig = fn(Ty<&str>) -> &str;
+ | ^^^^
+ |
+ = note: lifetimes appearing in an associated or opaque type are not considered constrained
+ = note: consider introducing a named lifetime parameter
+
+error[E0582]: binding for associated type `Output` references an anonymous lifetime, which does not appear in the trait input types
+ --> $DIR/constrain_inputs.rs:29:44
+ |
+LL | type BadTraitRef = dyn Fn(Ty<&str>) -> &str;
+ | ^^^^
+ |
+ = note: lifetimes appearing in an associated or opaque type are not considered constrained
+ = note: consider introducing a named lifetime parameter
+
+error: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0581, E0582.
+For more information about an error, try `rustc --explain E0581`.
diff --git a/src/test/ui/type-alias-impl-trait/constrain_inputs_unsound.rs b/src/test/ui/type-alias-impl-trait/constrain_inputs_unsound.rs
new file mode 100644
index 000000000..3bae0f173
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/constrain_inputs_unsound.rs
@@ -0,0 +1,31 @@
+#![feature(type_alias_impl_trait)]
+
+trait Static: 'static {}
+impl Static for () {}
+
+type Gal<T> = impl Static;
+fn _defining<T>() -> Gal<T> {}
+
+trait Callable<Arg> { type Output; }
+
+/// We can infer `<C as Callable<Arg>>::Output: 'static`,
+/// because we know `C: 'static` and `Arg: 'static`,
+fn box_str<C, Arg>(s: C::Output) -> Box<dyn AsRef<str> + 'static>
+where
+ Arg: Static,
+ C: ?Sized + Callable<Arg> + 'static,
+ C::Output: AsRef<str>,
+{
+ Box::new(s)
+}
+
+fn extend_lifetime(s: &str) -> Box<dyn AsRef<str> + 'static> {
+ type MalformedTy = dyn for<'a> Callable<Gal<&'a ()>, Output = &'a str>;
+ //~^ ERROR binding for associated type `Output` references lifetime `'a`
+ box_str::<MalformedTy, _>(s)
+}
+
+fn main() {
+ let extended = extend_lifetime(&String::from("hello"));
+ println!("{}", extended.as_ref().as_ref());
+}
diff --git a/src/test/ui/type-alias-impl-trait/constrain_inputs_unsound.stderr b/src/test/ui/type-alias-impl-trait/constrain_inputs_unsound.stderr
new file mode 100644
index 000000000..d5fc46cb1
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/constrain_inputs_unsound.stderr
@@ -0,0 +1,9 @@
+error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types
+ --> $DIR/constrain_inputs_unsound.rs:23:58
+ |
+LL | type MalformedTy = dyn for<'a> Callable<Gal<&'a ()>, Output = &'a str>;
+ | ^^^^^^^^^^^^^^^^
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0582`.
diff --git a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs b/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs
index 811832848..9a50c0f98 100644
--- a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs
+++ b/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.rs
@@ -1,8 +1,9 @@
// compile-flags: --edition=2021
+// check-pass
#![feature(type_alias_impl_trait)]
fn main() {
- type T = impl Copy; //~ ERROR unconstrained opaque type
+ type T = impl Copy;
let foo: T = (1u32, 2u32);
let (a, b): (u32, u32) = foo;
}
diff --git a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.stderr b/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.stderr
deleted file mode 100644
index 03b172e6d..000000000
--- a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: unconstrained opaque type
- --> $DIR/cross_inference_pattern_bug.rs:5:14
- |
-LL | type T = impl Copy;
- | ^^^^^^^^^
- |
- = note: `T` must be used in combination with a concrete type within the same module
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.rs b/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.rs
index 328096d44..b929122a6 100644
--- a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.rs
+++ b/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.rs
@@ -1,13 +1,13 @@
-// known-bug: #96572
// compile-flags: --edition=2021 --crate-type=lib
// rustc-env:RUST_BACKTRACE=0
+// check-pass
// tracked in https://github.com/rust-lang/rust/issues/96572
#![feature(type_alias_impl_trait)]
fn main() {
- type T = impl Copy; // error: unconstrained opaque type
+ type T = impl Copy;
let foo: T = (1u32, 2u32);
- let (a, b) = foo; // removing this line makes the code compile
+ let (a, b) = foo; // this line used to make the code fail
}
diff --git a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.stderr b/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.stderr
deleted file mode 100644
index 8aa1f4956..000000000
--- a/src/test/ui/type-alias-impl-trait/cross_inference_pattern_bug_no_type.stderr
+++ /dev/null
@@ -1,10 +0,0 @@
-error: unconstrained opaque type
- --> $DIR/cross_inference_pattern_bug_no_type.rs:10:14
- |
-LL | type T = impl Copy; // error: unconstrained opaque type
- | ^^^^^^^^^
- |
- = note: `T` must be used in combination with a concrete type within the same module
-
-error: aborting due to previous error
-
diff --git a/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.rs b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.rs
index 7740f774e..0b8157fe3 100644
--- a/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.rs
+++ b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.rs
@@ -1,5 +1,5 @@
#![feature(type_alias_impl_trait)]
-// check-pass
+
fn main() {}
// two definitions with different types
@@ -9,7 +9,7 @@ fn foo() -> Foo {
""
}
-fn bar() -> Foo {
+fn bar() -> Foo { //~ ERROR: concrete type differs from previous defining opaque type use
panic!()
}
diff --git a/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr
new file mode 100644
index 000000000..09dadb0af
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type.stderr
@@ -0,0 +1,14 @@
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/different_defining_uses_never_type.rs:12:13
+ |
+LL | fn bar() -> Foo {
+ | ^^^ expected `&'static str`, got `()`
+ |
+note: previous use here
+ --> $DIR/different_defining_uses_never_type.rs:9:5
+ |
+LL | ""
+ | ^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type3.rs b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type3.rs
new file mode 100644
index 000000000..bc827a8f2
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type3.rs
@@ -0,0 +1,12 @@
+#![feature(type_alias_impl_trait)]
+
+type Tait = impl Sized;
+
+struct One;
+fn one() -> Tait { One }
+
+struct Two<T>(T);
+fn two() -> Tait { Two::<()>(todo!()) }
+//~^ ERROR concrete type differs from previous defining opaque type use
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type3.stderr b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type3.stderr
new file mode 100644
index 000000000..146a57cbb
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/different_defining_uses_never_type3.stderr
@@ -0,0 +1,14 @@
+error: concrete type differs from previous defining opaque type use
+ --> $DIR/different_defining_uses_never_type3.rs:9:13
+ |
+LL | fn two() -> Tait { Two::<()>(todo!()) }
+ | ^^^^ expected `One`, got `Two<()>`
+ |
+note: previous use here
+ --> $DIR/different_defining_uses_never_type3.rs:6:20
+ |
+LL | fn one() -> Tait { One }
+ | ^^^
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs b/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs
index 4f424b8c6..5f75fdc71 100644
--- a/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs
+++ b/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.rs
@@ -1,7 +1,11 @@
#![feature(type_alias_impl_trait)]
#![allow(dead_code)]
-type OneLifetime<'a, 'b> = impl std::fmt::Debug;
+pub trait Captures<'a> {}
+
+impl<'a, T: ?Sized> Captures<'a> for T {}
+
+type OneLifetime<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>;
fn foo<'a, 'b>(a: &'a u32, b: &'b u32) -> OneLifetime<'a, 'b> {
a
diff --git a/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr b/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr
index 0c50a84e8..546598e8a 100644
--- a/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr
+++ b/src/test/ui/type-alias-impl-trait/different_lifetimes_defining_uses.stderr
@@ -1,11 +1,11 @@
error: concrete type differs from previous defining opaque type use
- --> $DIR/different_lifetimes_defining_uses.rs:11:5
+ --> $DIR/different_lifetimes_defining_uses.rs:15:5
|
LL | b
| ^ expected `&'a u32`, got `&'b u32`
|
note: previous use here
- --> $DIR/different_lifetimes_defining_uses.rs:7:5
+ --> $DIR/different_lifetimes_defining_uses.rs:11:5
|
LL | a
| ^
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs
index c9b9e128f..9d938a616 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.rs
@@ -2,8 +2,11 @@
fn main() {}
-type Two<'a, 'b> = impl std::fmt::Debug;
+pub trait Captures<'a> {}
+impl<'a, T: ?Sized> Captures<'a> for T {}
+
+type Two<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>;
fn one<'a>(t: &'a ()) -> Two<'a, 'a> {
t
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr
index 222aaea78..72e1ef4b4 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_lifetime_param.stderr
@@ -1,13 +1,13 @@
error: non-defining opaque type use in defining scope
- --> $DIR/generic_duplicate_lifetime_param.rs:9:5
+ --> $DIR/generic_duplicate_lifetime_param.rs:12:5
|
LL | t
| ^
|
note: lifetime used multiple times
- --> $DIR/generic_duplicate_lifetime_param.rs:5:10
+ --> $DIR/generic_duplicate_lifetime_param.rs:9:10
|
-LL | type Two<'a, 'b> = impl std::fmt::Debug;
+LL | type Two<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>;
| ^^ ^^
error: aborting due to previous error
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs
index 093c1c231..80462f8ac 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.rs
@@ -7,7 +7,12 @@ fn main() {}
// test that unused generic parameters are ok
type TwoTys<T, U> = impl Debug;
-type TwoLifetimes<'a, 'b> = impl Debug;
+
+pub trait Captures<'a> {}
+
+impl<'a, T: ?Sized> Captures<'a> for T {}
+
+type TwoLifetimes<'a, 'b> = impl Debug + Captures<'a> + Captures<'b>;
type TwoConsts<const X: usize, const Y: usize> = impl Debug;
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr
index b2edcc552..98e4bfea1 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use.stderr
@@ -1,5 +1,5 @@
error: non-defining opaque type use in defining scope
- --> $DIR/generic_duplicate_param_use.rs:16:5
+ --> $DIR/generic_duplicate_param_use.rs:21:5
|
LL | t
| ^
@@ -11,25 +11,25 @@ LL | type TwoTys<T, U> = impl Debug;
| ^ ^
error: non-defining opaque type use in defining scope
- --> $DIR/generic_duplicate_param_use.rs:21:5
+ --> $DIR/generic_duplicate_param_use.rs:26:5
|
LL | t
| ^
|
note: lifetime used multiple times
- --> $DIR/generic_duplicate_param_use.rs:10:19
+ --> $DIR/generic_duplicate_param_use.rs:15:19
|
-LL | type TwoLifetimes<'a, 'b> = impl Debug;
+LL | type TwoLifetimes<'a, 'b> = impl Debug + Captures<'a> + Captures<'b>;
| ^^ ^^
error: non-defining opaque type use in defining scope
- --> $DIR/generic_duplicate_param_use.rs:26:5
+ --> $DIR/generic_duplicate_param_use.rs:31:5
|
LL | t
| ^
|
note: constant used multiple times
- --> $DIR/generic_duplicate_param_use.rs:12:16
+ --> $DIR/generic_duplicate_param_use.rs:17:16
|
LL | type TwoConsts<const X: usize, const Y: usize> = impl Debug;
| ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.stderr
index 2768f0c3a..586ea8234 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use5.stderr
@@ -4,7 +4,7 @@ error[E0277]: `T` doesn't implement `Debug`
LL | (t, u)
| ^^^^^^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(T, U)`
+ = note: required for `(T, U)` to implement `Debug`
help: consider restricting type parameter `T`
|
LL | type Two<T: std::fmt::Debug, U> = impl Debug;
@@ -16,7 +16,7 @@ error[E0277]: `U` doesn't implement `Debug`
LL | (t, u)
| ^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(T, U)`
+ = note: required for `(T, U)` to implement `Debug`
help: consider restricting type parameter `U`
|
LL | type Two<T, U: std::fmt::Debug> = impl Debug;
@@ -28,7 +28,7 @@ error[E0277]: `U` doesn't implement `Debug`
LL | (u, t)
| ^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(U, T)`
+ = note: required for `(U, T)` to implement `Debug`
help: consider restricting type parameter `U`
|
LL | type Two<T, U: std::fmt::Debug> = impl Debug;
@@ -40,7 +40,7 @@ error[E0277]: `T` doesn't implement `Debug`
LL | (u, t)
| ^^^^^^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(U, T)`
+ = note: required for `(U, T)` to implement `Debug`
help: consider restricting type parameter `T`
|
LL | type Two<T: std::fmt::Debug, U> = impl Debug;
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.stderr
index c1712ca2e..cb162d382 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use6.stderr
@@ -4,7 +4,7 @@ error[E0277]: `T` doesn't implement `Debug`
LL | (t, t)
| ^^^^^^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(T, T)`
+ = note: required for `(T, T)` to implement `Debug`
help: consider restricting type parameter `T`
|
LL | type Two<T: std::fmt::Debug, U> = impl Debug;
@@ -16,7 +16,7 @@ error[E0277]: `U` doesn't implement `Debug`
LL | (u, t)
| ^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(U, T)`
+ = note: required for `(U, T)` to implement `Debug`
help: consider restricting type parameter `U`
|
LL | type Two<T, U: std::fmt::Debug> = impl Debug;
@@ -28,7 +28,7 @@ error[E0277]: `T` doesn't implement `Debug`
LL | (u, t)
| ^^^^^^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(U, T)`
+ = note: required for `(U, T)` to implement `Debug`
help: consider restricting type parameter `T`
|
LL | type Two<T: std::fmt::Debug, U> = impl Debug;
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.stderr
index b83105c45..14cbfb380 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use8.stderr
@@ -4,7 +4,7 @@ error[E0277]: `T` doesn't implement `Debug`
LL | (t, 4u32)
| ^^^^^^^^^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(T, u32)`
+ = note: required for `(T, u32)` to implement `Debug`
help: consider restricting type parameter `T`
|
LL | type Two<T: std::fmt::Debug, U> = impl Debug;
@@ -16,7 +16,7 @@ error[E0277]: `U` doesn't implement `Debug`
LL | (u, 4u32)
| ^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(U, u32)`
+ = note: required for `(U, u32)` to implement `Debug`
help: consider restricting type parameter `U`
|
LL | type Two<T, U: std::fmt::Debug> = impl Debug;
diff --git a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr
index 50cf98273..722693e42 100644
--- a/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr
+++ b/src/test/ui/type-alias-impl-trait/generic_duplicate_param_use9.stderr
@@ -15,7 +15,7 @@ error[E0277]: `A` doesn't implement `Debug`
LL | (t, u, T::BAR)
| ^^^^^^^^^^^^^^ `A` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(A, B, _)`
+ = note: required for `(A, B, _)` to implement `Debug`
help: consider restricting type parameter `A`
|
LL | type Two<A: std::fmt::Debug, B> = impl Debug;
@@ -27,7 +27,7 @@ error[E0277]: `B` doesn't implement `Debug`
LL | (t, u, T::BAR)
| ^^^^^^^^^^^^^^ `B` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(A, B, _)`
+ = note: required for `(A, B, _)` to implement `Debug`
help: consider restricting type parameter `B`
|
LL | type Two<A, B: std::fmt::Debug> = impl Debug;
@@ -39,7 +39,7 @@ error[E0277]: `A` doesn't implement `Debug`
LL | (t, u, 42)
| ^^^^^^^^^^ `A` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(A, B, i32)`
+ = note: required for `(A, B, i32)` to implement `Debug`
help: consider restricting type parameter `A`
|
LL | type Two<A: std::fmt::Debug, B> = impl Debug;
@@ -51,7 +51,7 @@ error[E0277]: `B` doesn't implement `Debug`
LL | (t, u, 42)
| ^^^^^^^^^^ `B` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(A, B, i32)`
+ = note: required for `(A, B, i32)` to implement `Debug`
help: consider restricting type parameter `B`
|
LL | type Two<A, B: std::fmt::Debug> = impl Debug;
diff --git a/src/test/ui/type-alias-impl-trait/generic_lifetime_param.rs b/src/test/ui/type-alias-impl-trait/generic_lifetime_param.rs
index e109c38c9..106efefba 100644
--- a/src/test/ui/type-alias-impl-trait/generic_lifetime_param.rs
+++ b/src/test/ui/type-alias-impl-trait/generic_lifetime_param.rs
@@ -1,10 +1,11 @@
-// build-pass (FIXME(62277): could be check-pass?)
+// check-pass
#![feature(type_alias_impl_trait)]
fn main() {}
-type Region<'a> = impl std::fmt::Debug;
+type Region<'a> = impl std::fmt::Debug + 'a;
+
fn region<'b>(a: &'b ()) -> Region<'b> {
a
diff --git a/src/test/ui/type-alias-impl-trait/implied_bounds.rs b/src/test/ui/type-alias-impl-trait/implied_bounds.rs
new file mode 100644
index 000000000..53cbf8d22
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_bounds.rs
@@ -0,0 +1,51 @@
+#![feature(type_alias_impl_trait)]
+
+type WithLifetime<'a> = impl Equals<SelfType = ()>;
+fn _defining_use<'a>() -> WithLifetime<'a> {}
+
+trait Convert<'a> {
+ type Witness;
+ fn convert<'b, T: ?Sized>(_proof: &'b Self::Witness, x: &'a T) -> &'b T;
+}
+
+impl<'a> Convert<'a> for () {
+ type Witness = WithLifetime<'a>;
+
+ fn convert<'b, T: ?Sized>(_proof: &'b WithLifetime<'a>, x: &'a T) -> &'b T {
+ // compiler used to think it gets to assume 'a: 'b here because
+ // of the `&'b WithLifetime<'a>` argument
+ x
+ //~^ ERROR lifetime may not live long enough
+ }
+}
+
+fn extend_lifetime<'a, 'b, T: ?Sized>(x: &'a T) -> &'b T {
+ WithLifetime::<'a>::convert_helper::<(), T>(&(), x)
+}
+
+trait Equals {
+ type SelfType;
+ fn convert_helper<'a, 'b, W: Convert<'a, Witness = Self>, T: ?Sized>(
+ proof: &'b Self::SelfType,
+ x: &'a T,
+ ) -> &'b T;
+}
+
+impl<S> Equals for S {
+ type SelfType = Self;
+ fn convert_helper<'a, 'b, W: Convert<'a, Witness = Self>, T: ?Sized>(
+ proof: &'b Self,
+ x: &'a T,
+ ) -> &'b T {
+ W::convert(proof, x)
+ }
+}
+
+fn main() {
+ let r;
+ {
+ let x = String::from("Hello World?");
+ r = extend_lifetime(&x);
+ }
+ println!("{}", r);
+}
diff --git a/src/test/ui/type-alias-impl-trait/implied_bounds.stderr b/src/test/ui/type-alias-impl-trait/implied_bounds.stderr
new file mode 100644
index 000000000..6f11b6663
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_bounds.stderr
@@ -0,0 +1,16 @@
+error: lifetime may not live long enough
+ --> $DIR/implied_bounds.rs:17:9
+ |
+LL | impl<'a> Convert<'a> for () {
+ | -- lifetime `'a` defined here
+...
+LL | fn convert<'b, T: ?Sized>(_proof: &'b WithLifetime<'a>, x: &'a T) -> &'b T {
+ | -- lifetime `'b` defined here
+...
+LL | x
+ | ^ associated function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
+ |
+ = help: consider adding the following bound: `'a: 'b`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/type-alias-impl-trait/implied_bounds2.rs b/src/test/ui/type-alias-impl-trait/implied_bounds2.rs
new file mode 100644
index 000000000..b4c4c013c
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_bounds2.rs
@@ -0,0 +1,10 @@
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+
+type Ty<'a, A> = impl Sized + 'a;
+fn defining<'a, A>() -> Ty<'a, A> {}
+fn assert_static<T: 'static>() {}
+fn test<'a, A>() where Ty<'a, A>: 'static, { assert_static::<Ty<'a, A>>() }
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/implied_bounds3.rs b/src/test/ui/type-alias-impl-trait/implied_bounds3.rs
new file mode 100644
index 000000000..e39c61328
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_bounds3.rs
@@ -0,0 +1,18 @@
+// check-pass
+
+fn foo<F>(_: F)
+where
+ F: 'static,
+{
+}
+
+fn from<F: Send>(f: F) -> impl Send {
+ f
+}
+
+fn bar<T>() {
+ foo(from(|| ()))
+}
+
+fn main() {
+}
diff --git a/src/test/ui/type-alias-impl-trait/implied_bounds_closure.rs b/src/test/ui/type-alias-impl-trait/implied_bounds_closure.rs
new file mode 100644
index 000000000..4cf35f951
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_bounds_closure.rs
@@ -0,0 +1,31 @@
+trait StaticDefaultRef: 'static {
+ fn default_ref() -> &'static Self;
+}
+
+impl StaticDefaultRef for str {
+ fn default_ref() -> &'static str {
+ ""
+ }
+}
+
+fn into_impl(x: &str) -> &(impl ?Sized + AsRef<str> + StaticDefaultRef + '_) {
+ x
+}
+
+fn extend_lifetime<'a>(x: &'a str) -> &'static str {
+ let t = into_impl(x);
+ helper(|_| t) //~ ERROR lifetime may not live long enough
+}
+
+fn helper<T: ?Sized + AsRef<str> + StaticDefaultRef>(f: impl FnOnce(&T) -> &T) -> &'static str {
+ f(T::default_ref()).as_ref()
+}
+
+fn main() {
+ let r;
+ {
+ let x = String::from("Hello World?");
+ r = extend_lifetime(&x);
+ }
+ println!("{}", r);
+}
diff --git a/src/test/ui/type-alias-impl-trait/implied_bounds_closure.stderr b/src/test/ui/type-alias-impl-trait/implied_bounds_closure.stderr
new file mode 100644
index 000000000..151564c3b
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_bounds_closure.stderr
@@ -0,0 +1,11 @@
+error: lifetime may not live long enough
+ --> $DIR/implied_bounds_closure.rs:17:16
+ |
+LL | fn extend_lifetime<'a>(x: &'a str) -> &'static str {
+ | -- lifetime `'a` defined here
+LL | let t = into_impl(x);
+LL | helper(|_| t)
+ | ^ returning this value requires that `'a` must outlive `'static`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/type-alias-impl-trait/implied_bounds_from_types.rs b/src/test/ui/type-alias-impl-trait/implied_bounds_from_types.rs
new file mode 100644
index 000000000..8023cd24f
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_bounds_from_types.rs
@@ -0,0 +1,51 @@
+#![feature(type_alias_impl_trait)]
+
+type WithLifetime<T> = impl Equals<SelfType = ()>;
+fn _defining_use<T>() -> WithLifetime<T> {}
+
+trait Convert<'a> {
+ type Witness;
+ fn convert<'b, T: ?Sized>(_proof: &'b Self::Witness, x: &'a T) -> &'b T;
+}
+
+impl<'a> Convert<'a> for () {
+ type Witness = WithLifetime<&'a ()>;
+
+ fn convert<'b, T: ?Sized>(_proof: &'b WithLifetime<&'a ()>, x: &'a T) -> &'b T {
+ // compiler used to think it gets to assume 'a: 'b here because
+ // of the `&'b WithLifetime<&'a ()>` argument
+ x
+ //~^ ERROR lifetime may not live long enough
+ }
+}
+
+fn extend_lifetime<'a, 'b, T: ?Sized>(x: &'a T) -> &'b T {
+ WithLifetime::<&'a ()>::convert_helper::<(), T>(&(), x)
+}
+
+trait Equals {
+ type SelfType;
+ fn convert_helper<'a, 'b, W: Convert<'a, Witness = Self>, T: ?Sized>(
+ proof: &'b Self::SelfType,
+ x: &'a T,
+ ) -> &'b T;
+}
+
+impl<S> Equals for S {
+ type SelfType = Self;
+ fn convert_helper<'a, 'b, W: Convert<'a, Witness = Self>, T: ?Sized>(
+ proof: &'b Self,
+ x: &'a T,
+ ) -> &'b T {
+ W::convert(proof, x)
+ }
+}
+
+fn main() {
+ let r;
+ {
+ let x = String::from("Hello World?");
+ r = extend_lifetime(&x);
+ }
+ println!("{}", r);
+}
diff --git a/src/test/ui/type-alias-impl-trait/implied_bounds_from_types.stderr b/src/test/ui/type-alias-impl-trait/implied_bounds_from_types.stderr
new file mode 100644
index 000000000..cbc5e6073
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_bounds_from_types.stderr
@@ -0,0 +1,16 @@
+error: lifetime may not live long enough
+ --> $DIR/implied_bounds_from_types.rs:17:9
+ |
+LL | impl<'a> Convert<'a> for () {
+ | -- lifetime `'a` defined here
+...
+LL | fn convert<'b, T: ?Sized>(_proof: &'b WithLifetime<&'a ()>, x: &'a T) -> &'b T {
+ | -- lifetime `'b` defined here
+...
+LL | x
+ | ^ associated function was supposed to return data with lifetime `'b` but it is returning data with lifetime `'a`
+ |
+ = help: consider adding the following bound: `'a: 'b`
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check.rs b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check.rs
new file mode 100644
index 000000000..b6a7264a5
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check.rs
@@ -0,0 +1,27 @@
+#![feature(type_alias_impl_trait)]
+
+// known-bug: #99840
+// this should not compile
+// check-pass
+
+type Alias = impl Sized;
+
+fn constrain() -> Alias {
+ 1i32
+}
+
+trait HideIt {
+ type Assoc;
+}
+
+impl HideIt for () {
+ type Assoc = Alias;
+}
+
+pub trait Yay {}
+
+impl Yay for <() as HideIt>::Assoc {}
+// impl Yay for i32 {} // this already errors
+// impl Yay for u32 {} // this also already errors
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs
new file mode 100644
index 000000000..07f825aea
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.rs
@@ -0,0 +1,43 @@
+#![feature(type_alias_impl_trait)]
+
+mod test_lifetime_param {
+ type Ty<'a> = impl Sized + 'a;
+ fn defining(a: &str) -> Ty<'_> { a }
+ fn assert_static<'a: 'static>() {}
+ //~^ WARN: unnecessary lifetime parameter `'a`
+ fn test<'a>() where Ty<'a>: 'static { assert_static::<'a>() }
+ //~^ ERROR: lifetime may not live long enough
+}
+
+mod test_higher_kinded_lifetime_param {
+ type Ty<'a> = impl Sized + 'a;
+ fn defining(a: &str) -> Ty<'_> { a }
+ fn assert_static<'a: 'static>() {}
+ //~^ WARN: unnecessary lifetime parameter `'a`
+ fn test<'a>() where for<'b> Ty<'b>: 'a { assert_static::<'a>() }
+ //~^ ERROR: lifetime may not live long enough
+}
+
+mod test_higher_kinded_lifetime_param2 {
+ fn assert_static<'a: 'static>() {}
+ //~^ WARN: unnecessary lifetime parameter `'a`
+ fn test<'a>() { assert_static::<'a>() }
+ //~^ ERROR: lifetime may not live long enough
+}
+
+mod test_type_param {
+ type Ty<A> = impl Sized;
+ fn defining<A>(s: A) -> Ty<A> { s }
+ fn assert_static<A: 'static>() {}
+ fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
+ //~^ ERROR: parameter type `A` may not live long enough
+}
+
+mod test_implied_from_fn_sig {
+ type Opaque<T: 'static> = impl Sized;
+ fn defining<T: 'static>() -> Opaque<T> {}
+ fn assert_static<T: 'static>() {}
+ fn test<T>(_: Opaque<T>) { assert_static::<T>(); }
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr
new file mode 100644
index 000000000..887620a4d
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check3.stderr
@@ -0,0 +1,58 @@
+warning: unnecessary lifetime parameter `'a`
+ --> $DIR/implied_lifetime_wf_check3.rs:6:22
+ |
+LL | fn assert_static<'a: 'static>() {}
+ | ^^
+ |
+ = help: you can use the `'static` lifetime directly, in place of `'a`
+
+warning: unnecessary lifetime parameter `'a`
+ --> $DIR/implied_lifetime_wf_check3.rs:15:22
+ |
+LL | fn assert_static<'a: 'static>() {}
+ | ^^
+ |
+ = help: you can use the `'static` lifetime directly, in place of `'a`
+
+warning: unnecessary lifetime parameter `'a`
+ --> $DIR/implied_lifetime_wf_check3.rs:22:22
+ |
+LL | fn assert_static<'a: 'static>() {}
+ | ^^
+ |
+ = help: you can use the `'static` lifetime directly, in place of `'a`
+
+error: lifetime may not live long enough
+ --> $DIR/implied_lifetime_wf_check3.rs:8:43
+ |
+LL | fn test<'a>() where Ty<'a>: 'static { assert_static::<'a>() }
+ | -- lifetime `'a` defined here ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
+
+error: lifetime may not live long enough
+ --> $DIR/implied_lifetime_wf_check3.rs:17:46
+ |
+LL | fn test<'a>() where for<'b> Ty<'b>: 'a { assert_static::<'a>() }
+ | -- lifetime `'a` defined here ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
+
+error: lifetime may not live long enough
+ --> $DIR/implied_lifetime_wf_check3.rs:24:21
+ |
+LL | fn test<'a>() { assert_static::<'a>() }
+ | -- ^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static`
+ | |
+ | lifetime `'a` defined here
+
+error[E0310]: the parameter type `A` may not live long enough
+ --> $DIR/implied_lifetime_wf_check3.rs:32:41
+ |
+LL | fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
+ | ^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound...
+ |
+LL | fn test<A: 'static>() where Ty<A>: 'static { assert_static::<A>() }
+ | +++++++++
+
+error: aborting due to 4 previous errors; 3 warnings emitted
+
+For more information about this error, try `rustc --explain E0310`.
diff --git a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.rs b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.rs
new file mode 100644
index 000000000..ac32dbde0
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.rs
@@ -0,0 +1,11 @@
+#![feature(type_alias_impl_trait)]
+
+mod test_type_param_static {
+ type Ty<A> = impl Sized + 'static;
+ //~^ ERROR: the parameter type `A` may not live long enough
+ fn defining<A: 'static>(s: A) -> Ty<A> { s }
+ fn assert_static<A: 'static>() {}
+ fn test<A>() where Ty<A>: 'static { assert_static::<A>() }
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr
new file mode 100644
index 000000000..47bc31e78
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/implied_lifetime_wf_check4_static.stderr
@@ -0,0 +1,14 @@
+error[E0310]: the parameter type `A` may not live long enough
+ --> $DIR/implied_lifetime_wf_check4_static.rs:4:18
+ |
+LL | type Ty<A> = impl Sized + 'static;
+ | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `A` will meet its required lifetime bounds
+ |
+help: consider adding an explicit lifetime bound...
+ |
+LL | type Ty<A: 'static> = impl Sized + 'static;
+ | +++++++++
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0310`.
diff --git a/src/test/ui/type-alias-impl-trait/issue-101750.rs b/src/test/ui/type-alias-impl-trait/issue-101750.rs
new file mode 100644
index 000000000..f564f4fa7
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/issue-101750.rs
@@ -0,0 +1,37 @@
+#![feature(type_alias_impl_trait)]
+
+// check-pass
+
+trait Trait {}
+
+type TAIT = impl Trait;
+
+struct Concrete;
+impl Trait for Concrete {}
+
+fn tait() -> TAIT {
+ Concrete
+}
+
+trait OuterTrait {
+ type Item;
+}
+struct Dummy<T> {
+ t: T,
+}
+impl<T> OuterTrait for Dummy<T> {
+ type Item = T;
+}
+
+fn tait_and_impl_trait() -> impl OuterTrait<Item = (TAIT, impl Trait)> {
+ Dummy {
+ t: (tait(), Concrete),
+ }
+}
+
+fn tait_and_dyn_trait() -> impl OuterTrait<Item = (TAIT, Box<dyn Trait>)> {
+ let b: Box<dyn Trait> = Box::new(Concrete);
+ Dummy { t: (tait(), b) }
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr b/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr
index d20b1cc6d..0a34e8486 100644
--- a/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-53398-cyclic-types.stderr
@@ -1,10 +1,11 @@
-error[E0275]: overflow evaluating the requirement `fn() -> Foo {foo}: Sized`
+error[E0275]: overflow evaluating the requirement `Foo: Sized`
--> $DIR/issue-53398-cyclic-types.rs:5:13
|
LL | fn foo() -> Foo {
| ^^^
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_53398_cyclic_types`)
+ = note: required because it appears within the type `fn() -> Foo {foo}`
error: aborting due to previous error
diff --git a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr
index f14bf6b0f..6344f114a 100644
--- a/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-57611-trait-alias.stderr
@@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | |x| x
| ^^^^^ one type is more general than the other
|
- = note: expected trait `for<'r> Fn<(&'r X,)>`
+ = note: expected trait `for<'a> Fn<(&'a X,)>`
found trait `Fn<(&X,)>`
note: this closure does not fulfill the lifetime requirements
--> $DIR/issue-57611-trait-alias.rs:21:9
diff --git a/src/test/ui/type-alias-impl-trait/issue-57961.rs b/src/test/ui/type-alias-impl-trait/issue-57961.rs
index 472886c9c..24b3a0458 100644
--- a/src/test/ui/type-alias-impl-trait/issue-57961.rs
+++ b/src/test/ui/type-alias-impl-trait/issue-57961.rs
@@ -8,7 +8,7 @@ trait Foo {
impl Foo for () {
type Bar = std::vec::IntoIter<u32>;
- //~^ ERROR type mismatch resolving `<std::vec::IntoIter<u32> as Iterator>::Item == X
+ //~^ ERROR expected `std::vec::IntoIter<u32>` to be an iterator that yields `X`, but it yields `u32`
}
fn incoherent() {
diff --git a/src/test/ui/type-alias-impl-trait/issue-57961.stderr b/src/test/ui/type-alias-impl-trait/issue-57961.stderr
index ed4caf6ce..fb40895c4 100644
--- a/src/test/ui/type-alias-impl-trait/issue-57961.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-57961.stderr
@@ -1,4 +1,4 @@
-error[E0271]: type mismatch resolving `<std::vec::IntoIter<u32> as Iterator>::Item == X`
+error[E0271]: expected `std::vec::IntoIter<u32>` to be an iterator that yields `X`, but it yields `u32`
--> $DIR/issue-57961.rs:10:16
|
LL | type X = impl Sized;
diff --git a/src/test/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs b/src/test/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs
index f20ddf020..477b61390 100644
--- a/src/test/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs
+++ b/src/test/ui/type-alias-impl-trait/issue-58662-generator-with-lifetime.rs
@@ -16,7 +16,7 @@ fn rand_generator<'a>(rng: &'a ()) -> RandGenerator<'a> {
}
}
-pub type RandGeneratorWithIndirection<'a> = impl Generator<Return = (), Yield = u64> + 'a;
+pub type RandGeneratorWithIndirection<'c> = impl Generator<Return = (), Yield = u64> + 'c;
pub fn rand_generator_with_indirection<'a>(rng: &'a ()) -> RandGeneratorWithIndirection<'a> {
fn helper<'b>(rng: &'b ()) -> impl 'b + Generator<Return = (), Yield = u64> {
move || {
diff --git a/src/test/ui/type-alias-impl-trait/issue-58662-simplified.rs b/src/test/ui/type-alias-impl-trait/issue-58662-simplified.rs
new file mode 100644
index 000000000..27ca7d0fd
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/issue-58662-simplified.rs
@@ -0,0 +1,20 @@
+// check-pass
+
+#![feature(generators, generator_trait)]
+#![feature(type_alias_impl_trait)]
+
+trait Trait {}
+
+impl<T> Trait for T {}
+
+type Foo<'c> = impl Trait + 'c;
+fn foo<'a>(rng: &'a ()) -> Foo<'a> {
+ fn helper<'b>(rng: &'b ()) -> impl 'b + Trait {
+ rng
+ }
+
+ helper(rng)
+}
+
+fn main() {
+}
diff --git a/src/test/ui/type-alias-impl-trait/issue-60371.stderr b/src/test/ui/type-alias-impl-trait/issue-60371.stderr
index 082b0f0c3..d0c04371b 100644
--- a/src/test/ui/type-alias-impl-trait/issue-60371.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-60371.stderr
@@ -11,7 +11,7 @@ error[E0277]: the trait bound `(): Bug` is not satisfied
--> $DIR/issue-60371.rs:10:40
|
LL | const FUN: fn() -> Self::Item = || ();
- | ^ the trait `Bug` is not implemented for `()`
+ | ^^ the trait `Bug` is not implemented for `()`
|
= help: the trait `Bug` is implemented for `&()`
diff --git a/src/test/ui/type-alias-impl-trait/issue-74280.stderr b/src/test/ui/type-alias-impl-trait/issue-74280.stderr
index 5ed29e0ac..66886db6e 100644
--- a/src/test/ui/type-alias-impl-trait/issue-74280.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-74280.stderr
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-74280.rs:9:5
|
LL | fn test() -> Test {
- | ---- expected `_` because of return type
+ | ---- expected `()` because of return type
LL | let y = || -> Test { () };
LL | 7
| ^ expected `()`, found integer
diff --git a/src/test/ui/type-alias-impl-trait/issue-89686.rs b/src/test/ui/type-alias-impl-trait/issue-89686.rs
index de070fc9d..058417bdb 100644
--- a/src/test/ui/type-alias-impl-trait/issue-89686.rs
+++ b/src/test/ui/type-alias-impl-trait/issue-89686.rs
@@ -4,7 +4,7 @@
use std::future::Future;
-type G<'a, T> = impl Future<Output = ()>;
+type G<'a, T> = impl Future<Output = ()> + 'a;
trait Trait {
type F: Future<Output = ()>;
diff --git a/src/test/ui/type-alias-impl-trait/issue-89686.stderr b/src/test/ui/type-alias-impl-trait/issue-89686.stderr
index b636ada8b..3b95a575a 100644
--- a/src/test/ui/type-alias-impl-trait/issue-89686.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-89686.stderr
@@ -6,7 +6,7 @@ LL | async move { self.f().await }
|
help: consider restricting type parameter `T`
|
-LL | type G<'a, T: Trait> = impl Future<Output = ()>;
+LL | type G<'a, T: Trait> = impl Future<Output = ()> + 'a;
| +++++++
error: aborting due to previous error
diff --git a/src/test/ui/type-alias-impl-trait/issue-90400-1.rs b/src/test/ui/type-alias-impl-trait/issue-90400-1.rs
index 8550a3e86..15aead2f6 100644
--- a/src/test/ui/type-alias-impl-trait/issue-90400-1.rs
+++ b/src/test/ui/type-alias-impl-trait/issue-90400-1.rs
@@ -1,7 +1,6 @@
// Regression test for #90400,
// taken from https://github.com/rust-lang/rust/issues/90400#issuecomment-954927836
-#![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]
trait Bar {
diff --git a/src/test/ui/type-alias-impl-trait/issue-90400-1.stderr b/src/test/ui/type-alias-impl-trait/issue-90400-1.stderr
index 428a10740..ead28769f 100644
--- a/src/test/ui/type-alias-impl-trait/issue-90400-1.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-90400-1.stderr
@@ -1,11 +1,11 @@
error[E0277]: the trait bound `B: Bar` is not satisfied
- --> $DIR/issue-90400-1.rs:23:9
+ --> $DIR/issue-90400-1.rs:22:9
|
LL | move || bar.bar()
| ^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `B`
|
note: required by a bound in `<MyFoo as Foo>::foo`
- --> $DIR/issue-90400-1.rs:22:15
+ --> $DIR/issue-90400-1.rs:21:15
|
LL | fn foo<B: Bar>(&self, bar: B) -> Self::FooFn<B> {
| ^^^ required by this bound in `<MyFoo as Foo>::foo`
diff --git a/src/test/ui/type-alias-impl-trait/issue-90400-2.rs b/src/test/ui/type-alias-impl-trait/issue-90400-2.rs
index 2b369bb8a..4c6e893c1 100644
--- a/src/test/ui/type-alias-impl-trait/issue-90400-2.rs
+++ b/src/test/ui/type-alias-impl-trait/issue-90400-2.rs
@@ -1,7 +1,6 @@
// Regression test for #90400,
// taken from https://github.com/rust-lang/rust/issues/90400#issuecomment-954927836
-#![feature(generic_associated_types)]
#![feature(type_alias_impl_trait)]
trait Bar {
diff --git a/src/test/ui/type-alias-impl-trait/issue-90400-2.stderr b/src/test/ui/type-alias-impl-trait/issue-90400-2.stderr
index 5da05a439..50b2dc049 100644
--- a/src/test/ui/type-alias-impl-trait/issue-90400-2.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-90400-2.stderr
@@ -1,11 +1,11 @@
error[E0277]: the trait bound `B: Bar` is not satisfied
- --> $DIR/issue-90400-2.rs:26:9
+ --> $DIR/issue-90400-2.rs:25:9
|
LL | MyBaz(bar)
| ^^^^^^^^^^ the trait `Bar` is not implemented for `B`
|
-note: required because of the requirements on the impl of `Baz` for `MyBaz<B>`
- --> $DIR/issue-90400-2.rs:31:14
+note: required for `MyBaz<B>` to implement `Baz`
+ --> $DIR/issue-90400-2.rs:30:14
|
LL | impl<B: Bar> Baz for MyBaz<B> {
| ^^^ ^^^^^^^^
diff --git a/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.rs b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.rs
new file mode 100644
index 000000000..825710851
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.rs
@@ -0,0 +1,10 @@
+#![feature(type_alias_impl_trait)]
+
+fn main() {
+ type T = impl Copy;
+ let foo: T = Some((1u32, 2u32));
+ match foo {
+ None => (),
+ Some((a, b, c)) => (), //~ ERROR mismatched types
+ }
+}
diff --git a/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.stderr b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.stderr
new file mode 100644
index 000000000..728244a18
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained-mismatch.stderr
@@ -0,0 +1,15 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-96572-unconstrained-mismatch.rs:8:14
+ |
+LL | match foo {
+ | --- this expression has type `T`
+LL | None => (),
+LL | Some((a, b, c)) => (),
+ | ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements
+ |
+ = note: expected tuple `(u32, u32)`
+ found tuple `(_, _, _)`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained.rs b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained.rs
new file mode 100644
index 000000000..2c740ccc1
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/issue-96572-unconstrained.rs
@@ -0,0 +1,92 @@
+#![feature(type_alias_impl_trait)]
+// check-pass
+
+fn main() {
+ type T = impl Copy;
+ let foo: T = Some((1u32, 2u32));
+ match foo {
+ None => (),
+ Some((a, b)) => (),
+ }
+}
+
+fn upvar() {
+ #[derive(Copy, Clone)]
+ struct Foo((u32, u32));
+
+ type T = impl Copy;
+ let foo: T = Foo((1u32, 2u32));
+ let x = move || {
+ let Foo((a, b)) = foo;
+ };
+}
+
+fn enum_upvar() {
+ type T = impl Copy;
+ let foo: T = Some((1u32, 2u32));
+ let x = move || {
+ match foo {
+ None => (),
+ Some((a, b)) => (),
+ }
+ };
+}
+
+fn r#struct() {
+ #[derive(Copy, Clone)]
+ struct Foo((u32, u32));
+
+ type U = impl Copy;
+ let foo: U = Foo((1u32, 2u32));
+ let Foo((a, b)) = foo;
+}
+
+mod only_pattern {
+ type T = impl Copy;
+
+ fn foo(foo: T) {
+ let (mut x, mut y) = foo;
+ x = 42;
+ y = "foo";
+ }
+
+ type U = impl Copy;
+
+ fn bar(bar: Option<U>) {
+ match bar {
+ Some((mut x, mut y)) => {
+ x = 42;
+ y = "foo";
+ }
+ None => {}
+ }
+ }
+}
+
+mod only_pattern_rpit {
+ #[allow(unconditional_recursion)]
+ fn foo(b: bool) -> impl Copy {
+ let (mut x, mut y) = foo(false);
+ x = 42;
+ y = "foo";
+ if b {
+ panic!()
+ } else {
+ foo(true)
+ }
+ }
+
+ fn bar(b: bool) -> Option<impl Copy> {
+ if b {
+ return None;
+ }
+ match bar(!b) {
+ Some((mut x, mut y)) => {
+ x = 42;
+ y = "foo";
+ }
+ None => {}
+ }
+ None
+ }
+}
diff --git a/src/test/ui/type-alias-impl-trait/issue-98604.rs b/src/test/ui/type-alias-impl-trait/issue-98604.rs
index a4fd8a82a..32c2f9ed5 100644
--- a/src/test/ui/type-alias-impl-trait/issue-98604.rs
+++ b/src/test/ui/type-alias-impl-trait/issue-98604.rs
@@ -1,13 +1,11 @@
// edition:2018
-type AsyncFnPtr = Box<
- dyn Fn() -> std::pin::Pin<Box<dyn std::future::Future<Output = ()>>>,
->;
+type AsyncFnPtr = Box<dyn Fn() -> std::pin::Pin<Box<dyn std::future::Future<Output = ()>>>>;
async fn test() {}
#[allow(unused_must_use)]
fn main() {
Box::new(test) as AsyncFnPtr;
- //~^ ERROR type mismatch
+ //~^ ERROR expected `fn() -> impl Future<Output = ()> {test}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
}
diff --git a/src/test/ui/type-alias-impl-trait/issue-98604.stderr b/src/test/ui/type-alias-impl-trait/issue-98604.stderr
index f04d1b4d7..92d01eb0d 100644
--- a/src/test/ui/type-alias-impl-trait/issue-98604.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-98604.stderr
@@ -1,11 +1,11 @@
-error[E0271]: type mismatch resolving `<fn() -> impl Future<Output = ()> {test} as FnOnce<()>>::Output == Pin<Box<(dyn Future<Output = ()> + 'static)>>`
- --> $DIR/issue-98604.rs:11:5
+error[E0271]: expected `fn() -> impl Future<Output = ()> {test}` to be a fn item that returns `Pin<Box<(dyn Future<Output = ()> + 'static)>>`, but it returns `impl Future<Output = ()>`
+ --> $DIR/issue-98604.rs:9:5
|
LL | Box::new(test) as AsyncFnPtr;
| ^^^^^^^^^^^^^^ expected struct `Pin`, found opaque type
|
note: while checking the return type of the `async fn`
- --> $DIR/issue-98604.rs:7:17
+ --> $DIR/issue-98604.rs:5:17
|
LL | async fn test() {}
| ^ checked the `Output` of this `async fn`, found opaque type
diff --git a/src/test/ui/type-alias-impl-trait/issue-98608.rs b/src/test/ui/type-alias-impl-trait/issue-98608.rs
index d75762a8b..1f89af045 100644
--- a/src/test/ui/type-alias-impl-trait/issue-98608.rs
+++ b/src/test/ui/type-alias-impl-trait/issue-98608.rs
@@ -1,8 +1,10 @@
-fn hi() -> impl Sized { std::ptr::null::<u8>() }
+fn hi() -> impl Sized {
+ std::ptr::null::<u8>()
+}
fn main() {
let b: Box<dyn Fn() -> Box<u8>> = Box::new(hi);
- //~^ ERROR type mismatch resolving `<fn() -> impl Sized {hi} as FnOnce<()>>::Output == Box<u8>`
+ //~^ ERROR expected `fn() -> impl Sized {hi}` to be a fn item that returns `Box<u8>`, but it returns `impl Sized`
let boxed = b();
let null = *boxed;
println!("{null:?}");
diff --git a/src/test/ui/type-alias-impl-trait/issue-98608.stderr b/src/test/ui/type-alias-impl-trait/issue-98608.stderr
index 8f3ec7d9d..916a58451 100644
--- a/src/test/ui/type-alias-impl-trait/issue-98608.stderr
+++ b/src/test/ui/type-alias-impl-trait/issue-98608.stderr
@@ -1,7 +1,7 @@
-error[E0271]: type mismatch resolving `<fn() -> impl Sized {hi} as FnOnce<()>>::Output == Box<u8>`
- --> $DIR/issue-98608.rs:4:39
+error[E0271]: expected `fn() -> impl Sized {hi}` to be a fn item that returns `Box<u8>`, but it returns `impl Sized`
+ --> $DIR/issue-98608.rs:6:39
|
-LL | fn hi() -> impl Sized { std::ptr::null::<u8>() }
+LL | fn hi() -> impl Sized {
| ---------- the found opaque type
...
LL | let b: Box<dyn Fn() -> Box<u8>> = Box::new(hi);
diff --git a/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.rs b/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.rs
new file mode 100644
index 000000000..428194058
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.rs
@@ -0,0 +1,7 @@
+#![feature(type_alias_impl_trait)]
+
+type Opaque<'a, T> = impl Sized;
+fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x }
+//~^ ERROR: non-defining opaque type use in defining scope
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.stderr b/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.stderr
new file mode 100644
index 000000000..df2b3ed19
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/missing_lifetime_bound.stderr
@@ -0,0 +1,8 @@
+error: non-defining opaque type use in defining scope
+ --> $DIR/missing_lifetime_bound.rs:4:47
+ |
+LL | fn defining<'a, T>(x: &'a i32) -> Opaque<T> { x }
+ | ^ lifetime `'a` is part of concrete type but not used in parameter list of the `impl Trait` type alias
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs
index 3f122f106..65eb2952e 100644
--- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs
+++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.rs
@@ -1,6 +1,10 @@
#![feature(type_alias_impl_trait)]
-type Foo<'a, 'b> = impl std::fmt::Debug;
+pub trait Captures<'a> {}
+
+impl<'a, T: ?Sized> Captures<'a> for T {}
+
+type Foo<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>;
fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) {
(i, i) //~ ERROR concrete type differs from previous
diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr
index 81e603e23..d7676b8e9 100644
--- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr
+++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-lifetimes.stderr
@@ -1,5 +1,5 @@
error: concrete type differs from previous defining opaque type use
- --> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:6:5
+ --> $DIR/multiple-def-uses-in-one-fn-lifetimes.rs:10:5
|
LL | (i, i)
| ^^^^^^
diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs
index 83fd9a1da..21fca047a 100644
--- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs
+++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn-pass.rs
@@ -7,7 +7,11 @@ fn f<A: ToString + Clone, B: ToString + Clone>(a: A, b: B) -> (X<A, B>, X<A, B>)
(a.clone(), a)
}
-type Foo<'a, 'b> = impl std::fmt::Debug;
+pub trait Captures<'a> {}
+
+impl<'a, T: ?Sized> Captures<'a> for T {}
+
+type Foo<'a, 'b> = impl std::fmt::Debug + Captures<'a> + Captures<'b>;
fn foo<'x, 'y>(i: &'x i32, j: &'y i32) -> (Foo<'x, 'y>, Foo<'y, 'x>) {
(i, j)
diff --git a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr
index cdaae99e2..66a6b0bbf 100644
--- a/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr
+++ b/src/test/ui/type-alias-impl-trait/multiple-def-uses-in-one-fn.stderr
@@ -4,7 +4,7 @@ error[E0277]: the trait bound `&'static B: From<&A>` is not satisfied
LL | fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) {
| ^^^^^^^^^^^^^^^^^^ the trait `From<&A>` is not implemented for `&'static B`
|
- = note: required because of the requirements on the impl of `Into<&'static B>` for `&A`
+ = note: required for `&A` to implement `Into<&'static B>`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
LL | fn f<A, B: 'static>(a: &'static A, b: B) -> (X<A, B>, X<B, A>) where &'static B: From<&A> {
diff --git a/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr b/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr
index a5ac38c38..b11198c58 100644
--- a/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr
+++ b/src/test/ui/type-alias-impl-trait/not_a_defining_use.stderr
@@ -4,7 +4,7 @@ error[E0277]: `T` doesn't implement `Debug`
LL | (t, 5i8)
| ^^^^^^^^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(T, i8)`
+ = note: required for `(T, i8)` to implement `Debug`
help: consider restricting type parameter `T`
|
LL | type Two<T: std::fmt::Debug, U> = impl Debug;
@@ -27,7 +27,7 @@ error[E0277]: `T` doesn't implement `Debug`
LL | (t, <U as Bar>::FOO)
| ^^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug`
|
- = note: required because of the requirements on the impl of `Debug` for `(T, _)`
+ = note: required for `(T, _)` to implement `Debug`
help: consider restricting type parameter `T`
|
LL | type Two<T: std::fmt::Debug, U> = impl Debug;
diff --git a/src/test/ui/type-alias-impl-trait/unbounded_opaque_type.rs b/src/test/ui/type-alias-impl-trait/unbounded_opaque_type.rs
new file mode 100644
index 000000000..f43ad7dce
--- /dev/null
+++ b/src/test/ui/type-alias-impl-trait/unbounded_opaque_type.rs
@@ -0,0 +1,14 @@
+// check-pass
+
+#![feature(type_alias_impl_trait)]
+type Opaque<T> = impl Sized;
+fn defining<T>() -> Opaque<T> {}
+struct Ss<'a, T>(&'a Opaque<T>);
+
+
+fn test<'a, T>(_: Ss<'a, T>) {
+ // test that we have an implied bound `Opaque<T>: 'a` from fn signature
+ None::<&'a Opaque<T>>;
+}
+
+fn main() {}
diff --git a/src/test/ui/type-alias-impl-trait/underconstrained_generic.stderr b/src/test/ui/type-alias-impl-trait/underconstrained_generic.stderr
index e70916573..95fb6f6a5 100644
--- a/src/test/ui/type-alias-impl-trait/underconstrained_generic.stderr
+++ b/src/test/ui/type-alias-impl-trait/underconstrained_generic.stderr
@@ -4,7 +4,7 @@ error[E0277]: the trait bound `T: Trait` is not satisfied
LL | ()
| ^^ the trait `Trait` is not implemented for `T`
|
-note: required because of the requirements on the impl of `ProofForConversion<T>` for `()`
+note: required for `()` to implement `ProofForConversion<T>`
--> $DIR/underconstrained_generic.rs:13:16
|
LL | impl<X: Trait> ProofForConversion<X> for () {
diff --git a/src/test/ui/type/issue-100584.rs b/src/test/ui/type/issue-100584.rs
new file mode 100644
index 000000000..102846563
--- /dev/null
+++ b/src/test/ui/type/issue-100584.rs
@@ -0,0 +1,15 @@
+#![deny(unused)]
+fn foo(xyza: &str) {
+//~^ ERROR unused variable: `xyza`
+ let _ = "{xyza}";
+}
+
+fn foo3(xyza: &str) {
+//~^ ERROR unused variable: `xyza`
+ let _ = "aaa{xyza}bbb";
+}
+
+fn main() {
+ foo("x");
+ foo3("xx");
+}
diff --git a/src/test/ui/type/issue-100584.stderr b/src/test/ui/type/issue-100584.stderr
new file mode 100644
index 000000000..e1db14d1f
--- /dev/null
+++ b/src/test/ui/type/issue-100584.stderr
@@ -0,0 +1,44 @@
+error: unused variable: `xyza`
+ --> $DIR/issue-100584.rs:2:8
+ |
+LL | fn foo(xyza: &str) {
+ | ^^^^ unused variable
+LL |
+LL | let _ = "{xyza}";
+ | -------- you might have meant to use string interpolation in this string literal
+ |
+note: the lint level is defined here
+ --> $DIR/issue-100584.rs:1:9
+ |
+LL | #![deny(unused)]
+ | ^^^^^^
+ = note: `#[deny(unused_variables)]` implied by `#[deny(unused)]`
+help: string interpolation only works in `format!` invocations
+ |
+LL | let _ = format!("{xyza}");
+ | ++++++++ +
+help: if this is intentional, prefix it with an underscore
+ |
+LL | fn foo(_xyza: &str) {
+ | ~~~~~
+
+error: unused variable: `xyza`
+ --> $DIR/issue-100584.rs:7:9
+ |
+LL | fn foo3(xyza: &str) {
+ | ^^^^ unused variable
+LL |
+LL | let _ = "aaa{xyza}bbb";
+ | -------------- you might have meant to use string interpolation in this string literal
+ |
+help: string interpolation only works in `format!` invocations
+ |
+LL | let _ = format!("aaa{xyza}bbb");
+ | ++++++++ +
+help: if this is intentional, prefix it with an underscore
+ |
+LL | fn foo3(_xyza: &str) {
+ | ~~~~~
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/type/issue-101866.rs b/src/test/ui/type/issue-101866.rs
new file mode 100644
index 000000000..d332c4adb
--- /dev/null
+++ b/src/test/ui/type/issue-101866.rs
@@ -0,0 +1,15 @@
+trait TraitA<T> {
+ fn func();
+}
+
+struct StructA {}
+
+impl TraitA<i32> for StructA {
+ fn func() {}
+}
+
+fn main() {
+ TraitA::<i32>::func();
+ //~^ ERROR: cannot call associated function on trait without specifying the corresponding `impl` type [E0790]
+ //~| help: use the fully-qualified path to the only available implementation
+}
diff --git a/src/test/ui/type/issue-101866.stderr b/src/test/ui/type/issue-101866.stderr
new file mode 100644
index 000000000..fe9982119
--- /dev/null
+++ b/src/test/ui/type/issue-101866.stderr
@@ -0,0 +1,18 @@
+error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
+ --> $DIR/issue-101866.rs:12:5
+ |
+LL | fn func();
+ | ---------- `TraitA::func` defined here
+...
+LL | TraitA::<i32>::func();
+ | ^^^^^^^^^^^^^^^^^^^ cannot call associated function of trait
+ |
+help: use the fully-qualified path to the only available implementation
+ |
+LL - TraitA::<i32>::func();
+LL + <StructA as TraitA<i32>>::func();
+ |
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0790`.
diff --git a/src/test/ui/type/issue-94187-verbose-type-name.rs b/src/test/ui/type/issue-94187-verbose-type-name.rs
new file mode 100644
index 000000000..902ef5ade
--- /dev/null
+++ b/src/test/ui/type/issue-94187-verbose-type-name.rs
@@ -0,0 +1,13 @@
+// Check to insure that the output of `std::any::type_name` does not change based on -Zverbose
+// when printing constants
+// run-pass
+// edition: 2018
+// revisions: normal verbose
+// [verbose]compile-flags:-Zverbose
+
+struct Wrapper<const VALUE: usize>;
+
+fn main() {
+ assert_eq!(std::any::type_name::<[u32; 0]>(), "[u32; 0]");
+ assert_eq!(std::any::type_name::<Wrapper<0>>(), "issue_94187_verbose_type_name::Wrapper<0>");
+}
diff --git a/src/test/ui/type/type-alias-bounds.rs b/src/test/ui/type/type-alias-bounds.rs
index 65b79650d..e49731725 100644
--- a/src/test/ui/type/type-alias-bounds.rs
+++ b/src/test/ui/type/type-alias-bounds.rs
@@ -52,7 +52,7 @@ type T2<U> where U: Bound = U::Assoc; //~ WARN not enforced in type aliases
// Do this instead:
type T4<U> = <U as Bound>::Assoc;
-// Make sure the help about associatd types is not shown incorrectly
+// Make sure the help about associated types is not shown incorrectly
type T5<U: Bound> = <U as Bound>::Assoc; //~ WARN not enforced in type aliases
type T6<U: Bound> = ::std::vec::Vec<U>; //~ WARN not enforced in type aliases
diff --git a/src/test/ui/type/type-arg-out-of-scope.stderr b/src/test/ui/type/type-arg-out-of-scope.stderr
index 0b6283fbc..7f18b4510 100644
--- a/src/test/ui/type/type-arg-out-of-scope.stderr
+++ b/src/test/ui/type/type-arg-out-of-scope.stderr
@@ -4,9 +4,9 @@ error[E0401]: can't use generic parameters from outer function
LL | fn foo<T>(x: T) {
| - type parameter from outer function
LL | fn bar(f: Box<dyn FnMut(T) -> T>) { }
- | --- ^ use of generic parameter from outer function
- | |
- | help: try using a local generic parameter instead: `bar<T>`
+ | - ^ use of generic parameter from outer function
+ | |
+ | help: try using a local generic parameter instead: `<T>`
error[E0401]: can't use generic parameters from outer function
--> $DIR/type-arg-out-of-scope.rs:3:35
@@ -14,9 +14,9 @@ error[E0401]: can't use generic parameters from outer function
LL | fn foo<T>(x: T) {
| - type parameter from outer function
LL | fn bar(f: Box<dyn FnMut(T) -> T>) { }
- | --- ^ use of generic parameter from outer function
- | |
- | help: try using a local generic parameter instead: `bar<T>`
+ | - ^ use of generic parameter from outer function
+ | |
+ | help: try using a local generic parameter instead: `<T>`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/type/type-ascription-instead-of-initializer.stderr b/src/test/ui/type/type-ascription-instead-of-initializer.stderr
index fcac6c495..de578ca93 100644
--- a/src/test/ui/type/type-ascription-instead-of-initializer.stderr
+++ b/src/test/ui/type/type-ascription-instead-of-initializer.stderr
@@ -21,7 +21,7 @@ LL | pub fn with_capacity(capacity: usize) -> Self {
help: remove the extra argument
|
LL | let x: Vec::with_capacity(10);
- | ~~~~~~~~~~~~~~~~~~~~~~
+ | ~~~~
error: aborting due to 2 previous errors
diff --git a/src/test/ui/type/type-check-defaults.stderr b/src/test/ui/type/type-check-defaults.stderr
index 56a9b5317..cf77c057d 100644
--- a/src/test/ui/type/type-check-defaults.stderr
+++ b/src/test/ui/type/type-check-defaults.stderr
@@ -1,8 +1,8 @@
error[E0277]: a value of type `i32` cannot be built from an iterator over elements of type `i32`
- --> $DIR/type-check-defaults.rs:6:19
+ --> $DIR/type-check-defaults.rs:6:23
|
LL | struct WellFormed<Z = Foo<i32, i32>>(Z);
- | ^^^^^^^^^^^^^^^^^ value of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
+ | ^^^^^^^^^^^^^ value of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
|
= help: the trait `FromIterator<i32>` is not implemented for `i32`
note: required by a bound in `Foo`
@@ -12,10 +12,10 @@ LL | struct Foo<T, U: FromIterator<T>>(T, U);
| ^^^^^^^^^^^^^^^ required by this bound in `Foo`
error[E0277]: a value of type `i32` cannot be built from an iterator over elements of type `i32`
- --> $DIR/type-check-defaults.rs:8:27
+ --> $DIR/type-check-defaults.rs:8:38
|
LL | struct WellFormedNoBounds<Z:?Sized = Foo<i32, i32>>(Z);
- | ^^^^^^^^^^^^^^^^^^^^^^^^ value of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
+ | ^^^^^^^^^^^^^ value of type `i32` cannot be built from `std::iter::Iterator<Item=i32>`
|
= help: the trait `FromIterator<i32>` is not implemented for `i32`
note: required by a bound in `Foo`
diff --git a/src/test/ui/type/type-check/assignment-expected-bool.stderr b/src/test/ui/type/type-check/assignment-expected-bool.stderr
index e2b821f7b..56494baff 100644
--- a/src/test/ui/type/type-check/assignment-expected-bool.stderr
+++ b/src/test/ui/type/type-check/assignment-expected-bool.stderr
@@ -7,7 +7,7 @@ LL | let _: bool = 0 = 0;
help: you might have meant to compare for equality
|
LL | let _: bool = 0 == 0;
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:9:14
@@ -18,7 +18,7 @@ LL | 0 => 0 = 0,
help: you might have meant to compare for equality
|
LL | 0 => 0 == 0,
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:10:14
@@ -29,7 +29,7 @@ LL | _ => 0 = 0,
help: you might have meant to compare for equality
|
LL | _ => 0 == 0,
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:14:17
@@ -40,7 +40,7 @@ LL | true => 0 = 0,
help: you might have meant to compare for equality
|
LL | true => 0 == 0,
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:18:8
@@ -51,7 +51,7 @@ LL | if 0 = 0 {}
help: you might have meant to compare for equality
|
LL | if 0 == 0 {}
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:20:24
@@ -62,7 +62,7 @@ LL | let _: bool = if { 0 = 0 } {
help: you might have meant to compare for equality
|
LL | let _: bool = if { 0 == 0 } {
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:21:9
@@ -73,7 +73,7 @@ LL | 0 = 0
help: you might have meant to compare for equality
|
LL | 0 == 0
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:23:9
@@ -84,7 +84,7 @@ LL | 0 = 0
help: you might have meant to compare for equality
|
LL | 0 == 0
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:26:13
@@ -95,7 +95,7 @@ LL | let _ = (0 = 0)
help: you might have meant to compare for equality
|
LL | let _ = (0 == 0)
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:27:14
@@ -106,7 +106,7 @@ LL | && { 0 = 0 }
help: you might have meant to compare for equality
|
LL | && { 0 == 0 }
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-expected-bool.rs:28:12
@@ -117,7 +117,7 @@ LL | || (0 = 0);
help: you might have meant to compare for equality
|
LL | || (0 == 0);
- | ~~
+ | +
error[E0070]: invalid left-hand side of assignment
--> $DIR/assignment-expected-bool.rs:31:22
diff --git a/src/test/ui/type/type-check/assignment-in-if.rs b/src/test/ui/type/type-check/assignment-in-if.rs
index 8da7b32b4..ada250df2 100644
--- a/src/test/ui/type/type-check/assignment-in-if.rs
+++ b/src/test/ui/type/type-check/assignment-in-if.rs
@@ -40,4 +40,23 @@ fn main() {
) {
println!("{}", x);
}
+
+ if x == x && x = x && x == x {
+ //~^ ERROR mismatched types
+ //~| ERROR mismatched types
+ //~| ERROR mismatched types
+ println!("{}", x);
+ }
+
+ if x == x && x == x && x = x {
+ //~^ ERROR mismatched types
+ //~| ERROR mismatched types
+ println!("{}", x);
+ }
+
+ if x = 1 && x == 1 {
+ //~^ ERROR mismatched types
+ //~| ERROR mismatched types
+ println!("{}", x);
+ }
}
diff --git a/src/test/ui/type/type-check/assignment-in-if.stderr b/src/test/ui/type/type-check/assignment-in-if.stderr
index f4ef44e24..8ab08e25e 100644
--- a/src/test/ui/type/type-check/assignment-in-if.stderr
+++ b/src/test/ui/type/type-check/assignment-in-if.stderr
@@ -7,7 +7,7 @@ LL | if x = x {
help: you might have meant to compare for equality
|
LL | if x == x {
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-in-if.rs:20:8
@@ -18,7 +18,7 @@ LL | if (x = x) {
help: you might have meant to compare for equality
|
LL | if (x == x) {
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-in-if.rs:25:8
@@ -29,7 +29,7 @@ LL | if y = (Foo { foo: x }) {
help: you might have meant to compare for equality
|
LL | if y == (Foo { foo: x }) {
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-in-if.rs:30:8
@@ -40,7 +40,7 @@ LL | if 3 = x {
help: you might have meant to compare for equality
|
LL | if 3 == x {
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-in-if.rs:36:13
@@ -51,7 +51,7 @@ LL | x = 4
help: you might have meant to compare for equality
|
LL | x == 4
- | ~~
+ | +
error[E0308]: mismatched types
--> $DIR/assignment-in-if.rs:38:13
@@ -62,8 +62,65 @@ LL | x = 5
help: you might have meant to compare for equality
|
LL | x == 5
- | ~~
+ | +
-error: aborting due to 6 previous errors
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:44:18
+ |
+LL | if x == x && x = x && x == x {
+ | ^ expected `bool`, found `usize`
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:44:22
+ |
+LL | if x == x && x = x && x == x {
+ | ^ expected `bool`, found `usize`
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:44:8
+ |
+LL | if x == x && x = x && x == x {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | if x == x && x == x && x == x {
+ | +
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:51:28
+ |
+LL | if x == x && x == x && x = x {
+ | ^ expected `bool`, found `usize`
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:51:8
+ |
+LL | if x == x && x == x && x = x {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | if x == x && x == x && x == x {
+ | +
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:57:12
+ |
+LL | if x = 1 && x == 1 {
+ | ^ expected `bool`, found integer
+
+error[E0308]: mismatched types
+ --> $DIR/assignment-in-if.rs:57:8
+ |
+LL | if x = 1 && x == 1 {
+ | ^^^^^^^^^^^^^^^ expected `bool`, found `()`
+ |
+help: you might have meant to compare for equality
+ |
+LL | if x == 1 && x == 1 {
+ | +
+
+error: aborting due to 13 previous errors
For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr b/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr
index 615fd2ccb..847bc517e 100644
--- a/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr
+++ b/src/test/ui/type/type-check/issue-88577-check-fn-with-more-than-65535-arguments.stderr
@@ -1,13 +1,13 @@
error: function can not have more than 65535 arguments
- --> $DIR/issue-88577-check-fn-with-more-than-65535-arguments.rs:6:24
+ --> $DIR/issue-88577-check-fn-with-more-than-65535-arguments.rs:6:22
|
-LL | fn _f($($t: ()),*) {}
- | ________________________^
-LL | | }
-LL | | }
-LL | |
-LL | | many_args!{[_]########## ######}
- | |____________^
+LL | fn _f($($t: ()),*) {}
+ | ^
+...
+LL | many_args!{[_]########## ######}
+ | -------------------------------- in this macro invocation
+ |
+ = note: this error originates in the macro `many_args` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
diff --git a/src/test/ui/type/type-mismatch-same-crate-name.stderr b/src/test/ui/type/type-mismatch-same-crate-name.stderr
index 783f747fa..fcafd315e 100644
--- a/src/test/ui/type/type-mismatch-same-crate-name.stderr
+++ b/src/test/ui/type/type-mismatch-same-crate-name.stderr
@@ -6,6 +6,17 @@ LL | a::try_foo(foo2);
| |
| arguments to this function are incorrect
|
+ = note: struct `main::a::Foo` and struct `main::a::Foo` have similar names, but are actually distinct types
+note: struct `main::a::Foo` is defined in crate `crate_a2`
+ --> $DIR/auxiliary/crate_a2.rs:1:1
+ |
+LL | pub struct Foo;
+ | ^^^^^^^^^^^^^^
+note: struct `main::a::Foo` is defined in crate `crate_a1`
+ --> $DIR/auxiliary/crate_a1.rs:1:1
+ |
+LL | pub struct Foo;
+ | ^^^^^^^^^^^^^^
= note: perhaps two different versions of crate `crate_a1` are being used?
note: function defined here
--> $DIR/auxiliary/crate_a1.rs:10:8
diff --git a/src/test/ui/type/type-params-in-different-spaces-2.stderr b/src/test/ui/type/type-params-in-different-spaces-2.stderr
index 53610985f..220b3929c 100644
--- a/src/test/ui/type/type-params-in-different-spaces-2.stderr
+++ b/src/test/ui/type/type-params-in-different-spaces-2.stderr
@@ -1,8 +1,10 @@
error[E0277]: the trait bound `Self: Tr<U>` is not satisfied
- --> $DIR/type-params-in-different-spaces-2.rs:10:9
+ --> $DIR/type-params-in-different-spaces-2.rs:10:16
|
LL | Tr::op(u)
- | ^^^^^^ the trait `Tr<U>` is not implemented for `Self`
+ | ------ ^ the trait `Tr<U>` is not implemented for `Self`
+ | |
+ | required by a bound introduced by this call
|
help: consider further restricting `Self`
|
@@ -10,10 +12,12 @@ LL | fn test<U>(u: U) -> Self where Self: Tr<U> {
| +++++++++++++++++
error[E0277]: the trait bound `Self: Tr<U>` is not satisfied
- --> $DIR/type-params-in-different-spaces-2.rs:16:9
+ --> $DIR/type-params-in-different-spaces-2.rs:16:16
|
LL | Tr::op(u)
- | ^^^^^^ the trait `Tr<U>` is not implemented for `Self`
+ | ------ ^ the trait `Tr<U>` is not implemented for `Self`
+ | |
+ | required by a bound introduced by this call
|
help: consider further restricting `Self`
|
diff --git a/src/test/ui/type/type-recursive-box-shadowed.stderr b/src/test/ui/type/type-recursive-box-shadowed.stderr
index c22d848f3..cb0e98287 100644
--- a/src/test/ui/type/type-recursive-box-shadowed.stderr
+++ b/src/test/ui/type/type-recursive-box-shadowed.stderr
@@ -2,12 +2,12 @@ error[E0072]: recursive type `Foo` has infinite size
--> $DIR/type-recursive-box-shadowed.rs:7:1
|
LL | struct Foo {
- | ^^^^^^^^^^ recursive type has infinite size
+ | ^^^^^^^^^^
LL |
LL | inner: Foo,
| --- recursive without indirection
|
-help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `Foo` representable
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
LL | inner: Box<Foo>,
| ++++ +
diff --git a/src/test/ui/type/type-recursive.stderr b/src/test/ui/type/type-recursive.stderr
index 320271028..9a4d798f6 100644
--- a/src/test/ui/type/type-recursive.stderr
+++ b/src/test/ui/type/type-recursive.stderr
@@ -2,12 +2,12 @@ error[E0072]: recursive type `T1` has infinite size
--> $DIR/type-recursive.rs:1:1
|
LL | struct T1 {
- | ^^^^^^^^^ recursive type has infinite size
+ | ^^^^^^^^^
LL | foo: isize,
LL | foolish: T1,
| -- recursive without indirection
|
-help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `T1` representable
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
LL | foolish: Box<T1>,
| ++++ +
@@ -16,11 +16,11 @@ error[E0072]: recursive type `T2` has infinite size
--> $DIR/type-recursive.rs:6:1
|
LL | struct T2 {
- | ^^^^^^^^^ recursive type has infinite size
+ | ^^^^^^^^^
LL | inner: Option<T2>,
- | ---------- recursive without indirection
+ | -- recursive without indirection
|
-help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `T2` representable
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
LL | inner: Option<Box<T2>>,
| ++++ +
@@ -29,11 +29,11 @@ error[E0072]: recursive type `T3` has infinite size
--> $DIR/type-recursive.rs:12:1
|
LL | struct T3 {
- | ^^^^^^^^^ recursive type has infinite size
+ | ^^^^^^^^^
LL | inner: OptionT3,
| -------- recursive without indirection
|
-help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `T3` representable
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
LL | inner: Box<OptionT3>,
| ++++ +
@@ -42,11 +42,9 @@ error[E0072]: recursive type `T4` has infinite size
--> $DIR/type-recursive.rs:16:1
|
LL | struct T4(Option<T4>);
- | ^^^^^^^^^ ---------- recursive without indirection
- | |
- | recursive type has infinite size
+ | ^^^^^^^^^ -- recursive without indirection
|
-help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `T4` representable
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
LL | struct T4(Option<Box<T4>>);
| ++++ +
@@ -55,11 +53,11 @@ error[E0072]: recursive type `T5` has infinite size
--> $DIR/type-recursive.rs:18:1
|
LL | enum T5 {
- | ^^^^^^^ recursive type has infinite size
+ | ^^^^^^^
LL | Variant(Option<T5>),
- | ---------- recursive without indirection
+ | -- recursive without indirection
|
-help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `T5` representable
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
LL | Variant(Option<Box<T5>>),
| ++++ +
@@ -68,11 +66,11 @@ error[E0072]: recursive type `T6` has infinite size
--> $DIR/type-recursive.rs:22:1
|
LL | enum T6 {
- | ^^^^^^^ recursive type has infinite size
+ | ^^^^^^^
LL | Variant{ field: Option<T6> },
- | ---------- recursive without indirection
+ | -- recursive without indirection
|
-help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `T6` representable
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
LL | Variant{ field: Option<Box<T6>> },
| ++++ +
@@ -81,14 +79,14 @@ error[E0072]: recursive type `T7` has infinite size
--> $DIR/type-recursive.rs:26:1
|
LL | struct T7 {
- | ^^^^^^^^^ recursive type has infinite size
+ | ^^^^^^^^^
LL | foo: std::cell::Cell<Option<T7>>,
- | --------------------------- recursive without indirection
+ | -- recursive without indirection
|
-help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to make `T7` representable
+help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle
|
-LL | foo: Box<std::cell::Cell<Option<T7>>>,
- | ++++ +
+LL | foo: std::cell::Cell<Option<Box<T7>>>,
+ | ++++ +
error: aborting due to 7 previous errors
diff --git a/src/test/ui/type_length_limit.stderr b/src/test/ui/type_length_limit.stderr
index 1508b84c1..84ac48b1e 100644
--- a/src/test/ui/type_length_limit.stderr
+++ b/src/test/ui/type_length_limit.stderr
@@ -4,8 +4,8 @@ error: reached the type-length limit while instantiating `std::mem::drop::<Optio
LL | pub fn drop<T>(_x: T) {}
| ^^^^^^^^^^^^^^^^^^^^^
|
- = note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit/type_length_limit.long-type.txt'
= help: consider adding a `#![type_length_limit="8"]` attribute to your crate
+ = note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit/type_length_limit.long-type.txt'
error: reached the type-length limit while instantiating `<[closure@std::rt::lang_start<()...e<()>>::call_once - shim(vtable)`
--> $SRC_DIR/core/src/ops/function.rs:LL:COL
@@ -13,8 +13,8 @@ error: reached the type-length limit while instantiating `<[closure@std::rt::lan
LL | extern "rust-call" fn call_once(self, args: Args) -> Self::Output;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
- = note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit/type_length_limit.long-type.txt'
= help: consider adding a `#![type_length_limit="8"]` attribute to your crate
+ = note: the full type name has been written to '$TEST_BUILD_DIR/type_length_limit/type_length_limit.long-type.txt'
error: aborting due to 2 previous errors
diff --git a/src/test/ui/typeck/assign-non-lval-derefmut.stderr b/src/test/ui/typeck/assign-non-lval-derefmut.stderr
index a6fcdfe21..e394cf820 100644
--- a/src/test/ui/typeck/assign-non-lval-derefmut.stderr
+++ b/src/test/ui/typeck/assign-non-lval-derefmut.stderr
@@ -19,7 +19,7 @@ LL | x.lock().unwrap() += 1;
| |
| cannot use `+=` on type `MutexGuard<'_, usize>`
|
-help: `+=` can be used on `usize`, you can dereference `x.lock().unwrap()`
+help: `+=` can be used on `usize` if you dereference the left-hand side
|
LL | *x.lock().unwrap() += 1;
| +
@@ -47,7 +47,7 @@ LL | y += 1;
| |
| cannot use `+=` on type `MutexGuard<'_, usize>`
|
-help: `+=` can be used on `usize`, you can dereference `y`
+help: `+=` can be used on `usize` if you dereference the left-hand side
|
LL | *y += 1;
| +
diff --git a/src/test/ui/typeck/assign-non-lval-mut-ref.stderr b/src/test/ui/typeck/assign-non-lval-mut-ref.stderr
index be2e9fe95..cbdc960ba 100644
--- a/src/test/ui/typeck/assign-non-lval-mut-ref.stderr
+++ b/src/test/ui/typeck/assign-non-lval-mut-ref.stderr
@@ -19,7 +19,7 @@ LL | x.last_mut().unwrap() += 1;
| |
| cannot use `+=` on type `&mut usize`
|
-help: `+=` can be used on `usize`, you can dereference `x.last_mut().unwrap()`
+help: `+=` can be used on `usize` if you dereference the left-hand side
|
LL | *x.last_mut().unwrap() += 1;
| +
@@ -45,7 +45,7 @@ LL | y += 1;
| |
| cannot use `+=` on type `&mut usize`
|
-help: `+=` can be used on `usize`, you can dereference `y`
+help: `+=` can be used on `usize` if you dereference the left-hand side
|
LL | *y += 1;
| +
diff --git a/src/test/ui/typeck/assign-non-lval-needs-deref.rs b/src/test/ui/typeck/assign-non-lval-needs-deref.rs
new file mode 100644
index 000000000..c979d76b4
--- /dev/null
+++ b/src/test/ui/typeck/assign-non-lval-needs-deref.rs
@@ -0,0 +1,19 @@
+// issue #101376
+
+use std::ops::AddAssign;
+struct Foo;
+
+impl AddAssign<()> for Foo {
+ fn add_assign(&mut self, _: ()) {}
+}
+
+impl AddAssign<()> for &mut Foo {
+ fn add_assign(&mut self, _: ()) {}
+}
+
+fn main() {
+ (&mut Foo) += ();
+ //~^ ERROR invalid left-hand side of assignment
+ //~| NOTE cannot assign to this expression
+ //~| HELP consider dereferencing the left-hand side of this operation
+}
diff --git a/src/test/ui/typeck/assign-non-lval-needs-deref.stderr b/src/test/ui/typeck/assign-non-lval-needs-deref.stderr
new file mode 100644
index 000000000..ee83b1453
--- /dev/null
+++ b/src/test/ui/typeck/assign-non-lval-needs-deref.stderr
@@ -0,0 +1,16 @@
+error[E0067]: invalid left-hand side of assignment
+ --> $DIR/assign-non-lval-needs-deref.rs:15:16
+ |
+LL | (&mut Foo) += ();
+ | ---------- ^^
+ | |
+ | cannot assign to this expression
+ |
+help: consider dereferencing the left-hand side of this operation
+ |
+LL | *(&mut Foo) += ();
+ | +
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0067`.
diff --git a/src/test/ui/typeck/do-not-suggest-placeholder-to-const-static-without-type.rs b/src/test/ui/typeck/do-not-suggest-placeholder-to-const-static-without-type.rs
new file mode 100644
index 000000000..97e0b213f
--- /dev/null
+++ b/src/test/ui/typeck/do-not-suggest-placeholder-to-const-static-without-type.rs
@@ -0,0 +1,8 @@
+trait Foo {
+ const A; //~ ERROR missing type for `const` item
+ static B;
+ //~^ ERROR associated `static` items are not allowed
+ //~| ERROR missing type for `static` item
+}
+
+fn main() {}
diff --git a/src/test/ui/typeck/do-not-suggest-placeholder-to-const-static-without-type.stderr b/src/test/ui/typeck/do-not-suggest-placeholder-to-const-static-without-type.stderr
new file mode 100644
index 000000000..8982d6285
--- /dev/null
+++ b/src/test/ui/typeck/do-not-suggest-placeholder-to-const-static-without-type.stderr
@@ -0,0 +1,20 @@
+error: associated `static` items are not allowed
+ --> $DIR/do-not-suggest-placeholder-to-const-static-without-type.rs:3:5
+ |
+LL | static B;
+ | ^^^^^^^^^
+
+error: missing type for `const` item
+ --> $DIR/do-not-suggest-placeholder-to-const-static-without-type.rs:2:12
+ |
+LL | const A;
+ | ^ help: provide a type for the item: `: <type>`
+
+error: missing type for `static` item
+ --> $DIR/do-not-suggest-placeholder-to-const-static-without-type.rs:3:13
+ |
+LL | static B;
+ | ^ help: provide a type for the item: `: <type>`
+
+error: aborting due to 3 previous errors
+
diff --git a/src/test/ui/typeck/issue-100164.fixed b/src/test/ui/typeck/issue-100164.fixed
new file mode 100644
index 000000000..a5f68beb1
--- /dev/null
+++ b/src/test/ui/typeck/issue-100164.fixed
@@ -0,0 +1,9 @@
+// run-rustfix
+
+const _A: i32 = 123;
+//~^ ERROR: missing type for `const` item
+
+fn main() {
+ const _B: i32 = 123;
+ //~^ ERROR: missing type for `const` item
+}
diff --git a/src/test/ui/typeck/issue-100164.rs b/src/test/ui/typeck/issue-100164.rs
new file mode 100644
index 000000000..7efb9ac62
--- /dev/null
+++ b/src/test/ui/typeck/issue-100164.rs
@@ -0,0 +1,9 @@
+// run-rustfix
+
+const _A: = 123;
+//~^ ERROR: missing type for `const` item
+
+fn main() {
+ const _B: = 123;
+ //~^ ERROR: missing type for `const` item
+}
diff --git a/src/test/ui/typeck/issue-100164.stderr b/src/test/ui/typeck/issue-100164.stderr
new file mode 100644
index 000000000..06a132d65
--- /dev/null
+++ b/src/test/ui/typeck/issue-100164.stderr
@@ -0,0 +1,14 @@
+error: missing type for `const` item
+ --> $DIR/issue-100164.rs:3:10
+ |
+LL | const _A: = 123;
+ | ^ help: provide a type for the constant: `i32`
+
+error: missing type for `const` item
+ --> $DIR/issue-100164.rs:7:14
+ |
+LL | const _B: = 123;
+ | ^ help: provide a type for the constant: `i32`
+
+error: aborting due to 2 previous errors
+
diff --git a/src/test/ui/typeck/issue-100246.rs b/src/test/ui/typeck/issue-100246.rs
new file mode 100644
index 000000000..8f0b34bab
--- /dev/null
+++ b/src/test/ui/typeck/issue-100246.rs
@@ -0,0 +1,30 @@
+#![recursion_limit = "5"] // To reduce noise
+
+//expect incompatible type error when ambiguous traits are in scope
+//and not an overflow error on the span in the main function.
+
+struct Ratio<T>(T);
+
+pub trait Pow {
+ fn pow(self) -> Self;
+}
+
+impl<'a, T> Pow for &'a Ratio<T>
+where
+ &'a T: Pow,
+{
+ fn pow(self) -> Self {
+ self
+ }
+}
+
+fn downcast<'a, W: ?Sized>() -> std::io::Result<&'a W> {
+ todo!()
+}
+
+struct Other;
+
+fn main() -> std::io::Result<()> {
+ let other: Other = downcast()?;//~ERROR 28:24: 28:35: `?` operator has incompatible types
+ Ok(())
+}
diff --git a/src/test/ui/typeck/issue-100246.stderr b/src/test/ui/typeck/issue-100246.stderr
new file mode 100644
index 000000000..8b77de94e
--- /dev/null
+++ b/src/test/ui/typeck/issue-100246.stderr
@@ -0,0 +1,13 @@
+error[E0308]: `?` operator has incompatible types
+ --> $DIR/issue-100246.rs:28:24
+ |
+LL | let other: Other = downcast()?;
+ | ^^^^^^^^^^^ expected struct `Other`, found reference
+ |
+ = note: `?` operator cannot convert from `&_` to `Other`
+ = note: expected struct `Other`
+ found reference `&_`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/typeck/issue-100285.rs b/src/test/ui/typeck/issue-100285.rs
new file mode 100644
index 000000000..e206469b8
--- /dev/null
+++ b/src/test/ui/typeck/issue-100285.rs
@@ -0,0 +1,22 @@
+fn foo(n: i32) -> i32 {
+ for i in 0..0 {
+ //~^ ERROR: mismatched types [E0308]
+ if n < 0 {
+ return i;
+ } else if n < 10 {
+ return 1;
+ } else if n < 20 {
+ return 2;
+ } else if n < 30 {
+ return 3;
+ } else if n < 40 {
+ return 4;
+ } else {
+ return 5;
+ }
+
+ }
+ //~| help: return a value for the case when the loop has zero elements to iterate on, or consider changing the return type to account for that possibility
+}
+
+fn main() {}
diff --git a/src/test/ui/typeck/issue-100285.stderr b/src/test/ui/typeck/issue-100285.stderr
new file mode 100644
index 000000000..42c64b039
--- /dev/null
+++ b/src/test/ui/typeck/issue-100285.stderr
@@ -0,0 +1,34 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-100285.rs:2:5
+ |
+LL | fn foo(n: i32) -> i32 {
+ | --- expected `i32` because of return type
+LL | / for i in 0..0 {
+LL | |
+LL | | if n < 0 {
+LL | | return i;
+... |
+LL | |
+LL | | }
+ | |_____^ expected `i32`, found `()`
+ |
+note: the function expects a value to always be returned, but loops might run zero times
+ --> $DIR/issue-100285.rs:2:5
+ |
+LL | for i in 0..0 {
+ | ^^^^^^^^^^^^^ this might have zero elements to iterate on
+...
+LL | return i;
+ | -------- if the loop doesn't execute, this value would never get returned
+LL | } else if n < 10 {
+LL | return 1;
+ | -------- if the loop doesn't execute, this value would never get returned
+LL | } else if n < 20 {
+LL | return 2;
+ | -------- if the loop doesn't execute, this value would never get returned
+ = note: if the loop doesn't execute, 3 other values would never get returned
+ = help: return a value for the case when the loop has zero elements to iterate on, or consider changing the return type to account for that possibility
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/typeck/issue-29124.stderr b/src/test/ui/typeck/issue-29124.stderr
index c5d2ec084..a837a7d2d 100644
--- a/src/test/ui/typeck/issue-29124.stderr
+++ b/src/test/ui/typeck/issue-29124.stderr
@@ -2,17 +2,13 @@ error[E0599]: no method named `x` found for fn item `fn() -> Ret {Obj::func}` in
--> $DIR/issue-29124.rs:15:15
|
LL | Obj::func.x();
- | --------- ^ method not found in `fn() -> Ret {Obj::func}`
- | |
- | this is a function, perhaps you wish to call it
+ | ^ method not found in `fn() -> Ret {Obj::func}`
error[E0599]: no method named `x` found for fn item `fn() -> Ret {func}` in the current scope
--> $DIR/issue-29124.rs:17:10
|
LL | func.x();
- | ---- ^ method not found in `fn() -> Ret {func}`
- | |
- | this is a function, perhaps you wish to call it
+ | ^ method not found in `fn() -> Ret {func}`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.stderr b/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.stderr
index 6bc9c8498..fc7c23a22 100644
--- a/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.stderr
+++ b/src/test/ui/typeck/issue-69378-ice-on-invalid-type-node-after-recovery.stderr
@@ -2,7 +2,9 @@ error: expected identifier, found `0`
--> $DIR/issue-69378-ice-on-invalid-type-node-after-recovery.rs:3:14
|
LL | struct Foo { 0: u8 }
- | ^ expected identifier
+ | --- ^ expected identifier
+ | |
+ | while parsing this struct
error: aborting due to previous error
diff --git a/src/test/ui/typeck/issue-79040.stderr b/src/test/ui/typeck/issue-79040.stderr
index aec2e1ec9..c820d1e08 100644
--- a/src/test/ui/typeck/issue-79040.stderr
+++ b/src/test/ui/typeck/issue-79040.stderr
@@ -7,10 +7,10 @@ LL | const FOO = "hello" + 1;
| &str
error: missing type for `const` item
- --> $DIR/issue-79040.rs:2:11
+ --> $DIR/issue-79040.rs:2:14
|
LL | const FOO = "hello" + 1;
- | ^^^ help: provide a type for the item: `FOO: <type>`
+ | ^ help: provide a type for the item: `: <type>`
error: aborting due to 2 previous errors
diff --git a/src/test/ui/typeck/issue-87181/empty-tuple-method.rs b/src/test/ui/typeck/issue-87181/empty-tuple-method.rs
index 1875d8280..be68ad32a 100644
--- a/src/test/ui/typeck/issue-87181/empty-tuple-method.rs
+++ b/src/test/ui/typeck/issue-87181/empty-tuple-method.rs
@@ -4,7 +4,7 @@ struct Bar<T> {
struct Foo();
impl Foo {
- fn foo() { }
+ fn foo(&self) { }
}
fn main() {
diff --git a/src/test/ui/typeck/issue-87181/empty-tuple-method.stderr b/src/test/ui/typeck/issue-87181/empty-tuple-method.stderr
index 6ed70b301..23e7b7cc3 100644
--- a/src/test/ui/typeck/issue-87181/empty-tuple-method.stderr
+++ b/src/test/ui/typeck/issue-87181/empty-tuple-method.stderr
@@ -2,11 +2,9 @@ error[E0599]: no method named `foo` found for fn item `fn() -> Foo {Foo}` in the
--> $DIR/empty-tuple-method.rs:12:15
|
LL | thing.bar.foo();
- | --------- ^^^ method not found in `fn() -> Foo {Foo}`
- | |
- | this is the constructor of a struct
+ | ^^^ method not found in `fn() -> Foo {Foo}`
|
-help: call the constructor
+help: use parentheses to construct this tuple struct
|
LL | (thing.bar)().foo();
| + +++
diff --git a/src/test/ui/typeck/issue-87181/enum-variant.rs b/src/test/ui/typeck/issue-87181/enum-variant.rs
index 3b926b90f..d87f99c3c 100644
--- a/src/test/ui/typeck/issue-87181/enum-variant.rs
+++ b/src/test/ui/typeck/issue-87181/enum-variant.rs
@@ -6,7 +6,7 @@ enum Foo{
Tup()
}
impl Foo {
- fn foo() { }
+ fn foo(&self) { }
}
fn main() {
diff --git a/src/test/ui/typeck/issue-87181/enum-variant.stderr b/src/test/ui/typeck/issue-87181/enum-variant.stderr
index a3a818696..2247ea270 100644
--- a/src/test/ui/typeck/issue-87181/enum-variant.stderr
+++ b/src/test/ui/typeck/issue-87181/enum-variant.stderr
@@ -2,11 +2,9 @@ error[E0599]: no method named `foo` found for fn item `fn() -> Foo {Foo::Tup}` i
--> $DIR/enum-variant.rs:14:15
|
LL | thing.bar.foo();
- | --------- ^^^ method not found in `fn() -> Foo {Foo::Tup}`
- | |
- | this is the constructor of an enum variant
+ | ^^^ method not found in `fn() -> Foo {Foo::Tup}`
|
-help: call the constructor
+help: use parentheses to construct this tuple variant
|
LL | (thing.bar)().foo();
| + +++
diff --git a/src/test/ui/typeck/issue-87181/tuple-field.stderr b/src/test/ui/typeck/issue-87181/tuple-field.stderr
index 4d22ada02..0a7d30b61 100644
--- a/src/test/ui/typeck/issue-87181/tuple-field.stderr
+++ b/src/test/ui/typeck/issue-87181/tuple-field.stderr
@@ -2,14 +2,12 @@ error[E0609]: no field `0` on type `fn(char, u16) -> Foo {Foo}`
--> $DIR/tuple-field.rs:12:15
|
LL | thing.bar.0;
- | --------- ^
- | |
- | this is the constructor of a struct
+ | ^
|
-help: call the constructor
+help: use parentheses to construct this tuple struct
|
-LL | (thing.bar)(_, _).0;
- | + +++++++
+LL | (thing.bar)(/* char */, /* u16 */).0;
+ | + ++++++++++++++++++++++++
error: aborting due to previous error
diff --git a/src/test/ui/typeck/issue-87181/tuple-method.stderr b/src/test/ui/typeck/issue-87181/tuple-method.stderr
index 1e392e179..e27c41858 100644
--- a/src/test/ui/typeck/issue-87181/tuple-method.stderr
+++ b/src/test/ui/typeck/issue-87181/tuple-method.stderr
@@ -2,14 +2,7 @@ error[E0599]: no method named `foo` found for fn item `fn(u8, i32) -> Foo {Foo}`
--> $DIR/tuple-method.rs:12:15
|
LL | thing.bar.foo();
- | --------- ^^^ method not found in `fn(u8, i32) -> Foo {Foo}`
- | |
- | this is the constructor of a struct
- |
-help: call the constructor
- |
-LL | (thing.bar)(_, _).foo();
- | + +++++++
+ | ^^^ method not found in `fn(u8, i32) -> Foo {Foo}`
error: aborting due to previous error
diff --git a/src/test/ui/typeck/issue-90101.stderr b/src/test/ui/typeck/issue-90101.stderr
index ab9a72edf..d2729d853 100644
--- a/src/test/ui/typeck/issue-90101.stderr
+++ b/src/test/ui/typeck/issue-90101.stderr
@@ -12,7 +12,7 @@ LL | func(Path::new("hello").to_path_buf().to_string_lossy(), "world")
<PathBuf as From<Cow<'a, Path>>>
<PathBuf as From<OsString>>
<PathBuf as From<String>>
- = note: required because of the requirements on the impl of `Into<PathBuf>` for `Cow<'_, str>`
+ = note: required for `Cow<'_, str>` to implement `Into<PathBuf>`
note: required by a bound in `func`
--> $DIR/issue-90101.rs:3:20
|
diff --git a/src/test/ui/typeck/issue-91210-ptr-method.stderr b/src/test/ui/typeck/issue-91210-ptr-method.stderr
index 503a32373..7a0cfb2cf 100644
--- a/src/test/ui/typeck/issue-91210-ptr-method.stderr
+++ b/src/test/ui/typeck/issue-91210-ptr-method.stderr
@@ -2,9 +2,12 @@ error[E0615]: attempted to take value of method `read` on type `*mut Foo`
--> $DIR/issue-91210-ptr-method.rs:10:7
|
LL | x.read = 4;
- | - ^^^^ method, not a field
- | |
- | help: to access the field, dereference first: `(*x)`
+ | ^^^^ method, not a field
+ |
+help: to access the field, dereference first
+ |
+LL | (*x).read = 4;
+ | ++ +
error: aborting due to previous error
diff --git a/src/test/ui/typeck/issue-91633.rs b/src/test/ui/typeck/issue-91633.rs
new file mode 100644
index 000000000..331a798dd
--- /dev/null
+++ b/src/test/ui/typeck/issue-91633.rs
@@ -0,0 +1,8 @@
+// check-pass
+fn f<T> (it: &[T])
+where
+ [T] : std::ops::Index<usize>,
+{
+ let _ = &it[0];
+}
+fn main(){}
diff --git a/src/test/ui/typeck/issue-96738.stderr b/src/test/ui/typeck/issue-96738.stderr
index 32f538498..0d4d87ef4 100644
--- a/src/test/ui/typeck/issue-96738.stderr
+++ b/src/test/ui/typeck/issue-96738.stderr
@@ -2,27 +2,13 @@ error[E0599]: no method named `nonexistent_method` found for fn item `fn(_) -> O
--> $DIR/issue-96738.rs:2:10
|
LL | Some.nonexistent_method();
- | ---- ^^^^^^^^^^^^^^^^^^ method not found in `fn(_) -> Option<_> {Option::<_>::Some}`
- | |
- | this is the constructor of an enum variant
- |
-help: call the constructor
- |
-LL | (Some)(_).nonexistent_method();
- | + ++++
+ | ^^^^^^^^^^^^^^^^^^ method not found in `fn(_) -> Option<_> {Option::<_>::Some}`
error[E0609]: no field `nonexistent_field` on type `fn(_) -> Option<_> {Option::<_>::Some}`
--> $DIR/issue-96738.rs:3:10
|
LL | Some.nonexistent_field;
- | ---- ^^^^^^^^^^^^^^^^^
- | |
- | this is the constructor of an enum variant
- |
-help: call the constructor
- |
-LL | (Some)(_).nonexistent_field;
- | + ++++
+ | ^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
diff --git a/src/test/ui/typeck/issue-98982.rs b/src/test/ui/typeck/issue-98982.rs
new file mode 100644
index 000000000..2553824bb
--- /dev/null
+++ b/src/test/ui/typeck/issue-98982.rs
@@ -0,0 +1,9 @@
+fn foo() -> i32 {
+ for i in 0..0 {
+ //~^ ERROR: mismatched types [E0308]
+ return i;
+ }
+ //~| help: return a value for the case when the loop has zero elements to iterate on, or consider changing the return type to account for that possibility
+}
+
+fn main() {}
diff --git a/src/test/ui/typeck/issue-98982.stderr b/src/test/ui/typeck/issue-98982.stderr
new file mode 100644
index 000000000..3c9806ac9
--- /dev/null
+++ b/src/test/ui/typeck/issue-98982.stderr
@@ -0,0 +1,24 @@
+error[E0308]: mismatched types
+ --> $DIR/issue-98982.rs:2:5
+ |
+LL | fn foo() -> i32 {
+ | --- expected `i32` because of return type
+LL | / for i in 0..0 {
+LL | |
+LL | | return i;
+LL | | }
+ | |_____^ expected `i32`, found `()`
+ |
+note: the function expects a value to always be returned, but loops might run zero times
+ --> $DIR/issue-98982.rs:2:5
+ |
+LL | for i in 0..0 {
+ | ^^^^^^^^^^^^^ this might have zero elements to iterate on
+LL |
+LL | return i;
+ | -------- if the loop doesn't execute, this value would never get returned
+ = help: return a value for the case when the loop has zero elements to iterate on, or consider changing the return type to account for that possibility
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0308`.
diff --git a/src/test/ui/typeck/point-at-type-param-in-path-expr.rs b/src/test/ui/typeck/point-at-type-param-in-path-expr.rs
new file mode 100644
index 000000000..9a21536f9
--- /dev/null
+++ b/src/test/ui/typeck/point-at-type-param-in-path-expr.rs
@@ -0,0 +1,6 @@
+fn foo<T: std::fmt::Display>() {}
+
+fn main() {
+ let x = foo::<()>;
+ //~^ ERROR `()` doesn't implement `std::fmt::Display`
+}
diff --git a/src/test/ui/typeck/point-at-type-param-in-path-expr.stderr b/src/test/ui/typeck/point-at-type-param-in-path-expr.stderr
new file mode 100644
index 000000000..1feaa0508
--- /dev/null
+++ b/src/test/ui/typeck/point-at-type-param-in-path-expr.stderr
@@ -0,0 +1,17 @@
+error[E0277]: `()` doesn't implement `std::fmt::Display`
+ --> $DIR/point-at-type-param-in-path-expr.rs:4:19
+ |
+LL | let x = foo::<()>;
+ | ^^ `()` cannot be formatted with the default formatter
+ |
+ = help: the trait `std::fmt::Display` is not implemented for `()`
+ = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
+note: required by a bound in `foo`
+ --> $DIR/point-at-type-param-in-path-expr.rs:1:11
+ |
+LL | fn foo<T: std::fmt::Display>() {}
+ | ^^^^^^^^^^^^^^^^^ required by this bound in `foo`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/typeck/remove-extra-argument.stderr b/src/test/ui/typeck/remove-extra-argument.stderr
index 703032a83..b734bcd4e 100644
--- a/src/test/ui/typeck/remove-extra-argument.stderr
+++ b/src/test/ui/typeck/remove-extra-argument.stderr
@@ -12,7 +12,7 @@ LL | fn l(_a: Vec<u8>) {}
help: remove the extra argument
|
LL | l(vec![])
- |
+ | ~~~~~~~~
error: aborting due to previous error
diff --git a/src/test/ui/typeck/slow-lhs-suggestion.rs b/src/test/ui/typeck/slow-lhs-suggestion.rs
new file mode 100644
index 000000000..80dfd6835
--- /dev/null
+++ b/src/test/ui/typeck/slow-lhs-suggestion.rs
@@ -0,0 +1,26 @@
+fn main() {
+ 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ //~^ ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+ //~| ERROR invalid left-hand side of assignment
+}
diff --git a/src/test/ui/typeck/slow-lhs-suggestion.stderr b/src/test/ui/typeck/slow-lhs-suggestion.stderr
new file mode 100644
index 000000000..c5bf795ee
--- /dev/null
+++ b/src/test/ui/typeck/slow-lhs-suggestion.stderr
@@ -0,0 +1,187 @@
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:95
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:91
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:87
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:83
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:79
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:75
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:71
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:67
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:63
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:59
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:55
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:51
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:47
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:43
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:39
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:35
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:31
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:27
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:23
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:19
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:15
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:11
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error[E0070]: invalid left-hand side of assignment
+ --> $DIR/slow-lhs-suggestion.rs:2:7
+ |
+LL | 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1 = 1;
+ | - ^
+ | |
+ | cannot assign to this expression
+
+error: aborting due to 23 previous errors
+
+For more information about this error, try `rustc --explain E0070`.
diff --git a/src/test/ui/typeck/struct-enum-wrong-args.stderr b/src/test/ui/typeck/struct-enum-wrong-args.stderr
index f72082d53..ea94bcbc2 100644
--- a/src/test/ui/typeck/struct-enum-wrong-args.stderr
+++ b/src/test/ui/typeck/struct-enum-wrong-args.stderr
@@ -12,7 +12,7 @@ LL | Some(#[stable(feature = "rust1", since = "1.0.0")] T),
help: remove the extra argument
|
LL | let _ = Some(3);
- | ~~~~~~~
+ | ~~~
error[E0061]: this enum variant takes 1 argument but 3 arguments were supplied
--> $DIR/struct-enum-wrong-args.rs:7:13
@@ -30,7 +30,7 @@ LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
help: remove the extra arguments
|
LL | let _ = Ok(3);
- | ~~~~~
+ | ~~~
error[E0061]: this enum variant takes 1 argument but 0 arguments were supplied
--> $DIR/struct-enum-wrong-args.rs:8:13
@@ -46,7 +46,7 @@ LL | Ok(#[stable(feature = "rust1", since = "1.0.0")] T),
help: provide the argument
|
LL | let _ = Ok(/* value */);
- | ~~~~~~~~~~~~~~~
+ | ~~~~~~~~~~~~~
error[E0061]: this struct takes 1 argument but 0 arguments were supplied
--> $DIR/struct-enum-wrong-args.rs:9:13
@@ -62,7 +62,7 @@ LL | struct Wrapper(i32);
help: provide the argument
|
LL | let _ = Wrapper(/* i32 */);
- | ~~~~~~~~~~~~~~~~~~
+ | ~~~~~~~~~~~
error[E0061]: this struct takes 1 argument but 2 arguments were supplied
--> $DIR/struct-enum-wrong-args.rs:10:13
@@ -78,7 +78,7 @@ LL | struct Wrapper(i32);
help: remove the extra argument
|
LL | let _ = Wrapper(5);
- | ~~~~~~~~~~
+ | ~~~
error[E0061]: this struct takes 2 arguments but 0 arguments were supplied
--> $DIR/struct-enum-wrong-args.rs:11:13
@@ -94,7 +94,7 @@ LL | struct DoubleWrapper(i32, i32);
help: provide the arguments
|
LL | let _ = DoubleWrapper(/* i32 */, /* i32 */);
- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ | ~~~~~~~~~~~~~~~~~~~~~~
error[E0061]: this struct takes 2 arguments but 1 argument was supplied
--> $DIR/struct-enum-wrong-args.rs:12:13
@@ -110,7 +110,7 @@ LL | struct DoubleWrapper(i32, i32);
help: provide the argument
|
LL | let _ = DoubleWrapper(5, /* i32 */);
- | ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ | ~~~~~~~~~~~~~~
error[E0061]: this struct takes 2 arguments but 3 arguments were supplied
--> $DIR/struct-enum-wrong-args.rs:13:13
@@ -126,7 +126,7 @@ LL | struct DoubleWrapper(i32, i32);
help: remove the extra argument
|
LL | let _ = DoubleWrapper(5, 2);
- | ~~~~~~~~~~~~~~~~~~~
+ | ~~~~~~
error: aborting due to 8 previous errors
diff --git a/src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.stderr b/src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.stderr
index e8e069708..503015f3b 100644
--- a/src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.stderr
+++ b/src/test/ui/typeck/suggest-adding-missing-zero-to-floating-point-number.stderr
@@ -4,7 +4,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
LL | 2.e1;
| ^^
|
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
|
LL | 2.0e1;
| +
@@ -15,7 +15,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
LL | 2.E1;
| ^^
|
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
|
LL | 2.0E1;
| +
@@ -26,7 +26,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
LL | 2.f32;
| ^^^
|
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
|
LL | 2.0f32;
| +
@@ -37,7 +37,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
LL | 2.f64;
| ^^^
|
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
|
LL | 2.0f64;
| +
@@ -48,7 +48,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
LL | 2.e+12;
| ^
|
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
|
LL | 2.0e+12;
| +
@@ -59,7 +59,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
LL | 2.e-12;
| ^
|
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
|
LL | 2.0e-12;
| +
@@ -70,7 +70,7 @@ error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields
LL | 2.e1f32;
| ^^^^^
|
-help: If the number is meant to be a floating point number, consider adding a `0` after the period
+help: if intended to be a floating point literal, consider adding a `0` after the period
|
LL | 2.0e1f32;
| +
diff --git a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr
index 6bb5e1f54..b9fca1a1b 100644
--- a/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr
+++ b/src/test/ui/typeck/typeck-default-trait-impl-negation-sync.stderr
@@ -12,10 +12,10 @@ LL | fn is_sync<T: Sync>() {}
| ^^^^ required by this bound in `is_sync`
error[E0277]: `UnsafeCell<u8>` cannot be shared between threads safely
- --> $DIR/typeck-default-trait-impl-negation-sync.rs:36:5
+ --> $DIR/typeck-default-trait-impl-negation-sync.rs:36:15
|
LL | is_sync::<MyTypeWUnsafe>();
- | ^^^^^^^^^^^^^^^^^^^^^^^^ `UnsafeCell<u8>` cannot be shared between threads safely
+ | ^^^^^^^^^^^^^ `UnsafeCell<u8>` cannot be shared between threads safely
|
= help: within `MyTypeWUnsafe`, the trait `Sync` is not implemented for `UnsafeCell<u8>`
note: required because it appears within the type `MyTypeWUnsafe`
@@ -30,10 +30,10 @@ LL | fn is_sync<T: Sync>() {}
| ^^^^ required by this bound in `is_sync`
error[E0277]: `Managed` cannot be shared between threads safely
- --> $DIR/typeck-default-trait-impl-negation-sync.rs:39:5
+ --> $DIR/typeck-default-trait-impl-negation-sync.rs:39:15
|
LL | is_sync::<MyTypeManaged>();
- | ^^^^^^^^^^^^^^^^^^^^^^^^ `Managed` cannot be shared between threads safely
+ | ^^^^^^^^^^^^^ `Managed` cannot be shared between threads safely
|
= help: within `MyTypeManaged`, the trait `Sync` is not implemented for `Managed`
note: required because it appears within the type `MyTypeManaged`
diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.stderr b/src/test/ui/typeck/typeck_type_placeholder_item.stderr
index 3ea317dfb..c57f71b80 100644
--- a/src/test/ui/typeck/typeck_type_placeholder_item.stderr
+++ b/src/test/ui/typeck/typeck_type_placeholder_item.stderr
@@ -189,10 +189,10 @@ LL ~ b: (T, T),
|
error: missing type for `static` item
- --> $DIR/typeck_type_placeholder_item.rs:73:12
+ --> $DIR/typeck_type_placeholder_item.rs:73:13
|
LL | static A = 42;
- | ^ help: provide a type for the static variable: `A: i32`
+ | ^ help: provide a type for the static variable: `: i32`
error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
--> $DIR/typeck_type_placeholder_item.rs:75:15
diff --git a/src/test/ui/typeof/issue-100183.rs b/src/test/ui/typeof/issue-100183.rs
new file mode 100644
index 000000000..13e9493ea
--- /dev/null
+++ b/src/test/ui/typeof/issue-100183.rs
@@ -0,0 +1,6 @@
+struct Struct {
+ y: (typeof("hey"),),
+ //~^ ERROR `typeof` is a reserved keyword but unimplemented
+}
+
+fn main() {}
diff --git a/src/test/ui/typeof/issue-100183.stderr b/src/test/ui/typeof/issue-100183.stderr
new file mode 100644
index 000000000..01d3079b2
--- /dev/null
+++ b/src/test/ui/typeof/issue-100183.stderr
@@ -0,0 +1,14 @@
+error[E0516]: `typeof` is a reserved keyword but unimplemented
+ --> $DIR/issue-100183.rs:2:9
+ |
+LL | y: (typeof("hey"),),
+ | ^^^^^^^^^^^^^ reserved keyword
+ |
+help: consider replacing `typeof(...)` with an actual type
+ |
+LL | y: (&'static str,),
+ | ~~~~~~~~~~~~
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0516`.