Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.39 KB | None | 0 0
  1. diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs
  2. index f71cce8273..2995b25308 100644
  3. --- a/src/librustc/infer/error_reporting/mod.rs
  4. +++ b/src/librustc/infer/error_reporting/mod.rs
  5. @@ -511,6 +511,18 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
  6. }
  7. }
  8. },
  9. + ObligationCauseCode::IfExpression { then, outer, semicolon } => {
  10. + err.span_label(then, "expected because of this");
  11. + outer.map(|sp| err.span_label(sp, "if and else have incompatible types"));
  12. + if let Some(sp) = semicolon {
  13. + err.span_suggestion_short_with_applicability(
  14. + sp,
  15. + "consider removing this semicolon",
  16. + String::new(),
  17. + Applicability::MachineApplicable,
  18. + );
  19. + }
  20. + }
  21. _ => (),
  22. }
  23. }
  24. @@ -1460,7 +1472,7 @@ impl<'tcx> ObligationCause<'tcx> {
  25. }
  26. _ => "match arms have incompatible types",
  27. }),
  28. - IfExpression => Error0308("if and else have incompatible types"),
  29. + IfExpression { .. } => Error0308("if and else have incompatible types"),
  30. IfExpressionWithNoElse => Error0317("if may be missing an else clause"),
  31. MainFunctionType => Error0580("main function has wrong type"),
  32. StartFunctionType => Error0308("start function has wrong type"),
  33. @@ -1488,7 +1500,7 @@ impl<'tcx> ObligationCause<'tcx> {
  34. hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have compatible types",
  35. _ => "match arms have compatible types",
  36. },
  37. - IfExpression => "if and else have compatible types",
  38. + IfExpression { .. } => "if and else have compatible types",
  39. IfExpressionWithNoElse => "if missing an else returns ()",
  40. MainFunctionType => "`main` function has the correct type",
  41. StartFunctionType => "`start` function has the correct type",
  42. diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs
  43. index a373faab3a..4c14c19688 100644
  44. --- a/src/librustc/lint/mod.rs
  45. +++ b/src/librustc/lint/mod.rs
  46. @@ -453,7 +453,7 @@ impl Level {
  47. }
  48.  
  49. /// How a lint level was set.
  50. -#[derive(Clone, Copy, PartialEq, Eq)]
  51. +#[derive(Clone, Copy, PartialEq, Eq, Debug)]
  52. pub enum LintSource {
  53. /// Lint is at the default level as declared
  54. /// in rustc or a plugin.
  55. @@ -523,6 +523,8 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
  56. msg: &str)
  57. -> DiagnosticBuilder<'a>
  58. {
  59. + debug!("struct_lint_level lint: {:?} level: {:?} src: {:?} span: {:?} msg: {:?}",
  60. + lint, level, src, span, msg);
  61. let mut err = match (level, span) {
  62. (Level::Allow, _) => return sess.diagnostic().struct_dummy(),
  63. (Level::Warn, Some(span)) => sess.struct_span_warn(span, msg),
  64. @@ -533,6 +535,8 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
  65. (Level::Forbid, None) => sess.struct_err(msg),
  66. };
  67.  
  68. + debug!("struct_lint_level err: {:?}", err);
  69. +
  70. let name = lint.name_lower();
  71. match src {
  72. LintSource::Default => {
  73. @@ -606,22 +610,140 @@ pub fn struct_lint_level<'a>(sess: &'a Session,
  74. err.note(&citation);
  75. }
  76.  
  77. + debug!("struct_lint_level prior to primary_spans check, err: {:?}", err);
  78. +
  79. + #[derive(Copy, Clone, Debug)]
  80. + /// This is a simple hierarchy for tracking whether the set of
  81. + /// primary spans should be considered to have been affected by a
  82. + /// macro defined by an external crate.
  83. + ///
  84. + /// The hierarchy looks like this:
  85. + ///
  86. + /// ```
  87. + /// HasSomeCurrentExtern
  88. + /// |
  89. + /// HasSomeHistoricalExtern
  90. + /// |
  91. + /// NoExterns
  92. + /// ```
  93. + ///
  94. + /// Combining two primary spans will choose whichever one is
  95. + /// higher in the hierarchy structure.
  96. + ///
  97. + /// The spans we associate with a given lint can change over time,
  98. + /// and those spans can affect whether a lint is actually
  99. + /// signalled. This state is used as part of ensuring that we
  100. + /// don't inject hard-errors into stable code that is denying (or
  101. + /// forbidding) a given lint, by tracking old spans that had been
  102. + /// used in previous versions of `rustc` and then making sure that
  103. + /// if an old span would cause a lint to be suppressed, then we
  104. + /// will not allow a previously-suppressed lint to suddenly become
  105. + /// a hard error.
  106. + enum ExternState {
  107. + /// At least one primary span associated with the error
  108. + /// originated from a macro defined by an external crate.
  109. + HasSomeCurrentExtern,
  110. +
  111. + /// None of the primary spans currently associated with error
  112. + /// originated with a macro from an external crate, *but* in
  113. + /// an earlier version of the compiler, there was some primary
  114. + /// span associated with the error that did originate from a
  115. + /// macro defined by an external crate.
  116. + HasSomeHistoricalExtern,
  117. +
  118. + /// None of the primary spans (neither currently nor in the
  119. + /// recorded history of the error's construction) originated
  120. + /// from a macro defined by an external crate.
  121. + NoExterns,
  122. + }
  123. +
  124. + impl ExternState {
  125. + /// Returns the higher point in the `ExternState` hierarchy.
  126. + fn combine(&self, other: ExternState) -> ExternState {
  127. + match (*self, other) {
  128. + (ExternState::HasSomeCurrentExtern, _) |
  129. + (_, ExternState::HasSomeCurrentExtern) => ExternState::HasSomeCurrentExtern,
  130. + (ExternState::HasSomeHistoricalExtern, _) |
  131. + (_, ExternState::HasSomeHistoricalExtern) => ExternState::HasSomeHistoricalExtern,
  132. + (ExternState::NoExterns, ExternState::NoExterns) => ExternState::NoExterns,
  133. + }
  134. + }
  135. +
  136. + /// Indicates whether the primary spans indicate that we
  137. + /// should not emit suggstions for use by `rustfix`.
  138. + fn disallow_suggestions(&self) -> bool {
  139. + match *self {
  140. + ExternState::HasSomeCurrentExtern => true,
  141. + ExternState::HasSomeHistoricalExtern => false,
  142. + ExternState::NoExterns => false,
  143. + }
  144. + }
  145. + }
  146. +
  147. // If this code originates in a foreign macro, aka something that this crate
  148. // did not itself author, then it's likely that there's nothing this crate
  149. // can do about it. We probably want to skip the lint entirely.
  150. - if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) {
  151. + let old_control = err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s));
  152. + let extern_state = err.span.primary_spans_with_migrations()
  153. + .enumerate()
  154. + .inspect(|(i, s)| {
  155. + debug!("struct_lint_level primary_span[{}]: {:?}, in_external_macro: {:?}",
  156. + i, s, (in_external_macro(sess, s.new),
  157. + s.old.map(|s|in_external_macro(sess, s))));
  158. + })
  159. + .fold(ExternState::NoExterns,
  160. + |ext_state, (_, migrate_span)| {
  161. + let new_state = if in_external_macro(sess, migrate_span.new) {
  162. + ExternState::HasSomeCurrentExtern
  163. + } else if migrate_span.old.map_or(false, |s| in_external_macro(sess, s)) {
  164. + ExternState::HasSomeHistoricalExtern
  165. + } else {
  166. + ExternState::NoExterns
  167. + };
  168. +
  169. + ext_state.combine(new_state)
  170. + });
  171. +
  172. + debug!("struct_lint_level old_control: {:?} extern_state: {:?} err: {:?}",
  173. + old_control, extern_state, err);
  174. +
  175. + if extern_state.disallow_suggestions() {
  176. // Any suggestions made here are likely to be incorrect, so anything we
  177. // emit shouldn't be automatically fixed by rustfix.
  178. err.allow_suggestions(false);
  179. + }
  180. +
  181. + // If this is a future incompatible lint it'll become a hard error, so
  182. + // we have to emit *something*. Also allow lints to whitelist themselves
  183. + // on a case-by-case basis for emission in a foreign macro.
  184. + if future_incompatible.is_none() && !lint.report_in_external_macro {
  185. + match extern_state {
  186. + ExternState::NoExterns => { }
  187.  
  188. - // If this is a future incompatible lint it'll become a hard error, so
  189. - // we have to emit *something*. Also allow lints to whitelist themselves
  190. - // on a case-by-case basis for emission in a foreign macro.
  191. - if future_incompatible.is_none() && !lint.report_in_external_macro {
  192. - err.cancel()
  193. + ExternState::HasSomeCurrentExtern => {
  194. + err.cancel()
  195. + }
  196. +
  197. + ExternState::HasSomeHistoricalExtern => {
  198. + if err.is_error() {
  199. + err.level = errors::Level::Warning;
  200. + err.warn(
  201. + "this lint has been downgraded to a warning for backwards \
  202. + compatibility with previous releases",
  203. + );
  204. + }
  205. + // note that we deliberately do not cancel these;
  206. + // there is no *current* primary span from an external
  207. + // crate, and thus it is best for the overall
  208. + // user-experience that we issue some form of
  209. + // diagnostic, as long as it does not lead to a
  210. + // hard-error.
  211. + }
  212. }
  213. }
  214.  
  215. + debug!("struct_lint_level finis err: {:?}", err);
  216. +
  217. return err
  218. }
  219.  
  220. diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs
  221. index 7d9e80fd60..367a7eacdf 100644
  222. --- a/src/librustc/traits/error_reporting.rs
  223. +++ b/src/librustc/traits/error_reporting.rs
  224. @@ -1445,7 +1445,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
  225. ObligationCauseCode::ExprAssignable |
  226. ObligationCauseCode::MatchExpressionArm { .. } |
  227. ObligationCauseCode::MatchExpressionArmPattern { .. } |
  228. - ObligationCauseCode::IfExpression |
  229. + ObligationCauseCode::IfExpression { .. } |
  230. ObligationCauseCode::IfExpressionWithNoElse |
  231. ObligationCauseCode::MainFunctionType |
  232. ObligationCauseCode::StartFunctionType |
  233. diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs
  234. index 14c25b77a1..68383bef37 100644
  235. --- a/src/librustc/traits/mod.rs
  236. +++ b/src/librustc/traits/mod.rs
  237. @@ -229,7 +229,11 @@ pub enum ObligationCauseCode<'tcx> {
  238. MatchExpressionArmPattern { span: Span, ty: Ty<'tcx> },
  239.  
  240. /// Computing common supertype in an if expression
  241. - IfExpression,
  242. + IfExpression {
  243. + then: Span,
  244. + outer: Option<Span>,
  245. + semicolon: Option<Span>,
  246. + },
  247.  
  248. /// Computing common supertype of an if expression with no else counter-part
  249. IfExpressionWithNoElse,
  250. diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs
  251. index 277e2ed0e8..2f5df02221 100644
  252. --- a/src/librustc/traits/structural_impls.rs
  253. +++ b/src/librustc/traits/structural_impls.rs
  254. @@ -520,7 +520,11 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> {
  255. super::MatchExpressionArmPattern { span, ty } => {
  256. tcx.lift(&ty).map(|ty| super::MatchExpressionArmPattern { span, ty })
  257. }
  258. - super::IfExpression => Some(super::IfExpression),
  259. + super::IfExpression { then, outer, semicolon } => Some(super::IfExpression {
  260. + then,
  261. + outer,
  262. + semicolon,
  263. + }),
  264. super::IfExpressionWithNoElse => Some(super::IfExpressionWithNoElse),
  265. super::MainFunctionType => Some(super::MainFunctionType),
  266. super::StartFunctionType => Some(super::StartFunctionType),
  267. diff --git a/src/librustc_lint/nonstandard_style.rs b/src/librustc_lint/nonstandard_style.rs
  268. index 2694a04b94..922c760485 100644
  269. --- a/src/librustc_lint/nonstandard_style.rs
  270. +++ b/src/librustc_lint/nonstandard_style.rs
  271. @@ -211,8 +211,12 @@ impl NonSnakeCase {
  272. } else {
  273. format!("{} `{}` should have a snake case name", sort, name)
  274. };
  275. + // let _migrate_span = MigrateSpan { new: ident.span, old: old_span };
  276. +
  277. match span {
  278. - Some(span) => cx.span_lint(NON_SNAKE_CASE, span, &msg),
  279. + Some(span) => {
  280. + cx.struct_span_lint(NON_SNAKE_CASE, span, &msg).emit();
  281. + }
  282. None => cx.lint(NON_SNAKE_CASE, &msg),
  283. }
  284. }
  285. diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs
  286. index dbbb7f42fe..1b07385d4d 100644
  287. --- a/src/librustc_typeck/check/mod.rs
  288. +++ b/src/librustc_typeck/check/mod.rs
  289. @@ -3366,13 +3366,103 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
  290. let coerce_to_ty = expected.coercion_target_type(self, sp);
  291. let mut coerce: DynamicCoerceMany = CoerceMany::new(coerce_to_ty);
  292.  
  293. - let if_cause = self.cause(sp, ObligationCauseCode::IfExpression);
  294. - coerce.coerce(self, &if_cause, then_expr, then_ty);
  295. + coerce.coerce(self, &self.misc(sp), then_expr, then_ty);
  296.  
  297. if let Some(else_expr) = opt_else_expr {
  298. let else_ty = self.check_expr_with_expectation(else_expr, expected);
  299. let else_diverges = self.diverges.get();
  300.  
  301. + let mut outer_sp = if self.tcx.sess.source_map().is_multiline(sp) {
  302. + // The `if`/`else` isn't in one line in the output, include some context to make it
  303. + // clear it is an if/else expression:
  304. + // ```
  305. + // LL | let x = if true {
  306. + // | _____________-
  307. + // LL || 10i32
  308. + // || ----- expected because of this
  309. + // LL || } else {
  310. + // LL || 10u32
  311. + // || ^^^^^ expected i32, found u32
  312. + // LL || };
  313. + // ||_____- if and else have incompatible types
  314. + // ```
  315. + Some(sp)
  316. + } else {
  317. + // The entire expression is in one line, only point at the arms
  318. + // ```
  319. + // LL | let x = if true { 10i32 } else { 10u32 };
  320. + // | ----- ^^^^^ expected i32, found u32
  321. + // | |
  322. + // | expected because of this
  323. + // ```
  324. + None
  325. + };
  326. + let mut remove_semicolon = None;
  327. + let error_sp = if let ExprKind::Block(block, _) = &else_expr.node {
  328. + if let Some(expr) = &block.expr {
  329. + expr.span
  330. + } else if let Some(stmt) = block.stmts.last() {
  331. + // possibly incorrect trailing `;` in the else arm
  332. + remove_semicolon = self.could_remove_semicolon(block, then_ty);
  333. + stmt.span
  334. + } else { // empty block, point at its entirety
  335. + // Avoid overlapping spans that aren't as readable:
  336. + // ```
  337. + // 2 | let x = if true {
  338. + // | _____________-
  339. + // 3 | | 3
  340. + // | | - expected because of this
  341. + // 4 | | } else {
  342. + // | |____________^
  343. + // 5 | ||
  344. + // 6 | || };
  345. + // | || ^
  346. + // | ||_____|
  347. + // | |______if and else have incompatible types
  348. + // | expected integer, found ()
  349. + // ```
  350. + // by not pointing at the entire expression:
  351. + // ```
  352. + // 2 | let x = if true {
  353. + // | ------- if and else have incompatible types
  354. + // 3 | 3
  355. + // | - expected because of this
  356. + // 4 | } else {
  357. + // | ____________^
  358. + // 5 | |
  359. + // 6 | | };
  360. + // | |_____^ expected integer, found ()
  361. + // ```
  362. + if outer_sp.is_some() {
  363. + outer_sp = Some(self.tcx.sess.source_map().def_span(sp));
  364. + }
  365. + else_expr.span
  366. + }
  367. + } else { // shouldn't happen unless the parser has done something weird
  368. + else_expr.span
  369. + };
  370. + let then_sp = if let ExprKind::Block(block, _) = &then_expr.node {
  371. + if let Some(expr) = &block.expr {
  372. + expr.span
  373. + } else if let Some(stmt) = block.stmts.last() {
  374. + // possibly incorrect trailing `;` in the else arm
  375. + remove_semicolon = remove_semicolon.or(
  376. + self.could_remove_semicolon(block, else_ty));
  377. + stmt.span
  378. + } else { // empty block, point at its entirety
  379. + outer_sp = None; // same as in `error_sp`, cleanup output
  380. + then_expr.span
  381. + }
  382. + } else { // shouldn't happen unless the parser has done something weird
  383. + then_expr.span
  384. + };
  385. +
  386. + let if_cause = self.cause(error_sp, ObligationCauseCode::IfExpression {
  387. + then: then_sp,
  388. + outer: outer_sp,
  389. + semicolon: remove_semicolon,
  390. + });
  391. +
  392. coerce.coerce(self, &if_cause, else_expr, else_ty);
  393.  
  394. // We won't diverge unless both branches do (or the condition does).
  395. @@ -5144,7 +5234,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
  396. }
  397. }
  398.  
  399. -
  400. /// A common error is to add an extra semicolon:
  401. ///
  402. /// ```
  403. @@ -5156,31 +5245,43 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
  404. /// This routine checks if the final statement in a block is an
  405. /// expression with an explicit semicolon whose type is compatible
  406. /// with `expected_ty`. If so, it suggests removing the semicolon.
  407. - fn consider_hint_about_removing_semicolon(&self,
  408. - blk: &'gcx hir::Block,
  409. - expected_ty: Ty<'tcx>,
  410. - err: &mut DiagnosticBuilder) {
  411. + fn consider_hint_about_removing_semicolon(
  412. + &self,
  413. + blk: &'gcx hir::Block,
  414. + expected_ty: Ty<'tcx>,
  415. + err: &mut DiagnosticBuilder,
  416. + ) {
  417. + if let Some(span_semi) = self.could_remove_semicolon(blk, expected_ty) {
  418. + err.span_suggestion_with_applicability(
  419. + span_semi,
  420. + "consider removing this semicolon",
  421. + String::new(),
  422. + Applicability::MachineApplicable,
  423. + );
  424. + }
  425. + }
  426. +
  427. + fn could_remove_semicolon(
  428. + &self,
  429. + blk: &'gcx hir::Block,
  430. + expected_ty: Ty<'tcx>,
  431. + ) -> Option<Span> {
  432. // Be helpful when the user wrote `{... expr;}` and
  433. // taking the `;` off is enough to fix the error.
  434. let last_stmt = match blk.stmts.last() {
  435. Some(s) => s,
  436. - None => return,
  437. + None => return None,
  438. };
  439. let last_expr = match last_stmt.node {
  440. hir::StmtKind::Semi(ref e, _) => e,
  441. - _ => return,
  442. + _ => return None,
  443. };
  444. let last_expr_ty = self.node_ty(last_expr.hir_id);
  445. if self.can_sub(self.param_env, last_expr_ty, expected_ty).is_err() {
  446. - return;
  447. + return None;
  448. }
  449. let original_span = original_sp(last_stmt.span, blk.span);
  450. - let span_semi = original_span.with_lo(original_span.hi() - BytePos(1));
  451. - err.span_suggestion_with_applicability(
  452. - span_semi,
  453. - "consider removing this semicolon",
  454. - String::new(),
  455. - Applicability::MachineApplicable);
  456. + Some(original_span.with_lo(original_span.hi() - BytePos(1)))
  457. }
  458.  
  459. // Instantiates the given path, which must refer to an item with the given
  460. diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs
  461. index 6a41a93f0b..23593f6bac 100644
  462. --- a/src/libsyntax_pos/lib.rs
  463. +++ b/src/libsyntax_pos/lib.rs
  464. @@ -264,6 +264,7 @@ impl Ord for Span {
  465. pub struct MultiSpan {
  466. primary_spans: Vec<Span>,
  467. span_labels: Vec<(Span, String)>,
  468. + old_spans: Vec<Span>,
  469. }
  470.  
  471. impl Span {
  472. @@ -636,21 +637,32 @@ impl MultiSpan {
  473. pub fn new() -> MultiSpan {
  474. MultiSpan {
  475. primary_spans: vec![],
  476. - span_labels: vec![]
  477. + span_labels: vec![],
  478. + old_spans: vec![],
  479. }
  480. }
  481.  
  482. pub fn from_span(primary_span: Span) -> MultiSpan {
  483. MultiSpan {
  484. primary_spans: vec![primary_span],
  485. - span_labels: vec![]
  486. + span_labels: vec![],
  487. + old_spans: vec![],
  488. + }
  489. + }
  490. +
  491. + pub fn from_span_migrating(primary_span: Span, old_span: Span) -> MultiSpan {
  492. + MultiSpan {
  493. + primary_spans: vec![primary_span],
  494. + span_labels: vec![],
  495. + old_spans: vec![old_span],
  496. }
  497. }
  498.  
  499. pub fn from_spans(vec: Vec<Span>) -> MultiSpan {
  500. MultiSpan {
  501. primary_spans: vec,
  502. - span_labels: vec![]
  503. + span_labels: vec![],
  504. + old_spans: vec![],
  505. }
  506. }
  507.  
  508. @@ -668,6 +680,19 @@ impl MultiSpan {
  509. &self.primary_spans
  510. }
  511.  
  512. + /// Returns all primary spans; also includes, when present, any
  513. + /// span that the compiler had previously used in the place of
  514. + /// that primary span.
  515. + pub fn primary_spans_with_migrations(&self) -> impl Iterator<Item=MigrateSpan> {
  516. + let mut vec = Vec::new();
  517. + let mut old_spans = self.old_spans.iter().fuse();
  518. + for &new in &self.primary_spans {
  519. + let old = old_spans.next().map(|&s|s);
  520. + vec.push(MigrateSpan { new, old })
  521. + }
  522. + vec.into_iter()
  523. + }
  524. +
  525. /// Returns `true` if this contains only a dummy primary span with any hygienic context.
  526. pub fn is_dummy(&self) -> bool {
  527. let mut is_dummy = true;
  528. @@ -740,6 +765,22 @@ impl From<Vec<Span>> for MultiSpan {
  529. }
  530. }
  531.  
  532. +// To be fully general, I suppose `old` might need to be a vector
  533. +// instead of a single span (i.e. when we've revised the span of a
  534. +// given lint twice across two stable versions of the compiler). But
  535. +// lets put off that work until we actually find a need for it.
  536. +#[derive(Debug)]
  537. +pub struct MigrateSpan { pub new: Span, pub old: Option<Span> }
  538. +
  539. +impl From<MigrateSpan> for MultiSpan {
  540. + fn from(MigrateSpan { new, old }: MigrateSpan) -> MultiSpan {
  541. + match old {
  542. + Some(old) => MultiSpan::from_span_migrating(new, old),
  543. + None => MultiSpan::from_span(new),
  544. + }
  545. + }
  546. +}
  547. +
  548. pub const NO_EXPANSION: SyntaxContext = SyntaxContext::empty();
  549.  
  550. /// Identifies an offset of a multi-byte character in a `SourceFile`.
  551. diff --git a/src/test/ui/if-else-type-mismatch.rs b/src/test/ui/if-else-type-mismatch.rs
  552. new file mode 100644
  553. index 0000000000..583c3d0b76
  554. --- /dev/null
  555. +++ b/src/test/ui/if-else-type-mismatch.rs
  556. @@ -0,0 +1,46 @@
  557. +fn main() {
  558. + let _ = if true {
  559. + 1i32
  560. + } else {
  561. + 2u32
  562. + };
  563. + //~^^ ERROR if and else have incompatible types
  564. + let _ = if true { 42i32 } else { 42u32 };
  565. + //~^ ERROR if and else have incompatible types
  566. + let _ = if true {
  567. + 3u32;
  568. + } else {
  569. + 4u32
  570. + };
  571. + //~^^ ERROR if and else have incompatible types
  572. + let _ = if true {
  573. + 5u32
  574. + } else {
  575. + 6u32;
  576. + };
  577. + //~^^ ERROR if and else have incompatible types
  578. + let _ = if true {
  579. + 7i32;
  580. + } else {
  581. + 8u32
  582. + };
  583. + //~^^ ERROR if and else have incompatible types
  584. + let _ = if true {
  585. + 9i32
  586. + } else {
  587. + 10u32;
  588. + };
  589. + //~^^ ERROR if and else have incompatible types
  590. + let _ = if true {
  591. +
  592. + } else {
  593. + 11u32
  594. + };
  595. + //~^^ ERROR if and else have incompatible types
  596. + let _ = if true {
  597. + 12i32
  598. + } else {
  599. +
  600. + };
  601. + //~^^^ ERROR if and else have incompatible types
  602. +}
  603. diff --git a/src/test/ui/if-else-type-mismatch.stderr b/src/test/ui/if-else-type-mismatch.stderr
  604. new file mode 100644
  605. index 0000000000..b418c96118
  606. --- /dev/null
  607. +++ b/src/test/ui/if-else-type-mismatch.stderr
  608. @@ -0,0 +1,130 @@
  609. +error[E0308]: if and else have incompatible types
  610. + --> $DIR/if-else-type-mismatch.rs:5:9
  611. + |
  612. +LL | let _ = if true {
  613. + | _____________-
  614. +LL | | 1i32
  615. + | | ---- expected because of this
  616. +LL | | } else {
  617. +LL | | 2u32
  618. + | | ^^^^ expected i32, found u32
  619. +LL | | };
  620. + | |_____- if and else have incompatible types
  621. + |
  622. + = note: expected type `i32`
  623. + found type `u32`
  624. +
  625. +error[E0308]: if and else have incompatible types
  626. + --> $DIR/if-else-type-mismatch.rs:8:38
  627. + |
  628. +LL | let _ = if true { 42i32 } else { 42u32 };
  629. + | ----- ^^^^^ expected i32, found u32
  630. + | |
  631. + | expected because of this
  632. + |
  633. + = note: expected type `i32`
  634. + found type `u32`
  635. +
  636. +error[E0308]: if and else have incompatible types
  637. + --> $DIR/if-else-type-mismatch.rs:13:9
  638. + |
  639. +LL | let _ = if true {
  640. + | _____________-
  641. +LL | | 3u32;
  642. + | | -----
  643. + | | | |
  644. + | | | help: consider removing this semicolon
  645. + | | expected because of this
  646. +LL | | } else {
  647. +LL | | 4u32
  648. + | | ^^^^ expected (), found u32
  649. +LL | | };
  650. + | |_____- if and else have incompatible types
  651. + |
  652. + = note: expected type `()`
  653. + found type `u32`
  654. +
  655. +error[E0308]: if and else have incompatible types
  656. + --> $DIR/if-else-type-mismatch.rs:19:9
  657. + |
  658. +LL | let _ = if true {
  659. + | _____________-
  660. +LL | | 5u32
  661. + | | ---- expected because of this
  662. +LL | | } else {
  663. +LL | | 6u32;
  664. + | | ^^^^-
  665. + | | | |
  666. + | | | help: consider removing this semicolon
  667. + | | expected u32, found ()
  668. +LL | | };
  669. + | |_____- if and else have incompatible types
  670. + |
  671. + = note: expected type `u32`
  672. + found type `()`
  673. +
  674. +error[E0308]: if and else have incompatible types
  675. + --> $DIR/if-else-type-mismatch.rs:25:9
  676. + |
  677. +LL | let _ = if true {
  678. + | _____________-
  679. +LL | | 7i32;
  680. + | | ----- expected because of this
  681. +LL | | } else {
  682. +LL | | 8u32
  683. + | | ^^^^ expected (), found u32
  684. +LL | | };
  685. + | |_____- if and else have incompatible types
  686. + |
  687. + = note: expected type `()`
  688. + found type `u32`
  689. +
  690. +error[E0308]: if and else have incompatible types
  691. + --> $DIR/if-else-type-mismatch.rs:31:9
  692. + |
  693. +LL | let _ = if true {
  694. + | _____________-
  695. +LL | | 9i32
  696. + | | ---- expected because of this
  697. +LL | | } else {
  698. +LL | | 10u32;
  699. + | | ^^^^^^ expected i32, found ()
  700. +LL | | };
  701. + | |_____- if and else have incompatible types
  702. + |
  703. + = note: expected type `i32`
  704. + found type `()`
  705. +
  706. +error[E0308]: if and else have incompatible types
  707. + --> $DIR/if-else-type-mismatch.rs:37:9
  708. + |
  709. +LL | let _ = if true {
  710. + | _____________________-
  711. +LL | |
  712. +LL | | } else {
  713. + | |_____- expected because of this
  714. +LL | 11u32
  715. + | ^^^^^ expected (), found u32
  716. + |
  717. + = note: expected type `()`
  718. + found type `u32`
  719. +
  720. +error[E0308]: if and else have incompatible types
  721. + --> $DIR/if-else-type-mismatch.rs:42:12
  722. + |
  723. +LL | let _ = if true {
  724. + | ------- if and else have incompatible types
  725. +LL | 12i32
  726. + | ----- expected because of this
  727. +LL | } else {
  728. + | ____________^
  729. +LL | |
  730. +LL | | };
  731. + | |_____^ expected i32, found ()
  732. + |
  733. + = note: expected type `i32`
  734. + found type `()`
  735. +
  736. +error: aborting due to 8 previous errors
  737. +
  738. +For more information about this error, try `rustc --explain E0308`.
  739. diff --git a/src/test/ui/if/if-branch-types.stderr b/src/test/ui/if/if-branch-types.stderr
  740. index 44e172da78..74b925f72f 100644
  741. --- a/src/test/ui/if/if-branch-types.stderr
  742. +++ b/src/test/ui/if/if-branch-types.stderr
  743. @@ -1,8 +1,10 @@
  744. error[E0308]: if and else have incompatible types
  745. - --> $DIR/if-branch-types.rs:2:13
  746. + --> $DIR/if-branch-types.rs:2:38
  747. |
  748. LL | let x = if true { 10i32 } else { 10u32 };
  749. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found u32
  750. + | ----- ^^^^^ expected i32, found u32
  751. + | |
  752. + | expected because of this
  753. |
  754. = note: expected type `i32`
  755. found type `u32`
  756. diff --git a/src/test/ui/lint/auxiliary/lints-in-foreign-macros-with-lint-attributes.rs b/src/test/ui/lint/auxiliary/lints-in-foreign-macros-with-lint-attributes.rs
  757. new file mode 100644
  758. index 0000000000..2f115e65f3
  759. --- /dev/null
  760. +++ b/src/test/ui/lint/auxiliary/lints-in-foreign-macros-with-lint-attributes.rs
  761. @@ -0,0 +1,74 @@
  762. +// This file declares a bunch of macros relevant to testing
  763. +// our precise behavior on cases explored as part of issue
  764. +// rust-lang/rust#58502
  765. +//
  766. +// In particular, this file is trying to explore how the
  767. +// lint-attributes (`#[allow(..)]`, `#[deny(..)]`, etc) attached to
  768. +// the context of a macro's definition-site interacts with similar
  769. +// lint-attributes attached to the context of a macro's use-site.
  770. +
  771. +#![crate_type="lib"]
  772. +
  773. +#[macro_export]
  774. +macro_rules! definition_context_silent_on_snakes {
  775. + ($name:ident) => {
  776. + pub fn $name() {}
  777. + };
  778. +}
  779. +
  780. +#[macro_export]
  781. +macro_rules! injecting_allow_nonsnakes {
  782. + ($name:ident) => {
  783. + #[allow(non_snake_case)]
  784. + pub fn $name() {}
  785. + };
  786. +}
  787. +
  788. +#[macro_export]
  789. +macro_rules! injecting_warn_nonsnakes {
  790. + ($name:ident) => {
  791. + #[warn(non_snake_case)]
  792. + pub fn $name() {}
  793. + };
  794. +}
  795. +
  796. +#[macro_export]
  797. +macro_rules! injecting_deny_nonsnakes {
  798. + ($name:ident) => {
  799. + #[deny(non_snake_case)]
  800. + pub fn $name() {}
  801. + };
  802. +}
  803. +
  804. +mod inner_allow {
  805. + #![allow(non_snake_case)]
  806. +
  807. + #[macro_export]
  808. + macro_rules! definition_context_allow_nonsnakes {
  809. + ($name:ident) => {
  810. + pub fn $name() {}
  811. + };
  812. + }
  813. +}
  814. +
  815. +mod inner_warn {
  816. + #![warn(non_snake_case)]
  817. +
  818. + #[macro_export]
  819. + macro_rules! definition_context_warn_nonsnakes {
  820. + ($name:ident) => {
  821. + pub fn $name() {}
  822. + };
  823. + }
  824. +}
  825. +
  826. +mod inner_deny {
  827. + #![warn(non_snake_case)]
  828. +
  829. + #[macro_export]
  830. + macro_rules! definition_context_deny_nonsnakes {
  831. + ($name:ident) => {
  832. + pub fn $name() {}
  833. + };
  834. + }
  835. +}
  836. diff --git a/src/test/ui/lint/issue-58502-lint-attrs-at-def-and-use-sites.rs b/src/test/ui/lint/issue-58502-lint-attrs-at-def-and-use-sites.rs
  837. new file mode 100644
  838. index 0000000000..a239dfc932
  839. --- /dev/null
  840. +++ b/src/test/ui/lint/issue-58502-lint-attrs-at-def-and-use-sites.rs
  841. @@ -0,0 +1,100 @@
  842. +// aux-build:lints-in-foreign-macros-with-lint-attributes.rs
  843. +
  844. +#[macro_use]
  845. +extern crate lints_in_foreign_macros_with_lint_attributes;
  846. +
  847. +definition_context_silent_on_snakes!(DefSilent_UseSilent);
  848. +//~^ WARN should have a snake case name
  849. +
  850. +injecting_allow_nonsnakes!(InjectsAllow_UseSilent); // OK
  851. +injecting_warn_nonsnakes!(InjectsWarn_UseSient);
  852. +//~^ WARN should have a snake case name
  853. +//~| NOTE lint level defined here
  854. +//~| NOTE originates in a macro outside of the current crate
  855. +injecting_deny_nonsnakes!(InjectsDeny_UseSient);
  856. +//~^ ERROR should have a snake case name
  857. +//~| NOTE lint level defined here
  858. +//~| NOTE originates in a macro outside of the current crate
  859. +
  860. +definition_context_allow_nonsnakes!(DefAllow_UseSilent);
  861. +//~^ WARN should have a snake case name
  862. +definition_context_warn_nonsnakes!(DefWarn_UseSilent);
  863. +//~^ WARN should have a snake case name
  864. +definition_context_deny_nonsnakes!(DefDeny_UseSilent);
  865. +//~^ WARN should have a snake case name
  866. +
  867. +mod use_allow {
  868. + #![allow(non_snake_case)]
  869. +
  870. + definition_context_silent_on_snakes!(DefSilent_UseAllow); // OK
  871. +
  872. + injecting_allow_nonsnakes!(InjectsAllow_UseAllow); // OK
  873. + injecting_warn_nonsnakes!(InjectsWarn_UseAllow);
  874. + //~^ WARN should have a snake case name
  875. + //~| NOTE lint level defined here
  876. + //~| NOTE originates in a macro outside of the current crate
  877. + injecting_deny_nonsnakes!(InjectsDeny_UseAllow);
  878. + //~^ ERROR should have a snake case name
  879. + //~| NOTE lint level defined here
  880. + //~| NOTE originates in a macro outside of the current crate
  881. +
  882. + definition_context_allow_nonsnakes!(DefAllow_UseAllow); // OK
  883. + definition_context_warn_nonsnakes!(DefWarn_UseAllow); // OK
  884. + definition_context_deny_nonsnakes!(DefDeny_UseAllow); // OK
  885. +}
  886. +
  887. +mod use_warn {
  888. + #![warn(non_snake_case)]
  889. + //~^ NOTE lint level defined here
  890. +
  891. + definition_context_silent_on_snakes!(DefSilent_UseWarn);
  892. + //~^ WARN should have a snake case name
  893. +
  894. + injecting_allow_nonsnakes!(InjectsAllow_UseWarn); // OK
  895. + injecting_warn_nonsnakes!(InjectsWarn_UseWarn);
  896. + //~^ WARN should have a snake case name
  897. + //~| NOTE lint level defined here
  898. + //~| NOTE originates in a macro outside of the current crate
  899. + injecting_deny_nonsnakes!(InjectsDeny_UseWarn);
  900. + //~^ ERROR should have a snake case name
  901. + //~| NOTE lint level defined here
  902. + //~| NOTE originates in a macro outside of the current crate
  903. +
  904. + definition_context_allow_nonsnakes!(DefAllow_UseWarn);
  905. + //~^ WARN should have a snake case name
  906. + definition_context_warn_nonsnakes!(DefWarn_UseWarn);
  907. + //~^ WARN should have a snake case name
  908. + definition_context_deny_nonsnakes!(DefDeny_UseWarn);
  909. + //~^ WARN should have a snake case name
  910. +}
  911. +
  912. +mod use_deny {
  913. + #![deny(non_snake_case)]
  914. + //~^ NOTE lint level defined here
  915. +
  916. + definition_context_silent_on_snakes!(DefSilent_UseDeny);
  917. + //~^ ERROR should have a snake case name
  918. +
  919. + injecting_allow_nonsnakes!(InjectsAllow_UseDeny); // OK
  920. + injecting_warn_nonsnakes!(InjectsWarn_UseDeny);
  921. + //~^ WARN should have a snake case name
  922. + //~| NOTE lint level defined here
  923. + //~| NOTE originates in a macro outside of the current crate
  924. + injecting_deny_nonsnakes!(InjectsDeny_UseDeny);
  925. + //~^ ERROR should have a snake case name
  926. + //~| NOTE lint level defined here
  927. + //~| NOTE originates in a macro outside of the current crate
  928. +
  929. + definition_context_allow_nonsnakes!(DefAllow_UseDeny);
  930. + //~^ ERROR should have a snake case name
  931. + definition_context_warn_nonsnakes!(DefWarn_UseDeny);
  932. + //~^ ERROR should have a snake case name
  933. + definition_context_deny_nonsnakes!(DefDeny_UseDeny);
  934. + //~^ ERROR should have a snake case name
  935. +}
  936. +
  937. +#[deny(non_snake_case)]
  938. +fn ForcedFailure() { }
  939. +
  940. +fn main() {
  941. +}
  942. diff --git a/src/test/ui/lint/issue-58502-lint-attrs-at-def-and-use-sites.stderr b/src/test/ui/lint/issue-58502-lint-attrs-at-def-and-use-sites.stderr
  943. new file mode 100644
  944. index 0000000000..161ce5e97f
  945. --- /dev/null
  946. +++ b/src/test/ui/lint/issue-58502-lint-attrs-at-def-and-use-sites.stderr
  947. @@ -0,0 +1,191 @@
  948. +warning: function `DefSilent_UseSilent` should have a snake case name
  949. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:6:38
  950. + |
  951. +LL | definition_context_silent_on_snakes!(DefSilent_UseSilent);
  952. + | ^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `def_silent_use_silent`
  953. + |
  954. + = note: #[warn(non_snake_case)] on by default
  955. +
  956. +warning: function `InjectsWarn_UseSient` should have a snake case name
  957. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:10:27
  958. + |
  959. +LL | injecting_warn_nonsnakes!(InjectsWarn_UseSient);
  960. + | ^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `injects_warn_use_sient`
  961. + |
  962. +note: lint level defined here
  963. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:10:1
  964. + |
  965. +LL | injecting_warn_nonsnakes!(InjectsWarn_UseSient);
  966. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  967. + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
  968. +
  969. +error: function `InjectsDeny_UseSient` should have a snake case name
  970. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:14:27
  971. + |
  972. +LL | injecting_deny_nonsnakes!(InjectsDeny_UseSient);
  973. + | ^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `injects_deny_use_sient`
  974. + |
  975. +note: lint level defined here
  976. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:14:1
  977. + |
  978. +LL | injecting_deny_nonsnakes!(InjectsDeny_UseSient);
  979. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  980. + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
  981. +
  982. +warning: function `DefAllow_UseSilent` should have a snake case name
  983. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:19:37
  984. + |
  985. +LL | definition_context_allow_nonsnakes!(DefAllow_UseSilent);
  986. + | ^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `def_allow_use_silent`
  987. +
  988. +warning: function `DefWarn_UseSilent` should have a snake case name
  989. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:21:36
  990. + |
  991. +LL | definition_context_warn_nonsnakes!(DefWarn_UseSilent);
  992. + | ^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `def_warn_use_silent`
  993. +
  994. +warning: function `DefDeny_UseSilent` should have a snake case name
  995. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:23:36
  996. + |
  997. +LL | definition_context_deny_nonsnakes!(DefDeny_UseSilent);
  998. + | ^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `def_deny_use_silent`
  999. +
  1000. +warning: function `InjectsWarn_UseAllow` should have a snake case name
  1001. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:32:31
  1002. + |
  1003. +LL | injecting_warn_nonsnakes!(InjectsWarn_UseAllow);
  1004. + | ^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `injects_warn_use_allow`
  1005. + |
  1006. +note: lint level defined here
  1007. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:32:5
  1008. + |
  1009. +LL | injecting_warn_nonsnakes!(InjectsWarn_UseAllow);
  1010. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1011. + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
  1012. +
  1013. +error: function `InjectsDeny_UseAllow` should have a snake case name
  1014. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:36:31
  1015. + |
  1016. +LL | injecting_deny_nonsnakes!(InjectsDeny_UseAllow);
  1017. + | ^^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `injects_deny_use_allow`
  1018. + |
  1019. +note: lint level defined here
  1020. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:36:5
  1021. + |
  1022. +LL | injecting_deny_nonsnakes!(InjectsDeny_UseAllow);
  1023. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1024. + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
  1025. +
  1026. +warning: function `DefSilent_UseWarn` should have a snake case name
  1027. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:50:42
  1028. + |
  1029. +LL | definition_context_silent_on_snakes!(DefSilent_UseWarn);
  1030. + | ^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `def_silent_use_warn`
  1031. + |
  1032. +note: lint level defined here
  1033. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:47:13
  1034. + |
  1035. +LL | #![warn(non_snake_case)]
  1036. + | ^^^^^^^^^^^^^^
  1037. +
  1038. +warning: function `InjectsWarn_UseWarn` should have a snake case name
  1039. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:54:31
  1040. + |
  1041. +LL | injecting_warn_nonsnakes!(InjectsWarn_UseWarn);
  1042. + | ^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `injects_warn_use_warn`
  1043. + |
  1044. +note: lint level defined here
  1045. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:54:5
  1046. + |
  1047. +LL | injecting_warn_nonsnakes!(InjectsWarn_UseWarn);
  1048. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1049. + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
  1050. +
  1051. +error: function `InjectsDeny_UseWarn` should have a snake case name
  1052. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:58:31
  1053. + |
  1054. +LL | injecting_deny_nonsnakes!(InjectsDeny_UseWarn);
  1055. + | ^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `injects_deny_use_warn`
  1056. + |
  1057. +note: lint level defined here
  1058. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:58:5
  1059. + |
  1060. +LL | injecting_deny_nonsnakes!(InjectsDeny_UseWarn);
  1061. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1062. + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
  1063. +
  1064. +warning: function `DefAllow_UseWarn` should have a snake case name
  1065. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:63:41
  1066. + |
  1067. +LL | definition_context_allow_nonsnakes!(DefAllow_UseWarn);
  1068. + | ^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `def_allow_use_warn`
  1069. +
  1070. +warning: function `DefWarn_UseWarn` should have a snake case name
  1071. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:65:40
  1072. + |
  1073. +LL | definition_context_warn_nonsnakes!(DefWarn_UseWarn);
  1074. + | ^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `def_warn_use_warn`
  1075. +
  1076. +warning: function `DefDeny_UseWarn` should have a snake case name
  1077. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:67:40
  1078. + |
  1079. +LL | definition_context_deny_nonsnakes!(DefDeny_UseWarn);
  1080. + | ^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `def_deny_use_warn`
  1081. +
  1082. +error: function `DefSilent_UseDeny` should have a snake case name
  1083. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:75:42
  1084. + |
  1085. +LL | definition_context_silent_on_snakes!(DefSilent_UseDeny);
  1086. + | ^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `def_silent_use_deny`
  1087. + |
  1088. +note: lint level defined here
  1089. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:72:13
  1090. + |
  1091. +LL | #![deny(non_snake_case)]
  1092. + | ^^^^^^^^^^^^^^
  1093. +
  1094. +warning: function `InjectsWarn_UseDeny` should have a snake case name
  1095. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:79:31
  1096. + |
  1097. +LL | injecting_warn_nonsnakes!(InjectsWarn_UseDeny);
  1098. + | ^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `injects_warn_use_deny`
  1099. + |
  1100. +note: lint level defined here
  1101. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:79:5
  1102. + |
  1103. +LL | injecting_warn_nonsnakes!(InjectsWarn_UseDeny);
  1104. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1105. + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
  1106. +
  1107. +error: function `InjectsDeny_UseDeny` should have a snake case name
  1108. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:83:31
  1109. + |
  1110. +LL | injecting_deny_nonsnakes!(InjectsDeny_UseDeny);
  1111. + | ^^^^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `injects_deny_use_deny`
  1112. + |
  1113. +note: lint level defined here
  1114. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:83:5
  1115. + |
  1116. +LL | injecting_deny_nonsnakes!(InjectsDeny_UseDeny);
  1117. + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  1118. + = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
  1119. +
  1120. +error: function `DefAllow_UseDeny` should have a snake case name
  1121. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:88:41
  1122. + |
  1123. +LL | definition_context_allow_nonsnakes!(DefAllow_UseDeny);
  1124. + | ^^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `def_allow_use_deny`
  1125. +
  1126. +error: function `DefWarn_UseDeny` should have a snake case name
  1127. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:90:40
  1128. + |
  1129. +LL | definition_context_warn_nonsnakes!(DefWarn_UseDeny);
  1130. + | ^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `def_warn_use_deny`
  1131. +
  1132. +error: function `DefDeny_UseDeny` should have a snake case name
  1133. + --> $DIR/issue-58502-lint-attrs-at-def-and-use-sites.rs:92:40
  1134. + |
  1135. +LL | definition_context_deny_nonsnakes!(DefDeny_UseDeny);
  1136. + | ^^^^^^^^^^^^^^^ help: convert the identifier to snake case: `def_deny_use_deny`
  1137. +
  1138. +error: aborting due to 8 previous errors
  1139. \ No newline at end of file
  1140. diff --git a/src/test/ui/regions/region-invariant-static-error-reporting.stderr b/src/test/ui/regions/region-invariant-static-error-reporting.stderr
  1141. index 40a3e7e964..60e70ddcd9 100644
  1142. --- a/src/test/ui/regions/region-invariant-static-error-reporting.stderr
  1143. +++ b/src/test/ui/regions/region-invariant-static-error-reporting.stderr
  1144. @@ -1,13 +1,15 @@
  1145. error[E0308]: if and else have incompatible types
  1146. - --> $DIR/region-invariant-static-error-reporting.rs:14:15
  1147. + --> $DIR/region-invariant-static-error-reporting.rs:17:9
  1148. |
  1149. LL | let bad = if x.is_some() {
  1150. - | _______________^
  1151. + | _______________-
  1152. LL | | x.unwrap()
  1153. + | | ---------- expected because of this
  1154. LL | | } else {
  1155. LL | | mk_static()
  1156. + | | ^^^^^^^^^^^ lifetime mismatch
  1157. LL | | };
  1158. - | |_____^ lifetime mismatch
  1159. + | |_____- if and else have incompatible types
  1160. |
  1161. = note: expected type `Invariant<'a>`
  1162. found type `Invariant<'static>`
  1163. diff --git a/src/test/ui/str/str-array-assignment.stderr b/src/test/ui/str/str-array-assignment.stderr
  1164. index 24d8db481b..87809d212d 100644
  1165. --- a/src/test/ui/str/str-array-assignment.stderr
  1166. +++ b/src/test/ui/str/str-array-assignment.stderr
  1167. @@ -1,8 +1,10 @@
  1168. error[E0308]: if and else have incompatible types
  1169. - --> $DIR/str-array-assignment.rs:3:11
  1170. + --> $DIR/str-array-assignment.rs:3:37
  1171. |
  1172. LL | let t = if true { s[..2] } else { s };
  1173. - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected str, found &str
  1174. + | ------ ^ expected str, found &str
  1175. + | |
  1176. + | expected because of this
  1177. |
  1178. = note: expected type `str`
  1179. found type `&str`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement