warning: unused import: wgpu::util::DeviceExt
--> src\main.rs:6:5
|
6 | use wgpu::util::DeviceExt;
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
error[E0308]: mismatched types
--> src\main.rs:18:40
|
18 | let instance = wgpu::Instance::new(wgpu::Backends::PRIMARY);
| ------------------- ^^^^^^^^^^^^^^^^^^^^^^^ expected InstanceDescriptor, found Backends
| |
| arguments to this function are incorrect
|
note: associated function defined here
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-0.16.3\src\lib.rs:1331:12
|
1331 | pub fn new(instance_desc: InstanceDescriptor) -> Self {
| ^^^
error[E0599]: no method named get_supported_formats found for struct Surface in the current scope
--> src\main.rs:42:34
|
42 | let surface_format = surface.get_supported_formats(&adapter)[0];
| ^^^^^^^^^^^^^^^^^^^^^ method not found in Surface
Some errors have detailed explanations: E0308, E0599.
For more information about an error, try rustc --explain E0308.
warning: my_project (bin "my_project") generated 1 warning
296 | pub fn create_surface<'window>(
| -------------- required by a bound in this associated function
297 | &self,
298 | target: impl Into<SurfaceTarget<'window>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in Instance::create_surface
error[E0061]: this method takes 1 argument but 2 arguments were supplied
--> src\main.rs:30:35
|
30 | let (device, queue) = adapter.request_device(
| ^^^^^^^^^^^^^^
31 | &wgpu::DeviceDescriptor::default(),
32 | None,
| ---- unexpected argument #2 of type Option<_>
|
note: method defined here
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\api\adapter.rs:57:12
|
57 | pub fn request_device(
| ^^^^^^^^^^^^^^
help: remove the extra argument
|
31 - &wgpu::DeviceDescriptor::default(),
32 - None,
31 + &wgpu::DeviceDescriptor::default(),
|
error[E0063]: missing field desired_maximum_frame_latency in initializer of wgpu::wgpu_types::SurfaceConfiguration<Vec<TextureFormat>>
--> src\main.rs:40:22
|
40 | let mut config = wgpu::SurfaceConfiguration {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ missing desired_maximum_frame_latency
error[E0063]: missing field depth_slice in initializer of wgpu::RenderPassColorAttachment<'_>
--> src\main.rs:87:51
|
87 | color_attachments: &[Some(wgpu::RenderPassColorAttachment {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing depth_slice
error[E0063]: missing fields occlusion_query_set and timestamp_writes in initializer of wgpu::RenderPassDescriptor<'_> --> src\main.rs:85:67
|
85 | let _render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ missing occlusion_query_set and timestamp_writes
Some errors have detailed explanations: E0061, E0063, E0277, E0308, E0560.
For more information about an error, try rustc --explain E0061.
error: could not compile my_project (bin "my_project") due to 9 previous errors
Assistant
這些錯誤可能是因為 wgpu 26.0.1 的 API 已經改動很多,建構函數跟方法的參數與欄位變多或改了型態。wgpu 在 26 版後介面變得更嚴格,必須提供更多初始值,也移除或拆分了許多之前使用的 API 參數。
下面我會示範更正確的、符合 wgpu 26.0.1 版 API 的最簡單紅色背景範例,並且詳細說明改動重點。
error[E0560]: struct wgpu::InstanceDescriptor has no field named dx12_shader_compiler
--> src\main.rs:26:9
|
26 | dx12_shader_compiler: Default::default(),
| ^^^^^^^^^^^^^^^^^^^^ wgpu::InstanceDescriptor does not have this field
|
= note: available fields are: flags, memory_budget_thresholds, backend_options
error[E0308]: mismatched types
--> src\main.rs:24:40
|
24 | let instance = wgpu::Instance::new(InstanceDescriptor {
| _______________-------------------_^
| | |
| | arguments to this function are incorrect
25 | | backends: wgpu::Backends::PRIMARY,
26 | | dx12_shader_compiler: Default::default(),
27 | | });
| |^ expected &InstanceDescriptor, found InstanceDescriptor
|
note: associated function defined here
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\api\instance.rs:113:12
|
113 | pub fn new(_instance_desc: &InstanceDescriptor) -> Self {
| ^^^
help: consider borrowing here
|
24 | let instance = wgpu::Instance::new(&InstanceDescriptor {
| +
error[E0277]: the trait bound &winit::window::Window: Into<SurfaceTarget<'_>> is not satisfied
--> src\main.rs:30:52
|
30 | let surface = unsafe { instance.create_surface(&window) }.unwrap();
| -------------- ^^^^^^^ the trait HasWindowHandle is not implemented for winit::window::Window
| |
| required by a bound introduced by this call
|
note: there are multiple different versions of crate raw_window_handle in the dependency graph
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.6.2\src\borrowed.rs:161:1
|
161 | pub trait HasWindowHandle {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
|
::: src\main.rs:1:5
|
1 | use wgpu::{
| ---- one version of crate raw_window_handle used here, as a dependency of crate
...
6 | use winit::{
| ----- one version of crate used here, as a dependency of crate
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\winit-0.28.7\src\window.rs:44:1
|
44 | pub struct Window {
| ----------------- this type doesn't implement the required trait
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.5.2\src\borrowed.rs:227:1
|
227 | pub trait HasDisplayHandle {
| -------------------------- this is the found trait
= help: you can use to explore your dependency tree
= note: required for to implement
= note: required for to implement
= note: required for to implement
= note: required for to implement
note: required by a bound in
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\api\instance.rs:298:22
|
296 | pub fn create_surface<'window>(
| -------------- required by a bound in this associated function
297 | &self,
298 | target: impl Into<SurfaceTarget<'window>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\api\instance.rs:298:22
|
296 | pub fn create_surface<'window>(
| -------------- required by a bound in this associated function
297 | &self,
298 | target: impl Into<SurfaceTarget<'window>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in Instance::create_surface
error[E0277]: the trait bound &winit::window::Window: Into<SurfaceTarget<'_>> is not satisfied
--> src\main.rs:25:52
|
25 | let surface = unsafe { instance.create_surface(&window) }.unwrap();
| -------------- ^^^^^^^ the trait HasDisplayHandle is not implemented for winit::window::Window
| |
| required by a bound introduced by this call
|
note: there are multiple different versions of crate raw_window_handle in the dependency graph
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.6.2\src\borrowed.rs:33:1
|
33 | pub trait HasDisplayHandle {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
|
::: src\main.rs:1:5
|
1 | use wgpu::{
| ---- one version of crate raw_window_handle used here, as a dependency of crate wgpu_hal
...
5 | use winit::{
| ----- one version of crate raw_window_handle used here, as a dependency of crate winit
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\winit-0.28.7\src\window.rs:44:1
|
44 | pub struct Window {
| ----------------- this type doesn't implement the required trait
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.5.2\src\borrowed.rs:227:1
|
227 | pub trait HasDisplayHandle {
| -------------------------- this is the found trait
= help: you can use cargo tree to explore your dependency tree
= note: required for &winit::window::Window to implement HasDisplayHandle
= note: required for &winit::window::Window to implement wgpu::WindowHandle
= note: required for SurfaceTarget<'_> to implement From<&winit::window::Window>
= note: required for &winit::window::Window to implement Into<SurfaceTarget<'_>>
note: required by a bound in wgpu::Instance::create_surface
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\api\instance.rs:298:22
|
296 | pub fn create_surface<'window>(
| -------------- required by a bound in this associated function
297 | &self,
298 | target: impl Into<SurfaceTarget<'window>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in
serde = { version = "1.0", features = ["derive"] }
Rust 最主要的序列化 / 反序列化框架,支援 JSON、YAML、Ron's 等格式。
serde_json = "1.0"
補充 serde 用於 JSON 格式的讀寫。
User
error: There are multiple raw-window-handle packages in your project, and the specification raw-window-handle is ambiguous.
Please re-run this command with one of the following specifications:
raw-window-handle@0.5.2
raw-window-handle@0.6.2
已經使用cargo clean
error: There are multiple `raw-window-handle` packages in your project, and the specification `raw-window-handle` is ambiguous.
Please re-run this command with one of the following specifications:
raw-window-handle@0.5.2
raw-window-handle@0.6.2
如果你貼 cargo tree -p raw-window-handle 的輸出,我可以幫你更精準分析問題。
User
error[E0063]: missing field backends in initializer of wgpu::InstanceDescriptor
--> src\main.rs:19:41
|
19 | let instance = wgpu::Instance::new(&InstanceDescriptor {
| ^^^^^^^^^^^^^^^^^^ missing backends
error[E0277]: the trait bound &winit::window::Window: Into<SurfaceTarget<'_>> is not satisfied
--> src\main.rs:25:52
|
25 | let surface = unsafe { instance.create_surface(&window) }.unwrap();
| -------------- ^^^^^^^ the trait HasWindowHandle is not implemented for winit::window::Window
| |
| required by a bound introduced by this call
|
note: there are multiple different versions of crate raw_window_handle in the dependency graph
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.6.2\src\borrowed.rs:161:1
|
161 | pub trait HasWindowHandle {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
|
::: src\main.rs:1:5
|
1 | use wgpu::{
| ---- one version of crate raw_window_handle used here, as a dependency of crate wgpu_hal
...
5 | use winit::{
| ----- one version of crate raw_window_handle used here, as a dependency of crate winit
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\winit-0.28.7\src\window.rs:44:1
|
44 | pub struct Window {
| ----------------- this type doesn't implement the required trait
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.5.2\src\borrowed.rs:227:1
|
227 | pub trait HasDisplayHandle {
| -------------------------- this is the found trait
= help: you can use cargo tree to explore your dependency tree
= note: required for &winit::window::Window to implement HasWindowHandle
= note: required for &winit::window::Window to implement wgpu::WindowHandle
= note: required for SurfaceTarget<'_> to implement From<&winit::window::Window>
= note: required for &winit::window::Window to implement Into<SurfaceTarget<'_>>
note: required by a bound in wgpu::Instance::create_surface
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\api\instance.rs:298:22
|
296 | pub fn create_surface<'window>(
| -------------- required by a bound in this associated function
297 | &self,
298 | target: impl Into<SurfaceTarget<'window>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in Instance::create_surface
error[E0277]: the trait bound is not satisfied
--> src\main.rs:25:52
|
25 | let surface = unsafe { instance.create_surface(&window) }.unwrap();
| -------------- ^^^^^^^ the trait is not implemented for
| |
| required by a bound introduced by this call
|
note: there are multiple different versions of crate in the dependency graph
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.6.2\src\borrowed.rs:33:1
|
33 | pub trait HasDisplayHandle {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
|
::: src\main.rs:1:5
|
1 | use wgpu::{
| ---- one version of crate used here, as a dependency of crate
...
5 | use winit::{
| ----- one version of crate used here, as a dependency of crate
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\winit-0.28.7\src\window.rs:44:1
|
44 | pub struct Window {
| ----------------- this type doesn't implement the required trait
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.5.2\src\borrowed.rs:227:1
|
227 | pub trait HasDisplayHandle {
| -------------------------- this is the found trait
= help: you can use to explore your dependency tree
= note: required for to implement
= note: required for to implement
= note: required for to implement
= note: required for to implement
note: required by a bound in
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\api\instance.rs:298:22
|
296 | pub fn create_surface<'window>(
| -------------- required by a bound in this associated function
297 | &self,
298 | target: impl Into<SurfaceTarget<'window>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in
Assistant
你遇到的錯誤與 wgpu 26.0.1 版本的 API 變動,以及多個 raw-window-handle 不同版本共存的問題有關,我整理重點與解決方案如下:
1. InstanceDescriptor 需填入 backends 欄位
錯誤:
code
error[E0063]: missing field `backends` in initializer of `wgpu::InstanceDescriptor`
Blocking waiting for file lock on package cache
Updating crates.io index
Locking 0 packages to latest Rust 1.89.0-nightly compatible versions
note: pass --verbose to see 81 unchanged dependencies behind latest
Assistant
這是 cargo update 或 cargo build 過程中常見的正常訊息,說明:
Blocking waiting for file lock on package cache
Cargo 正在等待本機的套件快取檔案鎖定(避免多程序同時改寫快取導致錯亂)。
Updating crates.io index
Cargo 正在更新你的「crates.io 索引」,確保抓取最新可用版本。
Compiling my_project v0.1.0 (C:\Users\fer52\mynewcargo\my_project)
error[E0560]: struct wgpu::InstanceDescriptor has no field named dx12_shader_compiler
--> src\main.rs:23:9
|
23 | dx12_shader_compiler: Default::default(),
| ^^^^^^^^^^^^^^^^^^^^ wgpu::InstanceDescriptor does not have this field
|
= note: all struct fields are already assigned
error[E0277]: the trait bound &winit::window::Window: Into<SurfaceTarget<'_>> is not satisfied
--> src\main.rs:29:52
|
29 | let surface = unsafe { instance.create_surface(&window) }.unwrap();
| -------------- ^^^^^^^ the trait HasWindowHandle is not implemented for winit::window::Window
| |
| required by a bound introduced by this call
|
note: there are multiple different versions of crate raw_window_handle in the dependency graph
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.6.2\src\borrowed.rs:161:1
|
161 | pub trait HasWindowHandle {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
|
::: src\main.rs:1:5
|
1 | use wgpu::{
| ---- one version of crate raw_window_handle used here, as a dependency of crate wgpu_hal
...
6 | use winit::{
| ----- one version of crate raw_window_handle used here, as a dependency of crate winit
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\winit-0.28.7\src\window.rs:44:1
|
44 | pub struct Window {
| ----------------- this type doesn't implement the required trait
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.5.2\src\borrowed.rs:227:1
|
227 | pub trait HasDisplayHandle {
| -------------------------- this is the found trait
= help: you can use cargo tree to explore your dependency tree
= note: required for &winit::window::Window to implement HasWindowHandle
= note: required for &winit::window::Window to implement wgpu::WindowHandle
= note: required for SurfaceTarget<'_> to implement From<&winit::window::Window>
= note: required for &winit::window::Window to implement Into<SurfaceTarget<'_>>
note: required by a bound in wgpu::Instance::create_surface
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\api\instance.rs:298:22
|
296 | pub fn create_surface<'window>(
| -------------- required by a bound in this associated function
297 | &self,
298 | target: impl Into<SurfaceTarget<'window>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in
error: expected item, found keyword let
--> src\main.rs:1:1
1 | let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor {
| ^^^
| |
| let cannot be used for global variables
| help: consider using static or const instead of let
|
= note: for a full list of items that can appear in modules, see https://doc.rust-lang.org/reference/items.html
error: could not compile my_project (bin "my_project") due to 1 previous error
PS C:\Users\fer52\mynewcargo\my_project> cargo run
Compiling my_project v0.1.0 (C:\Users\fer52\mynewcargo\my_project)
error[E0560]: struct wgpu::InstanceDescriptor has no field named dx12_shader_compiler
--> src\main.rs:27:9
|
27 | dx12_shader_compiler: Dx12Compiler::Fxc,
| ^^^^^^^^^^^^^^^^^^^^ wgpu::InstanceDescriptor does not have this field
|
= note: all struct fields are already assigned
error[E0277]: the trait bound &winit::window::Window: Into<SurfaceTarget<'_>> is not satisfied
--> src\main.rs:34:52
|
34 | let surface = unsafe { instance.create_surface(&window) }.unwrap();
| -------------- ^^^^^^^ the trait HasWindowHandle is not implemented for winit::window::Window
| |
| required by a bound introduced by this call
|
note: there are multiple different versions of crate raw_window_handle in the dependency graph
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.6.2\src\borrowed.rs:161:1
|
161 | pub trait HasWindowHandle {
| ^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
|
::: src\main.rs:1:5
|
1 | use wgpu::{
| ---- one version of crate raw_window_handle used here, as a dependency of crate wgpu_hal
...
7 | use winit::{
| ----- one version of crate raw_window_handle used here, as a dependency of crate winit
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\winit-0.28.7\src\window.rs:44:1
|
44 | pub struct Window {
| ----------------- this type doesn't implement the required trait
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.5.2\src\borrowed.rs:227:1
|
227 | pub trait HasDisplayHandle {
| -------------------------- this is the found trait
= help: you can use cargo tree to explore your dependency tree
= note: required for &winit::window::Window to implement HasWindowHandle
= note: required for &winit::window::Window to implement
= note: required for to implement
= note: required for to implement
note: required by a bound in
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\api\instance.rs:298:22
|
296 | pub fn create_surface<'window>(
| -------------- required by a bound in this associated function
297 | &self,
298 | target: impl Into<SurfaceTarget<'window>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in
Assistant
你這兩個主要問題如下:
1. dx12_shader_compiler 欄位不存在
wgpu::InstanceDescriptor 版本中**沒有 dx12_shader_compiler**欄位,代表 API 已經改版,你貼的程式碼用到的欄位不正確。
--> src\main.rs:6:5
|
6 | use wgpu::util::DeviceExt;
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
error[E0308]: mismatched types
--> src\main.rs:18:40
|
18 | let instance = wgpu::Instance::new(wgpu::Backends::PRIMARY);
| ------------------- ^^^^^^^^^^^^^^^^^^^^^^^ expected InstanceDescriptor, found Backends
| |
| arguments to this function are incorrect
|
note: associated function defined here
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-0.16.3\src\lib.rs:1331:12
|
1331 | pub fn new(instance_desc: InstanceDescriptor) -> Self {
| ^^^
error[E0599]: no method named get_supported_formats found for struct Surface in the current scope
--> src\main.rs:34:34
|
34 | let surface_format = surface.get_supported_formats(&adapter)[0];
| ^^^^^^^^^^^^^^^^^^^^^ method not found in Surface
error[E0063]: missing field view_formats in initializer of wgpu_types::SurfaceConfiguration<Vec<TextureFormat>>
--> src\main.rs:36:22
|
36 | let mut config = wgpu::SurfaceConfiguration {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ missing view_formats
Some errors have detailed explanations: E0063, E0308, E0599.
For more information about an error, try rustc --explain E0063.
warning: my_project (bin "my_project") generated 1 warning
error: could not compile my_project (bin "my_project") due to 3 previous errors; 1 warning emitted
error[E0599]: no method named get_supported_formats found for struct Surface in the current scope
--> src\main.rs:32:34
|
32 | let surface_format = surface.get_supported_formats(&adapter)[0];
| ^^^^^^^^^^^^^^^^^^^^^ method not found in Surface
For more information about this error, try rustc --explain E0599.
error: could not compile my_project (bin "my_project") due to 1 previous error
Compiling my_project v0.1.0 (C:\Users\fer52\mynewcargo\my_project)
error[E0308]: mismatched types
--> src\main.rs:17:40
|
17 | let instance = wgpu::Instance::new(wgpu::Backends::PRIMARY);
| ------------------- ^^^^^^^^^^^^^^^^^^^^^^^ expected InstanceDescriptor, found Backends
| |
| arguments to this function are incorrect
|
note: associated function defined here
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-0.16.3\src\lib.rs:1331:12
|
1331 | pub fn new(instance_desc: InstanceDescriptor) -> Self {
| ^^^
error[E0599]: no method named get_surface_preferred_format found for struct Adapter in the current scope
--> src\main.rs:40:10
|
39 | let surface_format = adapter
| ______________________-
40 | | .get_surface_preferred_format(&surface)
| | -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ method not found in Adapter
| |_____|
|
Some errors have detailed explanations: E0308, E0599.
For more information about an error, try rustc --explain E0308.
error: could not compile my_project (bin "my_project") due to 2 previous errors
error[E0308]: mismatched types
--> src\main.rs:15:40
|
15 | let instance = wgpu::Instance::new(wgpu::Backends::PRIMARY);
| ------------------- ^^^^^^^^^^^^^^^^^^^^^^^ expected InstanceDescriptor, found Backends
| |
| arguments to this function are incorrect
|
note: associated function defined here
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-0.16.3\src\lib.rs:1331:12
|
1331 | pub fn new(instance_desc: InstanceDescriptor) -> Self {
| ^^^
error[E0599]: no method named get_supported_formats found for struct Surface in the current scope
--> src\main.rs:29:34
|
29 | let surface_format = surface.get_supported_formats(&adapter)[0];
| ^^^^^^^^^^^^^^^^^^^^^ method not found in Surface
Some errors have detailed explanations: E0308, E0599.
For more information about an error, try rustc --explain E0308.
error: could not compile my_project (bin "my_project") due to 2 previous errors
Compiling my_project v0.1.0 (C:\Users\fer52\mynewcargo\my_project)
warning: unused variable: event_loop_window_target
--> src\main.rs:62:33
|
62 | event_loop.run(move |event, event_loop_window_target, control_flow| {
| ^^^^^^^^^^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: _event_loop_window_target
|
= note: #[warn(unused_variables)] on by default
error[E0382]: use of moved value: event_loop
--> src\main.rs:62:20
|
58 | let event_loop = EventLoop::new();
| ---------- move occurs because event_loop has type EventLoop<()>, which does not implement the Copy trait
...
62 | event_loop.run(move |event, event_loop_window_target, control_flow| {
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ value used here after move
| ______________|
| |
63 | | *control_flow = ControlFlow::Wait;
64 | |
65 | | match event {
... |
92 | | app.open_tip_window(&event_loop);
| | ---------- use occurs due to use in closure... |
122 | | });
| |____- event_loop moved due to this method call
|
note: EventLoop::<T>::run takes ownership of the receiver self, which moves event_loop
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\winit-0.28.7\src\event_loop.rs:301:19
|
301 | pub fn run(self, event_handler: F) -> !
| ^^^^
For more information about this error, try rustc --explain E0382.
warning: my_project (bin "my_project") generated 1 warning
error: could not compile my_project (bin "my_project") due to 1 previous error; 1 warning emitted
Compiling my_project v0.1.0 (C:\Users\fer52\mynewcargo\my_project)
error[E0433]: failed to resolve: use of unresolved module or unlinked crate futures
--> src\main.rs:186:9
|
186 | use futures::executor::block_on;
| ^^^^^^^ use of unresolved module or unlinked crate futures
|
= help: if you wanted to use a crate named futures, use cargo add futures to add it to your
Cargo.toml
error[E0599]: no method named create_surface found for struct Device in the current scope
--> src\main.rs:145:52
|
145 | let tip_surface = unsafe { self.device.create_surface(&tip_window) }.unwrap();
| ^^^^^^^^^^^^^^ method not found in Device
error[E0614]: type PhysicalSize<u32> cannot be dereferenced
--> src\main.rs:240:58
|
240 | ... app.main.resize(&app.device, **new_inner_size);
| ^^^^^^^^^^^^^^^^ can't be dereferenced
error[E0614]: type PhysicalSize<u32> cannot be dereferenced
--> src\main.rs:244:57
|
244 | ... tip.resize(&app.device, **new_inner_size);
| ^^^^^^^^^^^^^^^^ can't be dereferenced
Some errors have detailed explanations: E0433, E0599, E0614.
For more information about an error, try rustc --explain E0433.
warning: my_project (bin "my_project") generated 1 warning
error: could not compile my_project (bin "my_project") due to 4 previous errors; 1 warning emitted
[package]
name = "my_project"
version = "0.1.0"
edition = "2021"
[dependencies]
winit = "0.28"
wgpu = "0.16.3"
tokio = { version = "1", features = ["full"] }
main.rs
rust
User
warning: unused manifest key: package.futures
Compiling my_project v0.1.0 (C:\Users\fer52\mynewcargo\my_project)
error[E0433]: failed to resolve: use of unresolved module or unlinked crate futures
--> src\main.rs:186:9
|
186 | use futures::executor::block_on;
| ^^^^^^^ use of unresolved module or unlinked crate futures
|
= help: if you wanted to use a crate named futures, use cargo add futures to add it to your
Cargo.toml
warning: unused imports: ElementState, KeyboardInput, and VirtualKeyCode
--> src\main.rs:3:13
|
3 | event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent},
| ^^^^^^^^^^^^ ^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
|
= note: #[warn(unused_imports)] on by default
For more information about this error, try rustc --explain E0433.
warning: my_project (bin "my_project") generated 1 warning
error: could not compile my_project (bin "my_project") due to 1 previous error; 1 warning emitted
Assistant
你目前出現的錯誤是:
code
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `futures`
help: if you wanted to use a crate named `futures`, use `cargo add futures` to add it to your Cargo.toml
error[E0277]: the trait bound &winit::window::Window: Into<SurfaceTarget<'_>> is not satisfied
--> src\main.rs:30:52
|
30 | let surface = unsafe { instance.create_surface(&window) }.unwrap();
| -------------- ^^^^^^^ the trait HasDisplayHandle is not implemented for winit::window::Window
| |
| required by a bound introduced by this call
|
note: there are multiple different versions of crate raw_window_handle in the dependency graph
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.6.2\src\borrowed.rs:33:1
|
33 | pub trait HasDisplayHandle {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
|
::: src\main.rs:1:5
|
1 | use wgpu::{
| ---- one version of crate raw_window_handle used here, as a dependency of crate wgpu_hal
...
6 | use winit::{
| ----- one version of crate raw_window_handle used here, as a dependency of crate winit
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\winit-0.28.7\src\window.rs:44:1
|
44 | pub struct Window {
| ----------------- this type doesn't implement the required trait
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.5.2\src\borrowed.rs:227:1
|
227 | pub trait HasDisplayHandle {
| -------------------------- this is the found trait
= help: you can use cargo tree to explore your dependency tree
= note: required for &winit::window::Window to implement HasDisplayHandle
= note: required for &winit::window::Window to implement wgpu::WindowHandle
= note: required for SurfaceTarget<'_> to implement From<&winit::window::Window>
= note: required for &winit::window::Window to implement Into<SurfaceTarget<'_>>
note: required by a bound in wgpu::Instance::create_surface
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\api\instance.rs:298:22
|
296 | pub fn create_surface<'window>(
| -------------- required by a bound in this associated function
297 | &self,
298 | target: impl Into<SurfaceTarget<'window>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in Instance::create_surface
error[E0308]: mismatched types
--> src\main.rs:72:40
|
72 | desired_maximum_frame_latency: Some(2),
| ^^^^^^^ expected u32, found Option<{integer}>
|
= note: expected type u32
found enum Option<{integer}>
error[E0308]: mismatched types
--> src\main.rs:128:42
|
128 | ... depth_slice: 0,
| ^ expected Option<u32>, found integer
|
= note: expected enum Option<u32>
found type {integer}
help: try wrapping the expression in Some
|
128 | depth_slice: Some(0),
| +++++ +
Some errors have detailed explanations: E0277, E0308, E0560.
For more information about an error, try rustc --explain E0277.
warning: my_project (bin "my_project") generated 2 warnings
error: could not compile my_project (bin "my_project") due to 7 previous errors; 2 warnings emitted
error[E0599]: no method named describe found for reference &TextureFormat in the current scope
--> src\main.rs:38:21
|
38 | .find(|f| f.describe().srgb)
| ^^^^^^^^ method not found in &TextureFormat
Some errors have detailed explanations: E0063, E0277, E0308, E0599.
For more information about an error, try rustc --explain E0063.
error: could not compile my_project (bin "my_project") due to 5 previous errors
error[E0599]: no method named describe found for reference &TextureFormat in the current scope
--> src\main.rs:38:21
|
38 | .find(|f| f.describe().srgb)
| ^^^^^^^^ method not found in &TextureFormat
Some errors have detailed explanations: E0063, E0277, E0308, E0599.
For more information about an error, try rustc --explain E0063.
error: could not compile my_project (bin "my_project") due to 5 previous errors
若仍有問題,歡迎貼你的 Cargo.toml 和 cargo tree -d raw-window-handle 輸出,我能協助你更精確定位問題。
Instance::create_surface
error[E0277]: the trait bound &winit::window::Window: Into<SurfaceTarget<'_>> is not satisfied
--> src\main.rs:29:52
|
29 | let surface = unsafe { instance.create_surface(&window) }.unwrap();
| -------------- ^^^^^^^ the trait HasDisplayHandle is not implemented for winit::window::Window
| |
| required by a bound introduced by this call
|
note: there are multiple different versions of crate raw_window_handle in the dependency graph
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.6.2\src\borrowed.rs:33:1
|
33 | pub trait HasDisplayHandle {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
|
::: src\main.rs:1:5
|
1 | use wgpu::{
| ---- one version of crate raw_window_handle used here, as a dependency of crate wgpu_hal
...
6 | use winit::{
| ----- one version of crate raw_window_handle used here, as a dependency of crate winit
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\winit-0.28.7\src\window.rs:44:1
|
44 | pub struct Window {
| ----------------- this type doesn't implement the required trait
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.5.2\src\borrowed.rs:227:1
|
227 | pub trait HasDisplayHandle {
| -------------------------- this is the found trait
= help: you can use cargo tree to explore your dependency tree
= note: required for &winit::window::Window to implement HasDisplayHandle
= note: required for &winit::window::Window to implement wgpu::WindowHandle
= note: required for SurfaceTarget<'_> to implement From<&winit::window::Window>
= note: required for &winit::window::Window to implement Into<SurfaceTarget<'_>>
note: required by a bound in wgpu::Instance::create_surface
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\api\instance.rs:298:22
|
296 | pub fn create_surface<'window>(
| -------------- required by a bound in this associated function
297 | &self,
298 | target: impl Into<SurfaceTarget<'window>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in Instance::create_surface
Some errors have detailed explanations: E0277, E0560.
For more information about an error, try rustc --explain E0277.
error: could not compile my_project (bin "my_project") due to 3 previous errors
error[E0277]: the trait bound &winit::window::Window: Into<SurfaceTarget<'_>> is not satisfied
--> src\main.rs:34:52
|
34 | let surface = unsafe { instance.create_surface(&window) }.unwrap();
| -------------- ^^^^^^^ the trait HasDisplayHandle is not implemented for winit::window::Window
| |
| required by a bound introduced by this call
|
note: there are multiple different versions of crate raw_window_handle in the dependency graph
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.6.2\src\borrowed.rs:33:1
|
33 | pub trait HasDisplayHandle {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ this is the required trait
|
::: src\main.rs:1:5
|
1 | use wgpu::{
| ---- one version of crate raw_window_handle used here, as a dependency of crate wgpu_hal
...
7 | use winit::{
| ----- one version of crate raw_window_handle used here, as a dependency of crate winit
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\winit-0.28.7\src\window.rs:44:1
|
44 | pub struct Window {
| ----------------- this type doesn't implement the required trait
|
::: C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\raw-window-handle-0.5.2\src\borrowed.rs:227:1
|
227 | pub trait HasDisplayHandle {
| -------------------------- this is the found trait
= help: you can use cargo tree to explore your dependency tree
= note: required for &winit::window::Window to implement HasDisplayHandle
= note: required for &winit::window::Window to implement wgpu::WindowHandle
= note: required for SurfaceTarget<'_> to implement From<&winit::window::Window>
= note: required for &winit::window::Window to implement Into<SurfaceTarget<'_>>
note: required by a bound in wgpu::Instance::create_surface
--> C:\Users\fer52.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\wgpu-26.0.1\src\api\instance.rs:298:22
|
296 | pub fn create_surface<'window>(
| -------------- required by a bound in this associated function
297 | &self,
298 | target: impl Into<SurfaceTarget<'window>>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in Instance::create_surface
Some errors have detailed explanations: E0277, E0560.
For more information about an error, try rustc --explain E0277.
error: could not compile my_project (bin "my_project") due to 3 previous errors