Skip to content

Commit e77110e

Browse files
committed
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 #49983.
1 parent 7360d6d commit e77110e

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
@@ -1228,10 +1228,9 @@ fn leveled_feature_err<'a>(sess: &'a ParseSess, feature: &str, span: Span, issue
12281228
GateIssue::Library(lib) => lib,
12291229
};
12301230

1231-
let explanation = if let Some(n) = issue {
1232-
format!("{} (see issue #{})", explain, n)
1233-
} else {
1234-
explain.to_owned()
1231+
let explanation = match issue {
1232+
None | Some(0) => explain.to_owned(),
1233+
Some(n) => format!("{} (see issue #{})", explain, n)
12351234
};
12361235

12371236
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)