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

Method parse

crates/rustc_codegen_spirv/src/attr.rs:148–175  ·  view source on GitHub ↗

Compute `AggregatedSpirvAttributes` for use during codegen. Any errors for malformed/duplicate attributes will have been reported prior to codegen, by the `attr` check pass.

(cx: &CodegenCx<'tcx>, attrs: &'tcx [Attribute])

Source from the content-addressed store, hash-verified

146 /// Any errors for malformed/duplicate attributes will have been reported
147 /// prior to codegen, by the `attr` check pass.
148 pub fn parse<'tcx>(cx: &CodegenCx<'tcx>, attrs: &'tcx [Attribute]) -> Self {
149 let mut aggregated_attrs = Self::default();
150
151 // NOTE(eddyb) `delay_span_bug` ensures that if attribute checking fails
152 // to see an attribute error, it will cause an ICE instead.
153 for parse_attr_result in crate::symbols::parse_attrs_for_checking(&cx.sym, attrs) {
154 let (span, parsed_attr) = match parse_attr_result {
155 Ok(span_and_parsed_attr) => span_and_parsed_attr,
156 Err((span, msg)) => {
157 cx.tcx.sess.delay_span_bug(span, msg);
158 continue;
159 }
160 };
161 match aggregated_attrs.try_insert_attr(parsed_attr, span) {
162 Ok(()) => {}
163 Err(MultipleAttrs {
164 prev_span: _,
165 category,
166 }) => {
167 cx.tcx
168 .sess
169 .delay_span_bug(span, format!("multiple {category} attributes"));
170 }
171 }
172 }
173
174 aggregated_attrs
175 }
176
177 fn try_insert_attr(&mut self, attr: SpirvAttribute, span: Span) -> Result<(), MultipleAttrs> {
178 fn try_insert<T>(

Callers 6

run_modeMethod · 0.45
from_strMethod · 0.45
do_spirv_optFunction · 0.45
do_spirv_valFunction · 0.45
decodeMethod · 0.45
from_strMethod · 0.45

Calls 2

parse_attrs_for_checkingFunction · 0.85
try_insert_attrMethod · 0.80

Tested by

no test coverage detected