Auto merge of #145997 - matthiaskrgr:rollup-tsgylre, r=matthiaskrgr

Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#145675 (Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [rust-lang/rust#1 of Batch rust-lang/rust#2])
 - rust-lang/rust#145676 (Rehome 30 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [rust-lang/rust#2 of Batch rust-lang/rust#2])
 - rust-lang/rust#145982 (compiletest: Reduce the number of `println!` calls that don't have access to `TestCx`)
 - rust-lang/rust#145984 (`TokenStream` cleanups)

r? `@ghost`
`@rustbot` modify labels: rollup
This commit is contained in:
bors
2025-08-29 16:21:11 +00:00
95 changed files with 202 additions and 276 deletions

View File

@@ -3,15 +3,6 @@
//! `TokenStream`s represent syntactic objects before they are converted into ASTs. //! `TokenStream`s represent syntactic objects before they are converted into ASTs.
//! A `TokenStream` is, roughly speaking, a sequence of [`TokenTree`]s, //! A `TokenStream` is, roughly speaking, a sequence of [`TokenTree`]s,
//! which are themselves a single [`Token`] or a `Delimited` subsequence of tokens. //! which are themselves a single [`Token`] or a `Delimited` subsequence of tokens.
//!
//! ## Ownership
//!
//! `TokenStream`s are persistent data structures constructed as ropes with reference
//! counted-children. In general, this means that calling an operation on a `TokenStream`
//! (such as `slice`) produces an entirely new `TokenStream` from the borrowed reference to
//! the original. This essentially coerces `TokenStream`s into "views" of their subparts,
//! and a borrowed `TokenStream` is sufficient to build an owned `TokenStream` without taking
//! ownership of the original.
use std::borrow::Cow; use std::borrow::Cow;
use std::ops::Range; use std::ops::Range;
@@ -99,17 +90,6 @@ impl TokenTree {
} }
} }
impl<CTX> HashStable<CTX> for TokenStream
where
CTX: crate::HashStableContext,
{
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
for sub_tt in self.iter() {
sub_tt.hash_stable(hcx, hasher);
}
}
}
/// A lazy version of [`AttrTokenStream`], which defers creation of an actual /// A lazy version of [`AttrTokenStream`], which defers creation of an actual
/// `AttrTokenStream` until it is needed. /// `AttrTokenStream` until it is needed.
#[derive(Clone)] #[derive(Clone)]
@@ -556,10 +536,6 @@ pub struct AttrsTarget {
pub tokens: LazyAttrTokenStream, pub tokens: LazyAttrTokenStream,
} }
/// A `TokenStream` is an abstract sequence of tokens, organized into [`TokenTree`]s.
#[derive(Clone, Debug, Default, Encodable, Decodable)]
pub struct TokenStream(pub(crate) Arc<Vec<TokenTree>>);
/// Indicates whether a token can join with the following token to form a /// Indicates whether a token can join with the following token to form a
/// compound token. Used for conversions to `proc_macro::Spacing`. Also used to /// compound token. Used for conversions to `proc_macro::Spacing`. Also used to
/// guide pretty-printing, which is where the `JointHidden` value (which isn't /// guide pretty-printing, which is where the `JointHidden` value (which isn't
@@ -620,58 +596,9 @@ pub enum Spacing {
JointHidden, JointHidden,
} }
impl TokenStream { /// A `TokenStream` is an abstract sequence of tokens, organized into [`TokenTree`]s.
/// Given a `TokenStream` with a `Stream` of only two arguments, return a new `TokenStream` #[derive(Clone, Debug, Default, Encodable, Decodable)]
/// separating the two arguments with a comma for diagnostic suggestions. pub struct TokenStream(pub(crate) Arc<Vec<TokenTree>>);
pub fn add_comma(&self) -> Option<(TokenStream, Span)> {
// Used to suggest if a user writes `foo!(a b);`
let mut suggestion = None;
let mut iter = self.0.iter().enumerate().peekable();
while let Some((pos, ts)) = iter.next() {
if let Some((_, next)) = iter.peek() {
let sp = match (&ts, &next) {
(_, TokenTree::Token(Token { kind: token::Comma, .. }, _)) => continue,
(
TokenTree::Token(token_left, Spacing::Alone),
TokenTree::Token(token_right, _),
) if (token_left.is_non_reserved_ident() || token_left.is_lit())
&& (token_right.is_non_reserved_ident() || token_right.is_lit()) =>
{
token_left.span
}
(TokenTree::Delimited(sp, ..), _) => sp.entire(),
_ => continue,
};
let sp = sp.shrink_to_hi();
let comma = TokenTree::token_alone(token::Comma, sp);
suggestion = Some((pos, comma, sp));
}
}
if let Some((pos, comma, sp)) = suggestion {
let mut new_stream = Vec::with_capacity(self.0.len() + 1);
let parts = self.0.split_at(pos + 1);
new_stream.extend_from_slice(parts.0);
new_stream.push(comma);
new_stream.extend_from_slice(parts.1);
return Some((TokenStream::new(new_stream), sp));
}
None
}
}
impl FromIterator<TokenTree> for TokenStream {
fn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self {
TokenStream::new(iter.into_iter().collect::<Vec<TokenTree>>())
}
}
impl Eq for TokenStream {}
impl PartialEq<TokenStream> for TokenStream {
fn eq(&self, other: &TokenStream) -> bool {
self.iter().eq(other.iter())
}
}
impl TokenStream { impl TokenStream {
pub fn new(tts: Vec<TokenTree>) -> TokenStream { pub fn new(tts: Vec<TokenTree>) -> TokenStream {
@@ -847,6 +774,68 @@ impl TokenStream {
} }
} }
} }
/// Given a `TokenStream` with a `Stream` of only two arguments, return a new `TokenStream`
/// separating the two arguments with a comma for diagnostic suggestions.
pub fn add_comma(&self) -> Option<(TokenStream, Span)> {
// Used to suggest if a user writes `foo!(a b);`
let mut suggestion = None;
let mut iter = self.0.iter().enumerate().peekable();
while let Some((pos, ts)) = iter.next() {
if let Some((_, next)) = iter.peek() {
let sp = match (&ts, &next) {
(_, TokenTree::Token(Token { kind: token::Comma, .. }, _)) => continue,
(
TokenTree::Token(token_left, Spacing::Alone),
TokenTree::Token(token_right, _),
) if (token_left.is_non_reserved_ident() || token_left.is_lit())
&& (token_right.is_non_reserved_ident() || token_right.is_lit()) =>
{
token_left.span
}
(TokenTree::Delimited(sp, ..), _) => sp.entire(),
_ => continue,
};
let sp = sp.shrink_to_hi();
let comma = TokenTree::token_alone(token::Comma, sp);
suggestion = Some((pos, comma, sp));
}
}
if let Some((pos, comma, sp)) = suggestion {
let mut new_stream = Vec::with_capacity(self.0.len() + 1);
let parts = self.0.split_at(pos + 1);
new_stream.extend_from_slice(parts.0);
new_stream.push(comma);
new_stream.extend_from_slice(parts.1);
return Some((TokenStream::new(new_stream), sp));
}
None
}
}
impl PartialEq<TokenStream> for TokenStream {
fn eq(&self, other: &TokenStream) -> bool {
self.iter().eq(other.iter())
}
}
impl Eq for TokenStream {}
impl FromIterator<TokenTree> for TokenStream {
fn from_iter<I: IntoIterator<Item = TokenTree>>(iter: I) -> Self {
TokenStream::new(iter.into_iter().collect::<Vec<TokenTree>>())
}
}
impl<CTX> HashStable<CTX> for TokenStream
where
CTX: crate::HashStableContext,
{
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
for sub_tt in self.iter() {
sub_tt.hash_stable(hcx, hasher);
}
}
} }
#[derive(Clone)] #[derive(Clone)]

