MCPcopy Create free account
hub / github.com/Rust-GPU/rust-gpu / def_with_span

Method def_with_span

crates/rustc_codegen_spirv/src/builder_spirv.rs:118–193  ·  view source on GitHub ↗
(self, cx: &CodegenCx<'_>, span: Span)

Source from the content-addressed store, hash-verified

116 }
117
118 pub fn def_with_span(self, cx: &CodegenCx<'_>, span: Span) -> Word {
119 match self.kind {
120 SpirvValueKind::Def(id) => id,
121
122 SpirvValueKind::IllegalConst(id) => {
123 let entry = &cx.builder.id_to_const.borrow()[&id];
124 let msg = match entry.legal.unwrap_err() {
125 IllegalConst::Shallow(cause) => {
126 if let (
127 LeafIllegalConst::CompositeContainsPtrTo,
128 SpirvConst::Composite(_fields),
129 ) = (cause, &entry.val)
130 {
131 // FIXME(eddyb) materialize this at runtime, using
132 // `OpCompositeConstruct` (transitively, i.e. after
133 // putting every field through `SpirvValue::def`),
134 // if we have a `Builder` to do that in.
135 // FIXME(eddyb) this isn't possible right now, as
136 // the builder would be dynamically "locked" anyway
137 // (i.e. attempting to do `bx.emit()` would panic).
138 }
139
140 cause.message()
141 }
142
143 IllegalConst::Indirect(cause) => cause.message(),
144 };
145
146 cx.zombie_with_span(id, span, msg);
147
148 id
149 }
150
151 SpirvValueKind::IllegalTypeUsed(id) => {
152 cx.tcx
153 .sess
154 .struct_span_err(span, "Can't use type as a value")
155 .note(format!("Type: *{}", cx.debug_type(id)))
156 .emit();
157
158 id
159 }
160
161 SpirvValueKind::FnAddr { .. } => {
162 cx.builder
163 .const_to_id
164 .borrow()
165 .get(&WithType {
166 ty: self.ty,
167 val: SpirvConst::ZombieUndefForFnAddr,
168 })
169 .expect("FnAddr didn't go through proper undef registration")
170 .val
171 }
172
173 SpirvValueKind::LogicalPtrCast {
174 original_ptr: _,
175 original_pointee_ty,

Callers 2

defMethod · 0.80
def_cxMethod · 0.80

Calls 6

messageMethod · 0.80
zombie_with_spanMethod · 0.80
noteMethod · 0.80
expectMethod · 0.80
emitMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected