Skip to content

Commit cfb137b

Browse files
authored
Remove #![feature(try_trait)] from a test (#1142)
I'm working on `try_trait_v2` which will break this, so I'm going around removing uses from the rustc tree where I can.
1 parent 594e63b commit cfb137b

File tree

1 file changed

+38
-33
lines changed

1 file changed

+38
-33
lines changed

crates/stdarch-verify/tests/mips.rs

+38-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//! Verification of MIPS MSA intrinsics
2-
#![feature(try_trait)]
32
#![allow(bad_style, unused)]
43

54
// This file is obtained from
@@ -139,47 +138,53 @@ struct MsaIntrinsic {
139138
instruction: String,
140139
}
141140

141+
struct NoneError;
142+
142143
impl std::convert::TryFrom<&'static str> for MsaIntrinsic {
143144
// The intrinsics are just C function declarations of the form:
144145
// $ret_ty __builtin_${fn_id}($($arg_ty),*);
145-
type Error = std::option::NoneError;
146+
type Error = NoneError;
146147
fn try_from(line: &'static str) -> Result<Self, Self::Error> {
147-
let first_whitespace = line.find(char::is_whitespace)?;
148-
let ret_ty = &line[0..first_whitespace];
149-
let ret_ty = MsaTy::from(ret_ty);
148+
return inner(line).ok_or(NoneError);
150149

151-
let first_parentheses = line.find('(')?;
152-
assert!(first_parentheses > first_whitespace);
153-
let id = &line[first_whitespace + 1..first_parentheses].trim();
154-
assert!(id.starts_with("__builtin"));
155-
let mut id_str = "_".to_string();
156-
id_str += &id[9..];
157-
let id = id_str;
150+
fn inner(line: &'static str) -> Option<MsaIntrinsic> {
151+
let first_whitespace = line.find(char::is_whitespace)?;
152+
let ret_ty = &line[0..first_whitespace];
153+
let ret_ty = MsaTy::from(ret_ty);
158154

159-
let mut arg_tys = Vec::new();
155+
let first_parentheses = line.find('(')?;
156+
assert!(first_parentheses > first_whitespace);
157+
let id = &line[first_whitespace + 1..first_parentheses].trim();
158+
assert!(id.starts_with("__builtin"));
159+
let mut id_str = "_".to_string();
160+
id_str += &id[9..];
161+
let id = id_str;
160162

161-
let last_parentheses = line.find(')')?;
162-
for arg in (&line[first_parentheses + 1..last_parentheses]).split(',') {
163-
let arg = arg.trim();
164-
arg_tys.push(MsaTy::from(arg));
165-
}
163+
let mut arg_tys = Vec::new();
166164

167-
// The instruction is the intrinsic name without the __msa_ prefix.
168-
let instruction = &id[6..];
169-
let mut instruction = instruction.to_string();
170-
// With all underscores but the first one replaced with a `.`
171-
if let Some(first_underscore) = instruction.find('_') {
172-
let postfix = instruction[first_underscore + 1..].replace('_', ".");
173-
instruction = instruction[0..=first_underscore].to_string();
174-
instruction += &postfix;
175-
}
165+
let last_parentheses = line.find(')')?;
166+
for arg in (&line[first_parentheses + 1..last_parentheses]).split(',') {
167+
let arg = arg.trim();
168+
arg_tys.push(MsaTy::from(arg));
169+
}
176170

177-
Ok(MsaIntrinsic {
178-
id,
179-
ret_ty,
180-
arg_tys,
181-
instruction,
182-
})
171+
// The instruction is the intrinsic name without the __msa_ prefix.
172+
let instruction = &id[6..];
173+
let mut instruction = instruction.to_string();
174+
// With all underscores but the first one replaced with a `.`
175+
if let Some(first_underscore) = instruction.find('_') {
176+
let postfix = instruction[first_underscore + 1..].replace('_', ".");
177+
instruction = instruction[0..=first_underscore].to_string();
178+
instruction += &postfix;
179+
}
180+
181+
Some(MsaIntrinsic {
182+
id,
183+
ret_ty,
184+
arg_tys,
185+
instruction,
186+
})
187+
}
183188
}
184189
}
185190

0 commit comments

Comments
 (0)