8000 Rollup of 10 pull requests by Centril · Pull Request #58428 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Rollup of 10 pull requests #58428

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
da5a0cd
De-duplicate number formatting implementations for smaller code size
fitzgen Feb 7, 2019
ed2157a
De-duplicate write_prefix lambda in pad_integral
fitzgen Feb 7, 2019
e633f15
Un-monomorphize and inline formatting with padding
fitzgen Feb 7, 2019
05f0dee
Improve the error messages for missing stability attributes
varkor Feb 7, 2019
c104b5c
Also de-duplicate 32- and 64-bit number formatting on wasm32
fitzgen Feb 7, 2019
05df9ff
Add a wasm code size test for stringifying numbers
fitzgen Feb 7, 2019
8fea705
Use write_char for writing padding characters
fitzgen Feb 8, 2019
f00f0e6
Don't shadow the provided `stringify!` macro in a wasm code size test…
fitzgen Feb 8, 2019
03d4fd9
Use descriptive variant name
varkor Feb 8, 2019
bb1eed0
Correct descriptive item name for impl
varkor Feb 8, 2019
18089df
Fix ICE and invalid filenames in MIR printing code
matthewjasper Feb 10, 2019
d7afd3e
Add test for MIR printing changes
matthewjasper Feb 10, 2019
3737d4d
Do not apply future deprecation warning for #[deprecated]
varkor Feb 5, 2019
87cd09b
Don't display "Deprecated since" for non-rustc deprecated items
varkor Feb 5, 2019
2a8a25b
Display "Deprecation planned" in rustdoc for future rustc deprecations
varkor Feb 5, 2019
3dc660f
Update existing rustdoc test
varkor Feb 6, 2019
01df8fe
Add a rustdoc test for future rustc_deprecated attributes
varkor Feb 6, 2019
c875241
Add rustdoc index page test for future deprecation attributes
varkor Feb 6, 2019
b5fa870
Add a test for rustc_deprecated
varkor Feb 11, 2019
48b0c9d
Only suggest imports if not imported.
davidtwco Feb 11, 2019
ddb6c4f
Set the query in the ImplicitCtxt before trying to mark it green
Zoxc Feb 12, 2019
3a8448c
Fix rustc_driver swallowing errors when compilation is stopped
gnzlbg Feb 12, 2019
eac43cc
HirId-ify hir::BodyId
ljedrz Feb 4, 2019
15e4bd3
target/uefi: clarify documentation
dvdhrm Feb 13, 2019
fba102c
libpanic_unwind => 2018
Centril Feb 2, 2019
3657eaa
libpanic_unwind => 2018: fix ICEs.
Centril Feb 12, 2019
6a4f535
Rollup merge of #58110 - Centril:libpanic_unwind-2018, r=oli-obk
Centril Feb 13, 2019
d303710
Rollup merge of #58167 - ljedrz:HirIdify_body_id, r=Zoxc
Centril Feb 13, 2019
44352df
Rollup merge of #58202 - varkor:deprecated-future-external, r=Guillau…
Centril Feb 13, 2019
08d6585
Rollup merge of #58272 - fitzgen:num-format-code-size, r=Mark-Simulacrum
Centril Feb 13, 2019
23b5be4
Rollup merge of #58276 - varkor:missing-stability-attr-top-level, r=d…
Centril Feb 13, 2019
9d46076
Rollup merge of #58354 - matthewjasper:mir-dump-fixes, r=wesleywiser
Centril Feb 13, 2019
99fd506
Rollup merge of #58381 - davidtwco:issue-42944, r=estebank
Centril Feb 13, 2019
4597c05
Rollup merge of #58386 - Zoxc:fix-54242, r=michaelwoerister
Centril Feb 13, 2019
e1c97f2
Rollup merge of #58400 - gnzlbg:fix_driver, r=oli-obk
Centril Feb 13, 2019
f4dfad8
Rollup merge of #58420 - dvdhrm:target-uefi-comments, r=nagisa
Centril Feb 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve the error messages for missing stability attributes
This makes the capitalisation consistent and provides more context (especially for missing top-level attributes).
  • Loading branch information
varkor committed Feb 7, 2019
commit 05f0dee04a39912222f7237502e2230f0da1b551
25 changes: 15 additions & 10 deletions src/librustc/middle/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,17 @@ struct MissingStabilityAnnotations<'a, 'tcx: 'a> {
}

impl<'a, 'tcx: 'a> MissingStabilityAnnotations<'a, 'tcx> {
fn check_missing_stability(&self, id: NodeId, span: Span) {
fn check_missing_stability(&self, id: NodeId, span: Span, name: &str) {
let hir_id = self.tcx.hir().node_to_hir_id(id);
let stab = self.tcx.stability().local_stability(hir_id);
let is_error = !self.tcx.sess.opts.test &&
stab.is_none() &&
self.access_levels.is_reachable(id);
if is_error {
self.tcx.sess.span_err(span, "This node does not have a stability attribute");
self.tcx.sess.span_err(
span,
&format!("{} has missing stability attribute", name),
);
}
}
}
Expand All @@ -347,42 +350,44 @@ impl<'a, 'tcx> Visitor<'tcx> for MissingStabilityAnnotations<'a, 'tcx> {
// optional. They inherit stability from their parents when unannotated.
hir::ItemKind::Impl(.., None, _, _) | hir::ItemKind::ForeignMod(..) => {}

