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 #83300

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2cbea9f
Reuse `std::sys::unsupported::pipe` on `hermit`
CDirkx Feb 24, 2021
bbbefa3
Allow doc alias attributes to use both list and value
GuillaumeGomez Mar 6, 2021
2069d3e
Update doc alias ui tests
GuillaumeGomez Mar 6, 2021
1d26e6b
Improve code by removing similar function calls and using loops inste…
GuillaumeGomez Mar 8, 2021
22f2548
use checkout@v2
klensy Mar 16, 2021
cad3c42
Deprecate std::os::haiku::raw
bstrie Mar 16, 2021
bb7c04a
Remove unnecessary `forward_inner_docs` hack
jyn514 Mar 17, 2021
620ecc0
Move some test-only code to test files
jyn514 Mar 17, 2021
b1de9d4
Fix gitattibutes for old git versions
Mar 16, 2021
cfb4ad4
Remove unwrap_none/expect_none from compiler/.
m-ou-se Mar 4, 2021
390d1ef
Extend `proc_macro_back_compat` lint to `actix-web`
Aaron1011 Mar 16, 2021
99b2054
Fix typo/inaccuracy in the documentation of Iterator::skip_while
steffahn Mar 18, 2021
9dfda62
Clarify docs for Read::read's return value
jix Mar 8, 2021
477e594
Rollup merge of #82500 - CDirkx:hermit-pipe, r=joshtriplett
Dylan-DPC Mar 19, 2021
050d228
Rollup merge of #82759 - m-ou-se:remove-unwrap-none, r=petrochenkov
Dylan-DPC Mar 19, 2021
d9df689
Rollup merge of #82846 - GuillaumeGomez:doc-alias-list, r=jyn514
Dylan-DPC Mar 19, 2021
60e65cf
Rollup merge of #82892 - jix:clarify-read-read, r=joshtriplett
Dylan-DPC Mar 19, 2021
61a47e8
Rollup merge of #83179 - Aaron1011:actix-web-lint, r=petrochenkov
Dylan-DPC Mar 19, 2021
78cc51e
Rollup merge of #83197 - jyn514:cfg-test-dead-code, r=joshtriplett
Dylan-DPC Mar 19, 2021
2055a8d
Rollup merge of #83201 - klensy:checkout-v2, r=pietroalbini
Dylan-DPC Mar 19, 2021
e49b8b4
Rollup merge of #83208 - jethrogb:jb/gitignore, r=Xanewok
Dylan-DPC Mar 19, 2021
b6c25e5
Rollup merge of #83215 - bstrie:dephaikuraw, r=joshtriplett
Dylan-DPC Mar 19, 2021
a949b0f
Rollup merge of #83230 - jyn514:remove-macros, r=joshtriplett
Dylan-DPC Mar 19, 2021
ee3622d
Rollup merge of #83270 - steffahn:missing_word_in_skip_while_doc, r=j…
Dylan-DPC Mar 19, 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
6 changes: 3 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
*.fixed linguist-language=Rust
*.mir linguist-language=Rust
src/etc/installer/gfx/* binary
*.woff binary
*.woff2 binary
src/vendor/** -text
Cargo.lock linguist-generated=false

# Older git versions try to fix line endings on images, this prevents it.
# Older git versions try to fix line endings on images and fonts, this prevents it.
*.png binary
*.ico binary
*.woff binary
*.woff2 binary
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ jobs:
if: "github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'rust-lang-ci/rust'"
steps:
- name: checkout the source code
uses: actions/checkout@v1
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: publish toolstate
Expand Down
16 changes: 0 additions & 16 deletions compiler/rustc_arena/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,22 +298,6 @@ impl<T> TypedArena<T> {
}
}

/// Clears the arena. Deallocates all but the longest chunk which may be reused.
pub fn clear(&mut self) {
unsafe {
// Clear the last chunk, which is partially filled.
let mut chunks_borrow = self.chunks.borrow_mut();
if let Some(mut last_chunk) = chunks_borrow.last_mut() {
self.clear_last_chunk(&mut last_chunk);
let len = chunks_borrow.len();
// If `T` is ZST, code below has no effect.
for mut chunk in chunks_borrow.drain(..len - 1) {
chunk.destroy(chunk.entries);
}
}
}
}

// Drops the contents of the last chunk. The last chunk is partially empty, unlike all other
// chunks.
fn clear_last_chunk(&self, last_chunk: &mut TypedArenaChunk<T>) {
Expand Down
18 changes: 18 additions & 0 deletions compiler/rustc_arena/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ struct Point {
z: i32,
}

impl<T> TypedArena<T> {
/// Clears the arena. Deallocates all but the longest chunk which may be reused.
fn clear(&mut self) {
unsafe {
// Clear the last chunk, which is partially filled.
let mut chunks_borrow = self.chunks.borrow_mut();
if let Some(mut last_chunk) = chunks_borrow.last_mut() {
self.clear_last_chunk(&mut last_chunk);
let len = chunks_borrow.len();
// If `T` is ZST, code below has no effect.
for mut chunk in chunks_borrow.drain(..len - 1) {
chunk.destroy(chunk.entries);
}
}
}
}
}

#[test]
pub fn test_unused() {
let arena: TypedArena<Point> = TypedArena::default();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(assert_matches)]
#![feature(bool_to_option)]
#![feature(option_expect_none)]
#![feature(box_patterns)]
#![feature(drain_filter)]
#![feature(try_blocks)]
Expand Down
14 changes: 2 additions & 12 deletions compiler/rustc_data_structures/src/tiny_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
mod tests;

#[derive(Clone)]
pub struct TinyList<T: PartialEq> {
pub struct TinyList<T> {
head: Option<Element<T>>,
}

Expand Down Expand Up @@ -56,20 +56,10 @@ impl<T: PartialEq> TinyList<T> {
}
false
}

#[inline]
pub fn len(&self) -> usize {
let (mut elem, mut count) = (self.head.as_ref(), 0);
while let Some(ref e) = elem {
count += 1;
elem = e.next.as_deref();
}
count
}
}

#[derive(Clone)]
struct Element<T: PartialEq> {
struct Element<T> {
data: T,
next: Option<Box<Element<T>>>,
}
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_data_structures/src/tiny_list/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ use super::*;
extern crate test;
use test::{black_box, Bencher};

impl<T> TinyList<T> {
fn len(&self) -> usize {
let (mut elem, mut count) = (self.head.as_ref(), 0);
while let Some(ref e) = elem {
count += 1;
elem = e.next.as_deref();
}
count
}
}

#[test]
fn test_contains_and_insert() {
fn do_insert(i: u32) -> bool {
Expand Down
10 changes: 2 additions & 8 deletions compiler/rustc_data_structures/src/transitive_relation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::mem;
mod tests;

#[derive(Clone, Debug)]
pub struct TransitiveRelation<T: Eq + Hash> {
pub struct TransitiveRelation<T> {
// List of elements. This is used to map from a T to a usize.
elements: FxIndexSet<T>,

Expand Down Expand Up @@ -49,7 +49,7 @@ struct Edge {
target: Index,
}

impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
impl<T: Eq + Hash> TransitiveRelation<T> {
pub fn is_empty(&self) -> bool {
self.edges.is_empty()
}
Expand Down Expand Up @@ -322,12 +322,6 @@ impl<T: Clone + Debug + Eq + Hash> TransitiveRelation<T> {
.collect()
}

/// A "best" parent in some sense. See `parents` and
/// `postdom_upper_bound` for more details.
pub fn postdom_parent(&self, a: &T) -> Option<&T> {
self.mutual_immediate_postdominator(self.parents(a))
}

fn with_closure<OP, R>(&self, op: OP) -> R
where
OP: FnOnce(&BitMatrix<usize, usize>) -> R,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
use super::*;

impl<T: Eq + Hash> TransitiveRelation<T> {
/// A "best" parent in some sense. See `parents` and
/// `postdom_upper_bound` for more details.
fn postdom_parent(&self, a: &T) -> Option<&T> {
self.mutual_immediate_postdominator(self.parents(a))
}
}

#[test]
fn test_one_step() {
let mut relation = TransitiveRelation::default();
Expand Down
21 changes: 6 additions & 15 deletions compiler/rustc_errors/src/diagnostic_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ struct DiagnosticBuilderInner<'a> {
allow_suggestions: bool,
}

/// This is a helper macro for [`forward!`] that allows automatically adding documentation
/// that uses tokens from [`forward!`]'s input.
macro_rules! forward_inner_docs {
($e:expr => $i:item) => {
#[doc = $e]
$i
};
}

/// In general, the `DiagnosticBuilder` uses deref to allow access to
/// the fields and methods of the embedded `diagnostic` in a
/// transparent way. *However,* many of the methods are intended to
Expand All @@ -54,11 +45,11 @@ macro_rules! forward {
pub fn $n:ident(&self, $($name:ident: $ty:ty),* $(,)?) -> &Self
) => {
$(#[$attrs])*
forward_inner_docs!(concat!("See [`Diagnostic::", stringify!($n), "()`].") =>
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
pub fn $n(&self, $($name: $ty),*) -> &Self {
self.diagnostic.$n($($name),*);
self
});
}
};

// Forward pattern for &mut self -> &mut Self
Expand All @@ -67,11 +58,11 @@ macro_rules! forward {
pub fn $n:ident(&mut self, $($name:ident: $ty:ty),* $(,)?) -> &mut Self
) => {
$(#[$attrs])*
forward_inner_docs!(concat!("See [`Diagnostic::", stringify!($n), "()`].") =>
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
pub fn $n(&mut self, $($name: $ty),*) -> &mut Self {
self.0.diagnostic.$n($($name),*);
self
});
}
};

// Forward pattern for &mut self -> &mut Self, with generic parameters.
Expand All @@ -84,11 +75,11 @@ macro_rules! forward {
) -> &mut Self
) => {
$(#[$attrs])*
forward_inner_docs!(concat!("See [`Diagnostic::", stringify!($n), "()`].") =>
#[doc = concat!("See [`Diagnostic::", stringify!($n), "()`].")]
pub fn $n<$($generic: $bound),*>(&mut self, $($name: $ty),*) -> &mut Self {
self.0.diagnostic.$n($($name),*);
self
});
}
};
}

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_errors/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(crate_visibility_modifier)]
#![feature(backtrace)]
#![feature(extended_key_value_attributes)]
#![feature(nll)]

#[macro_use]
Expand Down
46 changes: 29 additions & 17 deletions compiler/rustc_expand/src/proc_macro_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ impl ToInternal<token::DelimToken> for Delimiter {
}
}

impl FromInternal<(TreeAndSpacing, &'_ ParseSess, &'_ mut Vec<Self>)>
impl FromInternal<(TreeAndSpacing, &'_ mut Vec<Self>, &mut Rustc<'_>)>
for TokenTree<Group, Punct, Ident, Literal>
{
fn from_internal(
((tree, spacing), sess, stack): (TreeAndSpacing, &ParseSess, &mut Vec<Self>),
((tree, spacing), stack, rustc): (TreeAndSpacing, &mut Vec<Self>, &mut Rustc<'_>),
) -> Self {
use rustc_ast::token::*;

Expand Down Expand Up @@ -146,10 +146,10 @@ impl FromInternal<(TreeAndSpacing, &'_ ParseSess, &'_ mut Vec<Self>)>
SingleQuote => op!('\''),

Ident(name, false) if name == kw::DollarCrate => tt!(Ident::dollar_crate()),
Ident(name, is_raw) => tt!(Ident::new(sess, name, is_raw)),
Ident(name, is_raw) => tt!(Ident::new(rustc.sess, name, is_raw)),
Lifetime(name) => {
let ident = symbol::Ident::new(name, span).without_first_quote();
stack.push(tt!(Ident::new(sess, ident.name, false)));
stack.push(tt!(Ident::new(rustc.sess, ident.name, false)));
tt!(Punct::new('\'', true))
}
Literal(lit) => tt!(Literal { lit }),
Expand Down Expand Up @@ -179,15 +179,15 @@ impl FromInternal<(TreeAndSpacing, &'_ ParseSess, &'_ mut Vec<Self>)>
}

Interpolated(nt) => {
if let Some((name, is_raw)) = ident_name_compatibility_hack(&nt, span, sess) {
TokenTree::Ident(Ident::new(sess, name.name, is_raw, name.span))
if let Some((name, is_raw)) = ident_name_compatibility_hack(&nt, span, rustc) {
TokenTree::Ident(Ident::new(rustc.sess, name.name, is_raw, name.span))
} else {
let stream = nt_to_tokenstream(&nt, sess, CanSynthesizeMissingTokens::No);
let stream = nt_to_tokenstream(&nt, rustc.sess, CanSynthesizeMissingTokens::No);
TokenTree::Group(Group {
delimiter: Delimiter::None,
stream,
span: DelimSpan::from_single(span),
flatten: crate::base::pretty_printing_compatibility_hack(&nt, sess),
flatten: crate::base::pretty_printing_compatibility_hack(&nt, rustc.sess),
})
}
}
Expand Down Expand Up @@ -449,7 +449,7 @@ impl server::TokenStreamIter for Rustc<'_> {
loop {
let tree = iter.stack.pop().or_else(|| {
let next = iter.cursor.next_with_spacing()?;
Some(TokenTree::from_internal((next, self.sess, &mut iter.stack)))
Some(TokenTree::from_internal((next, &mut iter.stack, self)))
})?;
// A hack used to pass AST fragments to attribute and derive macros
// as a single nonterminal token instead of a token stream.
Expand Down Expand Up @@ -719,11 +719,11 @@ impl server::Span for Rustc<'_> {
fn ident_name_compatibility_hack(
nt: &Nonterminal,
orig_span: Span,
sess: &ParseSess,
rustc: &mut Rustc<'_>,
) -> Option<(rustc_span::symbol::Ident, bool)> {
if let NtIdent(ident, is_raw) = nt {
if let ExpnKind::Macro(_, macro_name) = orig_span.ctxt().outer_expn_data().kind {
let source_map = sess.source_map();
let source_map = rustc.sess.source_map();
let filename = source_map.span_to_filename(orig_span);
if let FileName::Real(RealFileName::Named(path)) = filename {
let matches_prefix = |prefix, filename| {
Expand All @@ -745,7 +745,7 @@ fn ident_name_compatibility_hack(
let snippet = source_map.span_to_snippet(orig_span);
if snippet.as_deref() == Ok("$name") {
if time_macros_impl {
sess.buffer_lint_with_diagnostic(
rustc.sess.buffer_lint_with_diagnostic(
&PROC_MACRO_BACK_COMPAT,
orig_span,
ast::CRATE_NODE_ID,
Expand All @@ -759,13 +759,25 @@ fn ident_name_compatibility_hack(
}
}

if macro_name == sym::tuple_from_req
&& (matches_prefix("actix-web", "extract.rs")
|| matches_prefix("actori-web", "extract.rs"))
{
if macro_name == sym::tuple_from_req && matches_prefix("actix-web", "extract.rs") {
let snippet = source_map.span_to_snippet(orig_span);
if snippet.as_deref() == Ok("$T") {
return Some((*ident, *is_raw));
if let FileName::Real(RealFileName::Named(macro_path)) =
source_map.span_to_filename(rustc.def_site)
{
if macro_path.to_string_lossy().contains("pin-project-internal-0.") {
rustc.sess.buffer_lint_with_diagnostic(
&PROC_MACRO_BACK_COMPAT,
orig_span,
ast::CRATE_NODE_ID,
"using an old version of `actix-web`",
BuiltinLintDiagnostics::ProcMacroBackCompat(
"the version of `actix-web` you are using might stop compiling in future versions of Rust; \
please update to the latest version of the `actix-web` crate to avoid breakage".to_string())
);
return Some((*ident, *is_raw));
}
}
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_middle/src/ich/impls_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ impl<'ctx> rustc_ast::HashStableContext for StableHashingContext<'ctx> {
item.hash_stable(self, hasher);
style.hash_stable(self, hasher);
span.hash_stable(self, hasher);
tokens.as_ref().expect_none("Tokens should have been removed during lowering!");
assert_matches!(
tokens.as_ref(),
None,
"Tokens should have been removed during lowering!"
);
} else {
unreachable!();
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
#![feature(array_windows)]
#![feature(assert_matches)]
#![feature(assoc_char_funcs)]
#![feature(backtrace)]
#![feature(bool_to_option)]
Expand All @@ -38,7 +39,6 @@
#![feature(extern_types)]
#![feature(nll)]
#![feature(once_cell)]
#![feature(option_expect_none)]
#![feature(or_patterns)]
#![feature(min_specialization)]
#![feature(trusted_len)]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
for dest in bytes {
*dest = src.next().expect("iterator was shorter than it said it would be");
}
src.next().expect_none("iterator was longer than it said it would be");
assert_matches!(src.next(), None, "iterator was longer than it said it would be");
Ok(())
}

Expand Down
Loading