Repository: servo/servo
File: components/script/dom/webgl/webglprogram.rs (Rust)

Code before:
        Ref::map(self.active_uniforms.borrow(), |uniforms| &**uniforms)
    }

    pub(crate) fn active_uniform_blocks(&self) -> Ref<'_, [ActiveUniformBlockInfo]> {
        Ref::map(self.active_uniform_blocks.borrow(), |blocks| &**blocks)
    }

    /// glValidateProgram
    pub(crate) fn validate(&self) -> WebGLResult<()> {
        if self.is_deleted() {
            return Err(WebGLError::InvalidOperation);
        }
        self.upcast()
            .send_command(WebGLCommand::ValidateProgram(self.id()));
        Ok(())
    }

    /// glAttachShader
    pub(crate) fn attach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> {
        match self.droppable.borrow_mut().attach_shader(shader) {
            Ok(shader) => {
                let shader_slot = match shader.gl_type() {
                    constants::FRAGMENT_SHADER => &self.fragment_shader,
                    constants::VERTEX_SHADER => &self.vertex_shader,
                    _ => {
                        error!("detachShader: Unexpected shader type");
                        return Err(WebGLError::InvalidValue);
                    },
                };

                shader_slot.set(Some(shader));

                Ok(())
            },
            Err(e) => Err(e),
        }
    }

    /// glDetachShader
    pub(crate) fn detach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> {
        match self.droppable.borrow_mut().detach_shader(shader) {
            Ok(shader) => {
                let shader_slot = match shader.gl_type() {
                    constants::FRAGMENT_SHADER => &self.fragment_shader,
                    constants::VERTEX_SHADER => &self.vertex_shader,
                    _ => {
                        error!("detachShader: Unexpected shader type");
                        return Err(WebGLError::InvalidValue);
                    },
                };


Review comment (suggestion):
```suggestion
                        error!("attach_shader: Unexpected shader type");
```

Code after:
    }

    /// glValidateProgram
    pub(crate) fn validate(&self) -> WebGLResult<()> {
        if self.is_deleted() {
            return Err(WebGLError::InvalidOperation);
        }
        self.upcast()
            .send_command(WebGLCommand::ValidateProgram(self.id()));
        Ok(())
    }

    /// glAttachShader
    pub(crate) fn attach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> {
        match self.droppable.borrow_mut().attach_shader(shader) {
            Ok(shader) => {
                let shader_slot = match shader.gl_type() {
                    constants::FRAGMENT_SHADER => &self.fragment_shader,
                    constants::VERTEX_SHADER => &self.vertex_shader,
                    _ => {
                        error!("attach_shader: Unexpected shader type");
                        return Err(WebGLError::InvalidValue);
                    },
                };

                shader_slot.set(Some(shader));

                Ok(())
            },
            Err(e) => Err(e),
        }
    }

    /// glDetachShader
    pub(crate) fn detach_shader(&self, shader: &WebGLShader) -> WebGLResult<()> {
        match self.droppable.borrow_mut().detach_shader(shader) {
            Ok(shader) => {
                let shader_slot = match shader.gl_type() {
                    constants::FRAGMENT_SHADER => &self.fragment_shader,
                    constants::VERTEX_SHADER => &self.vertex_shader,
                    _ => {
                        error!("detach_shader: Unexpected shader type");
                        return Err(WebGLError::InvalidValue);
                    },
                };

                shader_slot.set(None);

                Ok(())
            },
            Err(e) => Err(e),