From e973240d18f131d4fe48c4920f92a044c7503299 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Sat, 3 Dec 2022 09:32:29 +0000 Subject: Do not call fn_sig on non-functions. --- src/test/ui/suggestions/assoc-const-as-fn.rs | 18 ++++++++++++++++++ src/test/ui/suggestions/assoc-const-as-fn.stderr | 14 ++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/test/ui/suggestions/assoc-const-as-fn.rs create mode 100644 src/test/ui/suggestions/assoc-const-as-fn.stderr (limited to 'src/test/ui') diff --git a/src/test/ui/suggestions/assoc-const-as-fn.rs b/src/test/ui/suggestions/assoc-const-as-fn.rs new file mode 100644 index 00000000000..4b4595dd5e6 --- /dev/null +++ b/src/test/ui/suggestions/assoc-const-as-fn.rs @@ -0,0 +1,18 @@ +unsafe fn pointer(v: usize, w: u32) {} + +pub trait UniformScalar {} +impl UniformScalar for u32 {} + +pub trait GlUniformScalar: UniformScalar { + const FACTORY: unsafe fn(usize, Self) -> (); +} +impl GlUniformScalar for u32 { + const FACTORY: unsafe fn(usize, Self) -> () = pointer; +} + +pub fn foo(value: T) { + ::FACTORY(1, value); + //~^ ERROR the trait bound `T: GlUniformScalar` is not satisfied +} + +fn main() {} diff --git a/src/test/ui/suggestions/assoc-const-as-fn.stderr b/src/test/ui/suggestions/assoc-const-as-fn.stderr new file mode 100644 index 00000000000..fa740687858 --- /dev/null +++ b/src/test/ui/suggestions/assoc-const-as-fn.stderr @@ -0,0 +1,14 @@ +error[E0277]: the trait bound `T: GlUniformScalar` is not satisfied + --> $DIR/assoc-const-as-fn.rs:14:5 + | +LL | ::FACTORY(1, value); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `GlUniformScalar` is not implemented for `T` + | +help: consider further restricting this bound + | +LL | pub fn foo(value: T) { + | +++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. -- cgit 1.4.1-3-g733a5