_ => self.check_missing_stability(i.id, i.span)
hir::ItemKind::Mod(..) => self.check_missing_stability(i.id, i.span, "module"),

_ => self.check_missing_stability(i.id, i.span, "node")
}

intravisit::walk_item(self, i)
}

fn visit_trait_item(&mut self, ti: &'tcx hir::TraitItem) {
self.check_missing_stability(ti.id, ti.span);
self.check_missing_stability(ti.id, ti.span, "node");
intravisit::walk_trait_item(self, ti);
}

fn visit_impl_item(&mut self, ii: &'tcx hir::ImplItem) {
let impl_def_id = self.tcx.hir().local_def_id(self.tcx.hir().get_parent(ii.id));
if self.tcx.impl_trait_ref(impl_def_id).is_none() {
self.check_missing_stability(ii.id, ii.span);
self.check_missing_stability(ii.id, ii.span, "node");
}
intravisit::walk_impl_item(self, ii);
}

fn visit_variant(&mut self, var: &'tcx Variant, g: &'tcx Generics, item_id: NodeId) {
self.check_missing_stability(var.node.data.id(), var.span);
self.check_missing_stability(var.node.data.id(), var.span, "variant");
intravisit::walk_variant(self, var, g, item_id);
}

fn visit_struct_field(&mut self, s: &'tcx StructField) {
self.check_missing_stability(s.id, s.span);
self.check_missing_stability(s.id, s.span, "field");
intravisit::walk_struct_field(self, s);
}

fn visit_foreign_item(&mut self, i: &'tcx hir::ForeignItem) {
self.check_missing_stability(i.id, i.span);
self.check_missing_stability(i.id, i.span, "node");
intravisit::walk_foreign_item(self, i);
}

fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef) {
self.check_missing_stability(md.id, md.span);
self.check_missing_stability(md.id, md.span, "macro");
}
}

Expand Down Expand Up @@ -867,7 +872,7 @@ pub fn check_unused_or_stable_features<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
tcx,
access_levels,
};
missing.check_missing_stability(ast::CRATE_NODE_ID, krate.span);
missing.check_missing_stability(ast::CRATE_NODE_ID, krate.span, "crate");
intravisit::walk_crate(&mut missing, krate);
krate.visit_all_item_likes(&mut missing.as_deep_visitor());
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/missing/missing-stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#![stable(feature = "stable_test_feature", since = "1.0.0")]

pub fn unmarked() {
//~^ ERROR This node does not have a stability attribute
//~^ ERROR node has missing stability attribute
()
}

Expand All @@ -20,5 +20,5 @@ pub mod foo {
pub mod bar {
// #[stable] is not inherited
pub fn unmarked() {}
//~^ ERROR This node does not have a stability attribute
//~^ ERROR node has missing stability attribute
}
6 changes: 3 additions & 3 deletions src/test/ui/missing/missing-stability.stderr
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error: This node does not have a stability attribute
error: node has missing stability attribute
--> $DIR/missing-stability.rs:8:1
|
LL | / pub fn unmarked() {
LL | | //~^ ERROR This node does not have a stability attribute
LL | | //~^ ERROR node has missing stability attribute
LL | | ()
LL | | }
| |_^

error: This node does not have a stability attribute
error: node has missing stability attribute
--> $DIR/missing-stability.rs:22:5
|
LL | pub fn unmarked() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![feature(staged_api)]
//~^ ERROR crate has missing stability attribute

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error: crate has missing stability attribute
--> $DIR/missing-stability-attr-at-top-level.rs:1:1
|
LL | / #![feature(staged_api)]
LL | | //~^ ERROR crate has missing stability attribute
LL | |
LL | | fn main() {}
| |____________^

error: aborting due to previous error

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#![stable(feature = "test", since = "0")]

#[stable(feature = "test", since = "0")]
pub struct Reverse<T>(pub T); //~ ERROR This node does not have a stability attribute
pub struct Reverse<T>(pub T); //~ ERROR field has missing stability attribute

fn main() {
// Make sure the field is used to fill the stability cache
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: This node does not have a stability attribute
error: field has missing stability attribute
--> $DIR/stability-attribute-issue-43027.rs:5:23
|
LL | pub struct Reverse<T>(pub T); //~ ERROR This node does not have a stability attribute
LL | pub struct Reverse<T>(pub T); //~ ERROR field has missing stability attribute
| ^^^^^

error: aborting due to previous error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#![stable(feature = "stable_test_feature", since = "1.0.0")]

#[macro_export]
macro_rules! mac { //~ ERROR This node does not have a stability attribute
macro_rules! mac { //~ ERROR macro has missing stability attribute
() => ()
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: This node does not have a stability attribute
error: macro has missing stability attribute
--> $DIR/stability-attribute-sanity-3.rs:8:1
|
LL | / macro_rules! mac { //~ ERROR This node does not have a stability attribute
LL | / macro_rules! mac { //~ ERROR macro has missing stability attribute
LL | | () => ()
LL | | }
| |_^
Expand Down
0