From 2953a2fb18ccc5a61aae79cd62a8383f3456c1db Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 26 Jul 2021 14:59:26 +0000 Subject: [PATCH 01/17] Mir borrowck does not generate lifetime variables for 'static lifetimes during opaque type resolution --- .../borrow_check/region_infer/opaque_types.rs | 1 + .../issue-87455-static-lifetime-ice.rs | 73 +++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/test/ui/type-alias-impl-trait/issue-87455-static-lifetime-ice.rs diff --git a/compiler/rustc_mir/src/borrow_check/region_infer/opaque_types.rs b/compiler/rustc_mir/src/borrow_check/region_infer/opaque_types.rs index f2d69255d50ff..e9ab62e1664f9 100644 --- a/compiler/rustc_mir/src/borrow_check/region_infer/opaque_types.rs +++ b/compiler/rustc_mir/src/borrow_check/region_infer/opaque_types.rs @@ -83,6 +83,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { .and_then(|ur_vid| self.definitions[*ur_vid].external_name) .unwrap_or(infcx.tcx.lifetimes.re_root_empty), ty::ReLateBound(..) => region, + ty::ReStatic => region, _ => { infcx.tcx.sess.delay_span_bug( span, diff --git a/src/test/ui/type-alias-impl-trait/issue-87455-static-lifetime-ice.rs b/src/test/ui/type-alias-impl-trait/issue-87455-static-lifetime-ice.rs new file mode 100644 index 0000000000000..80a74eb63a83e --- /dev/null +++ b/src/test/ui/type-alias-impl-trait/issue-87455-static-lifetime-ice.rs @@ -0,0 +1,73 @@ +// check-pass + +use std::error::Error as StdError; +use std::pin::Pin; +use std::task::{Context, Poll}; + +pub trait Stream { + type Item; + fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll>; + fn size_hint(&self) -> (usize, Option) { + (0, None) + } +} + +pub trait TryStream: Stream { + type Ok; + type Error; + + fn try_poll_next( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll>>; +} + +impl TryStream for S +where + S: ?Sized + Stream>, +{ + type Ok = T; + type Error = E; + + fn try_poll_next( + self: Pin<&mut Self>, + cx: &mut Context<'_>, + ) -> Poll>> { + self.poll_next(cx) + } +} + +pub trait ServerSentEvent: Sized + Send + Sync + 'static {} + +impl ServerSentEvent for T {} + +struct SseKeepAlive { + event_stream: S, +} + +struct SseComment(T); + +impl Stream for SseKeepAlive +where + S: TryStream + Send + 'static, + S::Ok: ServerSentEvent, + S::Error: StdError + Send + Sync + 'static, +{ + type Item = Result, ()>; + fn poll_next(self: Pin<&mut Self>, _cx: &mut Context) -> Poll> { + unimplemented!() + } +} + +pub fn keep( + event_stream: S, +) -> impl TryStream + Send + 'static +where + S: TryStream + Send + 'static, + S::Ok: ServerSentEvent + Send, + S::Error: StdError + Send + Sync + 'static, +{ + SseKeepAlive { event_stream } +} + +fn main() {} From 624df182ea20fa64509b21998a8a758b7bd3dd58 Mon Sep 17 00:00:00 2001 From: Kornel Date: Mon, 26 Jul 2021 18:39:59 +0100 Subject: [PATCH 02/17] Track caller of Vec::remove() --- library/alloc/src/vec/mod.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 2b380c444b8ab..58dd0b7ebcc44 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -1372,9 +1372,11 @@ impl Vec { /// assert_eq!(v, [1, 3]); /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[track_caller] pub fn remove(&mut self, index: usize) -> T { #[cold] #[inline(never)] + #[track_caller] fn assert_failed(index: usize, len: usize) -> ! { panic!("removal index (is {}) should be < len (is {})", index, len); } From 886dea2bcdad68cadc13ea84e42df0c94179f79a Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Thu, 22 Jul 2021 14:28:02 -0500 Subject: [PATCH 03/17] Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default --- compiler/rustc_lint_defs/src/builtin.rs | 2 +- library/std/src/macros.rs | 2 +- src/test/ui/hygiene/auxiliary/intercrate.rs | 2 +- src/test/ui/hygiene/hygienic-label-1.rs | 2 +- src/test/ui/hygiene/hygienic-label-1.stderr | 4 ++-- src/test/ui/hygiene/hygienic-label-3.rs | 2 +- src/test/ui/hygiene/hygienic-label-3.stderr | 4 ++-- ...low-semicolon-in-expressions-from-macros.rs | 15 --------------- ...arn-semicolon-in-expressions-from-macros.rs | 16 ++++++++++++++++ ...semicolon-in-expressions-from-macros.stderr | 16 ++++++++++++++++ src/test/ui/macros/macro-context.rs | 2 ++ src/test/ui/macros/macro-context.stderr | 16 +++++++++++++++- .../macros/macro-in-expression-context.fixed | 8 ++++++++ .../ui/macros/macro-in-expression-context.rs | 8 ++++++++ .../macros/macro-in-expression-context.stderr | 18 ++++++++++++++++-- .../ui/proc-macro/nested-nonterminal-tokens.rs | 2 +- 16 files changed, 91 insertions(+), 28 deletions(-) delete mode 100644 src/test/ui/lint/semicolon-in-expressions-from-macros/allow-semicolon-in-expressions-from-macros.rs create mode 100644 src/test/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.rs create mode 100644 src/test/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.stderr diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 5b1cd0bcb3ffe..7195c41eae92e 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -2799,7 +2799,7 @@ declare_lint! { /// [issue #79813]: https://github.com/rust-lang/rust/issues/79813 /// [future-incompatible]: ../index.md#future-incompatible-lints pub SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, - Allow, + Warn, "trailing semicolon in macro body used as expression", @future_incompatible = FutureIncompatibleInfo { reference: "issue #79813 ", diff --git a/library/std/src/macros.rs b/library/std/src/macros.rs index 7afe52a3fd693..676695795badc 100644 --- a/library/std/src/macros.rs +++ b/library/std/src/macros.rs @@ -290,7 +290,7 @@ macro_rules! dbg { // `$val` expression could be a block (`{ .. }`), in which case the `eprintln!` // will be malformed. () => { - $crate::eprintln!("[{}:{}]", $crate::file!(), $crate::line!()); + $crate::eprintln!("[{}:{}]", $crate::file!(), $crate::line!()) }; ($val:expr $(,)?) => { // Use of `match` here is intentional because it affects the lifetimes diff --git a/src/test/ui/hygiene/auxiliary/intercrate.rs b/src/test/ui/hygiene/auxiliary/intercrate.rs index 10d399ba54e71..0685358851edd 100644 --- a/src/test/ui/hygiene/auxiliary/intercrate.rs +++ b/src/test/ui/hygiene/auxiliary/intercrate.rs @@ -5,7 +5,7 @@ pub mod foo { mod bar { fn f() -> u32 { 1 } pub macro m() { - f(); + f() } } } diff --git a/src/test/ui/hygiene/hygienic-label-1.rs b/src/test/ui/hygiene/hygienic-label-1.rs index 66361eec21a52..a06d9255ab5b0 100644 --- a/src/test/ui/hygiene/hygienic-label-1.rs +++ b/src/test/ui/hygiene/hygienic-label-1.rs @@ -3,5 +3,5 @@ macro_rules! foo { } pub fn main() { - 'x: loop { foo!() } + 'x: loop { foo!(); } } diff --git a/src/test/ui/hygiene/hygienic-label-1.stderr b/src/test/ui/hygiene/hygienic-label-1.stderr index 97a7240b9069b..c1ed861836c1c 100644 --- a/src/test/ui/hygiene/hygienic-label-1.stderr +++ b/src/test/ui/hygiene/hygienic-label-1.stderr @@ -4,8 +4,8 @@ error[E0426]: use of undeclared label `'x` LL | () => { break 'x; } | ^^ undeclared label `'x` ... -LL | 'x: loop { foo!() } - | ------ in this macro invocation +LL | 'x: loop { foo!(); } + | ------- in this macro invocation | = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/hygiene/hygienic-label-3.rs b/src/test/ui/hygiene/hygienic-label-3.rs index a81eb84225970..ab0559e1b6a83 100644 --- a/src/test/ui/hygiene/hygienic-label-3.rs +++ b/src/test/ui/hygiene/hygienic-label-3.rs @@ -4,6 +4,6 @@ macro_rules! foo { pub fn main() { 'x: for _ in 0..1 { - foo!() + foo!(); }; } diff --git a/src/test/ui/hygiene/hygienic-label-3.stderr b/src/test/ui/hygiene/hygienic-label-3.stderr index 52840049f825a..29d1b67e09f9b 100644 --- a/src/test/ui/hygiene/hygienic-label-3.stderr +++ b/src/test/ui/hygiene/hygienic-label-3.stderr @@ -4,8 +4,8 @@ error[E0426]: use of undeclared label `'x` LL | () => { break 'x; } | ^^ undeclared label `'x` ... -LL | foo!() - | ------ in this macro invocation +LL | foo!(); + | ------- in this macro invocation | = note: this error originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/src/test/ui/lint/semicolon-in-expressions-from-macros/allow-semicolon-in-expressions-from-macros.rs b/src/test/ui/lint/semicolon-in-expressions-from-macros/allow-semicolon-in-expressions-from-macros.rs deleted file mode 100644 index 6f9e6ec0a57ff..0000000000000 --- a/src/test/ui/lint/semicolon-in-expressions-from-macros/allow-semicolon-in-expressions-from-macros.rs +++ /dev/null @@ -1,15 +0,0 @@ -// check-pass -// Ensure that trailing semicolons are allowed by default - -macro_rules! foo { - () => { - true; - } -} - -fn main() { - let val = match true { - true => false, - _ => foo!() - }; -} diff --git a/src/test/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.rs b/src/test/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.rs new file mode 100644 index 0000000000000..2c63311e65978 --- /dev/null +++ b/src/test/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.rs @@ -0,0 +1,16 @@ +// check-pass +// Ensure that trailing semicolons cause warnings by default + +macro_rules! foo { + () => { + true; //~ WARN trailing semicolon in macro + //~| WARN this was previously + } +} + +fn main() { + let _val = match true { + true => false, + _ => foo!() + }; +} diff --git a/src/test/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.stderr b/src/test/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.stderr new file mode 100644 index 0000000000000..d770a8c8f36e6 --- /dev/null +++ b/src/test/ui/lint/semicolon-in-expressions-from-macros/warn-semicolon-in-expressions-from-macros.stderr @@ -0,0 +1,16 @@ +warning: trailing semicolon in macro used in expression position + --> $DIR/warn-semicolon-in-expressions-from-macros.rs:6:13 + | +LL | true; + | ^ +... +LL | _ => foo!() + | ------ in this macro invocation + | + = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #79813 + = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: 1 warning emitted + diff --git a/src/test/ui/macros/macro-context.rs b/src/test/ui/macros/macro-context.rs index 13e179578ad01..d09fdf118e6f4 100644 --- a/src/test/ui/macros/macro-context.rs +++ b/src/test/ui/macros/macro-context.rs @@ -6,6 +6,8 @@ macro_rules! m { //~| ERROR macro expansion ignores token `;` //~| ERROR cannot find type `i` in this scope //~| ERROR cannot find value `i` in this scope + //~| WARN trailing semicolon in macro + //~| WARN this was previously } fn main() { diff --git a/src/test/ui/macros/macro-context.stderr b/src/test/ui/macros/macro-context.stderr index 5ed73b7fb93a3..3b8a6f1749158 100644 --- a/src/test/ui/macros/macro-context.stderr +++ b/src/test/ui/macros/macro-context.stderr @@ -64,7 +64,21 @@ LL | let i = m!(); | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 6 previous errors +warning: trailing semicolon in macro used in expression position + --> $DIR/macro-context.rs:3:15 + | +LL | () => ( i ; typeof ); + | ^ +... +LL | let i = m!(); + | ---- in this macro invocation + | + = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #79813 + = note: this warning originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 6 previous errors; 1 warning emitted Some errors have detailed explanations: E0412, E0425. For more information about an error, try `rustc --explain E0412`. diff --git a/src/test/ui/macros/macro-in-expression-context.fixed b/src/test/ui/macros/macro-in-expression-context.fixed index df36db0f49e72..3fb4e0dbfa649 100644 --- a/src/test/ui/macros/macro-in-expression-context.fixed +++ b/src/test/ui/macros/macro-in-expression-context.fixed @@ -3,6 +3,10 @@ macro_rules! foo { () => { assert_eq!("A", "A"); + //~^ WARN trailing semicolon in macro + //~| WARN this was previously + //~| NOTE for more information + //~| NOTE `#[warn(semicolon_in_expressions_from_macros)]` on by default assert_eq!("B", "B"); } //~^^ ERROR macro expansion ignores token `assert_eq` and any following @@ -12,4 +16,8 @@ macro_rules! foo { fn main() { foo!(); //~^ NOTE caused by the macro expansion here + //~| NOTE in this expansion + //~| NOTE in this expansion + //~| NOTE in this expansion + //~| NOTE in this expansion } diff --git a/src/test/ui/macros/macro-in-expression-context.rs b/src/test/ui/macros/macro-in-expression-context.rs index b3f5e568967e8..fc434071dcd28 100644 --- a/src/test/ui/macros/macro-in-expression-context.rs +++ b/src/test/ui/macros/macro-in-expression-context.rs @@ -3,6 +3,10 @@ macro_rules! foo { () => { assert_eq!("A", "A"); + //~^ WARN trailing semicolon in macro + //~| WARN this was previously + //~| NOTE for more information + //~| NOTE `#[warn(semicolon_in_expressions_from_macros)]` on by default assert_eq!("B", "B"); } //~^^ ERROR macro expansion ignores token `assert_eq` and any following @@ -12,4 +16,8 @@ macro_rules! foo { fn main() { foo!() //~^ NOTE caused by the macro expansion here + //~| NOTE in this expansion + //~| NOTE in this expansion + //~| NOTE in this expansion + //~| NOTE in this expansion } diff --git a/src/test/ui/macros/macro-in-expression-context.stderr b/src/test/ui/macros/macro-in-expression-context.stderr index d27d6fbaef7a6..ddc1709a27093 100644 --- a/src/test/ui/macros/macro-in-expression-context.stderr +++ b/src/test/ui/macros/macro-in-expression-context.stderr @@ -1,5 +1,5 @@ error: macro expansion ignores token `assert_eq` and any following - --> $DIR/macro-in-expression-context.rs:6:9 + --> $DIR/macro-in-expression-context.rs:10:9 | LL | assert_eq!("B", "B"); | ^^^^^^^^^ @@ -11,5 +11,19 @@ LL | foo!() | = note: the usage of `foo!` is likely invalid in expression context -error: aborting due to previous error +warning: trailing semicolon in macro used in expression position + --> $DIR/macro-in-expression-context.rs:5:29 + | +LL | assert_eq!("A", "A"); + | ^ +... +LL | foo!() + | ------ in this macro invocation + | + = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #79813 + = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error; 1 warning emitted diff --git a/src/test/ui/proc-macro/nested-nonterminal-tokens.rs b/src/test/ui/proc-macro/nested-nonterminal-tokens.rs index 2f5af10a40ac2..04d34e21cdc74 100644 --- a/src/test/ui/proc-macro/nested-nonterminal-tokens.rs +++ b/src/test/ui/proc-macro/nested-nonterminal-tokens.rs @@ -17,7 +17,7 @@ macro_rules! wrap { (first, $e:expr) => { wrap!(second, $e + 1) }; (second, $e:expr) => { wrap!(third, $e + 2) }; (third, $e:expr) => { - print_bang!($e + 3); + print_bang!($e + 3) }; } From cf167c9c9c0576472b67f5498a074bc697c9af23 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Sat, 24 Jul 2021 17:44:57 -0500 Subject: [PATCH 04/17] Only emit lint for local macros --- compiler/rustc_expand/src/mbe/macro_rules.rs | 26 ++++++++++++++----- .../auxiliary/foreign-crate.rs | 4 +++ .../foreign-crate.rs | 9 +++++++ 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 src/test/ui/lint/semicolon-in-expressions-from-macros/auxiliary/foreign-crate.rs create mode 100644 src/test/ui/lint/semicolon-in-expressions-from-macros/foreign-crate.rs diff --git a/compiler/rustc_expand/src/mbe/macro_rules.rs b/compiler/rustc_expand/src/mbe/macro_rules.rs index b97593b92b355..9aee86c9e57dd 100644 --- a/compiler/rustc_expand/src/mbe/macro_rules.rs +++ b/compiler/rustc_expand/src/mbe/macro_rules.rs @@ -45,6 +45,8 @@ crate struct ParserAnyMacro<'a> { lint_node_id: NodeId, is_trailing_mac: bool, arm_span: Span, + /// Whether or not this macro is defined in the current crate + is_local: bool, } crate fn annotate_err_with_kind( @@ -124,6 +126,7 @@ impl<'a> ParserAnyMacro<'a> { lint_node_id, arm_span, is_trailing_mac, + is_local, } = *self; let snapshot = &mut parser.clone(); let fragment = match parse_ast_fragment(parser, kind) { @@ -138,13 +141,15 @@ impl<'a> ParserAnyMacro<'a> { // `macro_rules! m { () => { panic!(); } }` isn't parsed by `.parse_expr()`, // but `m!()` is allowed in expression positions (cf. issue #34706). if kind == AstFragmentKind::Expr && parser.token == token::Semi { - parser.sess.buffer_lint_with_diagnostic( - SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, - parser.token.span, - lint_node_id, - "trailing semicolon in macro used in expression position", - BuiltinLintDiagnostics::TrailingMacro(is_trailing_mac, macro_ident), - ); + if is_local { + parser.sess.buffer_lint_with_diagnostic( + SEMICOLON_IN_EXPRESSIONS_FROM_MACROS, + parser.token.span, + lint_node_id, + "trailing semicolon in macro used in expression position", + BuiltinLintDiagnostics::TrailingMacro(is_trailing_mac, macro_ident), + ); + } parser.bump(); } @@ -162,6 +167,7 @@ struct MacroRulesMacroExpander { lhses: Vec, rhses: Vec, valid: bool, + is_local: bool, } impl TTMacroExpander for MacroRulesMacroExpander { @@ -183,6 +189,7 @@ impl TTMacroExpander for MacroRulesMacroExpander { input, &self.lhses, &self.rhses, + self.is_local, ) } } @@ -210,6 +217,7 @@ fn generic_extension<'cx>( arg: TokenStream, lhses: &[mbe::TokenTree], rhses: &[mbe::TokenTree], + is_local: bool, ) -> Box { let sess = &cx.sess.parse_sess; @@ -311,6 +319,7 @@ fn generic_extension<'cx>( lint_node_id: cx.current_expansion.lint_node_id, is_trailing_mac: cx.current_expansion.is_trailing_mac, arm_span, + is_local, }); } Failure(token, msg) => match best_failure { @@ -544,6 +553,9 @@ pub fn compile_declarative_macro( lhses, rhses, valid, + // Macros defined in the current crate have a real node id, + // whereas macros from an external crate have a dummy id. + is_local: def.id != DUMMY_NODE_ID, })) } diff --git a/src/test/ui/lint/semicolon-in-expressions-from-macros/auxiliary/foreign-crate.rs b/src/test/ui/lint/semicolon-in-expressions-from-macros/auxiliary/foreign-crate.rs new file mode 100644 index 0000000000000..781391cc574a9 --- /dev/null +++ b/src/test/ui/lint/semicolon-in-expressions-from-macros/auxiliary/foreign-crate.rs @@ -0,0 +1,4 @@ +#[macro_export] +macro_rules! my_macro { + () => { true; } +} diff --git a/src/test/ui/lint/semicolon-in-expressions-from-macros/foreign-crate.rs b/src/test/ui/lint/semicolon-in-expressions-from-macros/foreign-crate.rs new file mode 100644 index 0000000000000..374506366f802 --- /dev/null +++ b/src/test/ui/lint/semicolon-in-expressions-from-macros/foreign-crate.rs @@ -0,0 +1,9 @@ +// aux-build:foreign-crate.rs +// check-pass + +extern crate foreign_crate; + +// Test that we do not lint for a macro in a foreign crate +fn main() { + let _ = foreign_crate::my_macro!(); +} From b8eb1f167c6e3271df0797226048d85255434938 Mon Sep 17 00:00:00 2001 From: frogtd <31412003+frogtd@users.noreply.github.com> Date: Tue, 27 Jul 2021 16:02:35 -0400 Subject: [PATCH 05/17] Fix assert in diy_float The shifting should have gone the other way, the current incarnation is always true. --- library/core/src/num/diy_float.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/num/diy_float.rs b/library/core/src/num/diy_float.rs index 0a609417dcf4c..ce7f6475d0599 100644 --- a/library/core/src/num/diy_float.rs +++ b/library/core/src/num/diy_float.rs @@ -65,7 +65,7 @@ impl Fp { f <<= 1; e -= 1; } - debug_assert!(f >= (1 >> 63)); + debug_assert!(f >= (1 << 63)); Fp { f, e } } From 6954f9d4f21837e145b4aa629262a62b5f21fa8f Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Tue, 27 Jul 2021 17:50:18 -0500 Subject: [PATCH 06/17] Update stderr --- src/test/ui/macros/macro-in-expression-context.fixed | 4 ++++ src/test/ui/macros/macro-in-expression-context.rs | 4 ++++ src/test/ui/macros/macro-in-expression-context.stderr | 4 +++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/test/ui/macros/macro-in-expression-context.fixed b/src/test/ui/macros/macro-in-expression-context.fixed index 3fb4e0dbfa649..f22caf2793fd5 100644 --- a/src/test/ui/macros/macro-in-expression-context.fixed +++ b/src/test/ui/macros/macro-in-expression-context.fixed @@ -5,6 +5,8 @@ macro_rules! foo { assert_eq!("A", "A"); //~^ WARN trailing semicolon in macro //~| WARN this was previously + //~| NOTE macro invocations at the end of a block + //~| NOTE to ignore the value produced by the macro //~| NOTE for more information //~| NOTE `#[warn(semicolon_in_expressions_from_macros)]` on by default assert_eq!("B", "B"); @@ -20,4 +22,6 @@ fn main() { //~| NOTE in this expansion //~| NOTE in this expansion //~| NOTE in this expansion + //~| NOTE in this expansion + //~| NOTE in this expansion } diff --git a/src/test/ui/macros/macro-in-expression-context.rs b/src/test/ui/macros/macro-in-expression-context.rs index fc434071dcd28..1a056e582ff47 100644 --- a/src/test/ui/macros/macro-in-expression-context.rs +++ b/src/test/ui/macros/macro-in-expression-context.rs @@ -5,6 +5,8 @@ macro_rules! foo { assert_eq!("A", "A"); //~^ WARN trailing semicolon in macro //~| WARN this was previously + //~| NOTE macro invocations at the end of a block + //~| NOTE to ignore the value produced by the macro //~| NOTE for more information //~| NOTE `#[warn(semicolon_in_expressions_from_macros)]` on by default assert_eq!("B", "B"); @@ -20,4 +22,6 @@ fn main() { //~| NOTE in this expansion //~| NOTE in this expansion //~| NOTE in this expansion + //~| NOTE in this expansion + //~| NOTE in this expansion } diff --git a/src/test/ui/macros/macro-in-expression-context.stderr b/src/test/ui/macros/macro-in-expression-context.stderr index ddc1709a27093..1840babd61dc2 100644 --- a/src/test/ui/macros/macro-in-expression-context.stderr +++ b/src/test/ui/macros/macro-in-expression-context.stderr @@ -1,5 +1,5 @@ error: macro expansion ignores token `assert_eq` and any following - --> $DIR/macro-in-expression-context.rs:10:9 + --> $DIR/macro-in-expression-context.rs:12:9 | LL | assert_eq!("B", "B"); | ^^^^^^^^^ @@ -23,6 +23,8 @@ LL | foo!() = note: `#[warn(semicolon_in_expressions_from_macros)]` on by default = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #79813 + = note: macro invocations at the end of a block are treated as expressions + = note: to ignore the value produced by the macro, add a semicolon after the invocation of `foo` = note: this warning originates in the macro `foo` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error; 1 warning emitted From cd6c0e4e3b71cffd6e577146cbf989ad6ba29c63 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 28 Jul 2021 16:35:57 +0200 Subject: [PATCH 07/17] Fix typo in rustc_driver::version This caused rustc -Zcodegen-backend=foo.so -vV to look for oo.so instead of foo.so --- compiler/rustc_driver/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 326fefa59ab05..50932d498b317 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -766,7 +766,7 @@ pub fn version(binary: &str, matches: &getopts::Matches) { let debug_flags = matches.opt_strs("Z"); let backend_name = debug_flags.iter().find_map(|x| { if x.starts_with("codegen-backend=") { - Some(&x["codegen-backends=".len()..]) + Some(&x["codegen-backend=".len()..]) } else { None } From 9829efb892f7c249f2c889722a098e6a9b34f3fb Mon Sep 17 00:00:00 2001 From: Roxane Date: Wed, 28 Jul 2021 10:35:48 -0400 Subject: [PATCH 08/17] Range PatKind implies discr should be read --- compiler/rustc_typeck/src/expr_use_visitor.rs | 9 ++++++--- .../closures/2229_closure_analysis/issue-87426.rs | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 src/test/ui/closures/2229_closure_analysis/issue-87426.rs diff --git a/compiler/rustc_typeck/src/expr_use_visitor.rs b/compiler/rustc_typeck/src/expr_use_visitor.rs index 6c76a8960bbe1..201804f9fc40b 100644 --- a/compiler/rustc_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_typeck/src/expr_use_visitor.rs @@ -267,12 +267,15 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { } } } - PatKind::Lit(_) => { - // If the PatKind is a Lit then we want + PatKind::Lit(_) | PatKind::Range(..) => { + // If the PatKind is a Lit or a Range then we want // to borrow discr. needs_to_be_read = true; } - _ => {} + _ => { + // If the PatKind is Or, Box, Slice or Ref, the decision is made later + // as these patterns contains subpatterns + } } })); } diff --git a/src/test/ui/closures/2229_closure_analysis/issue-87426.rs b/src/test/ui/closures/2229_closure_analysis/issue-87426.rs new file mode 100644 index 0000000000000..4a6eb5154c136 --- /dev/null +++ b/src/test/ui/closures/2229_closure_analysis/issue-87426.rs @@ -0,0 +1,14 @@ +// run-pass +// edition:2021 + +pub fn foo() { + let ref_x_ck = 123; + let _y = || match ref_x_ck { + 2_000_000..=3_999_999 => { println!("A")} + _ => { println!("B")} + }; +} + +fn main() { + foo(); +} \ No newline at end of file From d380ed13043d52139b3c766a07edb93b891e2be6 Mon Sep 17 00:00:00 2001 From: Roxane Date: Wed, 28 Jul 2021 12:27:57 -0400 Subject: [PATCH 09/17] fix nit --- compiler/rustc_typeck/src/expr_use_visitor.rs | 8 +++++++- src/test/ui/closures/2229_closure_analysis/issue-87426.rs | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_typeck/src/expr_use_visitor.rs b/compiler/rustc_typeck/src/expr_use_visitor.rs index 201804f9fc40b..1d7852d964c1d 100644 --- a/compiler/rustc_typeck/src/expr_use_visitor.rs +++ b/compiler/rustc_typeck/src/expr_use_visitor.rs @@ -272,9 +272,15 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> { // to borrow discr. needs_to_be_read = true; } - _ => { + PatKind::Or(_) + | PatKind::Box(_) + | PatKind::Slice(..) + | PatKind::Ref(..) + | PatKind::Wild => { // If the PatKind is Or, Box, Slice or Ref, the decision is made later // as these patterns contains subpatterns + // If the PatKind is Wild, the decision is made based on the other patterns being + // examined } } })); diff --git a/src/test/ui/closures/2229_closure_analysis/issue-87426.rs b/src/test/ui/closures/2229_closure_analysis/issue-87426.rs index 4a6eb5154c136..74506979a28c5 100644 --- a/src/test/ui/closures/2229_closure_analysis/issue-87426.rs +++ b/src/test/ui/closures/2229_closure_analysis/issue-87426.rs @@ -11,4 +11,4 @@ pub fn foo() { fn main() { foo(); -} \ No newline at end of file +} From cf5e48d944fcc068c7d9b55399684f7e3437628a Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Wed, 28 Jul 2021 17:04:45 -0300 Subject: [PATCH 10/17] min_type_alias_impl_trait is going to be removed in 1.56 --- compiler/rustc_feature/src/removed.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_feature/src/removed.rs b/compiler/rustc_feature/src/removed.rs index 0aa7e82c20492..f63c207a540c2 100644 --- a/compiler/rustc_feature/src/removed.rs +++ b/compiler/rustc_feature/src/removed.rs @@ -153,7 +153,7 @@ declare_features! ( Some("the implementation was not maintainable, the feature may get reintroduced once the current refactorings are done")), /// Allows the use of type alias impl trait in function return positions - (removed, min_type_alias_impl_trait, "1.55.0", Some(63063), None, + (removed, min_type_alias_impl_trait, "1.56.0", Some(63063), None, Some("removed in favor of full type_alias_impl_trait")), // ------------------------------------------------------------------------- From 2f6662da85d47ebf89432c910a496812e9e2db12 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Thu, 29 Jul 2021 11:54:39 +0200 Subject: [PATCH 11/17] Use strip_prefix --- compiler/rustc_driver/src/lib.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/compiler/rustc_driver/src/lib.rs b/compiler/rustc_driver/src/lib.rs index 50932d498b317..84dd69ebd9634 100644 --- a/compiler/rustc_driver/src/lib.rs +++ b/compiler/rustc_driver/src/lib.rs @@ -764,13 +764,7 @@ pub fn version(binary: &str, matches: &getopts::Matches) { println!("release: {}", unw(util::release_str())); let debug_flags = matches.opt_strs("Z"); - let backend_name = debug_flags.iter().find_map(|x| { - if x.starts_with("codegen-backend=") { - Some(&x["codegen-backend=".len()..]) - } else { - None - } - }); + let backend_name = debug_flags.iter().find_map(|x| x.strip_prefix("codegen-backend=")); get_codegen_backend(&None, backend_name).print_version(); } } From a2f3e4a5da2292f2199139d8522ed9b51d485bd4 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 19 Jul 2021 17:00:21 +0200 Subject: [PATCH 12/17] Change span for intra-doc links errors --- .../passes/collect_intra_doc_links.rs | 97 ++++++++++++++----- 1 file changed, 73 insertions(+), 24 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index 21bd3ebd21bc8..ddb7b85d34a04 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -19,7 +19,7 @@ use rustc_resolve::ParentScope; use rustc_session::lint::Lint; use rustc_span::hygiene::{MacroKind, SyntaxContext}; use rustc_span::symbol::{sym, Ident, Symbol}; -use rustc_span::DUMMY_SP; +use rustc_span::{BytePos, DUMMY_SP}; use smallvec::{smallvec, SmallVec}; use pulldown_cmark::LinkType; @@ -1193,7 +1193,7 @@ impl LinkCollector<'_, '_> { let report_mismatch = |specified: Disambiguator, resolved: Disambiguator| { // The resolved item did not match the disambiguator; give a better error than 'not found' let msg = format!("incompatible link kind for `{}`", path_str); - let callback = |diag: &mut DiagnosticBuilder<'_>, sp| { + let callback = |diag: &mut DiagnosticBuilder<'_>, sp: Option| { let note = format!( "this link resolved to {} {}, which is not {} {}", resolved.article(), @@ -1201,8 +1201,12 @@ impl LinkCollector<'_, '_> { specified.article(), specified.descr() ); - diag.note(¬e); - suggest_disambiguator(resolved, diag, path_str, dox, sp, &ori_link.range); + if let Some(sp) = sp { + diag.span_label(sp, ¬e); + } else { + diag.note(¬e); + } + suggest_disambiguator(resolved, diag, path_str, &ori_link.link, sp); }; report_diagnostic(self.cx.tcx, BROKEN_INTRA_DOC_LINKS, &msg, &diag_info, callback); }; @@ -1699,6 +1703,51 @@ impl Suggestion { Self::RemoveDisambiguator => path_str.into(), } } + + fn as_help_span( + &self, + path_str: &str, + ori_link: &str, + sp: rustc_span::Span, + ) -> Vec<(rustc_span::Span, String)> { + let inner_sp = match ori_link.find('(') { + Some(index) => sp.with_hi(sp.lo() + BytePos(index as _)), + None => sp, + }; + let inner_sp = match ori_link.find('!') { + Some(index) => inner_sp.with_hi(inner_sp.lo() + BytePos(index as _)), + None => inner_sp, + }; + let inner_sp = match ori_link.find('@') { + Some(index) => inner_sp.with_lo(inner_sp.lo() + BytePos(index as u32 + 1)), + None => inner_sp, + }; + match self { + Self::Prefix(prefix) => { + // FIXME: if this is an implied shortcut link, it's bad style to suggest `@` + let mut sugg = vec![(sp.with_hi(inner_sp.lo()), format!("{}@", prefix))]; + if sp.hi() != inner_sp.hi() { + sugg.push((inner_sp.shrink_to_hi().with_hi(sp.hi()), String::new())); + } + sugg + } + Self::Function => { + let mut sugg = vec![(inner_sp.shrink_to_hi().with_hi(sp.hi()), "()".to_string())]; + if sp.lo() != inner_sp.lo() { + sugg.push((inner_sp.shrink_to_lo().with_lo(sp.lo()), String::new())); + } + sugg + } + Self::Macro => { + let mut sugg = vec![(inner_sp.shrink_to_hi(), "!".to_string())]; + if sp.lo() != inner_sp.lo() { + sugg.push((inner_sp.shrink_to_lo().with_lo(sp.lo()), String::new())); + } + sugg + } + Self::RemoveDisambiguator => return vec![(sp, path_str.into())], + } + } } /// Reports a diagnostic for an intra-doc link. @@ -1732,7 +1781,16 @@ fn report_diagnostic( tcx.struct_span_lint_hir(lint, hir_id, sp, |lint| { let mut diag = lint.build(msg); - let span = super::source_span_for_markdown_range(tcx, dox, link_range, &item.attrs); + let span = + super::source_span_for_markdown_range(tcx, dox, link_range, &item.attrs).map(|sp| { + if dox.bytes().nth(link_range.start) == Some(b'`') + && dox.bytes().nth(link_range.end - 1) == Some(b'`') + { + sp.with_lo(sp.lo() + BytePos(1)).with_hi(sp.hi() - BytePos(1)) + } else { + sp + } + }); if let Some(sp) = span { diag.set_span(sp); @@ -1938,9 +1996,8 @@ fn resolution_failure( disambiguator, diag, path_str, - diag_info.dox, + diag_info.ori_link, sp, - &diag_info.link_range, ) } @@ -2007,7 +2064,7 @@ fn anchor_failure(cx: &DocContext<'_>, diag_info: DiagnosticInfo<'_>, failure: A if let Some((fragment_offset, _)) = diag_info.ori_link.char_indices().filter(|(_, x)| *x == '#').nth(anchor_idx) { - sp = sp.with_lo(sp.lo() + rustc_span::BytePos(fragment_offset as _)); + sp = sp.with_lo(sp.lo() + BytePos(fragment_offset as _)); } diag.span_label(sp, "invalid anchor"); } @@ -2075,14 +2132,7 @@ fn ambiguity_error( for res in candidates { let disambiguator = Disambiguator::from_res(res); - suggest_disambiguator( - disambiguator, - diag, - path_str, - diag_info.dox, - sp, - &diag_info.link_range, - ); + suggest_disambiguator(disambiguator, diag, path_str, diag_info.ori_link, sp); } }); } @@ -2093,21 +2143,20 @@ fn suggest_disambiguator( disambiguator: Disambiguator, diag: &mut DiagnosticBuilder<'_>, path_str: &str, - dox: &str, + ori_link: &str, sp: Option, - link_range: &Range, ) { let suggestion = disambiguator.suggestion(); let help = format!("to link to the {}, {}", disambiguator.descr(), suggestion.descr()); if let Some(sp) = sp { - let msg = if dox.bytes().nth(link_range.start) == Some(b'`') { - format!("`{}`", suggestion.as_help(path_str)) + let mut spans = suggestion.as_help_span(path_str, ori_link, sp); + if spans.len() > 1 { + diag.multipart_suggestion(&help, spans, Applicability::MaybeIncorrect); } else { - suggestion.as_help(path_str) - }; - - diag.span_suggestion(sp, &help, msg, Applicability::MaybeIncorrect); + let (sp, suggestion_text) = spans.pop().unwrap(); + diag.span_suggestion_verbose(sp, &help, suggestion_text, Applicability::MaybeIncorrect); + } } else { diag.help(&format!("{}: {}", help, suggestion.as_help(path_str))); } From cbba940daf73abf9dc26e1f270bd1095aea7b9a3 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 1 Jun 2021 16:30:13 +0100 Subject: [PATCH 13/17] BufWriter: actually export WriterPanicked error I didn't notice the submodule, which means I failed to re-export this to make it actually-public. Reported-by: Andrew Gallant Signed-off-by: Ian Jackson --- library/std/src/io/buffered/mod.rs | 2 ++ library/std/src/io/mod.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/library/std/src/io/buffered/mod.rs b/library/std/src/io/buffered/mod.rs index 38076ab3a2b7b..896c7b8684f86 100644 --- a/library/std/src/io/buffered/mod.rs +++ b/library/std/src/io/buffered/mod.rs @@ -14,6 +14,8 @@ use crate::io::Error; pub use bufreader::BufReader; pub use bufwriter::BufWriter; +#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")] +pub use bufwriter::WriterPanicked; pub use linewriter::LineWriter; use linewritershim::LineWriterShim; diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index cc615b95f8625..dec8251ee0158 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -264,6 +264,8 @@ use crate::sys_common::memchr; #[stable(feature = "rust1", since = "1.0.0")] pub use self::buffered::IntoInnerError; +#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")] +pub use self::buffered::WriterPanicked; #[stable(feature = "rust1", since = "1.0.0")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; #[stable(feature = "rust1", since = "1.0.0")] From 66f38075aff7d168795544638893d87217defe64 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 1 Jun 2021 16:47:26 +0100 Subject: [PATCH 14/17] BufWriter: rename `into_parts` from `into_raw_parts` I looked in stdlib and as @BurntSushi thought, `raw` is generally used for raw pointers, or other hazardous kinds of thing. stdlib does not have `into_parts` apart from the one I added to `IntoInnerError`. I did an ad-hoc search of the rustdocs for my current game project Otter, which includes quite a large number of dependencies. `into_parts` seems heavily used for things quite like this. So change this name. Suggested-by: Andrew Gallant Signed-off-by: Ian Jackson --- library/std/src/io/buffered/bufwriter.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/std/src/io/buffered/bufwriter.rs b/library/std/src/io/buffered/bufwriter.rs index c98244132befd..88eec8dff9ecc 100644 --- a/library/std/src/io/buffered/bufwriter.rs +++ b/library/std/src/io/buffered/bufwriter.rs @@ -307,7 +307,7 @@ impl BufWriter { pub fn into_inner(mut self) -> Result>> { match self.flush_buf() { Err(e) => Err(IntoInnerError::new(self, e)), - Ok(()) => Ok(self.into_raw_parts().0), + Ok(()) => Ok(self.into_parts().0), } } @@ -318,7 +318,7 @@ impl BufWriter { /// In this case, we return `WriterPanicked` for the buffered data (from which the buffer /// contents can still be recovered). /// - /// `into_raw_parts` makes no attempt to flush data and cannot fail. + /// `into_parts` makes no attempt to flush data and cannot fail. /// /// # Examples /// @@ -330,12 +330,12 @@ impl BufWriter { /// let mut stream = BufWriter::new(buffer.as_mut()); /// write!(stream, "too much data").unwrap(); /// stream.flush().expect_err("it doesn't fit"); - /// let (recovered_writer, buffered_data) = stream.into_raw_parts(); + /// let (recovered_writer, buffered_data) = stream.into_parts(); /// assert_eq!(recovered_writer.len(), 0); /// assert_eq!(&buffered_data.unwrap(), b"ata"); /// ``` #[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")] - pub fn into_raw_parts(mut self) -> (W, Result, WriterPanicked>) { + pub fn into_parts(mut self) -> (W, Result, WriterPanicked>) { let buf = mem::take(&mut self.buf); let buf = if !self.panicked { Ok(buf) } else { Err(WriterPanicked { buf }) }; @@ -445,7 +445,7 @@ impl BufWriter { } #[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")] -/// Error returned for the buffered data from `BufWriter::into_raw_parts`, when the underlying +/// Error returned for the buffered data from `BufWriter::into_parts`, when the underlying /// writer has previously panicked. Contains the (possibly partly written) buffered data. /// /// # Example @@ -467,7 +467,7 @@ impl BufWriter { /// stream.flush().unwrap() /// })); /// assert!(result.is_err()); -/// let (recovered_writer, buffered_data) = stream.into_raw_parts(); +/// let (recovered_writer, buffered_data) = stream.into_parts(); /// assert!(matches!(recovered_writer, PanickingWriter)); /// assert_eq!(buffered_data.unwrap_err().into_inner(), b"some data"); /// ``` From bf30c51541c533830ec46ae65d9863666055a74b Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 19 Jul 2021 17:33:55 +0100 Subject: [PATCH 15/17] Rename feature gate bufwriter_into_parts from bufwriter_into_raw_parts As requested https://github.com/rust-lang/rust/pull/85901#pullrequestreview-698404772 Signed-off-by: Ian Jackson --- library/std/src/io/buffered/bufwriter.rs | 16 ++++++++-------- library/std/src/io/buffered/mod.rs | 2 +- library/std/src/io/mod.rs | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/library/std/src/io/buffered/bufwriter.rs b/library/std/src/io/buffered/bufwriter.rs index 88eec8dff9ecc..9da5fbff9cf02 100644 --- a/library/std/src/io/buffered/bufwriter.rs +++ b/library/std/src/io/buffered/bufwriter.rs @@ -323,7 +323,7 @@ impl BufWriter { /// # Examples /// /// ``` - /// #![feature(bufwriter_into_raw_parts)] + /// #![feature(bufwriter_into_parts)] /// use std::io::{BufWriter, Write}; /// /// let mut buffer = [0u8; 10]; @@ -334,7 +334,7 @@ impl BufWriter { /// assert_eq!(recovered_writer.len(), 0); /// assert_eq!(&buffered_data.unwrap(), b"ata"); /// ``` - #[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")] + #[unstable(feature = "bufwriter_into_parts", issue = "80690")] pub fn into_parts(mut self) -> (W, Result, WriterPanicked>) { let buf = mem::take(&mut self.buf); let buf = if !self.panicked { Ok(buf) } else { Err(WriterPanicked { buf }) }; @@ -444,14 +444,14 @@ impl BufWriter { } } -#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")] +#[unstable(feature = "bufwriter_into_parts", issue = "80690")] /// Error returned for the buffered data from `BufWriter::into_parts`, when the underlying /// writer has previously panicked. Contains the (possibly partly written) buffered data. /// /// # Example /// /// ``` -/// #![feature(bufwriter_into_raw_parts)] +/// #![feature(bufwriter_into_parts)] /// use std::io::{self, BufWriter, Write}; /// use std::panic::{catch_unwind, AssertUnwindSafe}; /// @@ -478,7 +478,7 @@ pub struct WriterPanicked { impl WriterPanicked { /// Returns the perhaps-unwritten data. Some of this data may have been written by the /// panicking call(s) to the underlying writer, so simply writing it again is not a good idea. - #[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")] + #[unstable(feature = "bufwriter_into_parts", issue = "80690")] pub fn into_inner(self) -> Vec { self.buf } @@ -487,7 +487,7 @@ impl WriterPanicked { "BufWriter inner writer panicked, what data remains unwritten is not known"; } -#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")] +#[unstable(feature = "bufwriter_into_parts", issue = "80690")] impl error::Error for WriterPanicked { #[allow(deprecated, deprecated_in_future)] fn description(&self) -> &str { @@ -495,14 +495,14 @@ impl error::Error for WriterPanicked { } } -#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")] +#[unstable(feature = "bufwriter_into_parts", issue = "80690")] impl fmt::Display for WriterPanicked { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", Self::DESCRIPTION) } } -#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")] +#[unstable(feature = "bufwriter_into_parts", issue = "80690")] impl fmt::Debug for WriterPanicked { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("WriterPanicked") diff --git a/library/std/src/io/buffered/mod.rs b/library/std/src/io/buffered/mod.rs index 896c7b8684f86..8cfffc2fd35a4 100644 --- a/library/std/src/io/buffered/mod.rs +++ b/library/std/src/io/buffered/mod.rs @@ -14,7 +14,7 @@ use crate::io::Error; pub use bufreader::BufReader; pub use bufwriter::BufWriter; -#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")] +#[unstable(feature = "bufwriter_into_parts", issue = "80690")] pub use bufwriter::WriterPanicked; pub use linewriter::LineWriter; use linewritershim::LineWriterShim; diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index dec8251ee0158..c58abf2a737a3 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -264,7 +264,7 @@ use crate::sys_common::memchr; #[stable(feature = "rust1", since = "1.0.0")] pub use self::buffered::IntoInnerError; -#[unstable(feature = "bufwriter_into_raw_parts", issue = "80690")] +#[unstable(feature = "bufwriter_into_parts", issue = "80690")] pub use self::buffered::WriterPanicked; #[stable(feature = "rust1", since = "1.0.0")] pub use self::buffered::{BufReader, BufWriter, LineWriter}; From e70ce57f306c730c7a949942671cd525e281f2ec Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Thu, 29 Jul 2021 09:52:35 -0500 Subject: [PATCH 16/17] Remove unnecessary trailing semicolons from clippy tests --- src/tools/clippy/tests/ui/needless_borrow_pat.rs | 2 +- src/tools/clippy/tests/ui/ref_binding_to_reference.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/clippy/tests/ui/needless_borrow_pat.rs b/src/tools/clippy/tests/ui/needless_borrow_pat.rs index f0926220755a2..7a8137778b446 100644 --- a/src/tools/clippy/tests/ui/needless_borrow_pat.rs +++ b/src/tools/clippy/tests/ui/needless_borrow_pat.rs @@ -7,7 +7,7 @@ fn f1(_: &str) {} macro_rules! m1 { ($e:expr) => { - f1($e); + f1($e) }; } macro_rules! m3 { diff --git a/src/tools/clippy/tests/ui/ref_binding_to_reference.rs b/src/tools/clippy/tests/ui/ref_binding_to_reference.rs index c7235e1c22105..cd6db8ddc8864 100644 --- a/src/tools/clippy/tests/ui/ref_binding_to_reference.rs +++ b/src/tools/clippy/tests/ui/ref_binding_to_reference.rs @@ -7,7 +7,7 @@ fn f1(_: &str) {} macro_rules! m2 { ($e:expr) => { - f1(*$e); + f1(*$e) }; } macro_rules! m3 { From 0f7f85ede9e816c01f9b0696b6113f2b4fad0d02 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 19 Jul 2021 17:00:35 +0200 Subject: [PATCH 17/17] Update rustdoc-ui tests for intra-doc links errors --- .../rustdoc-ui/assoc-item-not-in-scope.stderr | 4 +- .../rustdoc-ui/intra-doc/ambiguity.stderr | 38 +++--- .../intra-doc/disambiguator-mismatch.rs | 8 ++ .../intra-doc/disambiguator-mismatch.stderr | 112 ++++++++++++------ src/test/rustdoc-ui/intra-doc/errors.stderr | 50 ++++---- .../rustdoc-ui/intra-doc/field-ice.stderr | 9 +- ...ncompatible-primitive-disambiguator.stderr | 7 +- .../rustdoc-ui/intra-doc/prim-conflict.stderr | 22 ++-- .../rustdoc-ui/issue-74134.private.stderr | 4 +- src/test/rustdoc-ui/issue-74134.public.stderr | 4 +- 10 files changed, 166 insertions(+), 92 deletions(-) diff --git a/src/test/rustdoc-ui/assoc-item-not-in-scope.stderr b/src/test/rustdoc-ui/assoc-item-not-in-scope.stderr index 358871b532313..04594ad414250 100644 --- a/src/test/rustdoc-ui/assoc-item-not-in-scope.stderr +++ b/src/test/rustdoc-ui/assoc-item-not-in-scope.stderr @@ -1,8 +1,8 @@ error: unresolved link to `S::fmt` - --> $DIR/assoc-item-not-in-scope.rs:4:14 + --> $DIR/assoc-item-not-in-scope.rs:4:15 | LL | /// Link to [`S::fmt`] - | ^^^^^^^^ the struct `S` has no field or associated item named `fmt` + | ^^^^^^ the struct `S` has no field or associated item named `fmt` | note: the lint level is defined here --> $DIR/assoc-item-not-in-scope.rs:1:9 diff --git a/src/test/rustdoc-ui/intra-doc/ambiguity.stderr b/src/test/rustdoc-ui/intra-doc/ambiguity.stderr index 0f23b9b8adf67..e87c26e9cc5b0 100644 --- a/src/test/rustdoc-ui/intra-doc/ambiguity.stderr +++ b/src/test/rustdoc-ui/intra-doc/ambiguity.stderr @@ -12,26 +12,26 @@ LL | #![deny(rustdoc::broken_intra_doc_links)] help: to link to the module, prefix with `mod@` | LL | /// [mod@true] - | ^^^^^^^^ + | ^^^^ help: to link to the builtin type, prefix with `prim@` | LL | /// [prim@true] - | ^^^^^^^^^ + | ^^^^^ error: `ambiguous` is both a struct and a function - --> $DIR/ambiguity.rs:27:6 + --> $DIR/ambiguity.rs:27:7 | LL | /// [`ambiguous`] is ambiguous. - | ^^^^^^^^^^^ ambiguous link + | ^^^^^^^^^ ambiguous link | help: to link to the struct, prefix with `struct@` | LL | /// [`struct@ambiguous`] is ambiguous. - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ help: to link to the function, add parentheses | LL | /// [`ambiguous()`] is ambiguous. - | ^^^^^^^^^^^^^ + | ^^ error: `ambiguous` is both a struct and a function --> $DIR/ambiguity.rs:29:6 @@ -42,30 +42,30 @@ LL | /// [ambiguous] is ambiguous. help: to link to the struct, prefix with `struct@` | LL | /// [struct@ambiguous] is ambiguous. - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^ help: to link to the function, add parentheses | LL | /// [ambiguous()] is ambiguous. - | ^^^^^^^^^^^ + | ^^ error: `multi_conflict` is a struct, a function, and a macro - --> $DIR/ambiguity.rs:31:6 + --> $DIR/ambiguity.rs:31:7 | LL | /// [`multi_conflict`] is a three-way conflict. - | ^^^^^^^^^^^^^^^^ ambiguous link + | ^^^^^^^^^^^^^^ ambiguous link | help: to link to the struct, prefix with `struct@` | LL | /// [`struct@multi_conflict`] is a three-way conflict. - | ^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^ help: to link to the function, add parentheses | LL | /// [`multi_conflict()`] is a three-way conflict. - | ^^^^^^^^^^^^^^^^^^ + | ^^ help: to link to the macro, add an exclamation mark | LL | /// [`multi_conflict!`] is a three-way conflict. - | ^^^^^^^^^^^^^^^^^ + | ^ error: `type_and_value` is both a module and a constant --> $DIR/ambiguity.rs:33:16 @@ -76,26 +76,26 @@ LL | /// Ambiguous [type_and_value]. help: to link to the module, prefix with `mod@` | LL | /// Ambiguous [mod@type_and_value]. - | ^^^^^^^^^^^^^^^^^^ + | ^^^^ help: to link to the constant, prefix with `const@` | LL | /// Ambiguous [const@type_and_value]. - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^ error: `foo::bar` is both an enum and a function - --> $DIR/ambiguity.rs:35:42 + --> $DIR/ambiguity.rs:35:43 | LL | /// Ambiguous non-implied shortcut link [`foo::bar`]. - | ^^^^^^^^^^ ambiguous link + | ^^^^^^^^ ambiguous link | help: to link to the enum, prefix with `enum@` | LL | /// Ambiguous non-implied shortcut link [`enum@foo::bar`]. - | ^^^^^^^^^^^^^^^ + | ^^^^^ help: to link to the function, add parentheses | LL | /// Ambiguous non-implied shortcut link [`foo::bar()`]. - | ^^^^^^^^^^^^ + | ^^ error: aborting due to 6 previous errors diff --git a/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.rs b/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.rs index 596623190a33f..142008cf76508 100644 --- a/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.rs +++ b/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.rs @@ -1,7 +1,9 @@ #![deny(rustdoc::broken_intra_doc_links)] //~^ NOTE lint level is defined pub enum S {} +fn S() {} +#[macro_export] macro_rules! m { () => {}; } @@ -41,6 +43,12 @@ trait T {} //~| NOTE this link resolved //~| HELP add an exclamation mark +/// Link to [m()] +//~^ ERROR unresolved link to `m` +//~| NOTE this link resolves to the macro `m` +//~| HELP add an exclamation mark +/// and to [m!()] + /// Link to [const@s] //~^ ERROR incompatible link kind for `s` //~| NOTE this link resolved diff --git a/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr b/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr index 5d4d4a699e4f3..8d1519516ee76 100644 --- a/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr +++ b/src/test/rustdoc-ui/intra-doc/disambiguator-mismatch.stderr @@ -1,95 +1,139 @@ error: incompatible link kind for `S` - --> $DIR/disambiguator-mismatch.rs:14:14 + --> $DIR/disambiguator-mismatch.rs:16:14 | LL | /// Link to [struct@S] - | ^^^^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S` + | ^^^^^^^^ this link resolved to an enum, which is not a struct | note: the lint level is defined here --> $DIR/disambiguator-mismatch.rs:1:9 | LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this link resolved to an enum, which is not a struct +help: to link to the enum, prefix with `enum@` + | +LL | /// Link to [enum@S] + | ^^^^^ error: incompatible link kind for `S` - --> $DIR/disambiguator-mismatch.rs:19:14 + --> $DIR/disambiguator-mismatch.rs:21:14 | LL | /// Link to [mod@S] - | ^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S` + | ^^^^^ this link resolved to an enum, which is not a module + | +help: to link to the enum, prefix with `enum@` | - = note: this link resolved to an enum, which is not a module +LL | /// Link to [enum@S] + | ^^^^^ error: incompatible link kind for `S` - --> $DIR/disambiguator-mismatch.rs:24:14 + --> $DIR/disambiguator-mismatch.rs:26:14 | LL | /// Link to [union@S] - | ^^^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S` + | ^^^^^^^ this link resolved to an enum, which is not a union | - = note: this link resolved to an enum, which is not a union +help: to link to the enum, prefix with `enum@` + | +LL | /// Link to [enum@S] + | ^^^^^ error: incompatible link kind for `S` - --> $DIR/disambiguator-mismatch.rs:29:14 + --> $DIR/disambiguator-mismatch.rs:31:14 | LL | /// Link to [trait@S] - | ^^^^^^^ help: to link to the enum, prefix with `enum@`: `enum@S` + | ^^^^^^^ this link resolved to an enum, which is not a trait + | +help: to link to the enum, prefix with `enum@` | - = note: this link resolved to an enum, which is not a trait +LL | /// Link to [enum@S] + | ^^^^^ error: incompatible link kind for `T` - --> $DIR/disambiguator-mismatch.rs:34:14 + --> $DIR/disambiguator-mismatch.rs:36:14 | LL | /// Link to [struct@T] - | ^^^^^^^^ help: to link to the trait, prefix with `trait@`: `trait@T` + | ^^^^^^^^ this link resolved to a trait, which is not a struct | - = note: this link resolved to a trait, which is not a struct +help: to link to the trait, prefix with `trait@` + | +LL | /// Link to [trait@T] + | ^^^^^^ error: incompatible link kind for `m` - --> $DIR/disambiguator-mismatch.rs:39:14 + --> $DIR/disambiguator-mismatch.rs:41:14 | LL | /// Link to [derive@m] - | ^^^^^^^^ help: to link to the macro, add an exclamation mark: `m!` + | ^^^^^^^^ this link resolved to a macro, which is not a derive macro + | +help: to link to the macro, add an exclamation mark | - = note: this link resolved to a macro, which is not a derive macro +LL | /// Link to [m!] + | --^ + +error: unresolved link to `m` + --> $DIR/disambiguator-mismatch.rs:46:14 + | +LL | /// Link to [m()] + | ^^^ this link resolves to the macro `m`, which is not in the value namespace + | +help: to link to the macro, add an exclamation mark + | +LL | /// Link to [m!()] + | ^ error: incompatible link kind for `s` - --> $DIR/disambiguator-mismatch.rs:44:14 + --> $DIR/disambiguator-mismatch.rs:52:14 | LL | /// Link to [const@s] - | ^^^^^^^ help: to link to the static, prefix with `static@`: `static@s` + | ^^^^^^^ this link resolved to a static, which is not a constant | - = note: this link resolved to a static, which is not a constant +help: to link to the static, prefix with `static@` + | +LL | /// Link to [static@s] + | ^^^^^^^ error: incompatible link kind for `c` - --> $DIR/disambiguator-mismatch.rs:49:14 + --> $DIR/disambiguator-mismatch.rs:57:14 | LL | /// Link to [static@c] - | ^^^^^^^^ help: to link to the constant, prefix with `const@`: `const@c` + | ^^^^^^^^ this link resolved to a constant, which is not a static + | +help: to link to the constant, prefix with `const@` | - = note: this link resolved to a constant, which is not a static +LL | /// Link to [const@c] + | ^^^^^^ error: incompatible link kind for `c` - --> $DIR/disambiguator-mismatch.rs:54:14 + --> $DIR/disambiguator-mismatch.rs:62:14 | LL | /// Link to [fn@c] - | ^^^^ help: to link to the constant, prefix with `const@`: `const@c` + | ^^^^ this link resolved to a constant, which is not a function | - = note: this link resolved to a constant, which is not a function +help: to link to the constant, prefix with `const@` + | +LL | /// Link to [const@c] + | ^^^^^^ error: incompatible link kind for `c` - --> $DIR/disambiguator-mismatch.rs:59:14 + --> $DIR/disambiguator-mismatch.rs:67:14 | LL | /// Link to [c()] - | ^^^ help: to link to the constant, prefix with `const@`: `const@c` + | ^^^ this link resolved to a constant, which is not a function + | +help: to link to the constant, prefix with `const@` | - = note: this link resolved to a constant, which is not a function +LL | /// Link to [const@c] + | ^^^^^^-- error: incompatible link kind for `f` - --> $DIR/disambiguator-mismatch.rs:64:14 + --> $DIR/disambiguator-mismatch.rs:72:14 | LL | /// Link to [const@f] - | ^^^^^^^ help: to link to the function, add parentheses: `f()` + | ^^^^^^^ this link resolved to a function, which is not a constant + | +help: to link to the function, add parentheses | - = note: this link resolved to a function, which is not a constant +LL | /// Link to [f()] + | --^^ -error: aborting due to 11 previous errors +error: aborting due to 12 previous errors diff --git a/src/test/rustdoc-ui/intra-doc/errors.stderr b/src/test/rustdoc-ui/intra-doc/errors.stderr index 061151720578b..87d107b9c573b 100644 --- a/src/test/rustdoc-ui/intra-doc/errors.stderr +++ b/src/test/rustdoc-ui/intra-doc/errors.stderr @@ -92,37 +92,45 @@ error: unresolved link to `Vec::into_iter` --> $DIR/errors.rs:63:6 | LL | /// [type@Vec::into_iter] - | ^^^^^^^^^^^^^^^^^^^ - | | - | this link resolves to the associated function `into_iter`, which is not in the type namespace - | help: to link to the associated function, add parentheses: `Vec::into_iter()` + | ^^^^^^^^^^^^^^^^^^^ this link resolves to the associated function `into_iter`, which is not in the type namespace + | +help: to link to the associated function, add parentheses + | +LL | /// [Vec::into_iter()] + | -- ^^ error: unresolved link to `S` --> $DIR/errors.rs:68:6 | LL | /// [S!] - | ^^ - | | - | this link resolves to the struct `S`, which is not in the macro namespace - | help: to link to the struct, prefix with `struct@`: `struct@S` + | ^^ this link resolves to the struct `S`, which is not in the macro namespace + | +help: to link to the struct, prefix with `struct@` + | +LL | /// [struct@S] + | ^^^^^^^-- error: unresolved link to `S::h` --> $DIR/errors.rs:78:6 | LL | /// [type@S::h] - | ^^^^^^^^^ - | | - | this link resolves to the associated function `h`, which is not in the type namespace - | help: to link to the associated function, add parentheses: `S::h()` + | ^^^^^^^^^ this link resolves to the associated function `h`, which is not in the type namespace + | +help: to link to the associated function, add parentheses + | +LL | /// [S::h()] + | -- ^^ error: unresolved link to `T::g` --> $DIR/errors.rs:86:6 | LL | /// [type@T::g] - | ^^^^^^^^^ - | | - | this link resolves to the associated function `g`, which is not in the type namespace - | help: to link to the associated function, add parentheses: `T::g()` + | ^^^^^^^^^ this link resolves to the associated function `g`, which is not in the type namespace + | +help: to link to the associated function, add parentheses + | +LL | /// [T::g()] + | -- ^^ error: unresolved link to `T::h` --> $DIR/errors.rs:91:6 @@ -134,10 +142,12 @@ error: unresolved link to `m` --> $DIR/errors.rs:98:6 | LL | /// [m()] - | ^^^ - | | - | this link resolves to the macro `m`, which is not in the value namespace - | help: to link to the macro, add an exclamation mark: `m!` + | ^^^ this link resolves to the macro `m`, which is not in the value namespace + | +help: to link to the macro, add an exclamation mark + | +LL | /// [m!()] + | ^ error: aborting due to 20 previous errors diff --git a/src/test/rustdoc-ui/intra-doc/field-ice.stderr b/src/test/rustdoc-ui/intra-doc/field-ice.stderr index ccb05b84a7282..3ab35d2df07b0 100644 --- a/src/test/rustdoc-ui/intra-doc/field-ice.stderr +++ b/src/test/rustdoc-ui/intra-doc/field-ice.stderr @@ -1,15 +1,18 @@ error: incompatible link kind for `Foo::bar` - --> $DIR/field-ice.rs:5:6 + --> $DIR/field-ice.rs:5:7 | LL | /// [`Foo::bar()`] - | ^^^^^^^^^^^^ help: to link to the field, remove the disambiguator: ``Foo::bar`` + | ^^^^^^^^^^ this link resolved to a field, which is not a function | note: the lint level is defined here --> $DIR/field-ice.rs:1:9 | LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this link resolved to a field, which is not a function +help: to link to the field, remove the disambiguator + | +LL | /// [`Foo::bar`] + | ^^^^^^^^ error: aborting due to previous error diff --git a/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.stderr b/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.stderr index d4dcc493c8b6a..c2de5607ed64a 100644 --- a/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.stderr +++ b/src/test/rustdoc-ui/intra-doc/incompatible-primitive-disambiguator.stderr @@ -2,14 +2,17 @@ error: incompatible link kind for `u8::MIN` --> $DIR/incompatible-primitive-disambiguator.rs:2:6 | LL | //! [static@u8::MIN] - | ^^^^^^^^^^^^^^ help: to link to the associated constant, prefix with `const@`: `const@u8::MIN` + | ^^^^^^^^^^^^^^ this link resolved to an associated constant, which is not a static | note: the lint level is defined here --> $DIR/incompatible-primitive-disambiguator.rs:1:9 | LL | #![deny(rustdoc::broken_intra_doc_links)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: this link resolved to an associated constant, which is not a static +help: to link to the associated constant, prefix with `const@` + | +LL | //! [const@u8::MIN] + | ^^^^^^ error: aborting due to previous error diff --git a/src/test/rustdoc-ui/intra-doc/prim-conflict.stderr b/src/test/rustdoc-ui/intra-doc/prim-conflict.stderr index e4bd9fd4b8f1a..4dc1ce209007e 100644 --- a/src/test/rustdoc-ui/intra-doc/prim-conflict.stderr +++ b/src/test/rustdoc-ui/intra-doc/prim-conflict.stderr @@ -12,11 +12,11 @@ LL | #![deny(rustdoc::broken_intra_doc_links)] help: to link to the module, prefix with `mod@` | LL | /// [mod@char] - | ^^^^^^^^ + | ^^^^ help: to link to the builtin type, prefix with `prim@` | LL | /// [prim@char] - | ^^^^^^^^^ + | ^^^^^ error: `char` is both a module and a builtin type --> $DIR/prim-conflict.rs:10:6 @@ -27,27 +27,33 @@ LL | /// [type@char] help: to link to the module, prefix with `mod@` | LL | /// [mod@char] - | ^^^^^^^^ + | ^^^^ help: to link to the builtin type, prefix with `prim@` | LL | /// [prim@char] - | ^^^^^^^^^ + | ^^^^^ error: incompatible link kind for `char` --> $DIR/prim-conflict.rs:19:6 | LL | /// [struct@char] - | ^^^^^^^^^^^ help: to link to the module, prefix with `mod@`: `mod@char` + | ^^^^^^^^^^^ this link resolved to a module, which is not a struct | - = note: this link resolved to a module, which is not a struct +help: to link to the module, prefix with `mod@` + | +LL | /// [mod@char] + | ^^^^ error: incompatible link kind for `char` --> $DIR/prim-conflict.rs:26:10 | LL | //! [struct@char] - | ^^^^^^^^^^^ help: to link to the builtin type, prefix with `prim@`: `prim@char` + | ^^^^^^^^^^^ this link resolved to a builtin type, which is not a struct + | +help: to link to the builtin type, prefix with `prim@` | - = note: this link resolved to a builtin type, which is not a struct +LL | //! [prim@char] + | ^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/rustdoc-ui/issue-74134.private.stderr b/src/test/rustdoc-ui/issue-74134.private.stderr index 457987e207496..31d2dbe963758 100644 --- a/src/test/rustdoc-ui/issue-74134.private.stderr +++ b/src/test/rustdoc-ui/issue-74134.private.stderr @@ -1,8 +1,8 @@ warning: public documentation for `public_item` links to private item `PrivateType` - --> $DIR/issue-74134.rs:19:10 + --> $DIR/issue-74134.rs:19:11 | LL | /// [`PrivateType`] - | ^^^^^^^^^^^^^ this item is private + | ^^^^^^^^^^^ this item is private | = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default = note: this link resolves only because you passed `--document-private-items`, but will break without diff --git a/src/test/rustdoc-ui/issue-74134.public.stderr b/src/test/rustdoc-ui/issue-74134.public.stderr index 07aebc3541fe3..6a3173e3e0d6e 100644 --- a/src/test/rustdoc-ui/issue-74134.public.stderr +++ b/src/test/rustdoc-ui/issue-74134.public.stderr @@ -1,8 +1,8 @@ warning: public documentation for `public_item` links to private item `PrivateType` - --> $DIR/issue-74134.rs:19:10 + --> $DIR/issue-74134.rs:19:11 | LL | /// [`PrivateType`] - | ^^^^^^^^^^^^^ this item is private + | ^^^^^^^^^^^ this item is private | = note: `#[warn(rustdoc::private_intra_doc_links)]` on by default = note: this link will resolve properly if you pass `--document-private-items`