Skip to content
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

Rollup of 11 pull requests #82737

Closed
wants to merge 78 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
f45bdcc
Implement size_hint for BufReader
Xavientois Jan 15, 2021
c3e47d9
Fix implementation to specialize
Xavientois Jan 15, 2021
fa76db3
Use helper trait to follow min_specialization rules
Xavientois Jan 15, 2021
11c49f6
Add missing generic
Xavientois Jan 15, 2021
260a270
Move default to trait definition
Xavientois Jan 15, 2021
5f60a30
Fix incorrect token
Xavientois Jan 15, 2021
eea99f4
Add default keyword for specialization
Xavientois Jan 15, 2021
7e56637
Add back lower_bound as memeber
Xavientois Jan 16, 2021
442de9a
Fix semicolon
Xavientois Jan 16, 2021
1190321
Remove exposing private trait
Xavientois Jan 16, 2021
421b40c
Add dyn for SizeHint cast
Xavientois Jan 16, 2021
265db94
Fix formatting
Xavientois Jan 16, 2021
93870c8
Remove stable annotation
Xavientois Jan 16, 2021
7869371
Remove unnecessary default keyword
Xavientois Jan 16, 2021
c8e0f8a
Use fully qualified syntax to avoid dyn
Xavientois Jan 16, 2021
96255f8
Implement SizeHint trait for BufReader, Emtpy, and Chain
Xavientois Jan 16, 2021
389e638
Add tests for SizeHint implementations
Xavientois Jan 16, 2021
b837f3a
Remove trailing newline
Xavientois Jan 16, 2021
81aba38
Add space for proper indentation
Xavientois Jan 16, 2021
fc9cd4a
Fix formatting on mod
Xavientois Jan 16, 2021
7674ae1
Fix line length format
Xavientois Jan 31, 2021
4cb089b
Inherit `#[stable(..)]` annotations in enum variants and fields from …
estebank Apr 23, 2020
19806e4
Tweak stability attribute diagnostic output
estebank Feb 11, 2021
7b021aa
resolve: Reduce scope of `pub_use_of_private_extern_crate` deprecatio…
petrochenkov Jan 28, 2021
49310ce
Add test for "const stability on macro"
estebank Feb 11, 2021
fbd575a
process::unix: Handle other wait statuses in ExitStatus as Display
ijackson Feb 22, 2021
d8cfd56
process::unix: Test wait status formatting
ijackson Feb 22, 2021
4bb8425
ExitStatus: Improve documentation re wait status vs exit status
ijackson Feb 22, 2021
2f04a79
Revert `Vec::spare_capacity_mut` impl to prevent pointers invalidation
WaffleLapkin Feb 26, 2021
cc62018
Rename rustdoc lints to be a tool lint instead of built-in.
jyn514 Dec 30, 2020
37e4cfe
Move lint machinery into a separate file
jyn514 Dec 30, 2020
7195355
Add `declare_rustdoc_lint!` macro
jyn514 Dec 30, 2020
e8ddfda
Improve error messages
jyn514 Jan 17, 2021
0517ea7
Address review comments
jyn514 Jan 18, 2021
c7535d1
Update comments
jyn514 Jan 19, 2021
75efb6e
Test that using the previous lint names still applies the lint
jyn514 Feb 28, 2021
768d5e9
Load rustdoc's JS search index on-demand.
jsha Feb 20, 2021
9c4e3af
Add test that Vec::spare_capacity_mut doesn't invalidate pointers
WaffleLapkin Mar 2, 2021
a1835bc
Make Vec::split_at_spare_mut impl safer & simplier
WaffleLapkin Mar 2, 2021
d3e7ffa
Improve page load performance in rustdoc.
jsha Feb 20, 2021
f9cfe15
Use Arial as fallback font instead of sans-serif.
jsha Mar 3, 2021
040735c
First version of noop-lint
rylev Jan 5, 2021
f49ed7a
Add tests and support two more noop methods
rylev Jan 5, 2021
a6d926d
Fix tests
rylev Jan 5, 2021
618c395
Bless test where order of error message changed
rylev Jan 6, 2021
3a86184
Fix ui-full-deps suite
rylev Jan 6, 2021
ee65416
Fix core tests
rylev Jan 6, 2021
d3b49c2
Only allow new lint when not bootstrapping - since beta doesn't know …
rylev Jan 7, 2021
c5ff54c
Fix std tests
rylev Jan 7, 2021
217c886
Improve warning
rylev Jan 8, 2021
16c4afb
Fix tidy errors
rylev Jan 8, 2021
95e330b
Update error message
rylev Jan 11, 2021
316e9db
Fix tidy error
rylev Jan 11, 2021
49f32e0
Improve error messages
rylev Jan 12, 2021
e48670c
Increase accuracy of lint trigger
estebank Jan 13, 2021
055db16
Clean up code rightward drift
estebank Jan 13, 2021
4be7052
Allow noop_method_call in clippy ui test
rylev Jan 18, 2021
6bf6652
Move unrelated ui test back to what it was before
rylev Feb 10, 2021
da3995f
Remove lint pass on borrow and deref
rylev Feb 16, 2021
1999a31
Fix borrow and deref
rylev Feb 16, 2021
25637b2
Warn in doc test
rylev Feb 17, 2021
6111445
Add `-Z unpretty` flags for the AST
LeSeulArtichaut Feb 19, 2021
950f121
Update library/alloc/src/vec/mod.rs
WaffleLapkin Mar 3, 2021
5461ee0
rustc_target: add "unwind" payloads to `Abi`
Aug 27, 2020
9a007cf
implement unwinding abi's (RFC 2945)
Sep 10, 2020
0fd2fd9
add integration tests, unwind across FFI boundary
Dec 12, 2020
d8bfdc8
address pr review comments
Oct 23, 2020
229ffc3
Rollup merge of #71481 - estebank:inherit-stability, r=nikomatsakis
Dylan-DPC Mar 4, 2021
045261f
Rollup merge of #76570 - cratelyn:implement-rfc-2945-c-unwind-abi, r=…
Dylan-DPC Mar 4, 2021
ea7c3e7
Rollup merge of #80527 - jyn514:rustdoc-lints, r=GuillaumeGomez
Dylan-DPC Mar 4, 2021
72e5b5a
Rollup merge of #80723 - rylev:noop-lint-pass, r=estebank
Dylan-DPC Mar 4, 2021
cb909a6
Rollup merge of #80763 - petrochenkov:pubusecrate, r=estebank
Dylan-DPC Mar 4, 2021
1dfd766
Rollup merge of #81136 - Xavientois:io_reader_size_hint, r=cramertj
Dylan-DPC Mar 4, 2021
e0ef270
Rollup merge of #82304 - LeSeulArtichaut:unpretty-ast, r=spastorino
Dylan-DPC Mar 4, 2021
4cb61a3
Rollup merge of #82310 - jsha:rustdoc-search-onfocus, r=GuillaumeGomez
Dylan-DPC Mar 4, 2021
ba4ee48
Rollup merge of #82315 - jsha:font-display-swap, r=GuillaumeGomez
Dylan-DPC Mar 4, 2021
ae2482e
Rollup merge of #82411 - ijackson:fix-exitstatus, r=dtolnay
Dylan-DPC Mar 4, 2021
b0b63ec
Rollup merge of #82564 - WaffleLapkin:revert_spare_mut, r=RalfJung
Dylan-DPC Mar 4, 2021
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
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl MarkedAttrs {
}

