parse_if_expr: recover on attributes · rust-lang/rust@458383d (original) (raw)

`@@ -136,14 +136,14 @@ LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; }

`

136

136

` |

`

137

137

`` = note: inner attributes, like #![no_std], annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like #[test], annotate the item following them.

``

138

138

``

139

``

`` -

error: expected {, found #

``

``

139

`` +

error: outer attributes are not allowed on if and else branches

``

140

140

` --> $DIR/attr-stmt-expr-attr-bad.rs:41:37

`

141

141

` |

`

142

142

`LL | #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; }

`

143

``

`` -

| -- ^ -- help: try placing this code inside a block: { {} }

``

``

143

`+

| -- ^^^^^^^ -- the attributes are attached to this branch

`

144

144

` | | |

`

145

``

`` -

| | expected {

``

146

``

`` -

| this if expression has a condition, but no block

``

``

145

`+

| | help: remove the attributes

`

``

146

`` +

| the branch belongs to this if

``

147

147

``

148

148

`error: an inner attribute is not permitted in this context

`

149

149

` --> $DIR/attr-stmt-expr-attr-bad.rs:43:38

`

`` @@ -159,13 +159,14 @@ error: expected one of ., ;, ?, else, or an operator, found #

``

159

159

`LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} #[attr] else {}; }

`

160

160

`` | ^ expected one of ., ;, ?, else, or an operator

``

161

161

``

162

``

`` -

error: expected {, found #

``

``

162

`` +

error: outer attributes are not allowed on if and else branches

``

163

163

` --> $DIR/attr-stmt-expr-attr-bad.rs:47:45

`

164

164

` |

`

165

165

`LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; }

`

166

``

`` -

| ^ -- help: try placing this code inside a block: { {} }

``

167

``

`-

| |

`

168

``

`` -

| expected {

``

``

166

`+

| ---- ^^^^^^^ -- the attributes are attached to this branch

`

``

167

`+

| | |

`

``

168

`+

| | help: remove the attributes

`

``

169

`` +

| the branch belongs to this else

``

169

170

``

170

171

`error: an inner attribute is not permitted in this context

`

171

172

` --> $DIR/attr-stmt-expr-attr-bad.rs:49:46

`

`@@ -175,22 +176,23 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; }

`

175

176

` |

`

176

177

`` = note: inner attributes, like #![no_std], annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like #[test], annotate the item following them.

``

177

178

``

178

``

`` -

error: expected {, found #

``

``

179

`` +

error: outer attributes are not allowed on if and else branches

``

179

180

` --> $DIR/attr-stmt-expr-attr-bad.rs:51:45

`

180

181

` |

`

181

182

`LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; }

`

182

``

`` -

| ^ ------- help: try placing this code inside a block: { if 0 {} }

``

183

``

`-

| |

`

184

``

`` -

| expected {

``

``

183

`+

| ---- ^^^^^^^ ------- the attributes are attached to this branch

`

``

184

`+

| | |

`

``

185

`+

| | help: remove the attributes

`

``

186

`` +

| the branch belongs to this else

``

185

187

``

186

``

`` -

error: expected {, found #

``

``

188

`` +

error: outer attributes are not allowed on if and else branches

``

187

189

` --> $DIR/attr-stmt-expr-attr-bad.rs:53:50

`

188

190

` |

`

189

191

`LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; }

`

190

``

`` -

| -- ^ -- help: try placing this code inside a block: { {} }

``

``

192

`+

| -- ^^^^^^^ -- the attributes are attached to this branch

`

191

193

` | | |

`

192

``

`` -

| | expected {

``

193

``

`` -

| this if expression has a condition, but no block

``

``

194

`+

| | help: remove the attributes

`

``

195

`` +

| the branch belongs to this if

``

194

196

``

195

197

`error: an inner attribute is not permitted in this context

`

196

198

` --> $DIR/attr-stmt-expr-attr-bad.rs:55:51

`

`@@ -200,14 +202,14 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; }

`

200

202

` |

`

201

203

`` = note: inner attributes, like #![no_std], annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like #[test], annotate the item following them.

``

202

204

``

203

``

`` -

error: expected {, found #

``

``

205

`` +

error: outer attributes are not allowed on if and else branches

``

204

206

` --> $DIR/attr-stmt-expr-attr-bad.rs:57:45

`

205

207

` |

`

206

208

`LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; }

`

207

``

`` -

| -- ^ -- help: try placing this code inside a block: { {} }

``

``

209

`+

| -- ^^^^^^^ -- the attributes are attached to this branch

`

208

210

` | | |

`

209

``

`` -

| | expected {

``

210

``

`` -

| this if expression has a condition, but no block

``

``

211

`+

| | help: remove the attributes

`

``

212

`` +

| the branch belongs to this if

``

211

213

``

212

214

`error: an inner attribute is not permitted in this context

`

213

215

` --> $DIR/attr-stmt-expr-attr-bad.rs:59:46

`

`` @@ -223,13 +225,14 @@ error: expected one of ., ;, ?, else, or an operator, found #

``

223

225

`LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} #[attr] else {}; }

`

224

226

`` | ^ expected one of ., ;, ?, else, or an operator

``

225

227

``

226

``

`` -

error: expected {, found #

``

``

228

`` +

error: outer attributes are not allowed on if and else branches

``

227

229

` --> $DIR/attr-stmt-expr-attr-bad.rs:63:53

`

228

230

` |

`

229

231

`LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; }

`

230

``

`` -

| ^ -- help: try placing this code inside a block: { {} }

``

231

``

`-

| |

`

232

``

`` -

| expected {

``

``

232

`+

| ---- ^^^^^^^ -- the attributes are attached to this branch

`

``

233

`+

| | |

`

``

234

`+

| | help: remove the attributes

`

``

235

`` +

| the branch belongs to this else

``

233

236

``

234

237

`error: an inner attribute is not permitted in this context

`

235

238

` --> $DIR/attr-stmt-expr-attr-bad.rs:65:54

`

`@@ -239,22 +242,23 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; }

`

239

242

` |

`

240

243

`` = note: inner attributes, like #![no_std], annotate the item enclosing them, and are usually found at the beginning of source files. Outer attributes, like #[test], annotate the item following them.

``

241

244

``

242

``

`` -

error: expected {, found #

``

``

245

`` +

error: outer attributes are not allowed on if and else branches

``

243

246

` --> $DIR/attr-stmt-expr-attr-bad.rs:67:53

`

244

247

` |

`

245

248

`LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {}; }

`

246

``

`` -

| ^ --------------- help: try placing this code inside a block: { if let _ = 0 {} }

``

247

``

`-

| |

`

248

``

`` -

| expected {

``

``

249

`+

| ---- ^^^^^^^ --------------- the attributes are attached to this branch

`

``

250

`+

| | |

`

``

251

`+

| | help: remove the attributes

`

``

252

`` +

| the branch belongs to this else

``

249

253

``

250

``

`` -

error: expected {, found #

``

``

254

`` +

error: outer attributes are not allowed on if and else branches

``

251

255

` --> $DIR/attr-stmt-expr-attr-bad.rs:69:66

`

252

256

` |

`

253

257

`LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {}; }

`

254

``

`` -

| -- ^ -- help: try placing this code inside a block: { {} }

``

``

258

`+

| -- ^^^^^^^ -- the attributes are attached to this branch

`

255

259

` | | |

`

256

``

`` -

| | expected {

``

257

``

`` -

| this if expression has a condition, but no block

``

``

260

`+

| | help: remove the attributes

`

``

261

`` +

| the branch belongs to this if

``

258

262

``

259

263

`error: an inner attribute is not permitted in this context

`

260

264

` --> $DIR/attr-stmt-expr-attr-bad.rs:71:67

`