diff --git a/compiler/rustc_ast/src/ast.rs b/compiler/rustc_ast/src/ast.rs index bd5ce5d18b839..3e1fff594040e 100644 --- a/compiler/rustc_ast/src/ast.rs +++ b/compiler/rustc_ast/src/ast.rs @@ -407,7 +407,7 @@ impl GenericBound { } } -pub type GenericBounds = Vec; +pub type GenericBounds = ThinVec; /// Specifies the enforced ordering for generic parameters. In the future, /// if we wanted to relax this order, we could override `PartialEq` and @@ -1534,7 +1534,7 @@ impl Expr { let (Some(lhs), Some(rhs)) = (lhs.to_bound(), rhs.to_bound()) else { return None; }; - TyKind::TraitObject(vec![lhs, rhs], TraitObjectSyntax::None) + TyKind::TraitObject(thin_vec![lhs, rhs], TraitObjectSyntax::None) } ExprKind::Underscore => TyKind::Infer, @@ -1868,7 +1868,7 @@ pub enum ExprKind { /// /// Usually not written directly in user code but /// indirectly via the macro `core::mem::offset_of!(...)`. - OffsetOf(Box, Vec), + OffsetOf(Box, ThinVec), /// A macro invocation; pre-expansion. MacCall(Box), @@ -4391,27 +4391,37 @@ mod size_asserts { // tidy-alphabetical-start static_assert_size!(AssocItem, 80); static_assert_size!(AssocItemKind, 16); + static_assert_size!(AttrKind, 16); static_assert_size!(Attribute, 32); static_assert_size!(Block, 32); static_assert_size!(Expr, 72); static_assert_size!(ExprKind, 40); static_assert_size!(Fn, 192); + static_assert_size!(FnDecl, 24); + static_assert_size!(FnHeader, 76); + static_assert_size!(FnSig, 96); static_assert_size!(ForeignItem, 80); static_assert_size!(ForeignItemKind, 16); static_assert_size!(GenericArg, 24); + static_assert_size!(GenericArgs, 40); static_assert_size!(GenericBound, 88); + static_assert_size!(GenericParam, 80); static_assert_size!(Generics, 40); static_assert_size!(Impl, 80); static_assert_size!(Item, 152); static_assert_size!(ItemKind, 88); + static_assert_size!(Lifetime, 16); static_assert_size!(LitKind, 24); static_assert_size!(Local, 96); + static_assert_size!(MetaItem, 88); + static_assert_size!(MetaItemKind, 40); static_assert_size!(MetaItemLit, 40); static_assert_size!(Param, 40); static_assert_size!(Pat, 80); static_assert_size!(PatKind, 56); static_assert_size!(Path, 24); static_assert_size!(PathSegment, 24); + static_assert_size!(QSelf, 24); static_assert_size!(Stmt, 32); static_assert_size!(StmtKind, 16); static_assert_size!(TraitImplHeader, 72); diff --git a/compiler/rustc_ast/src/visit.rs b/compiler/rustc_ast/src/visit.rs index 1e96d1d52f7eb..fb4e76321d150 100644 --- a/compiler/rustc_ast/src/visit.rs +++ b/compiler/rustc_ast/src/visit.rs @@ -386,6 +386,8 @@ macro_rules! common_visitor_and_walkers { impl_visitable_list!(<$($lt)? $($mut)?> ThinVec, ThinVec, + ThinVec, + ThinVec, ThinVec<(Ident, Option)>, ThinVec<(NodeId, Path)>, ThinVec, diff --git a/compiler/rustc_attr_parsing/src/attributes/doc.rs b/compiler/rustc_attr_parsing/src/attributes/doc.rs index 23eef6334ccee..9b03792057b33 100644 --- a/compiler/rustc_attr_parsing/src/attributes/doc.rs +++ b/compiler/rustc_attr_parsing/src/attributes/doc.rs @@ -348,8 +348,11 @@ impl DocParser { // If it's a list, then only `any()` and `none()` are allowed and they must not // contain any item. MetaItemOrLitParser::MetaItemParser(sub_item) => { - if let Some(ident) = sub_item.ident() - && [sym::any, sym::none].contains(&ident.name) + let Some(ident) = sub_item.ident() else { + cx.adcx().expected_identifier(sub_item.path().span()); + continue; + }; + if [sym::any, sym::none].contains(&ident.name) && let ArgParser::List(list) = sub_item.args() && list.mixed().count() == 0 { @@ -371,9 +374,7 @@ impl DocParser { } else { cx.emit_lint( rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES, - DocAutoCfgHideShowUnexpectedItem { - attr_name: sub_item.ident().unwrap().name, - }, + DocAutoCfgHideShowUnexpectedItem { attr_name: ident.name }, sub_item.span(), ); } diff --git a/compiler/rustc_builtin_macros/src/deriving/debug.rs b/compiler/rustc_builtin_macros/src/deriving/debug.rs index 004b13bcc333d..2436800d0099d 100644 --- a/compiler/rustc_builtin_macros/src/deriving/debug.rs +++ b/compiler/rustc_builtin_macros/src/deriving/debug.rs @@ -167,7 +167,7 @@ fn show_substructure(cx: &ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) -> let ty_dyn_debug = cx.ty( span, ast::TyKind::TraitObject( - vec![cx.trait_bound(path_debug, false)], + thin_vec![cx.trait_bound(path_debug, false)], ast::TraitObjectSyntax::Dyn, ), ); diff --git a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs index ff6b15b173ed1..1577db640502c 100644 --- a/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs +++ b/compiler/rustc_builtin_macros/src/deriving/generic/mod.rs @@ -617,7 +617,7 @@ impl<'a> TraitDef<'a> { ident, generics: Generics::default(), after_where_clause: ast::WhereClause::default(), - bounds: Vec::new(), + bounds: ThinVec::new(), ty: Some(type_def.to_ty(cx, self.span, type_ident, generics)), })), tokens: None, @@ -639,7 +639,7 @@ impl<'a> TraitDef<'a> { // Extra restrictions on the generics parameters to the // type being derived upon. let span = param.ident.span.with_ctxt(ctxt); - let bounds: Vec<_> = self + let bounds: ThinVec<_> = self .additional_bounds .iter() .map(|p| { @@ -723,7 +723,7 @@ impl<'a> TraitDef<'a> { { continue; } - let mut bounds: Vec<_> = self + let mut bounds: ThinVec<_> = self .additional_bounds .iter() .map(|p| { diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index 60a94345c5325..df1877b82cb93 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1154,8 +1154,8 @@ impl<'a> Parser<'a> { /// Parse the field access used in offset_of, matched by `$(e:expr)+`. /// Currently returns a list of idents. However, it should be possible in /// future to also do array indices, which might be arbitrary expressions. - pub(crate) fn parse_floating_field_access(&mut self) -> PResult<'a, Vec> { - let mut fields = Vec::new(); + pub(crate) fn parse_floating_field_access(&mut self) -> PResult<'a, ThinVec> { + let mut fields = ThinVec::new(); let mut trailing_dot = None; loop { diff --git a/compiler/rustc_parse/src/parser/generics.rs b/compiler/rustc_parse/src/parser/generics.rs index e2df607fd0f86..506607f57191d 100644 --- a/compiler/rustc_parse/src/parser/generics.rs +++ b/compiler/rustc_parse/src/parser/generics.rs @@ -26,7 +26,7 @@ impl<'a> Parser<'a> { /// BOUND = LT_BOUND (e.g., `'a`) /// ``` fn parse_lt_param_bounds(&mut self) -> GenericBounds { - let mut lifetimes = Vec::new(); + let mut lifetimes = ThinVec::new(); while self.check_lifetime() { lifetimes.push(ast::GenericBound::Outlives(self.expect_lifetime())); @@ -86,7 +86,7 @@ impl<'a> Parser<'a> { } self.parse_generic_bounds()? } else { - Vec::new() + ThinVec::new() }; let default = if self.eat(exp!(Eq)) { Some(self.parse_ty()?) } else { None }; @@ -125,7 +125,7 @@ impl<'a> Parser<'a> { ident, id: ast::DUMMY_NODE_ID, attrs: preceding_attrs, - bounds: Vec::new(), + bounds: ThinVec::new(), kind: GenericParamKind::Const { ty, span, default: None }, is_placeholder: false, colon_span: None, @@ -148,7 +148,7 @@ impl<'a> Parser<'a> { ident, id: ast::DUMMY_NODE_ID, attrs: preceding_attrs, - bounds: Vec::new(), + bounds: ThinVec::new(), kind: GenericParamKind::Const { ty, span, default }, is_placeholder: false, colon_span: None, @@ -189,7 +189,7 @@ impl<'a> Parser<'a> { ident, id: ast::DUMMY_NODE_ID, attrs: preceding_attrs, - bounds: Vec::new(), + bounds: ThinVec::new(), kind: GenericParamKind::Const { ty, span, default }, is_placeholder: false, colon_span: None, @@ -225,7 +225,7 @@ impl<'a> Parser<'a> { let (colon_span, bounds) = if this.eat(exp!(Colon)) { (Some(this.prev_token.span), this.parse_lt_param_bounds()) } else { - (None, Vec::new()) + (None, ThinVec::new()) }; if this.check_noexpect(&token::Eq) && this.look_ahead(1, |t| t.is_lifetime()) { diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 16fed9c6c273b..6f5c4c874d83b 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -1135,7 +1135,7 @@ impl<'a> Parser<'a> { // Parse optional colon and supertrait bounds. let had_colon = self.eat(exp!(Colon)); let span_at_colon = self.prev_token.span; - let bounds = if had_colon { self.parse_generic_bounds()? } else { Vec::new() }; + let bounds = if had_colon { self.parse_generic_bounds()? } else { ThinVec::new() }; let span_before_eq = self.prev_token.span; if self.eat(exp!(Eq)) { @@ -1253,7 +1253,8 @@ impl<'a> Parser<'a> { let mut generics = self.parse_generics()?; // Parse optional colon and param bounds. - let bounds = if self.eat(exp!(Colon)) { self.parse_generic_bounds()? } else { Vec::new() }; + let bounds = + if self.eat(exp!(Colon)) { self.parse_generic_bounds()? } else { ThinVec::new() }; generics.where_clause = self.parse_where_clause()?; let ty = if self.eat(exp!(Eq)) { Some(self.parse_ty()?) } else { None }; diff --git a/compiler/rustc_parse/src/parser/ty.rs b/compiler/rustc_parse/src/parser/ty.rs index 8a881c6f8b568..9c873711e2f87 100644 --- a/compiler/rustc_parse/src/parser/ty.rs +++ b/compiler/rustc_parse/src/parser/ty.rs @@ -576,7 +576,7 @@ impl<'a> Parser<'a> { lo.to(self.prev_token.span), parens, ); - let bounds = vec![GenericBound::Trait(poly_trait_ref)]; + let bounds = thin_vec![GenericBound::Trait(poly_trait_ref)]; self.parse_remaining_bounds(bounds, parse_plus) } @@ -1080,7 +1080,7 @@ impl<'a> Parser<'a> { /// Only if `allow_plus` this parses a `+`-separated list of bounds (trailing `+` is admitted). /// Otherwise, this only parses a single bound or none. fn parse_generic_bounds_common(&mut self, allow_plus: AllowPlus) -> PResult<'a, GenericBounds> { - let mut bounds = Vec::new(); + let mut bounds = ThinVec::new(); // In addition to looping while we find generic bounds: // We continue even if we find a keyword. This is necessary for error recovery on, @@ -1432,7 +1432,7 @@ impl<'a> Parser<'a> { // Someone has written something like `&dyn (Trait + Other)`. The correct code // would be `&(dyn Trait + Other)` if self.token.is_like_plus() && leading_token.is_keyword(kw::Dyn) { - let bounds = vec![]; + let bounds = thin_vec![]; self.parse_remaining_bounds(bounds, true)?; self.expect(exp!(CloseParen))?; self.dcx().emit_err(errors::IncorrectParensTraitBounds { @@ -1617,7 +1617,7 @@ impl<'a> Parser<'a> { id: lt.id, ident: lt.ident, attrs: ast::AttrVec::new(), - bounds: Vec::new(), + bounds: ThinVec::new(), is_placeholder: false, kind: ast::GenericParamKind::Lifetime, colon_span: None, diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 8c5c7f5b2d76d..668278f13d9cf 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -28,7 +28,7 @@ use rustc_session::{Session, lint}; use rustc_span::edit_distance::{edit_distance, find_best_match_for_name}; use rustc_span::edition::Edition; use rustc_span::{DUMMY_SP, DesugaringKind, Ident, Span, Symbol, kw, sym}; -use thin_vec::ThinVec; +use thin_vec::{ThinVec, thin_vec}; use tracing::debug; use super::NoConstantGenericsReason; @@ -4522,7 +4522,7 @@ fn mk_where_bound_predicate( let new_where_bound_predicate = ast::WhereBoundPredicate { bound_generic_params: ThinVec::new(), bounded_ty: Box::new(ty.clone()), - bounds: vec![ast::GenericBound::Trait(ast::PolyTraitRef { + bounds: thin_vec![ast::GenericBound::Trait(ast::PolyTraitRef { bound_generic_params: ThinVec::new(), modifiers: ast::TraitBoundModifiers::NONE, trait_ref: ast::TraitRef { diff --git a/library/core/src/range.rs b/library/core/src/range.rs index fb7a51a779f6d..74d1cfde034eb 100644 --- a/library/core/src/range.rs +++ b/library/core/src/range.rs @@ -402,7 +402,8 @@ const impl From> for RangeInclusive { /// /// # Panics /// - /// Panics if the legacy range iterator has been exhausted. + /// If the legacy range iterator has been exhausted, + /// this function will either panic or return an empty range. /// /// # Examples /// @@ -419,19 +420,16 @@ const impl From> for RangeInclusive { /// assert_eq!((empty.start, empty.last), (0, 0)); /// ``` /// - /// ```should_panic + /// ``` /// use core::range::legacy; /// use core::range::RangeInclusive; + /// use std::panic::catch_unwind; /// /// let mut exhausted: legacy::RangeInclusive = 0..=0; /// exhausted.next(); - /// # if exhausted.is_empty() { - /// # // assert!s don't work correctly in `should_panic` doctests since you - /// # // can't assert the panic message. Skip the rest of the test instead, - /// # // so that the expected panic doesn't happen and the test fails. - /// assert!(exhausted.is_empty()); - /// let _ = RangeInclusive::from(exhausted); // this panics - /// # } + /// let result = catch_unwind(|| RangeInclusive::from(exhausted)); + /// // The `from` call either panicked or returned an empty range. + /// assert!(result.is_err() || result.is_ok_and(|range| range.is_empty())); /// ``` #[inline] fn from(value: legacy::RangeInclusive) -> Self { diff --git a/library/std/src/collections/hash/set/tests.rs b/library/std/src/collections/hash/set/tests.rs index d7bbc7bdc6a5b..5dfc02935c112 100644 --- a/library/std/src/collections/hash/set/tests.rs +++ b/library/std/src/collections/hash/set/tests.rs @@ -418,14 +418,32 @@ fn test_retain() { } #[test] -fn test_extract_if() { - let mut x: HashSet<_> = [1].iter().copied().collect(); - let mut y: HashSet<_> = [1].iter().copied().collect(); - - x.extract_if(|_| true).for_each(drop); - y.extract_if(|_| false).for_each(drop); - assert_eq!(x.len(), 0); - assert_eq!(y.len(), 1); +fn test_extract_if_empty() { + let mut set: HashSet = HashSet::new(); + let extracted: Vec<_> = + set.extract_if(|_| unreachable!("there's nothing to decide on")).collect(); + + assert!(extracted.is_empty()); + assert!(set.is_empty()); +} + +#[test] +fn test_extract_if_consuming_nothing() { + let mut set: HashSet<_> = (0..3).collect(); + let extracted: Vec<_> = set.extract_if(|_| false).collect(); + + assert!(extracted.is_empty()); + assert_eq!(set, HashSet::from([0, 1, 2])); +} + +#[test] +fn test_extract_if_consuming_all() { + let mut set: HashSet<_> = (0..3).collect(); + let mut extracted: Vec<_> = set.extract_if(|_| true).collect(); + extracted.sort_unstable(); + + assert_eq!(extracted, vec![0, 1, 2]); + assert!(set.is_empty()); } #[test] diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index dc623a3e82c2c..6396be588c0ff 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -1294,7 +1294,7 @@ pub trait Read { /// Ok(()) /// } /// ``` - #[unstable(feature = "read_le", issue = "156983")] + #[unstable(feature = "read_le", issue = "156984")] #[inline] fn read_le(&mut self) -> Result where @@ -1327,7 +1327,7 @@ pub trait Read { /// Ok(()) /// } /// ``` - #[unstable(feature = "read_le", issue = "156983")] + #[unstable(feature = "read_le", issue = "156984")] #[inline] fn read_be(&mut self) -> Result where diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs index afa30c8c00f27..4a3348d11123e 100644 --- a/library/std/src/lib.rs +++ b/library/std/src/lib.rs @@ -286,6 +286,7 @@ #![feature(doc_masked)] #![feature(doc_notable_trait)] #![feature(dropck_eyepatch)] +#![feature(exact_div)] #![feature(f16)] #![feature(f128)] #![feature(ffi_const)] diff --git a/library/std/src/sync/mod.rs b/library/std/src/sync/mod.rs index 439b5b09a5ac0..1c3b6d01ed9d8 100644 --- a/library/std/src/sync/mod.rs +++ b/library/std/src/sync/mod.rs @@ -9,7 +9,7 @@ //! Consider the following code, operating on some global static variables: //! //! ```rust -//! // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +//! // FIXME(static_mut_refs): use raw pointers instead of references //! #![allow(static_mut_refs)] //! //! static mut A: u32 = 0; diff --git a/library/std/src/sys/alloc/vexos.rs b/library/std/src/sys/alloc/vexos.rs index c1fb6896a89ae..5ccf6625ed626 100644 --- a/library/std/src/sys/alloc/vexos.rs +++ b/library/std/src/sys/alloc/vexos.rs @@ -1,4 +1,4 @@ -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use crate::alloc::{GlobalAlloc, Layout, System}; diff --git a/library/std/src/sys/alloc/xous.rs b/library/std/src/sys/alloc/xous.rs index c7f973b802791..af2dcabc1a23b 100644 --- a/library/std/src/sys/alloc/xous.rs +++ b/library/std/src/sys/alloc/xous.rs @@ -1,4 +1,4 @@ -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use crate::alloc::{GlobalAlloc, Layout, System}; diff --git a/library/std/src/sys/paths/unix.rs b/library/std/src/sys/paths/unix.rs index 36879b7b9bce3..c2ecc6e5da3d4 100644 --- a/library/std/src/sys/paths/unix.rs +++ b/library/std/src/sys/paths/unix.rs @@ -234,18 +234,31 @@ pub fn current_exe() -> io::Result { unsafe { let mut mib = [libc::CTL_KERN, libc::KERN_PROC_ARGS, libc::getpid(), libc::KERN_PROC_ARGV]; let mib = mib.as_mut_ptr(); - let mut argv_len = 0; - cvt(libc::sysctl(mib, 4, ptr::null_mut(), &mut argv_len, ptr::null_mut(), 0))?; - let mut argv = Vec::<*const libc::c_char>::with_capacity(argv_len as usize); - cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _, &mut argv_len, ptr::null_mut(), 0))?; - argv.set_len(argv_len as usize); + + // Determine the required size (in bytes) for the argument array ... + let mut argv_size = 0; + cvt(libc::sysctl(mib, 4, ptr::null_mut(), &mut argv_size, ptr::null_mut(), 0))?; + + // ... allocate a buffer for it ... + let argc = argv_size.div_exact(size_of::<*const libc::c_char>()).unwrap(); + let mut argv = Vec::<*const libc::c_char>::with_capacity(argc); + + // ... and retrieve the argument array. + cvt(libc::sysctl(mib, 4, argv.as_mut_ptr() as *mut _, &mut argv_size, ptr::null_mut(), 0))?; + let argc = argv_size.div_exact(size_of::<*const libc::c_char>()).unwrap(); + argv.set_len(argc); + if argv[0].is_null() { return Err(io::const_error!(io::ErrorKind::Uncategorized, "no current exe available")); } let argv0 = CStr::from_ptr(argv[0]).to_bytes(); - if argv0[0] == b'.' || argv0.iter().any(|b| *b == b'/') { + if argv0.iter().any(|b| *b == b'/') { + // The program name is path-like, so try to canonicalize it. crate::fs::canonicalize(OsStr::from_bytes(argv0)) } else { + // The program was probably found in the PATH. Instead of trying to + // find it again (which might not succeed if PATH has changed), just + // return the program name – this function is best-effort anyway. Ok(PathBuf::from(OsStr::from_bytes(argv0))) } } diff --git a/library/std/tests/thread_local/tests.rs b/library/std/tests/thread_local/tests.rs index 633bab38eb4db..1a25d91e43bc0 100644 --- a/library/std/tests/thread_local/tests.rs +++ b/library/std/tests/thread_local/tests.rs @@ -110,7 +110,7 @@ fn smoke_dtor() { #[test] fn circular() { - // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint + // FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] struct S1(&'static LocalKey>>, &'static LocalKey>>); diff --git a/src/bootstrap/src/core/builder/cargo.rs b/src/bootstrap/src/core/builder/cargo.rs index 72094373b5719..87fe911715fce 100644 --- a/src/bootstrap/src/core/builder/cargo.rs +++ b/src/bootstrap/src/core/builder/cargo.rs @@ -78,6 +78,26 @@ impl Rustflags { } } +/// Picks the environment variable and value to pass a set of [`Rustflags`] to cargo. +/// +/// `flags` is the `\x1f`-separated string built by [`Rustflags`]. We prefer the plain, +/// space-separated form (`RUSTFLAGS`/`RUSTDOCFLAGS`) so the command stays readable and +/// copy-pasteable in bootstrap's debug output, and only fall back to the `CARGO_ENCODED_*` form +/// (which keeps the `\x1f` separators) when a flag value contains a space that the plain, +/// whitespace-split form can't represent. See . +pub(super) fn flags_env( + plain: &'static str, + encoded: &'static str, + flags: &str, +) -> (&'static str, String) { + // A space can only appear inside a flag value, since the separators are `\x1f`. + if flags.contains(' ') { + (encoded, flags.to_string()) + } else { + (plain, flags.replace('\x1f', " ")) + } +} + /// Flags that are passed to the `rustc` shim binary. These flags will only be applied when /// compiling host code, i.e. when `--target` is unset. #[derive(Debug, Default)] @@ -465,21 +485,25 @@ impl From for BootstrapCommand { cargo.command.args(cargo.args); - // Always unset the plain RUSTFLAGS/RUSTDOCFLAGS so that downstream - // tools (e.g. build.rs scripts) see only the encoded form. Any flags - // from the caller's environment have already been folded into the - // Rustflags struct via `propagate_cargo_env`. + // Unset any inherited flag variables (plain and encoded) so cargo uses only the flags + // bootstrap sets below. Flags from the caller's environment have already been folded into + // the Rustflags struct via `propagate_cargo_env`. This also matters because we may set the + // plain form below, which cargo ignores when `CARGO_ENCODED_RUSTFLAGS` is also present. cargo.command.env_remove("RUSTFLAGS"); + cargo.command.env_remove("CARGO_ENCODED_RUSTFLAGS"); cargo.command.env_remove("RUSTDOCFLAGS"); + cargo.command.env_remove("CARGO_ENCODED_RUSTDOCFLAGS"); - let rustflags = &cargo.rustflags.0; - if !rustflags.is_empty() { - cargo.command.env("CARGO_ENCODED_RUSTFLAGS", rustflags); + if !cargo.rustflags.0.is_empty() { + let (var, value) = + flags_env("RUSTFLAGS", "CARGO_ENCODED_RUSTFLAGS", &cargo.rustflags.0); + cargo.command.env(var, value); } - let rustdocflags = &cargo.rustdocflags.0; - if !rustdocflags.is_empty() { - cargo.command.env("CARGO_ENCODED_RUSTDOCFLAGS", rustdocflags); + if !cargo.rustdocflags.0.is_empty() { + let (var, value) = + flags_env("RUSTDOCFLAGS", "CARGO_ENCODED_RUSTDOCFLAGS", &cargo.rustdocflags.0); + cargo.command.env(var, value); } let encoded_hostflags = cargo.hostflags.encode(); diff --git a/src/bootstrap/src/core/builder/tests.rs b/src/bootstrap/src/core/builder/tests.rs index 176a61b15c988..62ba7d79b13df 100644 --- a/src/bootstrap/src/core/builder/tests.rs +++ b/src/bootstrap/src/core/builder/tests.rs @@ -3349,3 +3349,26 @@ fn render_compiler(compiler: Compiler, config: &RenderConfig) -> String { fn host_target() -> String { get_host_target().to_string() } + +#[test] +fn flags_env_prefers_plain_form_without_spaces() { + use super::cargo::flags_env; + + // No flag value contains a space, so use the readable, copy-pasteable plain form + // rather than the `\x1f`-separated encoded form (rust-lang/rust#158749). + assert_eq!( + flags_env("RUSTFLAGS", "CARGO_ENCODED_RUSTFLAGS", "--cfg=foo\u{1f}-Cdebuginfo=0"), + ("RUSTFLAGS", "--cfg=foo -Cdebuginfo=0".to_string()), + ); + + // A flag value contains a space (e.g. an `-L` path), which the whitespace-split plain + // form can't represent, so keep the encoded form. + assert_eq!( + flags_env( + "RUSTFLAGS", + "CARGO_ENCODED_RUSTFLAGS", + "-Clink-arg=-L/opt/my libs\u{1f}--cfg=foo" + ), + ("CARGO_ENCODED_RUSTFLAGS", "-Clink-arg=-L/opt/my libs\u{1f}--cfg=foo".to_string()), + ); +} diff --git a/src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile b/src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile index 87bfc0766fbd9..220dbaeebd430 100644 --- a/src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile +++ b/src/ci/docker/host-aarch64/aarch64-gnu/Dockerfile @@ -26,4 +26,5 @@ ENV RUST_CONFIGURE_ARGS="--build=aarch64-unknown-linux-gnu \ --enable-profiler \ --enable-compiler-docs" ENV SCRIPT="python3 ../x.py --stage 2 test && \ - python3 ../x.py --stage 2 test src/tools/cargo" + python3 ../x.py --stage 2 test src/tools/cargo && \ + python3 ../x.py --stage 2 test library/stdarch/crates/intrinsic-test" diff --git a/src/doc/rustc-dev-guide/rust-version b/src/doc/rustc-dev-guide/rust-version index a05eac34eb1e9..f930573748e28 100644 --- a/src/doc/rustc-dev-guide/rust-version +++ b/src/doc/rustc-dev-guide/rust-version @@ -1 +1 @@ -8c75e93c5c7671c29f3e8c096b7acf56822ed23a +7fb284d9037fa54f6a9b24261c82b394472cbfd7 diff --git a/src/doc/rustc-dev-guide/src/SUMMARY.md b/src/doc/rustc-dev-guide/src/SUMMARY.md index d414f374b36cb..bf2de84575d69 100644 --- a/src/doc/rustc-dev-guide/src/SUMMARY.md +++ b/src/doc/rustc-dev-guide/src/SUMMARY.md @@ -193,6 +193,7 @@ - [Sharing the trait solver with rust-analyzer](./solve/sharing-crates-with-rust-analyzer.md) - [`Unsize` and `CoerceUnsized` traits](./traits/unsize.md) - [Having separate `Trait` and `Projection` bounds](./traits/separate-projection-bounds.md) +- [Well-formedness](./analysis/well-formed.md) - [Variance](./variance.md) - [Coherence checking](./coherence.md) - [HIR Type checking](./hir-typeck/summary.md) diff --git a/src/doc/rustc-dev-guide/src/analysis/well-formed.md b/src/doc/rustc-dev-guide/src/analysis/well-formed.md new file mode 100644 index 0000000000000..4a2450a480ed2 --- /dev/null +++ b/src/doc/rustc-dev-guide/src/analysis/well-formed.md @@ -0,0 +1,326 @@ +# Well-formedness + +## What is well-formedness? + +"Well-formed" means "correctly built"[^wf-history]. +Something is _well-formed_ when its structure follows rules. +When we use this term in the Rust compiler we are concerned with establishing some kind of _internal consistency_. + +## Well-formedness in Rust + +To check that something is well-formed is to perform a "Well-formedness check". + +In the Rust compiler there are two different forms of well-formedness checking: + +- **Type-Level Term**[^terms][^terms-abbreviated] well-formedness check. + - Also called "Term well-formedness" or "Term well-formedness checking". + - Not a distinct analysis stage, this gets performed throughout analysis. +- **Item**[^items] well-formedness check (item-wfck.) + - "Item-wfck" will often wind up requiring Terms be well-formed, but skips some areas. + - Inner "Terms" can (incorrectly) get normalized first. + - More coherent as a stage in the compiler than "term well-formedness" (which is performed in many places.) + +See: [What Well-Formedness Isn't](#what-well-formedness-isnt). + +## Well-formedness of type-level terms + +Term well-formedness checking begins with building a list of things that need to be true for a term to be well-formed. +We call these "Obligations"[^obligations]. + +Type-Level Terms are considered well-formed when their associated obligations are satisfied by the trait solver. + +### Obligations for well-formedness + +Specific obligations are things like `String: Clone`, `A: usize`, or `::Item: Debug`. + +On this page we show the split between obligations and terms/items as: + +```rust,ignore + +--- + +``` + +Here is an example of a well-formed type-level term: + +```rust,ignore +Vec +--- +// Obligations to fulfill +Vec where T: Sized +// Trait solver says `String: Sized` is true, so this is well-formed. +Vec where String: Sized +``` + +When we compute the obligations for `Vec`, we'll find that `Vec` generates the obligation `T: Sized`. +We substitute `T` with `String` in `Vec`, so we find the obligation `String: Sized` which the trait solver will determine to be satisfied. + +The following **is not** well-formed: + +```rust,ignore +Vec +--- +// Obligations to fulfill +Vec where T: Sized +// Trait solver says `str: Sized` is not true, so this is not well-formed. +Vec where str: Sized +``` + +The above computes the obligation `T: Sized`, like before, but we substitute `T` for `str` in the instance of `Vec` finding the obligation `str: sized`. +This obligation will be determined by the trait solver to be _unsatisfied_. + +#### Determining obligations + +In the compiler, obligations of terms are found through the [`obligations`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/wf/fn.obligations.html) function in the [term well-formedness module](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_trait_selection/traits/wf/index.html). + +#### Other obligations + +Obligations are more than just trait and const generic bounds, but we've only mentioned these specific obligations so far as they are what we care about when we do "well-formedness checking" of terms. +See: [`PredicateKind`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_type_ir/predicate_kind/enum.PredicateKind.html) and [`ClauseKind`](https://doc.rust-lang.org/beta/nightly-rustc/rustc_type_ir/predicate_kind/enum.ClauseKind.html) for a full list of obligations. + +### We don't need normalization (yet) + +[Normalization](../normalization.md) is the process of resolving [type aliases](../normalization.md#aliases) into their underlying type. + +A type alias is considered well-formed if its where clauses are satisfied. +The underlying type undergoes well-formedness checking at most definition and instantiation sites, but there are exceptions. + +### Const generic arguments + +Term well-formedness is responsible for getting "type checking" obligations of const generic terms[^tyck-const-generics]. +Let's look at the following use of const generics: + +```rust,ignore +fn use_const_generics() { /* ... */ } +// call site +use_const_generics::<6>(); +--- +// call site wfck obligations +const 6: usize +``` + +The call site will provide us with the obligation `6: usize` during well-formedness checking. +This obligation will be passed off to the trait solver just like any trait-style obligation, as the trait solver has more responsibilities than its name suggests. + +## Well-formedness of items + +Items are, generally speaking, "Things that get defined". +Item-wfck happens at the signature level for types and functions, methods, and definitions/implementations of traits. + +```rust,ignore +// The `Vec` is checked during item wfck +fn foo(_: Vec) { + // The `Vec<[u8]>` is not handled by item wfck as it's not in the signature + let _: Vec<[u8]> +} +--- +Vec: Sized // Generated +Vec<[u8]>: Sized // Not done at item-wfck. Done elsewhere. +``` + +Item-wfck has more responsibilities than only collecting the obligations of its internal type-level terms and passing them to the trait solver. +We do not talk about all of these here, but they can be found at the individual `check_*` functions in [**the item-wfck module**](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_analysis/check/wfcheck/index.html). + + + +### Global and trivial bounds + + + +Trait bounds are a common Obligation. +Global and Trivial trait bounds are kinds of trait bounds where we already have enough information to determine if they are true or false. +Item-wfck is responsible for finding and checking these bounds. + +- **Global bounds** are, in the old solver, post-normalization bounds that don't contain any generic parameters (likeΒ `` or `'a`) or bound variables (like `for<'b>`). +- **Trivial bounds** are bounds that do not need further normalization to determine if they're well-formed or not. + +Consider the following function definition: + +```rust,ignore +fn apartment_complex(block: T, name: String) where String: Clone { /* ... */ } +--- +String: Clone // Trivial & Global bound! There's no aliases to resolve. +// There could be bligations on T but we don't care about them here. +``` + +This produces a trait bound obligation `String: Clone` that is _Global_ (no generic parameters) and _Trivial_ (didn't require normalization to be well-formedness checked). +The trait solver doesn't need to be given any additional information for it to be able to make a judgment on the well-formedness of `String: Clone`. + +False trivial bounds are simply trivial bounds that do not hold. +The following is a basic example: + +```rust,ignore +fn apartment_simple(block: T, name: String) where String: Copy { /* ... */ } +--- +String: Copy // Trivial bound again, but this one is false! +``` + +Here we have a trivial bound that does not hold, because `String` is not `Copy`. + +#### Trivial bounds are not always global + +Trivial Bounds are not a subset of Global Bounds. +A trivial bound that isn't Global is `for<'a> String: Clone` (trivially true, has a bound variable) or `&'a str: Copy` (trivially false, has a generic parameter). + +#### Item-wfck and trivial/global bounds + + + +When checking items are well-formed we will check that there are no trivially false global bounds. + +## When we don't fully do well-formedness checking + +Well-formedness checking is not a coherent "stage" of type checking. +There are many areas where well-formedness checking is performed, and some areas where we skip over well-formedness checking due to limitations in what kinds of analysis we can currently perform. +Ideally, we would never skip or defer well-formedness checking. + +### We (sometimes) need normalization + +There are places where normalization of an Item happens before its Terms have gone through well-formedness checking. +This is considered problematic as doing so allows some terms to [bypass term well-formedness checking entirely](https://github.com/rust-lang/rust/issues/100041). + +### Trait objects + +We do not require the where clauses of trait objects to be well-formed when determining if that trait object is well-formed. +These where clauses are proven when coercing into a trait object, but this remains a hole in well-formedness checking. + +As an example, the following will compile because we don't have a point where we're constructing the trait object from a concrete type: + +```rust,ignore +trait Trait +where + for<'a> [u8]: Sized {} + +fn foo(_: &dyn Trait) {} +--- +// This doesn't end up being generated, because it happens within a trait object. +[u8]: Sized +``` + +The above should not compile because `[u8]: Sized`, but this won't be checked until actual use: + +```rust +trait Trait +where + for<'a> [u8]: Sized {} + +fn foo(_: &dyn Trait) {} + +// We still need to specify the bound here, otherwise `[u8]: Sized` _is_ +// checked as an obligation. +impl Trait for u8 where for<'a> [u8]: Sized {} + +fn main() { + // No matter what we do, this boundary between concrete type and trait + // object will produce the obligation `[u8]: Sized`, which will fail when + // handed over to the trait solver. + let object: Box = Box::new(42u8); + foo(&object); +} +``` + +This exception does not apply to Const Generic Arguments in trait objects: + +```rust,ignore +trait Trait {} +fn foo(_: &dyn Trait) {} +--- +const N: usize +const B: bool +N = B // Substitution +const B: usize + bool +``` + +The above doesn't compile, unlike the previous example we gave. +We're doing _some_ well-formedness checking here when it comes to the const generic arguments. + +### Binders / higher-ranked types + +Binders / Higher-Ranked Types reduce the amount well-formedness checking we do on a term, leaving well-formedness checking to when the bound is instantiated: + +```rust,ignore +let _: for<'a> fn(Vec<[&'a ()]>); +--- +// This doesn't end up being generated, because it happens within a HRB +[&'a ()]: Sized // slices aren't sized, this would fail! +``` + +Specifically, obligations involving variables from binders (`for<'a>`) are only checked when the binder is instantiated. +Some things are stilled checked under the `for<'a>`, but we still skip a lot of things. + +A lot of unsoundness surrounds this behavior. +See: [#25860](https://github.com/rust-lang/rust/issues/25860), [#84591](https://github.com/rust-lang/rust/issues/84591). + +Let's consider the following: + +```rust,ignore +for<'a, 'b> fn(&'a &'b ()) +``` + +The above HRB implies `'b: 'a` (a lifetime bound), rather than two completely separate lifetimes. +This is normal lifetime behavior, but during well-formedness checking we cannot prove that this bound is generally true[^horrible], so we skip it. + +### Free type aliases + +The right-hand side of Free Type Aliases[^fta] is not fully checked to be well-formed at the definition site, only the types of const generic arguments in the RHS are checked. + +The following free type alias passes type checking, at time of writing: + +```rust,ignore +type WorksButShouldNot = Vec; +--- +// This should fail! But we skip the RHS of free type aliases +str: Sized // Not generated +``` + +This shouldn't work, as both `T: Sized`, `str: Sized` are implied by `Vec`. +This "passes" item-wfck because the RHS of a free type alias doesn't go through well-formedness checking _until it's used_. +Item-wfck is **deferred until use** for this specific case. + +For Const Generics we still do a small amount of well-formedness checking at the definition site of a free type alias. +This is consistent with our current special-casing of const generic well-formedness checking when we skip over things like where bounds. + +This means that the following, despite being of a similar form to the above example, fails as it should: + +```rust,ignore +pub struct Consty; +type Alias = Consty<42>; +--- +// This *is* generated as an obligation, so this (correctly) fails. +42: bool // This is generated! +``` + + + +## "well-formed" or "wellformed"? + +Prefer "well-formed" over "wellformed", as this is consistent with logic literature. +This also gets abbreviated to WF in other parts of the dev guide / docs. + +## Informal usage + +In conversation, contributors may refer to something as "well-formed" and not necessarily mean what we cover here because "well-formedness" is a general phrase associated with the correctness of formal structures. +This isn't necessarily in error, but it should be looked out for. + +## What well-formedness isn't + +Well-formedness checking is not "number of parameters" or "parameter type" checking[^kind-checking]. +Neither term well-formedness checking nor item-wfck is concerned with if a type with 2 parameters has 1 or 3 types applied to it (assuming no defaults), or if a const generic parameter has a type applied to it. +These kinds of problems will get handled during HIR-ty Lowering[^hir-ty-lower], not wfck. + +Well-formedness doesn't check or validate lifetimes, this is handled in [MIR](../borrow-check.md). + +Well-formedness in the Rust compiler doesn't correspond to "correct syntax" as it does in logic. +The term has a history of general use in a mathematical context of "follows a given set of rules". +In Rust, our original usage was closer to "this thing is internally consistent" with respect to the bounds on a type in places such as the original [clarification on projections and well-formedness RFC](https://github.com/rust-lang/rfcs/blob/master/text/1214-projections-lifetimes-and-wf.md). + +[^obligations]: These get referred to as Obligations, Requirements, or Constraints in the documentation. Preferred term is "obligations", as this matches the suffix of the type and the names of relevant functions. In future, this may be superseded by the new solver's term "Goal". +[^wf-history]: In linguistics this is "grammatically correct", in logic it is "syntactically correct", and in casual mathematician use it can be read as a more general "follows the rules we set for this domain". +[^horrible]: Instead, this bound is checked during "MIR borrowck" when the lifetimes are instantiated. +[^fta]: Type aliases not associated with anything, i.e. a module-level `type Alias = Vec;`. +[^items]: "Definition" style things in rust, See the [glossary](../appendix/glossary.md). +[^terms]: AKA Type expressions and subexpressions in the general sense, not a specific struct or enum in the rust compiler. See the [glossary](../appendix/glossary.md). +[^terms-abbreviated]: Abbreviated as "Terms" on this page in some areas. +[^kind-checking]: AKA "kind checking", as we might see in languages like Haskell. +[^hir-ty-lower]: +[^tyck-const-generics]: #checking-types-of-const-arguments diff --git a/src/doc/rustc-dev-guide/src/appendix/glossary.md b/src/doc/rustc-dev-guide/src/appendix/glossary.md index 30959f4b39e6f..527da87b7b7e1 100644 --- a/src/doc/rustc-dev-guide/src/appendix/glossary.md +++ b/src/doc/rustc-dev-guide/src/appendix/glossary.md @@ -102,6 +102,7 @@ Term | Meaning trans πŸ‘Ž | Short for _translation_, the code to translate MIR into LLVM IR. **Renamed to** [codegen](#codegen). `Ty` | The internal representation of a type. ([see more](../ty.md)) `TyCtxt` | The data structure often referred to as [`tcx`](#tcx) in code which provides access to session data and the query system. +Type-Level Term | An expression at the type level, such as a Type or Const Generic. UFCS πŸ‘Ž | Short for _universal function call syntax_, this is an unambiguous syntax for calling a method. **Term no longer in use!** Prefer _fully-qualified path / syntax_. ([see more](../hir-typeck/summary.md), [see the reference](https://doc.rust-lang.org/reference/expressions/call-expr.html#disambiguating-function-calls)) uninhabited type | A type which has _no_ values. This is not the same as a ZST, which has exactly 1 value. An example of an uninhabited type is `enum Foo {}`, which has no variants, and so, can never be created. The compiler can treat code that deals with uninhabited types as dead code, since there is no such value to be manipulated. `!` (the never type) is an uninhabited type. Uninhabited types are also called _empty types_. upvar | A variable captured by a closure from outside the closure. diff --git a/src/doc/rustc-dev-guide/src/autodiff/installation.md b/src/doc/rustc-dev-guide/src/autodiff/installation.md index 7247efd46a380..4176763a7bd62 100644 --- a/src/doc/rustc-dev-guide/src/autodiff/installation.md +++ b/src/doc/rustc-dev-guide/src/autodiff/installation.md @@ -18,30 +18,30 @@ Please run: rustup +nightly component add enzyme ``` -## Installation guide for Nix user. +## Installation guide for Nix + +On [Nix], you can declare a nightly Rust toolchain with the Enzyme component using the [oxalica rust-overlay]. + +For example: + +```nix +rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { + extensions = [ "enzyme" ]; +}) +``` + +Alternatively, you can create a [toolchain file] that declares the Enzyme component such as + +```toml +[toolchain] +channel = "nightly-2026-06-23" +components = [ "enzyme" ] +``` + +and consume it in the overlay -This setup was recommended by a nix and autodiff user. -It uses [`Overlay`]. -Please verify for yourself if you are comfortable using that repository. -In that case you might use the following nix configuration to get a rustc that supports `std::autodiff`. ```nix -{ - enzymeLib = pkgs.fetchzip { - url = "https://ci-artifacts.rust-lang.org/rustc-builds/ec818fda361ca216eb186f5cf45131bd9c776bb4/enzyme-nightly-x86_64-unknown-linux-gnu.tar.xz"; - sha256 = "sha256-Rnrop44vzS+qmYNaRoMNNMFyAc3YsMnwdNGYMXpZ5VY="; - }; - - rustToolchain = pkgs.symlinkJoin { - name = "rust-with-enzyme"; - paths = [pkgs.rust-bin.nightly.latest.default]; - nativeBuildInputs = [pkgs.makeWrapper]; - postBuild = '' - libdir=$out/lib/rustlib/x86_64-unknown-linux-gnu/lib - cp ${enzymeLib}/enzyme-preview/lib/rustlib/x86_64-unknown-linux-gnu/lib/libEnzyme-22.so $libdir/ - wrapProgram $out/bin/rustc --add-flags "--sysroot $out" - ''; - }; -} +rust-bin.fromRustupToolchainFile ./rust-toolchain.toml ``` ## Build instructions @@ -135,4 +135,6 @@ This will build Enzyme, and you can find it in `Enzyme/enzyme/build/lib//bootstrap-trace/` directory. For convenience, bootstrap will also create a symlink to the latest generated trace output directory at `/bootstrap-trace/latest`. +The structured logs will be written to standard error output (`stderr`), while the other outputs will be stored in files in the `/bootstrap-trace/` directory. +For convenience, bootstrap will also create a symlink to the latest generated trace output directory at `/bootstrap-trace/latest`. > Note that if you execute bootstrap with `--dry-run`, the tracing output directory might change. Bootstrap will always print a path where the tracing output files were stored at the end of its execution. @@ -73,18 +77,24 @@ Build completed successfully in 0:00:00 #### Controlling tracing output -The environment variable `BOOTSTRAP_TRACING` accepts a [`tracing_subscriber` filter][tracing-env-filter]. If you set `BOOTSTRAP_TRACING=trace`, you will enable all logs, but that can be overwhelming. You can thus use the filter to reduce the amount of data logged. +The environment variable `BOOTSTRAP_TRACING` accepts a [`tracing_subscriber` filter][tracing-env-filter]. +If you set `BOOTSTRAP_TRACING=trace`, you will enable all logs, but that can be overwhelming. +You can thus use the filter to reduce the amount of data logged. There are two orthogonal ways to control which kind of tracing logs you want: 1. You can specify the log **level**, e.g. `debug` or `trace`. - If you select a level, all events/spans with an equal or higher priority level will be shown. 2. You can also control the log **target**, e.g. `bootstrap` or `bootstrap::core::config` or a custom target like `CONFIG_HANDLING` or `STEP`. - - Custom targets are used to limit what kinds of spans you are interested in, as the `BOOTSTRAP_TRACING=trace` output can be quite verbose. Currently, you can use the following custom targets: + - Custom targets are used to limit what kinds of spans you are interested in, as the `BOOTSTRAP_TRACING=trace` output can be quite verbose. + Currently, you can use the following custom targets: - `CONFIG_HANDLING`: show spans related to config handling. - - `STEP`: show all executed steps. Executed commands have `info` event level. - - `COMMAND`: show all executed commands. Executed commands have `trace` event level. - - `IO`: show performed I/O operations. Executed commands have `trace` event level. + - `STEP`: show all executed steps. + Executed commands have `info` event level. + - `COMMAND`: show all executed commands. + Executed commands have `trace` event level. + - `IO`: show performed I/O operations. + Executed commands have `trace` event level. - Note that many I/O are currently not being traced. You can of course combine them (custom target logs are typically gated behind `TRACE` log level additionally): @@ -100,14 +110,15 @@ Note that the level that you specify using `BOOTSTRAP_TRACING` also has an effec ##### FIXME(#96176): specific tracing for `compiler()` vs `compiler_for()` The additional targets `COMPILER` and `COMPILER_FOR` are used to help trace what -`builder.compiler()` and `builder.compiler_for()` does. They should be removed -if [#96176][cleanup-compiler-for] is resolved. +`builder.compiler()` and `builder.compiler_for()` does. +They should be removed if [#96176][cleanup-compiler-for] is resolved. [cleanup-compiler-for]: https://github.com/rust-lang/rust/issues/96176 ### Using `tracing` in bootstrap -Both `tracing::*` macros and the `tracing::instrument` proc-macro attribute need to be gated behind `tracing` feature. Examples: +Both `tracing::*` macros and the `tracing::instrument` proc-macro attribute need to be gated behind `tracing` feature. +Examples: ```rs #[cfg(feature = "tracing")] diff --git a/src/doc/rustc-dev-guide/src/building/bootstrapping/how-bootstrap-does-it.md b/src/doc/rustc-dev-guide/src/building/bootstrapping/how-bootstrap-does-it.md index 4d301b3abae1a..63c154d25d22f 100644 --- a/src/doc/rustc-dev-guide/src/building/bootstrapping/how-bootstrap-does-it.md +++ b/src/doc/rustc-dev-guide/src/building/bootstrapping/how-bootstrap-does-it.md @@ -1,14 +1,16 @@ # How Bootstrap does it The core concept in Bootstrap is a build [`Step`], which are chained together -by [`Builder::ensure`]. [`Builder::ensure`] takes a [`Step`] as input, and runs -the [`Step`] if and only if it has not already been run. Let's take a closer -look at [`Step`]. +by [`Builder::ensure`]. +[`Builder::ensure`] takes a [`Step`] as input, and runs +the [`Step`] if and only if it has not already been run. +Let's take a closer look at [`Step`]. ## Synopsis of [`Step`] A [`Step`] represents a granular collection of actions involved in the process -of producing some artifact. It can be thought of like a rule in Makefiles. +of producing some artifact. +It can be thought of like a rule in Makefiles. The [`Step`] trait is defined as: ```rs,no_run @@ -30,8 +32,8 @@ pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { - `run` is the function that is responsible for doing the work. [`Builder::ensure`] invokes `run`. - `should_run` is the command-line interface, which determines if an invocation - such as `x build foo` should run a given [`Step`]. In a "default" context - where no paths are provided, then `make_run` is called directly. + such as `x build foo` should run a given [`Step`]. + In a "default" context where no paths are provided, then `make_run` is called directly. - `make_run` is invoked only for things directly asked via the CLI and not for steps which are dependencies of other steps. diff --git a/src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md b/src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md index 7f53097824cc9..e4704a10e0a78 100644 --- a/src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md +++ b/src/doc/rustc-dev-guide/src/building/bootstrapping/intro.md @@ -1,14 +1,13 @@ # Bootstrapping the compiler -[*Bootstrapping*][boot] is the process of using a compiler to compile itself. -More accurately, it means using an older compiler to compile a newer version -of the same compiler. +[*Bootstrapping*] is the process of using a compiler to compile itself. +More accurately, it means using an older compiler to compile a newer version of the same compiler. This raises a chicken-and-egg paradox: where did the first compiler come from? -It must have been written in a different language. In Rust's case it was -[written in OCaml][ocaml-compiler]. However, it was abandoned long ago, and the -only way to build a modern version of rustc is with a slightly less modern -version. +It must have been written in a different language. +In Rust's case it was [written in OCaml]. +However, it was abandoned long ago, and the +only way to build a modern version of rustc is with a slightly less modern version. This is exactly how `x.py` works: it downloads the current beta release of rustc, then uses it to compile the new compiler. @@ -17,8 +16,7 @@ In this section, we give a high-level overview of [what Bootstrap does](./what-bootstrapping-does.md), followed by a high-level introduction to [how Bootstrap does it](./how-bootstrap-does-it.md). -Additionally, see [debugging bootstrap](./debugging-bootstrap.md) to learn -about debugging methods. +Additionally, see [debugging bootstrap](./debugging-bootstrap.md) to learn about debugging methods. -[boot]: https://en.wikipedia.org/wiki/Bootstrapping_(compilers) -[ocaml-compiler]: https://github.com/rust-lang/rust/tree/ef75860a0a72f79f97216f8aaa5b388d98da6480/src/boot +[*Bootstrapping*]: https://en.wikipedia.org/wiki/Bootstrapping_(compilers) +[written in OCaml]: https://github.com/rust-lang/rust/tree/ef75860a0a72f79f97216f8aaa5b388d98da6480/src/boot diff --git a/src/doc/rustc-dev-guide/src/compiler-debugging.md b/src/doc/rustc-dev-guide/src/compiler-debugging.md index a07b418c64d4d..49a965d49df33 100644 --- a/src/doc/rustc-dev-guide/src/compiler-debugging.md +++ b/src/doc/rustc-dev-guide/src/compiler-debugging.md @@ -236,7 +236,7 @@ The compiler uses the [`tracing`] crate for logging. For details, see [the chapter on tracing](./tracing.md). -## Narrowing (Bisecting) Regressions +## Narrowing (bisecting) regressions The [cargo-bisect-rustc][bisect] tool can be used as a quick and easy way to find exactly which PR caused a change in `rustc` behavior. @@ -248,7 +248,7 @@ You can then look at the PR to get more context on *why* it was changed. [bisect]: https://github.com/rust-lang/cargo-bisect-rustc [bisect-tutorial]: https://rust-lang.github.io/cargo-bisect-rustc/tutorial.html -## Downloading Artifacts from Rust's CI +## Downloading artifacts from Rust's CI The [rustup-toolchain-install-master][rtim] tool by kennytm can be used to download the artifacts produced by Rust's CI for a specific SHA1 -- this diff --git a/src/doc/rustc-dev-guide/src/contributing.md b/src/doc/rustc-dev-guide/src/contributing.md index 4e292c5476d1c..5cbffb1a49eee 100644 --- a/src/doc/rustc-dev-guide/src/contributing.md +++ b/src/doc/rustc-dev-guide/src/contributing.md @@ -257,7 +257,7 @@ In particular, we don't recommend running the full `./x test` suite locally, since it takes a very long time to execute. See the [Testing with CI] chapter for using Rust's CI to test your changes. -[Testing with CI]: https://rustc-dev-guide.rust-lang.org/tests/ci.html#testing-with-ci +[Testing with CI]: tests/ci.md#testing-with-ci ### r+ @@ -425,7 +425,7 @@ Just a few things to keep in mind: - When contributing text to the guide, please contextualize the information with some time period and/or a reason so that the reader knows how much to trust the information. - Aim to provide a reasonable amount of context, possibly including but not limited to: + Aim to provide a reasonable amount of context, and consider including: - A reason for why the text may be out of date other than "change", as change is a constant across the project. @@ -444,29 +444,29 @@ Just a few things to keep in mind: For the action to pick the date, add a special annotation before specifying the date: ```md - Nov 2025 + Jul 2026 ``` Example: ```md - As of Nov 2025, the foo did the bar. + As of Jul 2026, the foo did the bar. ``` For cases where the date should not be part of the visible rendered output, use the following instead: ```md - + ``` - A link to a relevant WG, tracking issue, `rustc` rustdoc page, or similar, that may provide further explanation for the change process or a way to verify that the information is not outdated. -- If a text grows rather long (more than a few page scrolls) or complicated (more than four - subsections), it might benefit from having a Table of Contents at the beginning, - which you can auto-generate by including the `` marker at the top. +- Use sentence case for chapter and sections titles. + +- Use dashes (`-`) to separate words file names. #### ⚠️ Note: Where to contribute `rustc-dev-guide` changes diff --git a/src/doc/rustc-dev-guide/src/offload/installation.md b/src/doc/rustc-dev-guide/src/offload/installation.md index 4b67f31cd3c28..ab8e7984d5b4a 100644 --- a/src/doc/rustc-dev-guide/src/offload/installation.md +++ b/src/doc/rustc-dev-guide/src/offload/installation.md @@ -44,7 +44,7 @@ Run this test script for offload-specific tests: ./x test --stage 1 tests/codegen-llvm/gpu_offload ``` -For testing the CI locally, you may use the commands outlined in [Testing with Docker](https://rustc-dev-guide.rust-lang.org/tests/docker.html): +For testing the CI locally, you may use the commands outlined in [Testing with Docker](../tests/docker.md): ```console cargo run --manifest-path src/ci/citool/Cargo.toml run-local dist-x86_64-linux ``` diff --git a/src/doc/rustc-dev-guide/src/tests/best-practices.md b/src/doc/rustc-dev-guide/src/tests/best-practices.md index b6daffa6683c0..d1378a849a9d4 100644 --- a/src/doc/rustc-dev-guide/src/tests/best-practices.md +++ b/src/doc/rustc-dev-guide/src/tests/best-practices.md @@ -171,7 +171,7 @@ place. If a test suite can randomly spuriously fail due to flaky tests, did the whole test suite pass or did I just get lucky/unlucky? -- Flaky tests can randomly fail in full CI, wasting previous full CI resources. +- Flaky tests can randomly fail in full CI, wasting precious resources. ## Compiletest directives diff --git a/src/doc/rustc-dev-guide/src/tests/ci.md b/src/doc/rustc-dev-guide/src/tests/ci.md index 8f06d69d8cffe..31c6949d85d6c 100644 --- a/src/doc/rustc-dev-guide/src/tests/ci.md +++ b/src/doc/rustc-dev-guide/src/tests/ci.md @@ -209,7 +209,7 @@ to help make the perf comparison as fair as possible. > > 3. Run the prescribed try jobs with `@bors try`. As aforementioned, this > requires the user to either (1) have `try` permissions or (2) be delegated -> with `try` permissions by `@bors delegate=try` by someone who has `try` +> with `try` permissions by `@bors delegate try` by someone who has `try` > permissions. > > Note that this is usually easier to do than manually edit [`jobs.yml`]. diff --git a/src/doc/rustc-dev-guide/src/traits/separate-projection-bounds.md b/src/doc/rustc-dev-guide/src/traits/separate-projection-bounds.md index 144e27316cbb4..94a0d752c945b 100644 --- a/src/doc/rustc-dev-guide/src/traits/separate-projection-bounds.md +++ b/src/doc/rustc-dev-guide/src/traits/separate-projection-bounds.md @@ -8,7 +8,7 @@ The way we prove `Projection` bounds directly relies on proving the correspondin It feels like it might make more sense to just have a single implementation which checks whether a trait is implemented and returns (a way to compute) its associated types. This is unfortunately quite difficult, as we may use a different candidate for norm than for the corresponding trait bound. -See [alias-bound vs where-bound](https://rustc-dev-guide.rust-lang.org/solve/candidate-preference.html#we-always-consider-aliasbound-candidates) and [global where-bound vs impl](https://rustc-dev-guide.rust-lang.org/solve/candidate-preference.html#we-prefer-global-where-bounds-over-impls). +See [alias-bound vs where-bound](../solve/candidate-preference.md#we-always-consider-aliasbound-candidates) and [global where-bound vs impl](../solve/candidate-preference.md#we-prefer-global-where-bounds-over-impls). There are also some other subtle reasons for why we can't do so. The most stupid is that for rigid aliases; diff --git a/src/tools/clippy/tests/ui/redundant_static_lifetimes.fixed b/src/tools/clippy/tests/ui/redundant_static_lifetimes.fixed index 86c6ca17eb20e..0a898032459f6 100644 --- a/src/tools/clippy/tests/ui/redundant_static_lifetimes.fixed +++ b/src/tools/clippy/tests/ui/redundant_static_lifetimes.fixed @@ -1,5 +1,5 @@ #![allow(unused)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #[derive(Debug)] diff --git a/src/tools/clippy/tests/ui/redundant_static_lifetimes.rs b/src/tools/clippy/tests/ui/redundant_static_lifetimes.rs index 6fefe6c232d2f..fa45eff0f2626 100644 --- a/src/tools/clippy/tests/ui/redundant_static_lifetimes.rs +++ b/src/tools/clippy/tests/ui/redundant_static_lifetimes.rs @@ -1,5 +1,5 @@ #![allow(unused)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #[derive(Debug)] diff --git a/src/tools/clippy/tests/ui/useless_conversion.fixed b/src/tools/clippy/tests/ui/useless_conversion.fixed index a22df7013f988..d74ea54354fdd 100644 --- a/src/tools/clippy/tests/ui/useless_conversion.fixed +++ b/src/tools/clippy/tests/ui/useless_conversion.fixed @@ -1,7 +1,7 @@ #![deny(clippy::useless_conversion)] #![allow(clippy::into_iter_on_ref)] #![allow(clippy::needless_ifs, clippy::unnecessary_wraps, unused)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::ops::ControlFlow; diff --git a/src/tools/clippy/tests/ui/useless_conversion.rs b/src/tools/clippy/tests/ui/useless_conversion.rs index 1f170cf87ac58..5d7d180635771 100644 --- a/src/tools/clippy/tests/ui/useless_conversion.rs +++ b/src/tools/clippy/tests/ui/useless_conversion.rs @@ -1,7 +1,7 @@ #![deny(clippy::useless_conversion)] #![allow(clippy::into_iter_on_ref)] #![allow(clippy::needless_ifs, clippy::unnecessary_wraps, unused)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::ops::ControlFlow; diff --git a/src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs b/src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs index 5b7a2b7039d80..2e45af9e28880 100644 --- a/src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs +++ b/src/tools/miri/tests/pass-dep/concurrency/linux-futex.rs @@ -1,7 +1,7 @@ //@only-target: linux android //@compile-flags: -Zmiri-disable-isolation -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::mem::MaybeUninit; diff --git a/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs b/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs index df42780021610..6ec4b6e48bc3f 100644 --- a/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs +++ b/src/tools/miri/tests/pass-dep/concurrency/tls_pthread_drop_order.rs @@ -5,7 +5,7 @@ //! the fallback path in `guard::key::enable`, which uses a *single* pthread_key //! to manage a thread-local list of dtors to call. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::{mem, ptr}; diff --git a/src/tools/miri/tests/pass-dep/libc/libc-eventfd.rs b/src/tools/miri/tests/pass-dep/libc/libc-eventfd.rs index e753983344bd4..d84ce42922886 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-eventfd.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-eventfd.rs @@ -3,7 +3,7 @@ //@compile-flags: -Zmiri-deterministic-concurrency //@run-native -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::{io, thread}; diff --git a/src/tools/miri/tests/pass-dep/libc/libc-pipe.rs b/src/tools/miri/tests/pass-dep/libc/libc-pipe.rs index 12b5ae5666cfd..de278c190b589 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-pipe.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-pipe.rs @@ -69,7 +69,7 @@ fn test_pipe_threaded() { thread2.join().unwrap(); } -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #[allow(static_mut_refs)] fn test_race() { static mut VAL: u8 = 0; diff --git a/src/tools/miri/tests/pass-dep/libc/libc-socketpair.rs b/src/tools/miri/tests/pass-dep/libc/libc-socketpair.rs index f994dc28a9349..bcfa52211dd9b 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-socketpair.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-socketpair.rs @@ -3,7 +3,7 @@ //@compile-flags: -Zmiri-deterministic-concurrency //@run-native -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::thread; diff --git a/src/tools/miri/tests/pass/atomic.rs b/src/tools/miri/tests/pass/atomic.rs index 842f036b0615a..0b7fff69d8ce2 100644 --- a/src/tools/miri/tests/pass/atomic.rs +++ b/src/tools/miri/tests/pass/atomic.rs @@ -3,7 +3,7 @@ //@[tree]compile-flags: -Zmiri-tree-borrows //@compile-flags: -Zmiri-strict-provenance -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::sync::atomic::Ordering::*; diff --git a/src/tools/miri/tests/pass/static_memory_modification.rs b/src/tools/miri/tests/pass/static_memory_modification.rs index 1900250bf4f8f..f55f2a251930e 100644 --- a/src/tools/miri/tests/pass/static_memory_modification.rs +++ b/src/tools/miri/tests/pass/static_memory_modification.rs @@ -1,4 +1,4 @@ -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::sync::atomic::{AtomicUsize, Ordering}; diff --git a/src/tools/miri/tests/pass/static_mut.rs b/src/tools/miri/tests/pass/static_mut.rs index f88c7a16e6dd7..005ec5f9dfcb4 100644 --- a/src/tools/miri/tests/pass/static_mut.rs +++ b/src/tools/miri/tests/pass/static_mut.rs @@ -1,4 +1,4 @@ -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::ptr::addr_of; diff --git a/src/tools/miri/tests/pass/tls/tls_static.rs b/src/tools/miri/tests/pass/tls/tls_static.rs index 600ecea334e13..dfc13720b4c8d 100644 --- a/src/tools/miri/tests/pass/tls/tls_static.rs +++ b/src/tools/miri/tests/pass/tls/tls_static.rs @@ -8,7 +8,7 @@ //! dereferencing the pointer on `t2` resolves to `t1`'s thread-local. In this //! test, we also check that thread-locals act as per-thread statics. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #![feature(thread_local)] diff --git a/src/tools/tidy/src/issues.txt b/src/tools/tidy/src/issues.txt index db6008da59b34..bb251a6823ac6 100644 --- a/src/tools/tidy/src/issues.txt +++ b/src/tools/tidy/src/issues.txt @@ -2324,8 +2324,6 @@ ui/resolve/issue-2356.rs ui/resolve/issue-23716.rs ui/resolve/issue-24968.rs ui/resolve/issue-26545.rs -ui/resolve/issue-3021-c.rs -ui/resolve/issue-3021.rs ui/resolve/issue-30535.rs ui/resolve/issue-3099-a.rs ui/resolve/issue-3099-b.rs diff --git a/tests/rustdoc-ui/doc-auto-cfg-values-non-ident.rs b/tests/rustdoc-ui/doc-auto-cfg-values-non-ident.rs new file mode 100644 index 0000000000000..213a804b8b63e --- /dev/null +++ b/tests/rustdoc-ui/doc-auto-cfg-values-non-ident.rs @@ -0,0 +1,7 @@ +// Regression test for https://github.com/rust-lang/rust/issues/158744. + +#![feature(doc_cfg)] + +#[doc(auto_cfg(hide(a, values(::b))))] +//~^ ERROR malformed `doc` attribute input +fn f() {} diff --git a/tests/rustdoc-ui/doc-auto-cfg-values-non-ident.stderr b/tests/rustdoc-ui/doc-auto-cfg-values-non-ident.stderr new file mode 100644 index 0000000000000..8c08c5ed4226d --- /dev/null +++ b/tests/rustdoc-ui/doc-auto-cfg-values-non-ident.stderr @@ -0,0 +1,11 @@ +error[E0565]: malformed `doc` attribute input + --> $DIR/doc-auto-cfg-values-non-ident.rs:5:1 + | +LL | #[doc(auto_cfg(hide(a, values(::b))))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---^^^^^ + | | + | expected a valid identifier here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0565`. diff --git a/tests/ui/abi/statics/static-mut-foreign.rs b/tests/ui/abi/statics/static-mut-foreign.rs index 40cd57637e6cd..f79400e7a6df8 100644 --- a/tests/ui/abi/statics/static-mut-foreign.rs +++ b/tests/ui/abi/statics/static-mut-foreign.rs @@ -3,7 +3,7 @@ // statics cannot. This ensures that there's some form of error if this is // attempted. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::ffi::c_int; diff --git a/tests/ui/array-slice-vec/slice-panic-1.rs b/tests/ui/array-slice-vec/slice-panic-1.rs index d7c1098fa2bda..60680c367a671 100644 --- a/tests/ui/array-slice-vec/slice-panic-1.rs +++ b/tests/ui/array-slice-vec/slice-panic-1.rs @@ -5,7 +5,7 @@ // Test that if a slicing expr[..] fails, the correct cleanups happen. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::thread; diff --git a/tests/ui/array-slice-vec/slice-panic-2.rs b/tests/ui/array-slice-vec/slice-panic-2.rs index 157e716a95d49..e5ba045248da2 100644 --- a/tests/ui/array-slice-vec/slice-panic-2.rs +++ b/tests/ui/array-slice-vec/slice-panic-2.rs @@ -5,7 +5,7 @@ // Test that if a slicing expr[..] fails, the correct cleanups happen. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::thread; diff --git a/tests/ui/array-slice-vec/slice.rs b/tests/ui/array-slice-vec/slice.rs index ad5db7a2102b4..b94a8e029f778 100644 --- a/tests/ui/array-slice-vec/slice.rs +++ b/tests/ui/array-slice-vec/slice.rs @@ -3,7 +3,7 @@ // Test slicing sugar. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] extern crate core; diff --git a/tests/ui/issues/issue-29861.rs b/tests/ui/associated-types/unconstrained-lifetime-in-projection.rs similarity index 70% rename from tests/ui/issues/issue-29861.rs rename to tests/ui/associated-types/unconstrained-lifetime-in-projection.rs index 875c168185feb..bee7d521c30f8 100644 --- a/tests/ui/issues/issue-29861.rs +++ b/tests/ui/associated-types/unconstrained-lifetime-in-projection.rs @@ -1,3 +1,7 @@ +//! Regression test for . +//! Unconstrained lifetimes in associated type were wrongly allowed when +//! occurred in projection. + pub trait MakeRef<'a> { type Ref; } diff --git a/tests/ui/issues/issue-29861.stderr b/tests/ui/associated-types/unconstrained-lifetime-in-projection.stderr similarity index 89% rename from tests/ui/issues/issue-29861.stderr rename to tests/ui/associated-types/unconstrained-lifetime-in-projection.stderr index a25cbf0515d84..0847fa652c55a 100644 --- a/tests/ui/issues/issue-29861.stderr +++ b/tests/ui/associated-types/unconstrained-lifetime-in-projection.stderr @@ -1,11 +1,11 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates - --> $DIR/issue-29861.rs:11:6 + --> $DIR/unconstrained-lifetime-in-projection.rs:15:6 | LL | impl<'a, T: 'a> MakeRef2 for T { | ^^ unconstrained lifetime parameter error[E0716]: temporary value dropped while borrowed - --> $DIR/issue-29861.rs:16:43 + --> $DIR/unconstrained-lifetime-in-projection.rs:20:43 | LL | fn foo() -> ::Ref2 { &String::from("foo") } | ^^^^^^^^^^^^^^^^^^^ -- borrow later used here diff --git a/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs b/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs index 04958352d3f2e..9f0869a3a0b43 100644 --- a/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs +++ b/tests/ui/async-await/issues/issue-67611-static-mut-refs.rs @@ -1,7 +1,7 @@ //@ build-pass //@ edition:2018 -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut A: [i32; 5] = [1, 2, 3, 4, 5]; diff --git a/tests/ui/binding/order-drop-with-match.rs b/tests/ui/binding/order-drop-with-match.rs index cd0ff73cf12da..db91ead4e0f85 100644 --- a/tests/ui/binding/order-drop-with-match.rs +++ b/tests/ui/binding/order-drop-with-match.rs @@ -5,7 +5,7 @@ // in ORDER matching up to when it ran. // Correct order is: matched, inner, outer -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut ORDER: [usize; 3] = [0, 0, 0]; diff --git a/tests/ui/binding/ref-pattern-drop-behavior-8860.rs b/tests/ui/binding/ref-pattern-drop-behavior-8860.rs index 1a67caf021cf7..bcb3ca2800396 100644 --- a/tests/ui/binding/ref-pattern-drop-behavior-8860.rs +++ b/tests/ui/binding/ref-pattern-drop-behavior-8860.rs @@ -1,6 +1,6 @@ // https://github.com/rust-lang/rust/issues/8860 //@ run-pass -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #![allow(dead_code)] diff --git a/tests/ui/borrowck/index-self-with-arithmetic-on-self-item.rs b/tests/ui/borrowck/index-self-with-arithmetic-on-self-item.rs new file mode 100644 index 0000000000000..3987e782af27b --- /dev/null +++ b/tests/ui/borrowck/index-self-with-arithmetic-on-self-item.rs @@ -0,0 +1,10 @@ +//! Regression test for . +//! Test borrowck doesn't complain about using arithmetic with self item +//! as index. +//@ check-pass + +fn main() { + let mut i = [1, 2, 3]; + i[i[0]] = 0; + i[i[0] - 1] = 0; +} diff --git a/tests/ui/issues/issue-2989.rs b/tests/ui/codegen/bitvec-to-bools-opt-miscompile.rs similarity index 92% rename from tests/ui/issues/issue-2989.rs rename to tests/ui/codegen/bitvec-to-bools-opt-miscompile.rs index fc35d1906368f..9611cd5485b60 100644 --- a/tests/ui/issues/issue-2989.rs +++ b/tests/ui/codegen/bitvec-to-bools-opt-miscompile.rs @@ -1,4 +1,6 @@ +//! Regression test for . //@ run-pass + #![allow(non_camel_case_types)] trait methods { //~ WARN trait `methods` is never used diff --git a/tests/ui/issues/issue-2989.stderr b/tests/ui/codegen/bitvec-to-bools-opt-miscompile.stderr similarity index 79% rename from tests/ui/issues/issue-2989.stderr rename to tests/ui/codegen/bitvec-to-bools-opt-miscompile.stderr index 500ace8f2753e..3eb03d3740fcd 100644 --- a/tests/ui/issues/issue-2989.stderr +++ b/tests/ui/codegen/bitvec-to-bools-opt-miscompile.stderr @@ -1,5 +1,5 @@ warning: trait `methods` is never used - --> $DIR/issue-2989.rs:4:7 + --> $DIR/bitvec-to-bools-opt-miscompile.rs:6:7 | LL | trait methods { | ^^^^^^^ diff --git a/tests/ui/issues/issue-30081.rs b/tests/ui/codegen/box-deref-segfault-misopt.rs similarity index 69% rename from tests/ui/issues/issue-30081.rs rename to tests/ui/codegen/box-deref-segfault-misopt.rs index 538e89f224697..f764db35e8c29 100644 --- a/tests/ui/issues/issue-30081.rs +++ b/tests/ui/codegen/box-deref-segfault-misopt.rs @@ -1,5 +1,6 @@ +//! Regression test for . +//! Misoptimization caused this to segfault. //@ run-pass -// This used to segfault #30081 pub enum Instruction { Increment(i8), diff --git a/tests/ui/issues/issue-43923.rs b/tests/ui/coercion/generic-fn-items-in-array-literal.rs similarity index 74% rename from tests/ui/issues/issue-43923.rs rename to tests/ui/coercion/generic-fn-items-in-array-literal.rs index 4cd46b6ca6025..cbc5d391ed1fe 100644 --- a/tests/ui/issues/issue-43923.rs +++ b/tests/ui/coercion/generic-fn-items-in-array-literal.rs @@ -1,3 +1,4 @@ +//! Regression test for //@ run-pass #![allow(dead_code)] #![allow(unused_variables)] diff --git a/tests/ui/consts/static-mut-refs.rs b/tests/ui/consts/static-mut-refs.rs index c0d0bb613325c..8eab90d0673e3 100644 --- a/tests/ui/consts/static-mut-refs.rs +++ b/tests/ui/consts/static-mut-refs.rs @@ -1,7 +1,7 @@ //@ run-pass #![allow(dead_code)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] // Checks that mutable static items can have mutable slices and other references diff --git a/tests/ui/coroutine/static-mut-reference-across-yield.rs b/tests/ui/coroutine/static-mut-reference-across-yield.rs index d45d6e6428b9c..b7a77e4b95b69 100644 --- a/tests/ui/coroutine/static-mut-reference-across-yield.rs +++ b/tests/ui/coroutine/static-mut-reference-across-yield.rs @@ -1,7 +1,7 @@ //@ build-pass #![feature(coroutines, stmt_expr_attributes)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut A: [i32; 5] = [1, 2, 3, 4, 5]; diff --git a/tests/ui/drop/conditional-drop-10734.rs b/tests/ui/drop/conditional-drop-10734.rs index 25f492bf9e087..3ac9239fe20fd 100644 --- a/tests/ui/drop/conditional-drop-10734.rs +++ b/tests/ui/drop/conditional-drop-10734.rs @@ -3,7 +3,7 @@ //@ run-pass #![allow(non_upper_case_globals)] -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut drop_count: usize = 0; diff --git a/tests/ui/drop/destructor-run-for-expression-4734.rs b/tests/ui/drop/destructor-run-for-expression-4734.rs index 57971ee5ef76e..15d676409738e 100644 --- a/tests/ui/drop/destructor-run-for-expression-4734.rs +++ b/tests/ui/drop/destructor-run-for-expression-4734.rs @@ -4,7 +4,7 @@ // Ensures that destructors are run for expressions of the form "e;" where // `e` is a type which requires a destructor. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #![allow(path_statements)] diff --git a/tests/ui/drop/destructor-run-for-let-ignore-6892.rs b/tests/ui/drop/destructor-run-for-let-ignore-6892.rs index 0fcf133c2b188..643eac466845a 100644 --- a/tests/ui/drop/destructor-run-for-let-ignore-6892.rs +++ b/tests/ui/drop/destructor-run-for-let-ignore-6892.rs @@ -4,7 +4,7 @@ // Ensures that destructors are run for expressions of the form "let _ = e;" // where `e` is a type which requires a destructor. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] struct Foo; diff --git a/tests/ui/drop/drop-count-assertion-16151.rs b/tests/ui/drop/drop-count-assertion-16151.rs index ede6bc23e733a..0e49708609ba7 100644 --- a/tests/ui/drop/drop-count-assertion-16151.rs +++ b/tests/ui/drop/drop-count-assertion-16151.rs @@ -1,7 +1,7 @@ // https://github.com/rust-lang/rust/issues/16151 //@ run-pass -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::mem; diff --git a/tests/ui/drop/drop-struct-as-object.rs b/tests/ui/drop/drop-struct-as-object.rs index 46633bd70751f..0f407e4fffb04 100644 --- a/tests/ui/drop/drop-struct-as-object.rs +++ b/tests/ui/drop/drop-struct-as-object.rs @@ -5,7 +5,7 @@ // Test that destructor on a struct runs successfully after the struct // is boxed and converted to an object. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut value: usize = 0; diff --git a/tests/ui/drop/generic-drop-trait-bound-15858.rs b/tests/ui/drop/generic-drop-trait-bound-15858.rs index 682604d17d864..237cef50ef55d 100644 --- a/tests/ui/drop/generic-drop-trait-bound-15858.rs +++ b/tests/ui/drop/generic-drop-trait-bound-15858.rs @@ -1,7 +1,7 @@ //! Regression test for https://github.com/rust-lang/rust/issues/15858 //@ run-pass -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut DROP_RAN: bool = false; diff --git a/tests/ui/drop/issue-23338-ensure-param-drop-order.rs b/tests/ui/drop/issue-23338-ensure-param-drop-order.rs index 54a9d3324b9e6..cdfc3ee889eae 100644 --- a/tests/ui/drop/issue-23338-ensure-param-drop-order.rs +++ b/tests/ui/drop/issue-23338-ensure-param-drop-order.rs @@ -1,6 +1,6 @@ //@ run-pass #![allow(non_upper_case_globals)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] // This test is ensuring that parameters are indeed dropped after diff --git a/tests/ui/drop/issue-23611-enum-swap-in-drop.rs b/tests/ui/drop/issue-23611-enum-swap-in-drop.rs index 208c6e2ada3d0..253c3c3c7f98a 100644 --- a/tests/ui/drop/issue-23611-enum-swap-in-drop.rs +++ b/tests/ui/drop/issue-23611-enum-swap-in-drop.rs @@ -1,6 +1,6 @@ //@ run-pass #![allow(non_upper_case_globals)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] // Issue 23611: this test is ensuring that, for an instance `X` of the diff --git a/tests/ui/drop/issue-48962.rs b/tests/ui/drop/issue-48962.rs index 98d3af49ac1ec..5ecc54c5a27b1 100644 --- a/tests/ui/drop/issue-48962.rs +++ b/tests/ui/drop/issue-48962.rs @@ -1,7 +1,7 @@ //@ run-pass #![allow(unused_must_use)] // Test that we are able to reinitialize box with moved referent -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut ORDER: [usize; 3] = [0, 0, 0]; diff --git a/tests/ui/issues/issue-29948.rs b/tests/ui/drop/move-closure-drop-on-unwind.rs similarity index 82% rename from tests/ui/issues/issue-29948.rs rename to tests/ui/drop/move-closure-drop-on-unwind.rs index 77a3885da042a..ad110c1de01c8 100644 --- a/tests/ui/issues/issue-29948.rs +++ b/tests/ui/drop/move-closure-drop-on-unwind.rs @@ -1,3 +1,7 @@ +//! Regression test for . +//! Test `FnOnce` impl closure's value gets properly dropped +//! (during unwind as well). + //@ run-pass //@ needs-unwind //@ ignore-backends: gcc diff --git a/tests/ui/issues/issue-30018-panic.rs b/tests/ui/drop/panic-during-slice-init.rs similarity index 50% rename from tests/ui/issues/issue-30018-panic.rs rename to tests/ui/drop/panic-during-slice-init.rs index 09b832bb59d02..ddf1e01dd8e7a 100644 --- a/tests/ui/issues/issue-30018-panic.rs +++ b/tests/ui/drop/panic-during-slice-init.rs @@ -1,9 +1,9 @@ -//@ run-pass -// Regression test for Issue #30018. This is very similar to the -// original reported test, except that the panic is wrapped in a -// spawned thread to isolate the expected error result from the -// SIGTRAP injected by the drop-flag consistency checking. +//! Regression test for . +//! This is very similar to the original reported test, except that the +//! panic is wrapped in a spawned thread to isolate the expected error +//! result from the SIGTRAP injected by the drop-flag consistency checking. +//@ run-pass //@ needs-unwind //@ needs-threads //@ ignore-backends: gcc diff --git a/tests/ui/drop/repeat-drop.rs b/tests/ui/drop/repeat-drop.rs index 7488d9113b0af..1b10e6e553b80 100644 --- a/tests/ui/drop/repeat-drop.rs +++ b/tests/ui/drop/repeat-drop.rs @@ -3,7 +3,7 @@ #![allow(dropping_references, dropping_copy_types)] -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut CHECK: usize = 0; diff --git a/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs b/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs index ecc862ec7be6b..449a4728963d9 100644 --- a/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs +++ b/tests/ui/drop/same-alloca-reassigned-match-binding-16151.rs @@ -2,7 +2,7 @@ //@ run-pass -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::mem; diff --git a/tests/ui/drop/static-issue-17302.rs b/tests/ui/drop/static-issue-17302.rs index 060f5564efdae..ef13da6ec6547 100644 --- a/tests/ui/drop/static-issue-17302.rs +++ b/tests/ui/drop/static-issue-17302.rs @@ -1,6 +1,6 @@ //@ run-pass -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut DROPPED: [bool; 2] = [false, false]; diff --git a/tests/ui/issues/issue-33241.rs b/tests/ui/dst/tuple-with-unsized-tail-field.rs similarity index 78% rename from tests/ui/issues/issue-33241.rs rename to tests/ui/dst/tuple-with-unsized-tail-field.rs index 1c497876a90da..db81106f0422b 100644 --- a/tests/ui/issues/issue-33241.rs +++ b/tests/ui/dst/tuple-with-unsized-tail-field.rs @@ -1,3 +1,4 @@ +//! Regression test for //@ check-pass use std::fmt; diff --git a/tests/ui/issues/issue-35988.rs b/tests/ui/enum/unsized-field-in-enum-variant.rs similarity index 53% rename from tests/ui/issues/issue-35988.rs rename to tests/ui/enum/unsized-field-in-enum-variant.rs index 5cf2f8e5212d1..a2640e1ba5b13 100644 --- a/tests/ui/issues/issue-35988.rs +++ b/tests/ui/enum/unsized-field-in-enum-variant.rs @@ -1,3 +1,4 @@ +//! Regression test for enum E { V([Box]), //~^ ERROR the size for values of type diff --git a/tests/ui/issues/issue-35988.stderr b/tests/ui/enum/unsized-field-in-enum-variant.stderr similarity index 93% rename from tests/ui/issues/issue-35988.stderr rename to tests/ui/enum/unsized-field-in-enum-variant.stderr index 4a674b010ea62..7ea40614da22d 100644 --- a/tests/ui/issues/issue-35988.stderr +++ b/tests/ui/enum/unsized-field-in-enum-variant.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[Box]` cannot be known at compilation time - --> $DIR/issue-35988.rs:2:7 + --> $DIR/unsized-field-in-enum-variant.rs:3:7 | LL | V([Box]), | ^^^^^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/issues/issue-44023.rs b/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.rs similarity index 64% rename from tests/ui/issues/issue-44023.rs rename to tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.rs index e4320b7dac592..4b1843bb5fb0f 100644 --- a/tests/ui/issues/issue-44023.rs +++ b/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.rs @@ -1,3 +1,4 @@ +//! Regression test for pub fn main () {} fn αƒ‘αƒαƒ­αƒ›αƒ”αƒšαƒαƒ“_αƒ’αƒ”αƒ›αƒ αƒ˜αƒ”αƒšαƒ˜_αƒ‘αƒαƒ“αƒ˜αƒšαƒ˜ ( ) -> isize { //~ ERROR mismatched types diff --git a/tests/ui/issues/issue-44023.stderr b/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.stderr similarity index 87% rename from tests/ui/issues/issue-44023.stderr rename to tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.stderr index 8554154fba515..9ced2d882b8f6 100644 --- a/tests/ui/issues/issue-44023.stderr +++ b/tests/ui/error-emitter/multibyte-char-in-diagnostic-source-line.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-44023.rs:3:36 + --> $DIR/multibyte-char-in-diagnostic-source-line.rs:4:36 | LL | fn αƒ‘αƒαƒ­αƒ›αƒ”αƒšαƒαƒ“_αƒ’αƒ”αƒ›αƒ αƒ˜αƒ”αƒšαƒ˜_αƒ‘αƒαƒ“αƒ˜αƒšαƒ˜ ( ) -> isize { | ------------------------ ^^^^^ expected `isize`, found `()` diff --git a/tests/ui/feature-gates/auxiliary/unstable-crate-import-gated-in-2018-edition.rs b/tests/ui/feature-gates/auxiliary/unstable-crate-import-gated-in-2018-edition.rs new file mode 100644 index 0000000000000..f725a948d6aec --- /dev/null +++ b/tests/ui/feature-gates/auxiliary/unstable-crate-import-gated-in-2018-edition.rs @@ -0,0 +1,4 @@ +//! Auxiliary crate for regression test of +#![crate_type = "lib"] +#![unstable(feature = "unstable_crate_import_gated_in_2018_edition", issue = "none")] +#![feature(staged_api)] diff --git a/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.rs b/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.rs new file mode 100644 index 0000000000000..9e2036357ff63 --- /dev/null +++ b/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.rs @@ -0,0 +1,9 @@ +//! Regression test for +//@ edition:2018 +//@ aux-build:unstable-crate-import-gated-in-2018-edition.rs +//@ compile-flags: --extern unstable_crate_import_gated_in_2018_edition + +use unstable_crate_import_gated_in_2018_edition; +//~^ ERROR use of unstable library feature `unstable_crate_import_gated_in_2018_edition` + +fn main() {} diff --git a/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.stderr b/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.stderr new file mode 100644 index 0000000000000..d9ef6c01ca0ab --- /dev/null +++ b/tests/ui/feature-gates/unstable-crate-import-gated-in-2018-edition.stderr @@ -0,0 +1,12 @@ +error[E0658]: use of unstable library feature `unstable_crate_import_gated_in_2018_edition` + --> $DIR/unstable-crate-import-gated-in-2018-edition.rs:6:5 + | +LL | use unstable_crate_import_gated_in_2018_edition; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(unstable_crate_import_gated_in_2018_edition)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/issues/issue-3556.rs b/tests/ui/fmt/format-enum-with-recursive-variant.rs similarity index 93% rename from tests/ui/issues/issue-3556.rs rename to tests/ui/fmt/format-enum-with-recursive-variant.rs index 72fd46e0a4a1c..9ea7c4d91a6c2 100644 --- a/tests/ui/issues/issue-3556.rs +++ b/tests/ui/fmt/format-enum-with-recursive-variant.rs @@ -1,3 +1,4 @@ +//! Regression test for //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/issues/issue-43431.rs b/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.rs similarity index 82% rename from tests/ui/issues/issue-43431.rs rename to tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.rs index 0286336910e10..8ccf231215689 100644 --- a/tests/ui/issues/issue-43431.rs +++ b/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.rs @@ -1,3 +1,4 @@ +//! Regression test for #![feature(fn_traits)] trait CallSingle { diff --git a/tests/ui/issues/issue-43431.stderr b/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.stderr similarity index 86% rename from tests/ui/issues/issue-43431.stderr rename to tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.stderr index 27a720408e4b7..33dbbfd7ac077 100644 --- a/tests/ui/issues/issue-43431.stderr +++ b/tests/ui/fn_traits/fn-trait-ufcs-call-in-impl.stderr @@ -1,5 +1,5 @@ error[E0229]: associated item constraints are not allowed here - --> $DIR/issue-43431.rs:9:27 + --> $DIR/fn-trait-ufcs-call-in-impl.rs:10:27 | LL | B>::call(self, (a,)) | ^ associated item constraint not allowed here diff --git a/tests/ui/issues/issue-45510.rs b/tests/ui/fn_traits/overloaded-fnonce-resolution.rs similarity index 91% rename from tests/ui/issues/issue-45510.rs rename to tests/ui/fn_traits/overloaded-fnonce-resolution.rs index d73218a385924..0f7a8649fd627 100644 --- a/tests/ui/issues/issue-45510.rs +++ b/tests/ui/fn_traits/overloaded-fnonce-resolution.rs @@ -1,3 +1,4 @@ +//! Regression test for // Test overloaded resolution of fn_traits. //@ run-pass diff --git a/tests/ui/issues/issue-39687.rs b/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.rs similarity index 65% rename from tests/ui/issues/issue-39687.rs rename to tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.rs index 58f981b63d11d..479b23ac30542 100644 --- a/tests/ui/issues/issue-39687.rs +++ b/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.rs @@ -1,3 +1,4 @@ +//! Regression test for #![feature(fn_traits)] fn main() { diff --git a/tests/ui/issues/issue-39687.stderr b/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.stderr similarity index 82% rename from tests/ui/issues/issue-39687.stderr rename to tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.stderr index 87e5fdc2d8f22..b863561f02855 100644 --- a/tests/ui/issues/issue-39687.stderr +++ b/tests/ui/fn_traits/parenthesized-fn-trait-in-qualified-path.stderr @@ -1,5 +1,5 @@ error[E0229]: associated item constraints are not allowed here - --> $DIR/issue-39687.rs:4:14 + --> $DIR/parenthesized-fn-trait-in-qualified-path.rs:5:14 | LL | ::call; | ^^^^ associated item constraint not allowed here diff --git a/tests/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs b/tests/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs index 57e8b2286497c..ac6eb209a9211 100644 --- a/tests/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs +++ b/tests/ui/for-loop-while/cleanup-rvalue-during-if-and-while.rs @@ -2,7 +2,7 @@ // This test verifies that temporaries created for `while`'s and `if` // conditions are dropped after the condition is evaluated. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] struct Temporary; diff --git a/tests/ui/functional-struct-update/functional-struct-update-respects-privacy.rs b/tests/ui/functional-struct-update/functional-struct-update-respects-privacy.rs index a05d20ffbd280..e90cf3f9e4cc1 100644 --- a/tests/ui/functional-struct-update/functional-struct-update-respects-privacy.rs +++ b/tests/ui/functional-struct-update/functional-struct-update-respects-privacy.rs @@ -3,7 +3,7 @@ // The `foo` module attempts to maintains an invariant that each `S` // has a unique `u64` id. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use self::foo::S; diff --git a/tests/ui/issues/auxiliary/issue-52489.rs b/tests/ui/issues/auxiliary/issue-52489.rs deleted file mode 100644 index f53bf7db52536..0000000000000 --- a/tests/ui/issues/auxiliary/issue-52489.rs +++ /dev/null @@ -1,3 +0,0 @@ -#![crate_type = "lib"] -#![unstable(feature = "issue_52489_unstable", issue = "none")] -#![feature(staged_api)] diff --git a/tests/ui/issues/issue-29743.rs b/tests/ui/issues/issue-29743.rs deleted file mode 100644 index 8e522a7482190..0000000000000 --- a/tests/ui/issues/issue-29743.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ check-pass - -fn main() { - let mut i = [1, 2, 3]; - i[i[0]] = 0; - i[i[0] - 1] = 0; -} diff --git a/tests/ui/issues/issue-52489.rs b/tests/ui/issues/issue-52489.rs deleted file mode 100644 index c1e1cb41c76d6..0000000000000 --- a/tests/ui/issues/issue-52489.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ edition:2018 -//@ aux-build:issue-52489.rs -//@ compile-flags:--extern issue_52489 - -use issue_52489; -//~^ ERROR use of unstable library feature `issue_52489_unstable` - -fn main() {} diff --git a/tests/ui/issues/issue-52489.stderr b/tests/ui/issues/issue-52489.stderr deleted file mode 100644 index 8e5b87b7f0fd2..0000000000000 --- a/tests/ui/issues/issue-52489.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: use of unstable library feature `issue_52489_unstable` - --> $DIR/issue-52489.rs:5:5 - | -LL | use issue_52489; - | ^^^^^^^^^^^ - | - = help: add `#![feature(issue_52489_unstable)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/linkage-attr/link-section-placement.rs b/tests/ui/linkage-attr/link-section-placement.rs index 299ad31d82d0d..b1b88e911861f 100644 --- a/tests/ui/linkage-attr/link-section-placement.rs +++ b/tests/ui/linkage-attr/link-section-placement.rs @@ -3,7 +3,7 @@ //@ run-pass #![feature(cfg_target_object_format)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #![allow(non_upper_case_globals)] diff --git a/tests/ui/linkage-attr/linkage-attr-mutable-static.rs b/tests/ui/linkage-attr/linkage-attr-mutable-static.rs index cc93f61e28f37..09f7d65f97e4d 100644 --- a/tests/ui/linkage-attr/linkage-attr-mutable-static.rs +++ b/tests/ui/linkage-attr/linkage-attr-mutable-static.rs @@ -2,7 +2,7 @@ //! them at runtime, so deny mutable statics with #[linkage]. #![feature(linkage)] -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] fn main() { diff --git a/tests/ui/lto/lto-still-runs-thread-dtors.rs b/tests/ui/lto/lto-still-runs-thread-dtors.rs index 9a97677773cca..780e8eb844faf 100644 --- a/tests/ui/lto/lto-still-runs-thread-dtors.rs +++ b/tests/ui/lto/lto-still-runs-thread-dtors.rs @@ -4,7 +4,7 @@ //@ needs-threads //@ ignore-backends: gcc -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::thread; diff --git a/tests/ui/methods/method-self-arg-trait.rs b/tests/ui/methods/method-self-arg-trait.rs index ccffe02328bbf..7b945fc3c38a4 100644 --- a/tests/ui/methods/method-self-arg-trait.rs +++ b/tests/ui/methods/method-self-arg-trait.rs @@ -1,7 +1,7 @@ //@ run-pass // Test method calls with self as an argument -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut COUNT: u64 = 1; diff --git a/tests/ui/methods/method-self-arg.rs b/tests/ui/methods/method-self-arg.rs index 2e058ee1077c6..e54b47b3b645f 100644 --- a/tests/ui/methods/method-self-arg.rs +++ b/tests/ui/methods/method-self-arg.rs @@ -1,7 +1,7 @@ //@ run-pass // Test method calls with self as an argument -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut COUNT: usize = 1; diff --git a/tests/ui/mir/mir_early_return_scope.rs b/tests/ui/mir/mir_early_return_scope.rs index 42f1cc50d15da..7e550c3ef5dff 100644 --- a/tests/ui/mir/mir_early_return_scope.rs +++ b/tests/ui/mir/mir_early_return_scope.rs @@ -1,6 +1,6 @@ //@ run-pass #![allow(unused_variables)] -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut DROP: bool = false; diff --git a/tests/ui/nll/issue-69114-static-mut-ty.rs b/tests/ui/nll/issue-69114-static-mut-ty.rs index 95c787488c08e..dd5fe3c6ff26b 100644 --- a/tests/ui/nll/issue-69114-static-mut-ty.rs +++ b/tests/ui/nll/issue-69114-static-mut-ty.rs @@ -1,6 +1,6 @@ // Check that borrowck ensures that `static mut` items have the expected type. -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static FOO: u8 = 42; diff --git a/tests/ui/numbers-arithmetic/shift-near-oflo.rs b/tests/ui/numbers-arithmetic/shift-near-oflo.rs index 97227bd843f07..714ff6e86fd5a 100644 --- a/tests/ui/numbers-arithmetic/shift-near-oflo.rs +++ b/tests/ui/numbers-arithmetic/shift-near-oflo.rs @@ -1,7 +1,7 @@ //@ run-pass //@ compile-flags: -C debug-assertions -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] // Check that we do *not* overflow on a number of edge cases. diff --git a/tests/ui/issues/issue-37733.rs b/tests/ui/parser/accept-lifetime-list-empty-or-trailing-comma.rs similarity index 57% rename from tests/ui/issues/issue-37733.rs rename to tests/ui/parser/accept-lifetime-list-empty-or-trailing-comma.rs index fff42e9fc3c99..3bac134f39682 100644 --- a/tests/ui/issues/issue-37733.rs +++ b/tests/ui/parser/accept-lifetime-list-empty-or-trailing-comma.rs @@ -1,3 +1,4 @@ +//! Regression test for //@ build-pass #![allow(dead_code)] type A = for<> fn(); diff --git a/tests/ui/issues/issue-29668.rs b/tests/ui/privacy/fn-returns-unnameable-type.rs similarity index 61% rename from tests/ui/issues/issue-29668.rs rename to tests/ui/privacy/fn-returns-unnameable-type.rs index 76b9429329631..1e4474cfafefa 100644 --- a/tests/ui/issues/issue-29668.rs +++ b/tests/ui/privacy/fn-returns-unnameable-type.rs @@ -1,5 +1,6 @@ +//! Regression test for . +//! Test functions can return unnameable types. //@ run-pass -// Functions can return unnameable types mod m1 { mod m2 { diff --git a/tests/ui/issues/issue-3021-b.rs b/tests/ui/resolve/impl-method-cant-capture-env.rs similarity index 63% rename from tests/ui/issues/issue-3021-b.rs rename to tests/ui/resolve/impl-method-cant-capture-env.rs index f1630afe1730e..57ef5b83e2ccb 100644 --- a/tests/ui/issues/issue-3021-b.rs +++ b/tests/ui/resolve/impl-method-cant-capture-env.rs @@ -1,3 +1,6 @@ +//! Regression test for . +//! Ensure upvars from fn cannot be used in impl method block body. + fn siphash(k0 : u64) { struct SipHash { diff --git a/tests/ui/resolve/issue-3021.stderr b/tests/ui/resolve/impl-method-cant-capture-env.stderr similarity index 86% rename from tests/ui/resolve/issue-3021.stderr rename to tests/ui/resolve/impl-method-cant-capture-env.stderr index 5dc4f9542fee5..360598dee5827 100644 --- a/tests/ui/resolve/issue-3021.stderr +++ b/tests/ui/resolve/impl-method-cant-capture-env.stderr @@ -1,5 +1,5 @@ error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/issue-3021.rs:12:22 + --> $DIR/impl-method-cant-capture-env.rs:12:22 | LL | self.v0 = k0 ^ 0x736f6d6570736575; | ^^ diff --git a/tests/ui/resolve/issue-3021.rs b/tests/ui/resolve/impl-trait-for-type-cant-capture-env.rs similarity index 67% rename from tests/ui/resolve/issue-3021.rs rename to tests/ui/resolve/impl-trait-for-type-cant-capture-env.rs index a672261f8d681..29c4ca07c22f2 100644 --- a/tests/ui/resolve/issue-3021.rs +++ b/tests/ui/resolve/impl-trait-for-type-cant-capture-env.rs @@ -1,3 +1,6 @@ +//! Regression test for . +//! Test accessing upvars in impl trait for type method is forbidden. + trait SipHash { fn reset(&self); } diff --git a/tests/ui/issues/issue-3021-b.stderr b/tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr similarity index 84% rename from tests/ui/issues/issue-3021-b.stderr rename to tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr index 48777fec0a3ff..2c25f6b1b8954 100644 --- a/tests/ui/issues/issue-3021-b.stderr +++ b/tests/ui/resolve/impl-trait-for-type-cant-capture-env.stderr @@ -1,5 +1,5 @@ error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/issue-3021-b.rs:9:22 + --> $DIR/impl-trait-for-type-cant-capture-env.rs:15:22 | LL | self.v0 = k0 ^ 0x736f6d6570736575; | ^^ diff --git a/tests/ui/resolve/issue-3021-c.rs b/tests/ui/resolve/outer-generic-in-trait-method.rs similarity index 57% rename from tests/ui/resolve/issue-3021-c.rs rename to tests/ui/resolve/outer-generic-in-trait-method.rs index bd21d1244235d..a31062f480463 100644 --- a/tests/ui/resolve/issue-3021-c.rs +++ b/tests/ui/resolve/outer-generic-in-trait-method.rs @@ -1,3 +1,6 @@ +//! Regression test for . +//! Test we can't use outer generic param in trait method defined in fn body. + fn siphash() { trait U { diff --git a/tests/ui/resolve/issue-3021-c.stderr b/tests/ui/resolve/outer-generic-in-trait-method.stderr similarity index 92% rename from tests/ui/resolve/issue-3021-c.stderr rename to tests/ui/resolve/outer-generic-in-trait-method.stderr index d521d4f4a73ae..f85b9623a52f3 100644 --- a/tests/ui/resolve/issue-3021-c.stderr +++ b/tests/ui/resolve/outer-generic-in-trait-method.stderr @@ -1,5 +1,5 @@ error[E0401]: can't use generic parameters from outer item - --> $DIR/issue-3021-c.rs:4:24 + --> $DIR/outer-generic-in-trait-method.rs:7:24 | LL | fn siphash() { | - type parameter from outer item @@ -16,7 +16,7 @@ LL | trait U { | +++ error[E0401]: can't use generic parameters from outer item - --> $DIR/issue-3021-c.rs:4:30 + --> $DIR/outer-generic-in-trait-method.rs:7:30 | LL | fn siphash() { | - type parameter from outer item diff --git a/tests/ui/issues/issue-3021-d.rs b/tests/ui/resolve/trait-impl-cant-capture-env.rs similarity index 81% rename from tests/ui/issues/issue-3021-d.rs rename to tests/ui/resolve/trait-impl-cant-capture-env.rs index 1fb0002b2fc73..751e49f9863c9 100644 --- a/tests/ui/issues/issue-3021-d.rs +++ b/tests/ui/resolve/trait-impl-cant-capture-env.rs @@ -1,3 +1,6 @@ +//! Regression test for . +//! Ensure upvars from fn cannot be used in impl method block body. + trait SipHash { fn result(&self) -> u64; fn reset(&self); diff --git a/tests/ui/issues/issue-3021-d.stderr b/tests/ui/resolve/trait-impl-cant-capture-env.stderr similarity index 84% rename from tests/ui/issues/issue-3021-d.stderr rename to tests/ui/resolve/trait-impl-cant-capture-env.stderr index 39e6e8c43e944..3c80960a235cb 100644 --- a/tests/ui/issues/issue-3021-d.stderr +++ b/tests/ui/resolve/trait-impl-cant-capture-env.stderr @@ -1,5 +1,5 @@ error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/issue-3021-d.rs:21:23 + --> $DIR/trait-impl-cant-capture-env.rs:24:23 | LL | self.v0 = k0 ^ 0x736f6d6570736575; | ^^ @@ -7,7 +7,7 @@ LL | self.v0 = k0 ^ 0x736f6d6570736575; = help: use the `|| { ... }` closure form instead error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/issue-3021-d.rs:22:23 + --> $DIR/trait-impl-cant-capture-env.rs:25:23 | LL | self.v1 = k1 ^ 0x646f72616e646f6d; | ^^ diff --git a/tests/ui/self/where-for-self.rs b/tests/ui/self/where-for-self.rs index d31bb1f22c4ce..d874cbd5bcdde 100644 --- a/tests/ui/self/where-for-self.rs +++ b/tests/ui/self/where-for-self.rs @@ -2,7 +2,7 @@ // Test that we can quantify lifetimes outside a constraint (i.e., including // the self type) in a where clause. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] static mut COUNT: u32 = 1; diff --git a/tests/ui/stats/input-stats.stderr b/tests/ui/stats/input-stats.stderr index b4d8277a46c00..f4c6808431687 100644 --- a/tests/ui/stats/input-stats.stderr +++ b/tests/ui/stats/input-stats.stderr @@ -27,7 +27,7 @@ ast-stats Pat 560 (NN.N%) 7 80 ast-stats - Struct 80 (NN.N%) 1 ast-stats - Wild 80 (NN.N%) 1 ast-stats - Ident 400 (NN.N%) 5 -ast-stats GenericParam 480 (NN.N%) 5 96 +ast-stats GenericParam 400 (NN.N%) 5 80 ast-stats GenericBound 352 (NN.N%) 4 88 ast-stats - Trait 352 (NN.N%) 4 ast-stats AssocItem 320 (NN.N%) 4 80 @@ -50,14 +50,14 @@ ast-stats Local 96 (NN.N%) 1 96 ast-stats Arm 96 (NN.N%) 2 48 ast-stats ForeignItem 80 (NN.N%) 1 80 ast-stats - Fn 80 (NN.N%) 1 -ast-stats WherePredicate 72 (NN.N%) 1 72 -ast-stats - BoundPredicate 72 (NN.N%) 1 +ast-stats WherePredicate 56 (NN.N%) 1 56 +ast-stats - BoundPredicate 56 (NN.N%) 1 ast-stats ExprField 48 (NN.N%) 1 48 ast-stats GenericArgs 40 (NN.N%) 1 40 ast-stats - AngleBracketed 40 (NN.N%) 1 ast-stats Crate 40 (NN.N%) 1 40 ast-stats ---------------------------------------------------------------- -ast-stats Total 7_624 127 +ast-stats Total 7_528 127 ast-stats ================================================================ hir-stats ================================================================ hir-stats HIR STATS: input_stats diff --git a/tests/ui/thread-local/thread-local-issue-37508.rs b/tests/ui/thread-local/thread-local-issue-37508.rs index 34c3945345184..ef7670af3d384 100644 --- a/tests/ui/thread-local/thread-local-issue-37508.rs +++ b/tests/ui/thread-local/thread-local-issue-37508.rs @@ -4,7 +4,7 @@ // // Regression test for issue #37508 -// FIXME(static_mut_refs): Do not allow `static_mut_refs` lint +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] #![no_main] diff --git a/tests/ui/traits/impl.rs b/tests/ui/traits/impl.rs index b45935fd86a41..8858db8fad26e 100644 --- a/tests/ui/traits/impl.rs +++ b/tests/ui/traits/impl.rs @@ -3,7 +3,7 @@ //@ aux-build:traitimpl.rs -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] extern crate traitimpl; diff --git a/tests/ui/union/union-drop-assign.rs b/tests/ui/union/union-drop-assign.rs index 451fb14eddf93..710a6f6205e01 100644 --- a/tests/ui/union/union-drop-assign.rs +++ b/tests/ui/union/union-drop-assign.rs @@ -3,7 +3,7 @@ // Drop works for union itself. -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] use std::mem::ManuallyDrop; diff --git a/tests/ui/union/union-drop.rs b/tests/ui/union/union-drop.rs index 6f6d5c1416534..9a2911599dfe2 100644 --- a/tests/ui/union/union-drop.rs +++ b/tests/ui/union/union-drop.rs @@ -2,7 +2,7 @@ #![allow(dead_code)] #![allow(unused_variables)] -// FIXME(static_mut_refs): this could use an atomic +// FIXME(static_mut_refs): use raw pointers instead of references #![allow(static_mut_refs)] // Drop works for union itself.