pub fn is_known_lint_tool(m_item: Ident) -> bool {
[sym::clippy, sym::rustc].contains(&m_item.name)
[sym::clippy, sym::rustc, sym::rustdoc].contains(&m_item.name)
}

impl NestedMetaItem {
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_ast_lowering/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
},
ItemKind::ForeignMod(ref fm) => {
if fm.abi.is_none() {
self.maybe_lint_missing_abi(span, id, abi::Abi::C);
self.maybe_lint_missing_abi(span, id, abi::Abi::C { unwind: false });
}
hir::ItemKind::ForeignMod {
abi: fm.abi.map_or(abi::Abi::C, |abi| self.lower_abi(abi)),
abi: fm.abi.map_or(abi::Abi::C { unwind: false }, |abi| self.lower_abi(abi)),
items: self
.arena
.alloc_from_iter(fm.items.iter().map(|x| self.lower_foreign_item_ref(x))),
Expand Down Expand Up @@ -1322,8 +1322,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
match ext {
Extern::None => abi::Abi::Rust,
Extern::Implicit => {
self.maybe_lint_missing_abi(span, id, abi::Abi::C);
abi::Abi::C
self.maybe_lint_missing_abi(span, id, abi::Abi::C { unwind: false });
abi::Abi::C { unwind: false }
}
Extern::Explicit(abi) => self.lower_abi(abi),
}
Expand Down
32 changes: 32 additions & 0 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,38 @@ impl<'a> PostExpansionVisitor<'a> {
"C-cmse-nonsecure-call ABI is experimental and subject to change"
);
}
"C-unwind" => {
gate_feature_post!(
&self,
c_unwind,
span,
"C-unwind ABI is experimental and subject to change"
);
}
"stdcall-unwind" => {
gate_feature_post!(
&self,
c_unwind,
span,
"stdcall-unwind ABI is experimental and subject to change"
);
}
"system-unwind" => {
gate_feature_post!(
&self,
c_unwind,
span,
"system-unwind ABI is experimental and subject to change"
);
}
"thiscall-unwind" => {
gate_feature_post!(
&self,
c_unwind,
span,
"thiscall-unwind ABI is experimental and subject to change"
);
}
abi => self
.sess
.parse_sess
Expand Down
27 changes: 16 additions & 11 deletions compiler/rustc_attr/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,23 +176,24 @@ pub fn find_stability(
sess: &Session,
attrs: &[Attribute],
item_sp: Span,
) -> (Option<Stability>, Option<ConstStability>) {
) -> (Option<(Stability, Span)>, Option<(ConstStability, Span)>) {
find_stability_generic(sess, attrs.iter(), item_sp)
}

fn find_stability_generic<'a, I>(
sess: &Session,
attrs_iter: I,
item_sp: Span,
) -> (Option<Stability>, Option<ConstStability>)
) -> (Option<(Stability, Span)>, Option<(ConstStability, Span)>)
where
I: Iterator<Item = &'a Attribute>,
{
use StabilityLevel::*;

let mut stab: Option<Stability> = None;
let mut const_stab: Option<ConstStability> = None;
let mut stab: Option<(Stability, Span)> = None;
let mut const_stab: Option<(ConstStability, Span)> = None;
let mut promotable = false;

let diagnostic = &sess.parse_sess.span_diagnostic;

'outer: for attr in attrs_iter {
Expand Down Expand Up @@ -356,10 +357,12 @@ where
}
let level = Unstable { reason, issue: issue_num, is_soft };
if sym::unstable == meta_name {
stab = Some(Stability { level, feature });
stab = Some((Stability { level, feature }, attr.span));
} else {
const_stab =
Some(ConstStability { level, feature, promotable: false });
const_stab = Some((
ConstStability { level, feature, promotable: false },
attr.span,
));
}
}
(None, _, _) => {
Expand Down Expand Up @@ -432,10 +435,12 @@ where
(Some(feature), Some(since)) => {
let level = Stable { since };
if sym::stable == meta_name {
stab = Some(Stability { level, feature });
stab = Some((Stability { level, feature }, attr.span));
} else {
const_stab =
Some(ConstStability { level, feature, promotable: false });
const_stab = Some((
ConstStability { level, feature, promotable: false },
attr.span,
));
}
}
(None, _) => {
Expand All @@ -455,7 +460,7 @@ where

// Merge the const-unstable info into the stability info
if promotable {
if let Some(ref mut stab) = const_stab {
if let Some((ref mut stab, _)) = const_stab {
stab.promotable = promotable;
} else {
struct_span_err!(
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ pub(crate) fn codegen_terminator_call<'tcx>(

// FIXME find a cleaner way to support varargs
if fn_sig.c_variadic {
if fn_sig.abi != Abi::C {
if !matches!(fn_sig.abi, Abi::C { .. }) {
fx.tcx.sess.span_fatal(
span,
&format!("Variadic call for non-C abi {:?}", fn_sig.abi),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub fn get_rpath_flags(config: &mut RPathConfig<'_>) -> Vec<String> {

debug!("preparing the RPATH!");

let libs = config.used_crates.clone();
let libs = config.used_crates;
let libs = libs.iter().filter_map(|&(_, ref l)| l.option()).collect::<Vec<_>>();
let rpaths = get_rpaths(config, &libs);
let mut flags = rpaths_to_flags(&rpaths);
Expand Down
48 changes: 29 additions & 19 deletions compiler/rustc_driver/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_hir_pretty as pprust_hir;
use rustc_middle::hir::map as hir_map;
use rustc_middle::ty::{self, TyCtxt};
use rustc_mir::util::{write_mir_graphviz, write_mir_pretty};
use rustc_session::config::{Input, PpHirMode, PpMode, PpSourceMode};
use rustc_session::config::{Input, PpAstTreeMode, PpHirMode, PpMode, PpSourceMode};
use rustc_session::Session;
use rustc_span::symbol::Ident;
use rustc_span::FileName;
Expand Down Expand Up @@ -391,24 +391,29 @@ pub fn print_after_parsing(
) {
let (src, src_name) = get_source(input, sess);

let out = if let Source(s) = ppm {
// Silently ignores an identified node.
call_with_pp_support(&s, sess, None, move |annotation| {
debug!("pretty printing source code {:?}", s);
let sess = annotation.sess();
let parse = &sess.parse_sess;
pprust::print_crate(
sess.source_map(),
krate,
src_name,
src,
annotation.pp_ann(),
false,
parse.edition,
)
})
} else {
unreachable!()
let out = match ppm {
Source(s) => {
// Silently ignores an identified node.
call_with_pp_support(&s, sess, None, move |annotation| {
debug!("pretty printing source code {:?}", s);
let sess = annotation.sess();
let parse = &sess.parse_sess;
pprust::print_crate(
sess.source_map(),
krate,
src_name,
src,
annotation.pp_ann(),
false,
parse.edition,
)
})
}
AstTree(PpAstTreeMode::Normal) => {
debug!("pretty printing AST tree");
format!("{:#?}", krate)
}
_ => unreachable!(),
};

write_or_print(&out, ofile);
Expand Down Expand Up @@ -447,6 +452,11 @@ pub fn print_after_hir_lowering<'tcx>(
})
}

AstTree(PpAstTreeMode::Expanded) => {
debug!("pretty-printing expanded AST");
format!("{:#?}", krate)
}

Hir(s) => call_with_pp_support_hir(&s, tcx, move |annotation, krate| {
debug!("pretty printing HIR {:?}", s);
let sess = annotation.sess();
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_error_codes/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#![deny(invalid_codeblock_attributes)]
#![cfg_attr(bootstrap, deny(invalid_codeblock_attributes))]
#![cfg_attr(not(bootstrap), deny(rustdoc::invalid_codeblock_attributes))]
//! This library is used to gather all error codes into one place,
//! the goal being to make their maintenance easier.

Expand Down
12 changes: 9 additions & 3 deletions compiler/rustc_expand/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,16 @@ impl SyntaxExtension {
.find_by_name(attrs, sym::rustc_builtin_macro)
.map(|a| a.value_str().unwrap_or(name));
let (stability, const_stability) = attr::find_stability(&sess, attrs, span);
if const_stability.is_some() {
if let Some((_, sp)) = const_stability {
sess.parse_sess
.span_diagnostic
.span_err(span, "macros cannot have const stability attributes");
.struct_span_err(sp, "macros cannot have const stability attributes")
.span_label(sp, "invalid const stability attribute")
.span_label(
sess.source_map().guess_head_span(span),
"const stability attribute affects this macro",
)
.emit();
}

SyntaxExtension {
Expand All @@ -786,7 +792,7 @@ impl SyntaxExtension {
allow_internal_unstable,
allow_internal_unsafe: sess.contains_name(attrs, sym::allow_internal_unsafe),
local_inner_macros,
stability,
stability: stability.map(|(s, _)| s),
deprecation: attr::find_deprecation(&sess, attrs).map(|(d, _)| d),
helper_attrs,
edition,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,9 @@ declare_features! (
/// Allows associated types in inherent impls.
(active, inherent_associated_types, "1.52.0", Some(8995), None),

/// Allows `extern "C-unwind" fn` to enable unwinding across ABI boundaries.
(active, c_unwind, "1.52.0", Some(74990), None),

// -------------------------------------------------------------------------
// feature-group-end: actual feature gates
// -------------------------------------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_lint/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ impl SessionLintStore for LintStore {
}

/// The target of the `by_name` map, which accounts for renaming/deprecation.
#[derive(Debug)]
enum TargetLint {
/// A direct lint target
Id(LintId),
Expand Down Expand Up @@ -470,7 +471,10 @@ impl LintStore {
Some(&Id(ref id)) => {
CheckLintNameResult::Tool(Err((Some(slice::from_ref(id)), complete_name)))
}
_ => CheckLintNameResult::NoLint(None),
Some(other) => {
tracing::debug!("got renamed lint {:?}", other);
CheckLintNameResult::NoLint(None)
}
}
}
}
Expand Down
41 changes: 26 additions & 15 deletions compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ mod methods;
mod non_ascii_idents;
mod non_fmt_panic;
mod nonstandard_style;
mod noop_method_call;
mod passes;
mod redundant_semicolon;
mod traits;
Expand All @@ -69,9 +70,7 @@ use rustc_hir::def_id::LocalDefId;
use rustc_middle::ty::query::Providers;
use rustc_middle::ty::TyCtxt;
use rustc_session::lint::builtin::{
BARE_TRAIT_OBJECTS, BROKEN_INTRA_DOC_LINKS, ELIDED_LIFETIMES_IN_PATHS,
EXPLICIT_OUTLIVES_REQUIREMENTS, INVALID_CODEBLOCK_ATTRIBUTES, INVALID_HTML_TAGS,
MISSING_DOC_CODE_EXAMPLES, NON_AUTOLINKS, PRIVATE_DOC_TESTS,
BARE_TRAIT_OBJECTS, ELIDED_LIFETIMES_IN_PATHS, EXPLICIT_OUTLIVES_REQUIREMENTS,
};
use rustc_span::symbol::{Ident, Symbol};
use rustc_span::Span;
Expand All @@ -83,6 +82,7 @@ use methods::*;
use non_ascii_idents::*;
use non_fmt_panic::NonPanicFmt;
use nonstandard_style::*;
use noop_method_call::*;
use redundant_semicolon::*;
use traits::*;
use types::*;
Expand Down Expand Up @@ -170,6 +170,7 @@ macro_rules! late_lint_passes {
DropTraitConstraints: DropTraitConstraints,
TemporaryCStringAsPtr: TemporaryCStringAsPtr,
NonPanicFmt: NonPanicFmt,
NoopMethodCall: NoopMethodCall,
]
);
};
Expand Down Expand Up @@ -314,17 +315,6 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
// MACRO_USE_EXTERN_CRATE
);

add_lint_group!(
"rustdoc",
NON_AUTOLINKS,
BROKEN_INTRA_DOC_LINKS,
PRIVATE_INTRA_DOC_LINKS,
INVALID_CODEBLOCK_ATTRIBUTES,
MISSING_DOC_CODE_EXAMPLES,
PRIVATE_DOC_TESTS,
INVALID_HTML_TAGS
);

// Register renamed and removed lints.
store.register_renamed("single_use_lifetime", "single_use_lifetimes");
store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths");
Expand All @@ -334,8 +324,29 @@ fn register_builtins(store: &mut LintStore, no_interleave_lints: bool) {
store.register_renamed("async_idents", "keyword_idents");
store.register_renamed("exceeding_bitshifts", "arithmetic_overflow");
store.register_renamed("redundant_semicolon", "redundant_semicolons");
store.register_renamed("intra_doc_link_resolution_failure", "broken_intra_doc_links");
store.register_renamed("overlapping_patterns", "overlapping_range_endpoints");

// These were moved to tool lints, but rustc still sees them when compiling normally, before
// tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use
// `register_removed` explicitly.
const RUSTDOC_LINTS: &[&str] = &[
"broken_intra_doc_links",
"private_intra_doc_links",
"missing_crate_level_docs",
"missing_doc_code_examples",
"private_doc_tests",
"invalid_codeblock_attributes",
"invalid_html_tags",
"non_autolinks",
];
for rustdoc_lint in RUSTDOC_LINTS {
store.register_removed(rustdoc_lint, &format!("use `rustdoc::{}` instead", rustdoc_lint));
}
store.register_removed(
"intra_doc_link_resolution_failure",
"use `rustdoc::broken_intra_doc_links` instead",
);

store.register_removed("unknown_features", "replaced by an error");
store.register_removed("unsigned_negation", "replaced by negate_unsigned feature gate");
store.register_removed("negate_unsigned", "cast a signed value instead");
Expand Down
Loading