Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upDisallow uses of `unwrap` in constellation.rs, compositor.rs, and pipeline.rs #10446
Comments
|
If that is sufficient, feel free to assign to me. |
|
Or do you really want |
|
Unwrap_or_else is fine, since it doesn't actually panic like unwrap does. And yes, I would be ok with using shell scripts for this, but we should make a separate script in |
|
Could we add it to tidy? |
…ap". Should fix servo#10446.
travis: add and run script which checks if listed files contain "unwrap". Should fix #10446. Unfortunately there is a lot of python code in tidy.py that I don't understand yet, so I simply wrote a bash script to do the job and hooked it up in travis.yml. Tests are expected to fail: ```` components/compositing/compositor.rs:758: self.pipeline_details.get_mut(&pipeline_id).unwrap() components/compositing/compositor.rs:2194: RgbImage::from_raw(width as u32, height as u32, pixels).unwrap() components/compositing/pipeline.rs:130: let (paint_shutdown_chan, paint_shutdown_port) = ipc::channel().unwrap(); components/compositing/pipeline.rs:131: let (layout_shutdown_chan, layout_shutdown_port) = ipc::channel().unwrap(); components/compositing/pipeline.rs:132: let (pipeline_chan, pipeline_port) = ipc::channel().unwrap(); components/compositing/pipeline.rs:133: let (script_to_compositor_chan, script_to_compositor_port) = ipc::channel().unwrap(); components/compositing/pipeline.rs:151: let (script_to_devtools_chan, script_to_devtools_port) = ipc::channel().unwrap(); components/compositing/pipeline.rs:154: let message: ScriptToDevtoolsControlMsg = message.to().unwrap(); components/compositing/pipeline.rs:155: devtools_chan.send(DevtoolsControlMsg::FromScript(message)).unwrap() components/compositing/pipeline.rs:161: ipc::channel().unwrap(); components/compositing/pipeline.rs:174: pipeline_port: mem::replace(&mut pipeline_port, None).unwrap(), components/compositing/pipeline.rs:180: .unwrap(); components/compositing/pipeline.rs:184: let (script_chan, script_port) = ipc::channel().unwrap(); components/compositing/pipeline.rs:190: ipc::channel().unwrap(); components/compositing/pipeline.rs:298: let (sender, receiver) = ipc::channel().unwrap(); components/compositing/pipeline.rs:300: receiver.recv().unwrap(); components/compositing/pipeline.rs:315: let _ = self.script_chan.send(ConstellationControlMsg::Freeze(self.id)).unwrap(); components/compositing/pipeline.rs:319: let _ = self.script_chan.send(ConstellationControlMsg::Thaw(self.id)).unwrap(); components/compositing/pipeline.rs:323: let _ = self.script_chan.send(ConstellationControlMsg::ExitPipeline(self.id)).unwrap(); components/compositing/pipeline.rs:326: let _ = layout_channel.send(LayoutControlMsg::ExitNow).unwrap(); components/compositing/pipeline.rs:343: let index = self.children.iter().position(|id| *id == frame_id).unwrap(); components/compositing/pipeline.rs:355: self.script_chan.send(event).unwrap(); components/compositing/pipeline.rs:402: control_port: mem::replace(&mut self.script_port, None).unwrap(), components/compositing/pipeline.rs:423: self.pipeline_port.unwrap(), components/compositing/pipeline.rs:437: self.script_content_process_shutdown_port.recv().unwrap(); components/compositing/pipeline.rs:438: self.layout_content_process_shutdown_port.recv().unwrap(); components/compositing/constellation.rs:464: IpcOneShotServer::<IpcSender<UnprivilegedPipelineContent>>::new().unwrap(); components/compositing/constellation.rs:468: let mut command = sandbox::Command::me().unwrap(); components/compositing/constellation.rs:474: let path_to_self = env::current_exe().unwrap(); components/compositing/constellation.rs:478: ChildProcess::Unsandboxed(child_process.spawn().unwrap()) components/compositing/constellation.rs:482: let (_receiver, sender) = server.accept().unwrap(); components/compositing/constellation.rs:835: stderr.write_all("Pipeline failed in hard-fail mode. Crashing!\n".as_bytes()).unwrap(); components/compositing/constellation.rs:1621: let (sender, receiver) = ipc::channel().unwrap(); components/compositing/constellation.rs:1657: let (sender, receiver) = ipc::channel().unwrap(); components/compositing/constellation.rs:1659: layout_chan.send(LayoutControlMsg::GetCurrentEpoch(sender)).unwrap(); components/compositing/constellation.rs:1660: let layout_thread_epoch = receiver.recv().unwrap(); components/compositing/constellation.rs:1838: let (chan, port) = ipc::channel().unwrap(); ```` <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10448) <!-- Reviewable:end -->
|
Yep, this could be given to tidy (it already checks all the lines in Rust source files). It shouldn't add any painful overhead. @jdm Why don't we go for tidy here? |
|
I guess it seemed so specifically targeted (three files) that it seemed like the wrong tool to reach for. |
|
Yes, but (with the bulk of unwraps we have everywhere) won't the count increase, as we clean the other files in the near future? |
|
Oh, never mind, we'll add it later :) |
|
I would be very happy to see this, for stopping regressions to #10124 and friends. |
…ap". Should fix servo#10446.
…ap". Should fix servo#10446.
…ap". Should fix servo#10446.
travis: add and run script which checks if listed files contain "unwrap". Should fix #10446. Unfortunately there is a lot of python code in tidy.py that I don't understand yet, so I simply wrote a bash script to do the job and hooked it up in travis.yml. Tests are expected to fail: ```` components/compositing/compositor.rs:758: self.pipeline_details.get_mut(&pipeline_id).unwrap() components/compositing/compositor.rs:2194: RgbImage::from_raw(width as u32, height as u32, pixels).unwrap() components/compositing/pipeline.rs:130: let (paint_shutdown_chan, paint_shutdown_port) = ipc::channel().unwrap(); components/compositing/pipeline.rs:131: let (layout_shutdown_chan, layout_shutdown_port) = ipc::channel().unwrap(); components/compositing/pipeline.rs:132: let (pipeline_chan, pipeline_port) = ipc::channel().unwrap(); components/compositing/pipeline.rs:133: let (script_to_compositor_chan, script_to_compositor_port) = ipc::channel().unwrap(); components/compositing/pipeline.rs:151: let (script_to_devtools_chan, script_to_devtools_port) = ipc::channel().unwrap(); components/compositing/pipeline.rs:154: let message: ScriptToDevtoolsControlMsg = message.to().unwrap(); components/compositing/pipeline.rs:155: devtools_chan.send(DevtoolsControlMsg::FromScript(message)).unwrap() components/compositing/pipeline.rs:161: ipc::channel().unwrap(); components/compositing/pipeline.rs:174: pipeline_port: mem::replace(&mut pipeline_port, None).unwrap(), components/compositing/pipeline.rs:180: .unwrap(); components/compositing/pipeline.rs:184: let (script_chan, script_port) = ipc::channel().unwrap(); components/compositing/pipeline.rs:190: ipc::channel().unwrap(); components/compositing/pipeline.rs:298: let (sender, receiver) = ipc::channel().unwrap(); components/compositing/pipeline.rs:300: receiver.recv().unwrap(); components/compositing/pipeline.rs:315: let _ = self.script_chan.send(ConstellationControlMsg::Freeze(self.id)).unwrap(); components/compositing/pipeline.rs:319: let _ = self.script_chan.send(ConstellationControlMsg::Thaw(self.id)).unwrap(); components/compositing/pipeline.rs:323: let _ = self.script_chan.send(ConstellationControlMsg::ExitPipeline(self.id)).unwrap(); components/compositing/pipeline.rs:326: let _ = layout_channel.send(LayoutControlMsg::ExitNow).unwrap(); components/compositing/pipeline.rs:343: let index = self.children.iter().position(|id| *id == frame_id).unwrap(); components/compositing/pipeline.rs:355: self.script_chan.send(event).unwrap(); components/compositing/pipeline.rs:402: control_port: mem::replace(&mut self.script_port, None).unwrap(), components/compositing/pipeline.rs:423: self.pipeline_port.unwrap(), components/compositing/pipeline.rs:437: self.script_content_process_shutdown_port.recv().unwrap(); components/compositing/pipeline.rs:438: self.layout_content_process_shutdown_port.recv().unwrap(); components/compositing/constellation.rs:464: IpcOneShotServer::<IpcSender<UnprivilegedPipelineContent>>::new().unwrap(); components/compositing/constellation.rs:468: let mut command = sandbox::Command::me().unwrap(); components/compositing/constellation.rs:474: let path_to_self = env::current_exe().unwrap(); components/compositing/constellation.rs:478: ChildProcess::Unsandboxed(child_process.spawn().unwrap()) components/compositing/constellation.rs:482: let (_receiver, sender) = server.accept().unwrap(); components/compositing/constellation.rs:835: stderr.write_all("Pipeline failed in hard-fail mode. Crashing!\n".as_bytes()).unwrap(); components/compositing/constellation.rs:1621: let (sender, receiver) = ipc::channel().unwrap(); components/compositing/constellation.rs:1657: let (sender, receiver) = ipc::channel().unwrap(); components/compositing/constellation.rs:1659: layout_chan.send(LayoutControlMsg::GetCurrentEpoch(sender)).unwrap(); components/compositing/constellation.rs:1660: let layout_thread_epoch = receiver.recv().unwrap(); components/compositing/constellation.rs:1838: let (chan, port) = ipc::channel().unwrap(); ```` <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10448) <!-- Reviewable:end -->
Three options:
unwrapin those files and runs on travisunwrapin files marked#[disallow(unwrap)]unwrap