Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a0df420
Implement FromStr for PathBuf
SimonSapin Oct 17, 2018
ac18635
Add MaybeUninit::new
SimonSapin Oct 21, 2018
412ad9b
Allow extern statics with an extern type
mjbshaw Oct 22, 2018
5b84550
Keep an obligation for both sized and unsized types
mjbshaw Oct 22, 2018
1c8fb66
Move `BoundTy` to `ty::TyKind`
scalexm Oct 22, 2018
cdf5547
Shift both late bound regions and bound types
scalexm Oct 22, 2018
ab820ad
Rename `BoundTyIndex` to `BoundVar`
scalexm Oct 23, 2018
9049c85
Rename `BoundTy` field `level` -> `index`
scalexm Oct 23, 2018
8642a23
Adjust bound tys indices in canonicalization
scalexm Oct 23, 2018
e76fffc
Remove `ReCanonical` in favor of `ReLateBound`
scalexm Oct 24, 2018
b86d700
Rename `Binder::no_late_bound_regions` to `Binder::no_bound_vars`
scalexm Oct 24, 2018
235c848
Extend `ty::fold::RegionReplacer` to `ty::fold::BoundVarReplacer`
scalexm Oct 24, 2018
47499cc
Fix doc comment
scalexm Oct 25, 2018
18eeed5
Move cg_llvm::back::linker to cg_utils
bjorn3 Oct 20, 2018
2bf01aa
Rename `as_bound_var` to `assert_bound_var`
scalexm Oct 25, 2018
2b205dc
Substitute binders directly
scalexm Oct 25, 2018
029cf2f
Move collect_and_partition_mono_items to rustc_mir
bjorn3 Oct 25, 2018
06695c2
Remove rustc_metadata_utils, which contains only one function
bjorn3 Oct 25, 2018
adafd0f
Fix indentation
bjorn3 Oct 25, 2018
8d5fb4c
Add note linking to Rust 2018 path semantics docs.
davidtwco Oct 18, 2018
c674802
Remove unnecessary mut in iterator.find_map documentation example, Re…
meven Oct 23, 2018
bb37f18
Turn ICE for dangling pointers into error
oli-obk Oct 22, 2018
caabc72
Reproduce the underlying issue
oli-obk Oct 22, 2018
7a2879f
Update dangling-alloc-id-ice-2.rs
oli-obk Oct 23, 2018
9d18968
Typo
oli-obk Oct 24, 2018
5c45fef
Update and add new test (fixes #55353)
oli-obk Oct 26, 2018
599eb12
Add trailing newline
oli-obk Oct 26, 2018
4cb611f
Update string.rs
rick68 Oct 27, 2018
c04893a
Fix an ICE in the min_const_fn analysis
oli-obk Oct 27, 2018
630c6a5
introducing lint reason annotations (RFC 2383)
zackmdavis Sep 30, 2018
dc0609c
feature-gate lint reasons
zackmdavis Sep 30, 2018
f90de11
in which lint reasons are restricted to come last in the attribute
zackmdavis Oct 12, 2018
f66ea66
wherein the status of empty and reason-only lint attributes is clarified
zackmdavis Oct 16, 2018
80c1f0b
Rollup merge of #54683 - zackmdavis:critique_of_pure_lints, r=petroch…
Mark-Simulacrum Oct 27, 2018
ef8f09a
Rollup merge of #55148 - SimonSapin:path-fromstr, r=oli-obk
Mark-Simulacrum Oct 27, 2018
be00065
Rollup merge of #55185 - davidtwco:issue-55130, r=nikomatsakis
Mark-Simulacrum Oct 27, 2018
671e8ea
Rollup merge of #55252 - SimonSapin:maybeuninit-new, r=bluss
Mark-Simulacrum Oct 27, 2018
b3740b1
Rollup merge of #55257 - mjbshaw:static, r=oli-obk
Mark-Simulacrum Oct 27, 2018
805fcb6
Rollup merge of #55262 - oli-obk:dangling_alloc_id_ice, r=RalfJung
Mark-Simulacrum Oct 27, 2018
0956690
Rollup merge of #55330 - scalexm:bound-ty, r=nikomatsakis
Mark-Simulacrum Oct 27, 2018
2994675
Rollup merge of #55349 - bjorn3:rustc_mir_collect_and_partition_mono_…
Mark-Simulacrum Oct 27, 2018
18d3f3f
Rollup merge of #55389 - meven:master, r=shepmaster
Mark-Simulacrum Oct 27, 2018
545eae8
Rollup merge of #55406 - rick68:patch-16, r=varkor
Mark-Simulacrum Oct 27, 2018
25be4f6
Rollup merge of #55412 - oli-obk:min_const_fn_ice, r=estebank
Mark-Simulacrum Oct 27, 2018
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
in which lint reasons are restricted to come last in the attribute
Vadim Petrochenkov suggested this in review ("an error? just to be
conservative"), and it turns out to be convenient from the
implementer's perspective: in the initial proposed implementation (or
`HEAD~2`, as some might prefer to call it), we were doing an entire
whole iteration over the meta items just to find the reason (before
iterating over them to set the actual lint levels). This way, we can
just peek at the end rather than adding that extra loop (or
restructuring the existing code). The RFC doesn't seem to take a
position on this, and there's some precedent for restricting things to
be at the end of a sequence (we only allow `..` at the end of a struct
pattern, even if it would be possible to let it appear anywhere in the
sequence).
  • Loading branch information
zackmdavis committed Oct 27, 2018
commit f90de1110d93ea389342220caad19e05c4e6ad10
73 changes: 42 additions & 31 deletions src/librustc/lint/levels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey,
use session::Session;
use syntax::ast;
use syntax::attr;
use syntax::feature_gate;
use syntax::source_map::MultiSpan;
use syntax::symbol::Symbol;
use util::nodemap::FxHashMap;
Expand Down Expand Up @@ -210,60 +211,70 @@ impl<'a> LintLevelsBuilder<'a> {
let meta = unwrap_or!(attr.meta(), continue);
attr::mark_used(attr);

let metas = if let Some(metas) = meta.meta_item_list() {
let mut metas = if let Some(metas) = meta.meta_item_list() {
metas
} else {
let mut err = bad_attr(meta.span);
err.emit();
continue
};

// Before processing the lint names, look for a reason (RFC 2383).
// Before processing the lint names, look for a reason (RFC 2383)
// at the end.
let mut reason = None;
for li in metas {
if let Some(item) = li.meta_item() {
match item.node {
ast::MetaItemKind::Word => {} // actual lint names handled later
ast::MetaItemKind::NameValue(ref name_value) => {
let gate_reasons = !self.sess.features_untracked().lint_reasons;
let name_ident = item.ident.segments[0].ident;
let name = name_ident.name.as_str();

if name == "reason" {
if let ast::LitKind::Str(rationale, _) = name_value.node {
if gate_reasons {
feature_gate::emit_feature_err(
&self.sess.parse_sess,
"lint_reasons",
item.span,
feature_gate::GateIssue::Language,
"lint reasons are experimental"
);
} else {
reason = Some(rationale);
}
let tail_li = &metas[metas.len()-1];
if let Some(item) = tail_li.meta_item() {
match item.node {
ast::MetaItemKind::Word => {} // actual lint names handled later
ast::MetaItemKind::NameValue(ref name_value) => {
let gate_reasons = !self.sess.features_untracked().lint_reasons;
if item.ident == "reason" {
// found reason, reslice meta list to exclude it
metas = &metas[0..metas.len()-1];
if let ast::LitKind::Str(rationale, _) = name_value.node {
if gate_reasons {
feature_gate::emit_feature_err(
&self.sess.parse_sess,
"lint_reasons",
item.span,
feature_gate::GateIssue::Language,
"lint reasons are experimental"
);
} else {
let mut err = bad_attr(name_value.span);
err.help("reason must be a string literal");
err.emit();
reason = Some(rationale);
}
} else {
let mut err = bad_attr(item.span);
let mut err = bad_attr(name_value.span);
err.help("reason must be a string literal");
err.emit();
}
},
ast::MetaItemKind::List(_) => {
} else {
let mut err = bad_attr(item.span);
err.emit();
}
},
ast::MetaItemKind::List(_) => {
let mut err = bad_attr(item.span);
err.emit();
}
}
}

for li in metas {
let word = match li.word() {
Some(word) => word,
None => { continue; }
None => {
let mut err = bad_attr(li.span);
if let Some(item) = li.meta_item() {
if let ast::MetaItemKind::NameValue(_) = item.node {
if item.ident == "reason" {
err.help("reason in lint attribute must come last");
}
}
}
err.emit();
continue;
}
};
let tool_name = if let Some(lint_tool) = word.is_scoped() {
if !attr::is_known_lint_tool(lint_tool) {
Expand Down
8 changes: 7 additions & 1 deletion src/test/ui/lint/reasons-erroneous.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@
//~^ ERROR malformed lint attribute
#![warn(elided_lifetimes_in_paths, reason("disrespectful to ancestors", "irresponsible to heirs"))]
//~^ ERROR malformed lint attribute
#![warn(ellipsis_inclusive_range_patterns, reason)]
#![warn(ellipsis_inclusive_range_patterns, reason = "born barren", reason = "a freak growth")]
//~^ ERROR malformed lint attribute
//~| HELP reason in lint attribute must come last
#![warn(keyword_idents, reason = "root in rubble", macro_use_extern_crate)]
//~^ ERROR malformed lint attribute
//~| HELP reason in lint attribute must come last
#![warn(missing_copy_implementations, reason)]
//~^ WARN unknown lint

fn main() {}
24 changes: 20 additions & 4 deletions src/test/ui/lint/reasons-erroneous.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,30 @@ error[E0452]: malformed lint attribute
LL | #![warn(elided_lifetimes_in_paths, reason("disrespectful to ancestors", "irresponsible to heirs"))]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: unknown lint: `reason`
error[E0452]: malformed lint attribute
--> $DIR/reasons-erroneous.rs:15:44
|
LL | #![warn(ellipsis_inclusive_range_patterns, reason)]
| ^^^^^^
LL | #![warn(ellipsis_inclusive_range_patterns, reason = "born barren", reason = "a freak growth")]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: reason in lint attribute must come last

error[E0452]: malformed lint attribute
--> $DIR/reasons-erroneous.rs:18:25
|
LL | #![warn(keyword_idents, reason = "root in rubble", macro_use_extern_crate)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: reason in lint attribute must come last

warning: unknown lint: `reason`
--> $DIR/reasons-erroneous.rs:21:39
|
LL | #![warn(missing_copy_implementations, reason)]
| ^^^^^^
|
= note: #[warn(unknown_lints)] on by default

error: aborting due to 5 previous errors
error: aborting due to 7 previous errors

For more information about this error, try `rustc --explain E0452`.