@@ -271,16 +271,8 @@ pub fn find_stability(
271271 for attr in attrs {
272272 match attr. name_or_empty ( ) {
273273 sym:: rustc_allowed_through_unstable_modules => allowed_through_unstable_modules = true ,
274- sym:: unstable => {
275- if try_add_unstability ( sess, attr, & mut level, & mut stab_spans) . is_err ( ) {
276- break ;
277- }
278- }
279- sym:: stable => {
280- if try_add_stability ( sess, attr, & mut level, & mut stab_spans) . is_err ( ) {
281- break ;
282- }
283- }
274+ sym:: unstable => try_add_unstability ( sess, attr, & mut level, & mut stab_spans) ,
275+ sym:: stable => try_add_stability ( sess, attr, & mut level, & mut stab_spans) ,
284276 _ => { }
285277 }
286278 }
@@ -315,15 +307,9 @@ pub fn find_const_stability(
315307 match attr. name_or_empty ( ) {
316308 sym:: rustc_promotable => promotable = true ,
317309 sym:: rustc_const_unstable => {
318- if try_add_unstability ( sess, attr, & mut level, & mut stab_spans) . is_err ( ) {
319- break ;
320- }
321- }
322- sym:: rustc_const_stable => {
323- if try_add_stability ( sess, attr, & mut level, & mut stab_spans) . is_err ( ) {
324- break ;
325- }
310+ try_add_unstability ( sess, attr, & mut level, & mut stab_spans)
326311 }
312+ sym:: rustc_const_stable => try_add_stability ( sess, attr, & mut level, & mut stab_spans) ,
327313 _ => { }
328314 }
329315 }
@@ -350,9 +336,7 @@ pub fn find_body_stability(
350336
351337 for attr in attrs {
352338 if attr. has_name ( sym:: rustc_default_body_unstable) {
353- if try_add_unstability ( sess, attr, & mut level, & mut stab_spans) . is_err ( ) {
354- break ;
355- }
339+ try_add_unstability ( sess, attr, & mut level, & mut stab_spans) ;
356340 }
357341 }
358342
@@ -366,15 +350,13 @@ fn try_add_unstability(
366350 attr : & Attribute ,
367351 level : & mut Option < StabilityLevel > ,
368352 stab_spans : & mut StabilitySpans ,
369- ) -> Result < ( ) , ErrorGuaranteed > {
353+ ) {
370354 use StabilityLevel :: * ;
371355
372356 match level {
373357 // adding #[unstable] to an item with #[stable] is not permitted
374358 Some ( Stable { .. } ) => {
375- return Err ( sess
376- . dcx ( )
377- . emit_err ( session_diagnostics:: MultipleStabilityLevels { span : attr. span } ) ) ;
359+ sess. dcx ( ) . emit_err ( session_diagnostics:: MultipleStabilityLevels { span : attr. span } ) ;
378360 }
379361 // if other unstable attributes have been found, attempt to merge them
380362 Some ( Unstable { unstables, is_soft } )
@@ -386,9 +368,9 @@ fn try_add_unstability(
386368 // stability levels" clear enough, given an update to E0544.md?
387369 // should MultipleStabilityLevels have more fields for diagnostics?
388370 if unstables. iter ( ) . any ( |u| new_unstable. iter ( ) . any ( |v| u. feature == v. feature ) ) {
389- return Err ( sess
390- . dcx ( )
391- . emit_err ( session_diagnostics :: MultipleStabilityLevels { span : attr . span } ) ) ;
371+ sess. dcx ( )
372+ . emit_err ( session_diagnostics :: MultipleStabilityLevels { span : attr . span } ) ;
373+ return ;
392374 }
393375 unstables. extend ( new_unstable. clone ( ) ) ;
394376 // Make the unstability soft if any unstable attributes are marked 'soft'; if an
@@ -405,7 +387,6 @@ fn try_add_unstability(
405387 // if there was an error in `parse_unstability`, it's already been emitted; do nothing
406388 _ => { }
407389 }
408- Ok ( ( ) )
409390}
410391
411392/// Collects stability info from a single `stable`/`rustc_const_stable` attribute, `attr`.
@@ -415,18 +396,14 @@ fn try_add_stability(
415396 attr : & Attribute ,
416397 level : & mut Option < StabilityLevel > ,
417398 stab_spans : & mut StabilitySpans ,
418- ) -> Result < ( ) , ErrorGuaranteed > {
399+ ) {
419400 // at most one #[stable] attribute is permitted, and not when #[unstable] is present
420401 if level. is_some ( ) {
421- return Err ( sess
422- . dcx ( )
423- . emit_err ( session_diagnostics:: MultipleStabilityLevels { span : attr. span } ) ) ;
424- }
425- if let Some ( new_level) = parse_stability ( sess, attr) {
402+ sess. dcx ( ) . emit_err ( session_diagnostics:: MultipleStabilityLevels { span : attr. span } ) ;
403+ } else if let Some ( new_level) = parse_stability ( sess, attr) {
426404 * level = Some ( new_level. clone ( ) ) ;
427405 stab_spans. 0 . push ( ( new_level, attr. span ) ) ;
428406 }
429- Ok ( ( ) )
430407}
431408
432409fn insert_or_error ( sess : & Session , meta : & MetaItem , item : & mut Option < Symbol > ) -> Option < ( ) > {
0 commit comments