View File

@@ -2,7 +2,7 @@ use std::env;
use std::io::IsTerminal; use std::io::IsTerminal;
use std::sync::Arc; use std::sync::Arc;
use compiletest::{early_config_check, log_config, parse_config, run_tests}; use compiletest::{early_config_check, parse_config, run_tests};
fn main() { fn main() {
tracing_subscriber::fmt::init(); tracing_subscriber::fmt::init();
@@ -19,6 +19,5 @@ fn main() {
early_config_check(&config); early_config_check(&config);
log_config(&config);
run_tests(config); run_tests(config);
} }

View File

@@ -9,7 +9,6 @@
mod tests; mod tests;
pub mod common; pub mod common;
pub mod compute_diff;
mod debuggers; mod debuggers;
pub mod diagnostics; pub mod diagnostics;
pub mod directives; pub mod directives;
@@ -44,7 +43,6 @@ use crate::common::{
}; };
use crate::directives::DirectivesCache; use crate::directives::DirectivesCache;
use crate::executor::{CollectedTest, ColorConfig}; use crate::executor::{CollectedTest, ColorConfig};
use crate::util::logv;
/// Creates the `Config` instance for this invocation of compiletest. /// Creates the `Config` instance for this invocation of compiletest.
/// ///
@@ -477,51 +475,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
} }
} }
pub fn log_config(config: &Config) {
let c = config;
logv(c, "configuration:".to_string());
logv(c, format!("compile_lib_path: {}", config.compile_lib_path));
logv(c, format!("run_lib_path: {}", config.run_lib_path));
logv(c, format!("rustc_path: {}", config.rustc_path));
logv(c, format!("cargo_path: {:?}", config.cargo_path));
logv(c, format!("rustdoc_path: {:?}", config.rustdoc_path));
logv(c, format!("src_root: {}", config.src_root));
logv(c, format!("src_test_suite_root: {}", config.src_test_suite_root));
logv(c, format!("build_root: {}", config.build_root));
logv(c, format!("build_test_suite_root: {}", config.build_test_suite_root));
logv(c, format!("sysroot_base: {}", config.sysroot_base));
logv(c, format!("stage: {}", config.stage));
logv(c, format!("stage_id: {}", config.stage_id));
logv(c, format!("mode: {}", config.mode));
logv(c, format!("run_ignored: {}", config.run_ignored));
logv(c, format!("filters: {:?}", config.filters));
logv(c, format!("skip: {:?}", config.skip));
logv(c, format!("filter_exact: {}", config.filter_exact));
logv(
c,
format!("force_pass_mode: {}", opt_str(&config.force_pass_mode.map(|m| format!("{}", m))),),
);
logv(c, format!("runner: {}", opt_str(&config.runner)));
logv(c, format!("host-rustcflags: {:?}", config.host_rustcflags));
logv(c, format!("target-rustcflags: {:?}", config.target_rustcflags));
logv(c, format!("target: {}", config.target));
logv(c, format!("host: {}", config.host));
logv(c, format!("android-cross-path: {}", config.android_cross_path));
logv(c, format!("adb_path: {}", config.adb_path));
logv(c, format!("adb_test_dir: {}", config.adb_test_dir));
logv(c, format!("adb_device_status: {}", config.adb_device_status));
logv(c, format!("ar: {}", config.ar));
logv(c, format!("target-linker: {:?}", config.target_linker));
logv(c, format!("host-linker: {:?}", config.host_linker));
logv(c, format!("verbose: {}", config.verbose));
logv(c, format!("minicore_path: {}", config.minicore_path));
logv(c, "\n".to_string());
}
pub fn opt_str(maybestr: &Option<String>) -> &str { pub fn opt_str(maybestr: &Option<String>) -> &str {
match *maybestr { match *maybestr {
None => "(none)", None => "(none)",
@@ -538,6 +491,8 @@ pub fn opt_str2(maybestr: Option<String>) -> String {
/// Called by `main` after the config has been parsed. /// Called by `main` after the config has been parsed.
pub fn run_tests(config: Arc<Config>) { pub fn run_tests(config: Arc<Config>) {
debug!(?config, "run_tests");
// If we want to collect rustfix coverage information, // If we want to collect rustfix coverage information,
// we first make sure that the coverage file does not exist. // we first make sure that the coverage file does not exist.
// It will be created later on. // It will be created later on.

View File

@@ -7,7 +7,7 @@ use std::io::prelude::*;
use std::io::{self, BufReader}; use std::io::{self, BufReader};
use std::process::{Child, Command, ExitStatus, Output, Stdio}; use std::process::{Child, Command, ExitStatus, Output, Stdio};
use std::sync::Arc; use std::sync::Arc;
use std::{env, iter, str}; use std::{env, fmt, iter, str};
use build_helper::fs::remove_and_create_dir_all; use build_helper::fs::remove_and_create_dir_all;
use camino::{Utf8Path, Utf8PathBuf}; use camino::{Utf8Path, Utf8PathBuf};
@@ -21,15 +21,13 @@ use crate::common::{
UI_WINDOWS_SVG, expected_output_path, incremental_dir, output_base_dir, output_base_name, UI_WINDOWS_SVG, expected_output_path, incremental_dir, output_base_dir, output_base_name,
output_testname_unique, output_testname_unique,
}; };
use crate::compute_diff::{DiffLine, make_diff, write_diff, write_filtered_diff};
use crate::directives::TestProps; use crate::directives::TestProps;
use crate::errors::{Error, ErrorKind, load_errors}; use crate::errors::{Error, ErrorKind, load_errors};
use crate::read2::{Truncated, read2_abbreviated}; use crate::read2::{Truncated, read2_abbreviated};
use crate::util::{Utf8PathBufExt, add_dylib_path, logv, static_regex}; use crate::runtest::compute_diff::{DiffLine, make_diff, write_diff, write_filtered_diff};
use crate::util::{Utf8PathBufExt, add_dylib_path, static_regex};
use crate::{ColorConfig, help, json, stamp_file_path, warning}; use crate::{ColorConfig, help, json, stamp_file_path, warning};
mod debugger;
// Helper modules that implement test running logic for each test suite. // Helper modules that implement test running logic for each test suite.
// tidy-alphabetical-start // tidy-alphabetical-start
mod assembly; mod assembly;
@@ -48,6 +46,8 @@ mod rustdoc_json;
mod ui; mod ui;
// tidy-alphabetical-end // tidy-alphabetical-end
mod compute_diff;
mod debugger;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
@@ -1459,7 +1459,7 @@ impl<'test> TestCx<'test> {
) -> ProcRes { ) -> ProcRes {
let cmdline = { let cmdline = {
let cmdline = self.make_cmdline(&command, lib_path); let cmdline = self.make_cmdline(&command, lib_path);
logv(self.config, format!("executing {}", cmdline)); self.logv(format_args!("executing {cmdline}"));
cmdline cmdline
}; };
@@ -2006,6 +2006,18 @@ impl<'test> TestCx<'test> {
output_base_name(self.config, self.testpaths, self.safe_revision()) output_base_name(self.config, self.testpaths, self.safe_revision())
} }
/// Prints a message to (captured) stdout if `config.verbose` is true.
/// The message is also logged to `tracing::debug!` regardles of verbosity.
///
/// Use `format_args!` as the argument to perform formatting if required.
fn logv(&self, message: impl fmt::Display) {
debug!("{message}");
if self.config.verbose {
// Note: `./x test ... --verbose --no-capture` is needed to see this print.
println!("{message}");
}
}
/// Prefix to print before error messages. Normally just `error`, but also /// Prefix to print before error messages. Normally just `error`, but also
/// includes the revision name for tests that use revisions. /// includes the revision name for tests that use revisions.
#[must_use] #[must_use]
@@ -2666,8 +2678,8 @@ impl<'test> TestCx<'test> {
// //
// It's not possible to detect paths in the error messages generally, but this is a // It's not possible to detect paths in the error messages generally, but this is a
// decent enough heuristic. // decent enough heuristic.
static_regex!( let re = static_regex!(
r#"(?x) r#"(?x)
(?: (?:
# Match paths that don't include spaces. # Match paths that don't include spaces.
(?:\\[\pL\pN\.\-_']+)+\.\pL+ (?:\\[\pL\pN\.\-_']+)+\.\pL+
@@ -2675,11 +2687,8 @@ impl<'test> TestCx<'test> {
# If the path starts with a well-known root, then allow spaces and no file extension. # If the path starts with a well-known root, then allow spaces and no file extension.
\$(?:DIR|SRC_DIR|TEST_BUILD_DIR|BUILD_DIR|LIB_DIR)(?:\\[\pL\pN\.\-_'\ ]+)+ \$(?:DIR|SRC_DIR|TEST_BUILD_DIR|BUILD_DIR|LIB_DIR)(?:\\[\pL\pN\.\-_'\ ]+)+
)"# )"#
) );
.replace_all(&output, |caps: &Captures<'_>| { re.replace_all(&output, |caps: &Captures<'_>| caps[0].replace(r"\", "/"))
println!("{}", &caps[0]);
caps[0].replace(r"\", "/")
})
.replace("\r\n", "\n") .replace("\r\n", "\n")
} }

View File

@@ -10,7 +10,6 @@ use super::debugger::DebuggerCommands;
use super::{Debugger, Emit, ProcRes, TestCx, Truncated, WillExecute}; use super::{Debugger, Emit, ProcRes, TestCx, Truncated, WillExecute};
use crate::common::Config; use crate::common::Config;
use crate::debuggers::{extract_gdb_version, is_android_gdb_target}; use crate::debuggers::{extract_gdb_version, is_android_gdb_target};
use crate::util::logv;
impl TestCx<'_> { impl TestCx<'_> {
pub(super) fn run_debuginfo_test(&self) { pub(super) fn run_debuginfo_test(&self) {
@@ -234,7 +233,7 @@ impl TestCx<'_> {
gdb.args(debugger_opts); gdb.args(debugger_opts);
// FIXME(jieyouxu): don't pass an empty Path // FIXME(jieyouxu): don't pass an empty Path
let cmdline = self.make_cmdline(&gdb, Utf8Path::new("")); let cmdline = self.make_cmdline(&gdb, Utf8Path::new(""));
logv(self.config, format!("executing {}", cmdline)); self.logv(format_args!("executing {cmdline}"));
cmdline cmdline
}; };

View File

@@ -6,7 +6,7 @@ use miropt_test_tools::{MiroptTest, MiroptTestFile, files_for_miropt_test};
use tracing::debug; use tracing::debug;
use super::{Emit, TestCx, WillExecute}; use super::{Emit, TestCx, WillExecute};
use crate::compute_diff::write_diff; use crate::runtest::compute_diff::write_diff;
impl TestCx<'_> { impl TestCx<'_> {
pub(super) fn run_mir_opt_test(&self) { pub(super) fn run_mir_opt_test(&self) {

View File

@@ -1,14 +1,13 @@
use std::fs; use std::fs;
use super::{ProcRes, ReadFrom, TestCx}; use super::{ProcRes, ReadFrom, TestCx};
use crate::util::logv;
impl TestCx<'_> { impl TestCx<'_> {
pub(super) fn run_pretty_test(&self) { pub(super) fn run_pretty_test(&self) {
if self.props.pp_exact.is_some() { if self.props.pp_exact.is_some() {
logv(self.config, "testing for exact pretty-printing".to_owned()); self.logv("testing for exact pretty-printing");
} else { } else {
logv(self.config, "testing for converging pretty-printing".to_owned()); self.logv("testing for converging pretty-printing");
} }
let rounds = match self.props.pp_exact { let rounds = match self.props.pp_exact {
@@ -21,10 +20,7 @@ impl TestCx<'_> {
let mut round = 0; let mut round = 0;
while round < rounds { while round < rounds {
logv( self.logv(format_args!("pretty-printing round {round} revision {:?}", self.revision));
self.config,
format!("pretty-printing round {} revision {:?}", round, self.revision),
);
let read_from = let read_from =
if round == 0 { ReadFrom::Path } else { ReadFrom::Stdin(srcs[round].to_owned()) }; if round == 0 { ReadFrom::Path } else { ReadFrom::Stdin(srcs[round].to_owned()) };

View File

@@ -2,9 +2,6 @@ use std::env;
use std::process::Command; use std::process::Command;
use camino::{Utf8Path, Utf8PathBuf}; use camino::{Utf8Path, Utf8PathBuf};
use tracing::*;
use crate::common::Config;
#[cfg(test)] #[cfg(test)]
mod tests; mod tests;
@@ -26,14 +23,6 @@ fn path_div() -> &'static str {
";" ";"
} }
pub fn logv(config: &Config, s: String) {
debug!("{}", s);
if config.verbose {
// Note: `./x test ... --verbose --no-capture` is needed to see this print.
println!("{}", s);
}
}
pub trait Utf8PathBufExt { pub trait Utf8PathBufExt {
/// Append an extension to the path, even if it already has one. /// Append an extension to the path, even if it already has one.
fn with_extra_extension(&self, extension: &str) -> Utf8PathBuf; fn with_extra_extension(&self, extension: &str) -> Utf8PathBuf;

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/7092
enum Whatever { enum Whatever {
} }

View File

@@ -1,5 +1,5 @@
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/issue-7092.rs:6:9 --> $DIR/method-call-nonsensical-pattern-binding-7092.rs:7:9
| |
LL | match x { LL | match x {
| - this expression has type `Whatever` | - this expression has type `Whatever`

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/6738
struct Foo<T> { struct Foo<T> {
x: T, x: T,
} }

View File

@@ -1,5 +1,5 @@
error[E0368]: binary assignment operation `+=` cannot be applied to type `T` error[E0368]: binary assignment operation `+=` cannot be applied to type `T`
--> $DIR/issue-6738.rs:6:9 --> $DIR/struct-field-generic-type-binary-assignment-error-6738.rs:7:9
| |
LL | self.x += v.x; LL | self.x += v.x;
| ------^^^^^^^ | ------^^^^^^^

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5884
//@ build-pass //@ build-pass
#![allow(dead_code)] #![allow(dead_code)]

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5550
//@ run-pass //@ run-pass
#![allow(unused_assignments)] #![allow(unused_assignments)]

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5708
//@ run-pass //@ run-pass
#![allow(unused_variables)] #![allow(unused_variables)]
/* /*
@@ -10,7 +11,6 @@ This does not occur with concrete types, only with references
to traits. to traits.
*/ */
// original // original
trait Inner { trait Inner {
fn print(&self); fn print(&self);
@@ -38,7 +38,6 @@ pub fn main() {
outer.inner.print(); outer.inner.print();
} }
// minimal // minimal
pub trait MyTrait<T> { pub trait MyTrait<T> {
fn dummy(&self, t: T) -> T { panic!() } fn dummy(&self, t: T) -> T { panic!() }

View File

@@ -0,0 +1,7 @@
// https://github.com/rust-lang/rust/issues/5518
//@ run-pass
//@ aux-build:aux-5518.rs
extern crate aux_5518 as other;
fn main() {}

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/6557
//@ check-pass //@ check-pass
#![allow(dead_code)] #![allow(dead_code)]

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/54094
//@ check-pass //@ check-pass
trait Zoo { trait Zoo {
type X; type X;

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/6318
//@ run-pass //@ run-pass
pub enum Thing { pub enum Thing {

View File

@@ -1,6 +1,6 @@
// https://github.com/rust-lang/rust/issues/6153
//@ run-pass //@ run-pass
fn swap<F>(f: F) -> Vec<isize> where F: FnOnce(Vec<isize>) -> Vec<isize> { fn swap<F>(f: F) -> Vec<isize> where F: FnOnce(Vec<isize>) -> Vec<isize> {
let x = vec![1, 2, 3]; let x = vec![1, 2, 3];
f(x) f(x)

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/54462
//@ run-pass //@ run-pass
// //
//@ compile-flags: -Ccodegen-units=1 -O //@ compile-flags: -Ccodegen-units=1 -O

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/7012
//@ run-pass //@ run-pass
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)] #![allow(non_upper_case_globals)]

View File

@@ -1,5 +1,5 @@
warning: method `dummy` is never used warning: method `dummy` is never used
--> $DIR/mut-trait-coercion-8248.rs:5:8 --> $DIR/coerce-mut-trait-object-8248.rs:5:8
| |
LL | trait A { LL | trait A {
| - method in this trait | - method in this trait

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/54477
//@ run-pass //@ run-pass
// rust-lang/rust#54477: runtime bug in the VecDeque library that was // rust-lang/rust#54477: runtime bug in the VecDeque library that was
// exposed by this test case, derived from test suite of crates.io // exposed by this test case, derived from test suite of crates.io

View File

@@ -0,0 +1,9 @@
// https://github.com/rust-lang/rust/issues/7178
//@ run-pass
//@ aux-build:aux-7178.rs
extern crate aux_7178 as cross_crate_self;
pub fn main() {
let _ = cross_crate_self::Foo::new(&1);
}

View File

@@ -0,0 +1,10 @@
// https://github.com/rust-lang/rust/issues/7899
//@ run-pass
#![allow(unused_variables)]
//@ aux-build:aux-7899.rs
extern crate aux_7899 as testcrate;
fn main() {
let f = testcrate::V2(1.0f32, 2.0f32);
}

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5900
//@ check-pass //@ check-pass
#![allow(dead_code)] #![allow(dead_code)]

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5997
//@ run-pass //@ run-pass
#![allow(dead_code)] #![allow(dead_code)]

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/6117
//@ run-pass //@ run-pass
#![allow(dead_code)] #![allow(dead_code)]

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/54696
//@ run-pass //@ run-pass
#![allow(unpredictable_function_pointer_comparisons)] #![allow(unpredictable_function_pointer_comparisons)]

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5997
fn f<Z>() -> bool { fn f<Z>() -> bool {
enum E { V(Z) } enum E { V(Z) }
//~^ ERROR can't use generic parameters from outer item //~^ ERROR can't use generic parameters from outer item

View File

@@ -1,5 +1,5 @@
error[E0401]: can't use generic parameters from outer item error[E0401]: can't use generic parameters from outer item
--> $DIR/issue-5997-enum.rs:2:16 --> $DIR/enum-definition-with-outer-generic-parameter-5997.rs:3:16
| |
LL | fn f<Z>() -> bool { LL | fn f<Z>() -> bool {
| - type parameter from outer item | - type parameter from outer item

View File

@@ -1,8 +0,0 @@
extern "C" {
pub static mut symbol: [i8];
//~^ ERROR the size for values of type `[i8]` cannot be known at compilation time
}
fn main() {
println!("{:p}", unsafe { &symbol });
}

View File

@@ -1,12 +0,0 @@
error[E0277]: the size for values of type `[i8]` cannot be known at compilation time
--> $DIR/issue-54410.rs:2:5
|
LL | pub static mut symbol: [i8];
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time
|
= help: the trait `Sized` is not implemented for `[i8]`
= note: statics and constants must have a statically known size
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.

View File

@@ -1,7 +0,0 @@
//@ run-pass
//@ aux-build:issue-5518.rs
extern crate issue_5518 as other;
fn main() {}

View File

@@ -1,7 +0,0 @@
//@aux-build:issue-5844-aux.rs
extern crate issue_5844_aux;
fn main() {
issue_5844_aux::rand(); //~ ERROR: requires unsafe
}

View File

@@ -1,10 +0,0 @@
fn f<T>() -> bool {
struct S(T); //~ ERROR can't use generic parameters from outer item
true
}
fn main() {
let b = f::<isize>();
assert!(b);
}

View File

@@ -1,13 +0,0 @@
error[E0401]: can't use generic parameters from outer item
--> $DIR/issue-5997-struct.rs:2:14
|
LL | fn f<T>() -> bool {
| - type parameter from outer item
LL | struct S(T);
| -^ use of generic parameter from outer item
| |
| help: try introducing a local generic parameter here: `<T>`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0401`.

View File

@@ -1,18 +0,0 @@
//@ run-pass
#![allow(non_shorthand_field_patterns)]
struct A { x: usize }
impl Drop for A {
fn drop(&mut self) {}
}
pub fn main() {
let a = A { x: 0 };
match a {
A { x : ref x } => {
println!("{}", x)
}
}
}

View File

@@ -1,9 +0,0 @@
//@ run-pass
//@ aux-build:issue-7178.rs
extern crate issue_7178 as cross_crate_self;
pub fn main() {
let _ = cross_crate_self::Foo::new(&1);
}

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/53419
//@ check-pass //@ check-pass
struct Foo { struct Foo {

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/7268
//@ check-pass //@ check-pass
#![allow(dead_code)] #![allow(dead_code)]

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5741
//@ run-pass //@ run-pass
#![allow(while_true)] #![allow(while_true)]
#![allow(unreachable_code)] #![allow(unreachable_code)]

View File

@@ -1,7 +1,7 @@
// https://github.com/rust-lang/rust/issues/5554
//@ run-pass //@ run-pass
#![allow(dead_code)] #![allow(dead_code)]
pub struct X<T> { pub struct X<T> {
a: T, a: T,
} }

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5718
//@ run-pass //@ run-pass
struct Element; struct Element;

View File

@@ -1,8 +1,13 @@
enum Either<T, U> { Left(T), Right(U) } // https://github.com/rust-lang/rust/issues/5358
enum Either<T, U> {
Left(T),
Right(U),
}
struct S(Either<usize, usize>); struct S(Either<usize, usize>);
fn main() { fn main() {
match S(Either::Left(5)) { //~ NOTE this expression has type `S` match S(Either::Left(5)) {
//~^ NOTE this expression has type `S`
Either::Right(_) => {} Either::Right(_) => {}
//~^ ERROR mismatched types //~^ ERROR mismatched types
//~| NOTE expected `S`, found `Either<_, _>` //~| NOTE expected `S`, found `Either<_, _>`

View File

@@ -1,8 +1,9 @@
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/issue-5358-1.rs:6:9 --> $DIR/mismatched-types-in-match-5358.rs:11:9
| |
LL | match S(Either::Left(5)) { LL | match S(Either::Left(5)) {
| ------------------ this expression has type `S` | ------------------ this expression has type `S`
LL |
LL | Either::Right(_) => {} LL | Either::Right(_) => {}
| ^^^^^^^^^^^^^^^^ expected `S`, found `Either<_, _>` | ^^^^^^^^^^^^^^^^ expected `S`, found `Either<_, _>`
| |

View File

@@ -1,5 +1,5 @@
error[E0308]: mismatched types error[E0308]: mismatched types
--> $DIR/mismatched-types-in-match-pattern-7867.rs:10:9 --> $DIR/mismatched-types-in-match-7867.rs:10:9
| |
LL | enum A { B, C } LL | enum A { B, C }
| - unit variant defined here | - unit variant defined here

View File

@@ -1,5 +1,5 @@
warning: trait `Foo` is never used warning: trait `Foo` is never used
--> $DIR/trait-method-self-param-error-7575.rs:4:7 --> $DIR/trait-method-resolution-7575.rs:4:7
| |
LL | trait Foo { LL | trait Foo {
| ^^^ | ^^^

View File

@@ -1,6 +1,6 @@
// https://github.com/rust-lang/rust/issues/5950
//@ check-pass //@ check-pass
pub use local as local_alias; pub use local as local_alias;
pub mod local { } pub mod local { }

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/6130
//@ run-pass //@ run-pass
pub fn main() { pub fn main() {

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5572
//@ check-pass //@ check-pass
#![allow(dead_code)] #![allow(dead_code)]

View File

@@ -1,7 +1,7 @@
// https://github.com/rust-lang/rust/issues/6919
//@ run-pass //@ run-pass
#![allow(unused_attributes)] #![allow(unused_attributes)]
//@ aux-build:iss.rs //@ aux-build:iss-6919.rs
extern crate issue6919_3; extern crate issue6919_3;

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/55376
//@ run-pass //@ run-pass
// Tests that paths in `pub(...)` don't fail HIR verification. // Tests that paths in `pub(...)` don't fail HIR verification.

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/53728
//@ run-pass //@ run-pass
#![allow(dead_code)] #![allow(dead_code)]

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/6936
struct T; struct T;
mod t1 { mod t1 {
@@ -30,5 +31,4 @@ mod t6 {
impl Foo {} // ok impl Foo {} // ok
} }
fn main() {} fn main() {}

View File

@@ -1,5 +1,5 @@
error[E0428]: the name `Foo` is defined multiple times error[E0428]: the name `Foo` is defined multiple times
--> $DIR/issue-6936.rs:5:5 --> $DIR/duplicate-name-in-module-6936.rs:6:5
| |
LL | type Foo = crate::T; LL | type Foo = crate::T;
| -------------------- previous definition of the type `Foo` here | -------------------- previous definition of the type `Foo` here
@@ -9,7 +9,7 @@ LL | mod Foo {}
= note: `Foo` must be defined only once in the type namespace of this module = note: `Foo` must be defined only once in the type namespace of this module
error[E0428]: the name `Foo` is defined multiple times error[E0428]: the name `Foo` is defined multiple times
--> $DIR/issue-6936.rs:10:5 --> $DIR/duplicate-name-in-module-6936.rs:11:5
| |
LL | type Foo = crate::T; LL | type Foo = crate::T;
| -------------------- previous definition of the type `Foo` here | -------------------- previous definition of the type `Foo` here
@@ -19,7 +19,7 @@ LL | struct Foo;
= note: `Foo` must be defined only once in the type namespace of this module = note: `Foo` must be defined only once in the type namespace of this module
error[E0428]: the name `Foo` is defined multiple times error[E0428]: the name `Foo` is defined multiple times
--> $DIR/issue-6936.rs:15:5 --> $DIR/duplicate-name-in-module-6936.rs:16:5
| |
LL | type Foo = crate::T; LL | type Foo = crate::T;
| -------------------- previous definition of the type `Foo` here | -------------------- previous definition of the type `Foo` here
@@ -29,7 +29,7 @@ LL | enum Foo {}
= note: `Foo` must be defined only once in the type namespace of this module = note: `Foo` must be defined only once in the type namespace of this module
error[E0428]: the name `Bar` is defined multiple times error[E0428]: the name `Bar` is defined multiple times
--> $DIR/issue-6936.rs:25:5 --> $DIR/duplicate-name-in-module-6936.rs:26:5
| |
LL | type Bar<T> = T; LL | type Bar<T> = T;
| ---------------- previous definition of the type `Bar` here | ---------------- previous definition of the type `Bar` here

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/7044
static X: isize = 0; static X: isize = 0;
struct X; //~ ERROR the name `X` is defined multiple times struct X; //~ ERROR the name `X` is defined multiple times

View File

@@ -1,5 +1,5 @@
error[E0428]: the name `X` is defined multiple times error[E0428]: the name `X` is defined multiple times
--> $DIR/issue-7044.rs:2:1 --> $DIR/unit-like-struct-masks-constant-7044.rs:3:1
| |
LL | static X: isize = 0; LL | static X: isize = 0;
| -------------------- previous definition of the value `X` here | -------------------- previous definition of the value `X` here

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/55380
//@ run-pass //@ run-pass
#![feature(specialization)] #![feature(specialization)]
//~^ WARN the feature `specialization` is incomplete //~^ WARN the feature `specialization` is incomplete

View File

@@ -1,5 +1,5 @@
warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/issue-55380.rs:2:12 --> $DIR/trait-specialization-default-methods-55380.rs:3:12
| |
LL | #![feature(specialization)] LL | #![feature(specialization)]
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/7364
use std::cell::RefCell; use std::cell::RefCell;
// Regression test for issue 7364 // Regression test for issue 7364

View File

@@ -1,5 +1,5 @@
error[E0277]: `RefCell<isize>` cannot be shared between threads safely error[E0277]: `RefCell<isize>` cannot be shared between threads safely
--> $DIR/issue-7364.rs:4:15 --> $DIR/global-variable-promotion-error-7364.rs:5:15
| |
LL | static boxed: Box<RefCell<isize>> = Box::new(RefCell::new(0)); LL | static boxed: Box<RefCell<isize>> = Box::new(RefCell::new(0));
| ^^^^^^^^^^^^^^^^^^^ `RefCell<isize>` cannot be shared between threads safely | ^^^^^^^^^^^^^^^^^^^ `RefCell<isize>` cannot be shared between threads safely
@@ -12,7 +12,7 @@ note: required because it appears within the type `Box<RefCell<isize>>`
= note: shared static variables must have a type that implements `Sync` = note: shared static variables must have a type that implements `Sync`
error[E0015]: cannot call non-const associated function `Box::<RefCell<isize>>::new` in statics error[E0015]: cannot call non-const associated function `Box::<RefCell<isize>>::new` in statics
--> $DIR/issue-7364.rs:4:37 --> $DIR/global-variable-promotion-error-7364.rs:5:37
| |
LL | static boxed: Box<RefCell<isize>> = Box::new(RefCell::new(0)); LL | static boxed: Box<RefCell<isize>> = Box::new(RefCell::new(0));
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5917
//@ run-pass //@ run-pass
#![allow(non_upper_case_globals)] #![allow(non_upper_case_globals)]

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5688
//@ run-pass //@ run-pass
/* /*
# Corrupted initialization in the static struct # Corrupted initialization in the static struct

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/6344
//@ run-pass //@ run-pass
#![allow(non_shorthand_field_patterns)] #![allow(non_shorthand_field_patterns)]

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5439
struct Foo { struct Foo {
foo: isize, foo: isize,
} }

View File

@@ -1,5 +1,5 @@
error[E0560]: struct `Foo` has no field named `nonexistent` error[E0560]: struct `Foo` has no field named `nonexistent`
--> $DIR/issue-5439.rs:11:31 --> $DIR/nonexistent-struct-field-error-5439.rs:12:31
| |
LL | return Box::new(Foo { nonexistent: self, foo: i }); LL | return Box::new(Foo { nonexistent: self, foo: i });
| ^^^^^^^^^^^ `Foo` does not have this field | ^^^^^^^^^^^ `Foo` does not have this field

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5666
//@ run-pass //@ run-pass
struct Dog { struct Dog {
@@ -14,7 +15,6 @@ impl Barks for Dog {
} }
} }
pub fn main() { pub fn main() {
let snoopy = Box::new(Dog{name: "snoopy".to_string()}); let snoopy = Box::new(Dog{name: "snoopy".to_string()});
let bubbles = Box::new(Dog{name: "bubbles".to_string()}); let bubbles = Box::new(Dog{name: "bubbles".to_string()});

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/53568
// Regression test for an NLL-related ICE (#53568) -- we failed to // Regression test for an NLL-related ICE (#53568) -- we failed to
// resolve inference variables in "custom type-ops". // resolve inference variables in "custom type-ops".
// //

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5883
trait A {} trait A {}
struct Struct { struct Struct {

View File

@@ -1,19 +1,19 @@
error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time
--> $DIR/issue-5883.rs:9:6 --> $DIR/opaque-trait-size-error-5883.rs:10:6
| |
LL | ) -> Struct { LL | ) -> Struct {
| ^^^^^^ doesn't have a size known at compile-time | ^^^^^^ doesn't have a size known at compile-time
| |
= help: within `Struct`, the trait `Sized` is not implemented for `(dyn A + 'static)` = help: within `Struct`, the trait `Sized` is not implemented for `(dyn A + 'static)`
note: required because it appears within the type `Struct` note: required because it appears within the type `Struct`
--> $DIR/issue-5883.rs:3:8 --> $DIR/opaque-trait-size-error-5883.rs:4:8
| |
LL | struct Struct { LL | struct Struct {
| ^^^^^^ | ^^^^^^
= note: the return type of a function must have a statically known size = note: the return type of a function must have a statically known size
error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time
--> $DIR/issue-5883.rs:8:8 --> $DIR/opaque-trait-size-error-5883.rs:9:8
| |
LL | r: dyn A + 'static LL | r: dyn A + 'static
| ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/6898
//@ check-pass //@ check-pass
use std::mem; use std::mem;

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/5988
//@ run-pass //@ run-pass
trait B { trait B {

View File

@@ -1,3 +1,4 @@
// https://github.com/rust-lang/rust/issues/7344
//@ run-pass //@ run-pass
#![allow(unused_must_use)] #![allow(unused_must_use)]

View File

@@ -0,0 +1,8 @@
// https://github.com/rust-lang/rust/issues/5844
//@aux-build:aux-5844.rs
extern crate aux_5844;
fn main() {
aux_5844::rand(); //~ ERROR: requires unsafe
}

View File

@@ -1,8 +1,8 @@
error[E0133]: call to unsafe function `rand` is unsafe and requires unsafe function or block error[E0133]: call to unsafe function `rand` is unsafe and requires unsafe function or block
--> $DIR/issue-5844.rs:6:5 --> $DIR/extern-function-requires-unsafe-5844.rs:7:5
| |
LL | issue_5844_aux::rand(); LL | aux_5844::rand();
| ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function | ^^^^^^^^^^^^^^^^ call to unsafe function
| |
= note: consult the function's documentation for information on how to avoid undefined behavior = note: consult the function's documentation for information on how to avoid undefined behavior