Skip to content

Rollup of 8 pull requests #88165

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

Merged
merged 16 commits into from
Aug 19, 2021
Merged
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -113,6 +113,7 @@ Hanna Kruppe <[email protected]> <[email protected]>
Heather <[email protected]> <[email protected]>
Heather <[email protected]> <[email protected]>
Herman J. Radtke III <[email protected]> Herman J. Radtke III <[email protected]>
Hirochika Matsumoto <[email protected]> <[email protected]>
Ian Jackson <[email protected]> <[email protected]>
Ian Jackson <[email protected]> <[email protected]>
Ian Jackson <[email protected]> <[email protected]>
104 changes: 56 additions & 48 deletions compiler/rustc_macros/src/query.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use proc_macro::TokenStream;
use proc_macro2::{Delimiter, TokenTree};
use quote::quote;
use quote::{quote, quote_spanned};
use syn::parse::{Parse, ParseStream, Result};
use syn::punctuated::Punctuated;
use syn::spanned::Spanned;
@@ -42,19 +42,19 @@ enum QueryModifier {
LoadCached(Ident, Ident, Block),

/// A cycle error for this query aborting the compilation with a fatal error.
FatalCycle,
FatalCycle(Ident),

/// A cycle error results in a delay_bug call
CycleDelayBug,
CycleDelayBug(Ident),

/// Don't hash the result, instead just mark a query red if it runs
NoHash,
NoHash(Ident),

/// Generate a dep node based on the dependencies of the query
Anon,
Anon(Ident),

/// Always evaluate the query, ignoring its dependencies
EvalAlways,
EvalAlways(Ident),
}

