Skip to content

Commit 7c552a2

Browse files
authored
Rollup merge of rust-lang#49985 - zackmdavis:0, r=estebank
don't see issue #0 The unstable-feature attribute requires an issue (neglecting it is E0547), which gets used in the error messages. Unfortunately, there are some cases where "0" is apparently used a placeholder where no issue exists, directing the user to see the (nonexistent) issue #0. (It would have been better to either let `issue` be optional—compare to how issue is an `Option<u32>` in the feature-gate declarations in libsyntax/feature-gate.rs—or actually require that an issue be created.) Rather than endeavoring to change how `#[unstable]` works at this time (given competing contributor and reviewer priorities), this simple patch proposes the less-ambitious solution of just not adding the "(see issue)" note when the number is zero. Resolves rust-lang#49983.
2 parents 6b1ed8e + e77110e commit 7c552a2

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

src/libsyntax/feature_gate.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1242,10 +1242,9 @@ fn leveled_feature_err<'a>(sess: &'a ParseSess, feature: &str, span: Span, issue
12421242
GateIssue::Library(lib) => lib,
12431243
};
12441244

1245-
let explanation = if let Some(n) = issue {
1246-
format!("{} (see issue #{})", explain, n)
1247-
} else {
1248-
explain.to_owned()
1245+
let explanation = match issue {
1246+
None | Some(0) => explain.to_owned(),
1247+
Some(n) => format!("{} (see issue #{})", explain, n)
12491248
};
12501249

12511250
let mut err = match level {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
extern crate core;
12+
13+
// error should not say "(see issue #0)"
14+
#[allow(unused_imports)] use core::ptr::Unique; //~ ERROR use of unstable library feature
15+
16+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0658]: use of unstable library feature 'ptr_internals': use NonNull instead and consider PhantomData<T> (if you also use #[may_dangle]), Send, and/or Sync
2+
--> $DIR/issue-49983-see-issue-0.rs:14:30
3+
|
4+
LL | #[allow(unused_imports)] use core::ptr::Unique; //~ ERROR use of unstable library feature
5+
| ^^^^^^^^^^^^^^^^^
6+
|
7+
= help: add #![feature(ptr_internals)] to the crate attributes to enable
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)