impl Parse for QueryModifier {
@@ -111,15 +111,15 @@ impl Parse for QueryModifier {
let ty = args.parse()?;
Ok(QueryModifier::Storage(ty))
} else if modifier == "fatal_cycle" {
Ok(QueryModifier::FatalCycle)
Ok(QueryModifier::FatalCycle(modifier))
} else if modifier == "cycle_delay_bug" {
Ok(QueryModifier::CycleDelayBug)
Ok(QueryModifier::CycleDelayBug(modifier))
} else if modifier == "no_hash" {
Ok(QueryModifier::NoHash)
Ok(QueryModifier::NoHash(modifier))
} else if modifier == "anon" {
Ok(QueryModifier::Anon)
Ok(QueryModifier::Anon(modifier))
} else if modifier == "eval_always" {
Ok(QueryModifier::EvalAlways)
Ok(QueryModifier::EvalAlways(modifier))
} else {
Err(Error::new(modifier.span(), "unknown query modifier"))
}
@@ -203,19 +203,19 @@ struct QueryModifiers {
load_cached: Option<(Ident, Ident, Block)>,

/// A cycle error for this query aborting the compilation with a fatal error.
fatal_cycle: bool,
fatal_cycle: Option<Ident>,

/// A cycle error results in a delay_bug call
cycle_delay_bug: bool,
cycle_delay_bug: Option<Ident>,

/// Don't hash the result, instead just mark a query red if it runs
no_hash: bool,
no_hash: Option<Ident>,

/// Generate a dep node based on the dependencies of the query
anon: bool,
anon: Option<Ident>,

// Always evaluate the query, ignoring its dependencies
eval_always: bool,
eval_always: Option<Ident>,
}

/// Process query modifiers into a struct, erroring on duplicates
@@ -224,11 +224,11 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
let mut storage = None;
let mut cache = None;
let mut desc = None;
let mut fatal_cycle = false;
let mut cycle_delay_bug = false;
let mut no_hash = false;
let mut anon = false;
let mut eval_always = false;
let mut fatal_cycle = None;
let mut cycle_delay_bug = None;
let mut no_hash = None;
let mut anon = None;
let mut eval_always = None;
for modifier in query.modifiers.0.drain(..) {
match modifier {
QueryModifier::LoadCached(tcx, id, block) => {
@@ -289,35 +289,35 @@ fn process_modifiers(query: &mut Query) -> QueryModifiers {
}
desc = Some((tcx, list));
}
QueryModifier::FatalCycle => {
if fatal_cycle {
QueryModifier::FatalCycle(ident) => {
if fatal_cycle.is_some() {
panic!("duplicate modifier `fatal_cycle` for query `{}`", query.name);
}
fatal_cycle = true;
fatal_cycle = Some(ident);
}
QueryModifier::CycleDelayBug => {
if cycle_delay_bug {
QueryModifier::CycleDelayBug(ident) => {
if cycle_delay_bug.is_some() {
panic!("duplicate modifier `cycle_delay_bug` for query `{}`", query.name);
}
cycle_delay_bug = true;
cycle_delay_bug = Some(ident);
}
QueryModifier::NoHash => {
if no_hash {
QueryModifier::NoHash(ident) => {
if no_hash.is_some() {
panic!("duplicate modifier `no_hash` for query `{}`", query.name);
}
no_hash = true;
no_hash = Some(ident);
}
QueryModifier::Anon => {
if anon {
QueryModifier::Anon(ident) => {
if anon.is_some() {
panic!("duplicate modifier `anon` for query `{}`", query.name);
}
anon = true;
anon = Some(ident);
}
QueryModifier::EvalAlways => {
if eval_always {
QueryModifier::EvalAlways(ident) => {
if eval_always.is_some() {
panic!("duplicate modifier `eval_always` for query `{}`", query.name);
}
eval_always = true;
eval_always = Some(ident);
}
}
}
@@ -454,31 +454,39 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
let mut attributes = Vec::new();

// Pass on the fatal_cycle modifier
if modifiers.fatal_cycle {
attributes.push(quote! { fatal_cycle });
if let Some(fatal_cycle) = &modifiers.fatal_cycle {
attributes.push(quote! { #fatal_cycle });
};
// Pass on the storage modifier
if let Some(ref ty) = modifiers.storage {
attributes.push(quote! { storage(#ty) });
let span = ty.span();
attributes.push(quote_spanned! {span=> storage(#ty) });
};
// Pass on the cycle_delay_bug modifier
if modifiers.cycle_delay_bug {
attributes.push(quote! { cycle_delay_bug });
if let Some(cycle_delay_bug) = &modifiers.cycle_delay_bug {
attributes.push(quote! { #cycle_delay_bug });
};
// Pass on the no_hash modifier
if modifiers.no_hash {
attributes.push(quote! { no_hash });
if let Some(no_hash) = &modifiers.no_hash {
attributes.push(quote! { #no_hash });
};
// Pass on the anon modifier
if modifiers.anon {
attributes.push(quote! { anon });
if let Some(anon) = &modifiers.anon {
attributes.push(quote! { #anon });
};
// Pass on the eval_always modifier
if modifiers.eval_always {
attributes.push(quote! { eval_always });
if let Some(eval_always) = &modifiers.eval_always {
attributes.push(quote! { #eval_always });
};

let attribute_stream = quote! {#(#attributes),*};
// This uses the span of the query definition for the commas,
// which can be important if we later encounter any ambiguity
// errors with any of the numerous macro_rules! macros that
// we use. Using the call-site span would result in a span pointing
// at the entire `rustc_queries!` invocation, which wouldn't
// be very useful.
let span = name.span();
let attribute_stream = quote_spanned! {span=> #(#attributes),*};
let doc_comments = query.doc_comments.iter();
// Add the query to the group
query_stream.extend(quote! {
139 changes: 76 additions & 63 deletions compiler/rustc_privacy/src/lib.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
@@ -157,7 +157,7 @@ scoped_tls::scoped_thread_local!(static SESSION_GLOBALS: SessionGlobals);
// FIXME: We should use this enum or something like it to get rid of the
// use of magic `/rust/1.x/...` paths across the board.
#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd)]
#[derive(HashStable_Generic, Decodable)]
#[derive(Decodable)]
pub enum RealFileName {
LocalPath(PathBuf),
/// For remapped paths (namely paths into libstd that have been mapped
@@ -269,7 +269,7 @@ impl RealFileName {

/// Differentiates between real files and common virtual files.
#[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash)]
#[derive(HashStable_Generic, Decodable, Encodable)]
#[derive(Decodable, Encodable)]
pub enum FileName {
Real(RealFileName),
/// Call to `quote!`.
21 changes: 14 additions & 7 deletions library/std/src/net/tcp.rs
Original file line number Diff line number Diff line change
@@ -767,17 +767,24 @@ impl TcpListener {
/// # Examples
///
/// ```no_run
/// use std::net::TcpListener;
/// use std::net::{TcpListener, TcpStream};
///
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
/// fn handle_connection(stream: TcpStream) {
/// //...
/// }
///
/// for stream in listener.incoming() {
/// match stream {
/// Ok(stream) => {
/// println!("new client!");
/// fn main() -> std::io::Result<()> {
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
///
/// for stream in listener.incoming() {
/// match stream {
/// Ok(stream) => {
/// handle_connection(stream);
/// }
/// Err(e) => { /* connection failed */ }
/// }
/// Err(e) => { /* connection failed */ }
/// }
/// Ok(())
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
7 changes: 4 additions & 3 deletions src/librustdoc/html/highlight.rs
Original file line number Diff line number Diff line change
@@ -65,10 +65,11 @@ fn write_header(out: &mut Buffer, class: Option<&str>, extra_content: Option<Buf
out.push_buffer(extra);
}
if let Some(class) = class {
writeln!(out, "<pre class=\"rust {}\">", class);
write!(out, "<pre class=\"rust {}\">", class);
} else {
writeln!(out, "<pre class=\"rust\">");
write!(out, "<pre class=\"rust\">");
}
write!(out, "<code>");
}

/// Convert the given `src` source code into HTML by adding classes for highlighting.
@@ -101,7 +102,7 @@ fn write_code(
}

fn write_footer(out: &mut Buffer, playground_button: Option<&str>) {
writeln!(out, "</pre>{}</div>", playground_button.unwrap_or_default());
writeln!(out, "</code></pre>{}</div>", playground_button.unwrap_or_default());
}

/// How a span of text is classified. Mostly corresponds to token kinds.
2 changes: 1 addition & 1 deletion src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
@@ -234,7 +234,7 @@ impl<'a, I: Iterator<Item = Event<'a>>> Iterator for CodeBlocks<'_, 'a, I> {
return Some(Event::Html(
format!(
"<div class=\"example-wrap\">\
<pre class=\"language-{}\">{}</pre>\
<pre class=\"language-{}\"><code>{}</code></pre>\
</div>",
lang,
Escape(&text),
550 changes: 289 additions & 261 deletions src/librustdoc/html/render/print_item.rs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
@@ -249,7 +249,6 @@ code, pre, a.test-arrow, .code-header {
}
.docblock pre code, .docblock-short pre code {
padding: 0;
padding-right: 1ex;
}
pre {
padding: 14px;
15 changes: 15 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// revisions: cfail
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
// regression test for #77650
fn c<T, const N: std::num::NonZeroUsize>()
where
[T; N.get()]: Sized,
{
use std::convert::TryFrom;
<[T; N.get()]>::try_from(())
//~^ error: the trait bound
//~^^ error: mismatched types
}

fn main() {}
35 changes: 35 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
error[E0277]: the trait bound `[T; _]: From<()>` is not satisfied
--> $DIR/hash-tyvid-regression-1.rs:9:5
|
LL | <[T; N.get()]>::try_from(())
| ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<()>` is not implemented for `[T; _]`
|
= note: required because of the requirements on the impl of `Into<[T; _]>` for `()`
= note: required because of the requirements on the impl of `TryFrom<()>` for `[T; _]`
note: required by `try_from`
--> $SRC_DIR/core/src/convert/mod.rs:LL:COL
|
LL | fn try_from(value: T) -> Result<Self, Self::Error>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
--> $DIR/hash-tyvid-regression-1.rs:9:5
|
LL | <[T; N.get()]>::try_from(())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found enum `Result`
|
= note: expected unit type `()`
found enum `Result<[T; _], Infallible>`
help: consider using a semicolon here
|
LL | <[T; N.get()]>::try_from(());
| +
help: try adding a return type
|
LL | -> Result<[T; _], Infallible> where
| +++++++++++++++++++++++++++++

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.
18 changes: 18 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// revisions: cfail
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
// regression test for #77650
struct C<T, const N: core::num::NonZeroUsize>([T; N.get()])
where
[T; N.get()]: Sized;
impl<'a, const N: core::num::NonZeroUsize, A, B: PartialEq<A>> PartialEq<&'a [A]> for C<B, N>
where
[B; N.get()]: Sized,
{
fn eq(&self, other: &&'a [A]) -> bool {
self.0 == other
//~^ error: can't compare
}
}

fn main() {}
11 changes: 11 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
error[E0277]: can't compare `[B; _]` with `&&[A]`
--> $DIR/hash-tyvid-regression-2.rs:12:16
|
LL | self.0 == other
| ^^ no implementation for `[B; _] == &&[A]`
|
= help: the trait `PartialEq<&&[A]>` is not implemented for `[B; _]`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
26 changes: 26 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// revisions: cfail
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
// regression test for #79251
struct Node<const D: usize>
where
SmallVec<{ D * 2 }>: ,
{
keys: SmallVec<{ D * 2 }>,
}

impl<const D: usize> Node<D>
where
SmallVec<{ D * 2 }>: ,
{
fn new() -> Self {
let mut node = Node::new();
node.keys.some_function();
//~^ error: no method named
node
}
}

struct SmallVec<const D: usize> {}

fn main() {}
12 changes: 12 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-3.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0599]: no method named `some_function` found for struct `SmallVec` in the current scope
--> $DIR/hash-tyvid-regression-3.rs:17:19
|
LL | node.keys.some_function();
| ^^^^^^^^^^^^^ method not found in `SmallVec<{ D * 2 }>`
...
LL | struct SmallVec<const D: usize> {}
| ------------------------------- method `some_function` not found for this

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
40 changes: 40 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-4.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// revisions: cfail
#![feature(const_generics, const_evaluatable_checked)]
#![allow(incomplete_features)]
// regression test for #79251
#[derive(Debug)]
struct Node<K, const D: usize>
where
SmallVec<K, { D * 2 }>: ,
{
keys: SmallVec<K, { D * 2 }>,
}

impl<K, const D: usize> Node<K, D>
where
SmallVec<K, { D * 2 }>: ,
{
fn new() -> Self {
panic!()
}

#[inline(never)]
fn split(&mut self, i: usize, k: K, right: bool) -> Node<K, D> {
let mut node = Node::new();
node.keys.push(k);
//~^ error: no method named
node
}
}

#[derive(Debug)]
struct SmallVec<T, const D: usize> {
data: [T; D],
}
impl<T, const D: usize> SmallVec<T, D> {
fn new() -> Self {
panic!()
}
}

fn main() {}
12 changes: 12 additions & 0 deletions src/test/incremental/const-generics/hash-tyvid-regression-4.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
error[E0599]: no method named `push` found for struct `SmallVec` in the current scope
--> $DIR/hash-tyvid-regression-4.rs:23:19
|
LL | node.keys.push(k);
| ^^^^ method not found in `SmallVec<_, { D * 2 }>`
...
LL | struct SmallVec<T, const D: usize> {
| ---------------------------------- method `push` not found for this

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
20 changes: 20 additions & 0 deletions src/test/rustdoc-gui/code-tags.goml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// This test ensures that items and documentation code blocks are wrapped in <pre><code>
goto: file://|DOC_PATH|/test_docs/fn.foo.html
size: (1080, 600)
// There should be three doc codeblocks
// Check that their content is inside <pre><code>
assert-count: (".example-wrap pre > code", 3)
// Check that function signature is inside <pre><code>
assert: "pre.rust.fn > code"

goto: file://|DOC_PATH|/test_docs/struct.Foo.html
assert: "pre.rust.struct > code"

goto: file://|DOC_PATH|/test_docs/enum.AnEnum.html
assert: "pre.rust.enum > code"

goto: file://|DOC_PATH|/test_docs/trait.AnotherOne.html
assert: "pre.rust.trait > code"

goto: file://|DOC_PATH|/test_docs/type.SomeType.html
assert: "pre.rust.typedef > code"
2 changes: 1 addition & 1 deletion src/test/rustdoc-gui/source-code-page.goml
Original file line number Diff line number Diff line change
@@ -12,4 +12,4 @@ assert-attribute: (".line-numbers > span:nth-child(5)", {"class": "line-highligh
assert-attribute: (".line-numbers > span:nth-child(6)", {"class": "line-highlighted"})
assert-attribute-false: (".line-numbers > span:nth-child(7)", {"class": "line-highlighted"})
// This is to ensure that the content is correctly align with the line numbers.
compare-elements-position: ("//*[@id='1']", ".rust > span", ("y"))
compare-elements-position: ("//*[@id='1']", ".rust > code > span", ("y"))
9 changes: 5 additions & 4 deletions src/test/ui/type-alias-impl-trait/unused_generic_param.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// check-pass

#![feature(type_alias_impl_trait)]
#![allow(dead_code)]

fn main() {}

type PartiallyDefined<T> = impl 'static;
//~^ ERROR: at least one trait must be specified
type PartiallyDefined<T> = impl Sized;

fn partially_defined<T: std::fmt::Debug>(_: T) -> PartiallyDefined<T> {
4u32
}

type PartiallyDefined2<T> = impl 'static;
//~^ ERROR: at least one trait must be specified
type PartiallyDefined2<T> = impl Sized;

fn partially_defined2<T: std::fmt::Debug>(_: T) -> PartiallyDefined2<T> {
4u32
14 changes: 0 additions & 14 deletions src/test/ui/type-alias-impl-trait/unused_generic_param.stderr

This file was deleted.