Skip to content

Rollup of 6 pull requests #141995

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions compiler/rustc_ast/src/tokenstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ impl TokenTree {
match (self, other) {
(TokenTree::Token(token, _), TokenTree::Token(token2, _)) => token.kind == token2.kind,
(TokenTree::Delimited(.., delim, tts), TokenTree::Delimited(.., delim2, tts2)) => {
delim == delim2 && tts.eq_unspanned(tts2)
delim == delim2
&& tts.len() == tts2.len()
&& tts.iter().zip(tts2.iter()).all(|(a, b)| a.eq_unspanned(b))
}
_ => false,
}
Expand Down Expand Up @@ -694,18 +696,6 @@ impl TokenStream {
TokenStreamIter::new(self)
}

/// Compares two `TokenStream`s, checking equality without regarding span information.
pub fn eq_unspanned(&self, other: &TokenStream) -> bool {
let mut iter1 = self.iter();
let mut iter2 = other.iter();
for (tt1, tt2) in iter::zip(&mut iter1, &mut iter2) {
if !tt1.eq_unspanned(tt2) {
return false;
}
}
iter1.next().is_none() && iter2.next().is_none()
}

/// Create a token stream containing a single token with alone spacing. The
/// spacing used for the final token in a constructed stream doesn't matter
/// because it's never used. In practice we arbitrarily use
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ pub(crate) fn to_llvm_features<'a>(sess: &Session, s: &'a str) -> Option<LLVMFea
}
// Filter out features that are not supported by the current LLVM version
("riscv32" | "riscv64", "zacas") if get_version().0 < 20 => None,
(
"s390x",
"message-security-assist-extension12"
| "concurrent-functions"
| "miscellaneous-extensions-4"
| "vector-enhancements-3"
| "vector-packed-decimal-enhancement-3",
) if get_version().0 < 20 => None,
// Enable the evex512 target feature if an avx512 target feature is enabled.
("x86", s) if s.starts_with("avx512") => Some(LLVMFeature::with_dependencies(
s,
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_parse/src/parser/tokenstream/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ fn sp(a: u32, b: u32) -> Span {
Span::with_root_ctxt(BytePos(a), BytePos(b))
}

fn cmp_token_stream(a: &TokenStream, b: &TokenStream) -> bool {
a.len() == b.len() && a.iter().zip(b.iter()).all(|(x, y)| x.eq_unspanned(y))
}

#[test]
fn test_concat() {
create_default_session_globals_then(|| {
Expand All @@ -25,7 +29,7 @@ fn test_concat() {
eq_res.push_stream(test_snd);
assert_eq!(test_res.iter().count(), 5);
assert_eq!(eq_res.iter().count(), 5);
assert_eq!(test_res.eq_unspanned(&eq_res), true);
assert_eq!(cmp_token_stream(&test_res, &eq_res), true);
})
}

Expand Down Expand Up @@ -104,7 +108,7 @@ fn test_dotdotdot() {
stream.push_tree(TokenTree::token_joint(token::Dot, sp(0, 1)));
stream.push_tree(TokenTree::token_joint(token::Dot, sp(1, 2)));
stream.push_tree(TokenTree::token_alone(token::Dot, sp(2, 3)));
assert!(stream.eq_unspanned(&string_to_ts("...")));
assert!(cmp_token_stream(&stream, &string_to_ts("...")));
assert_eq!(stream.iter().count(), 1);
})
}
26 changes: 16 additions & 10 deletions compiler/rustc_target/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,29 +710,35 @@ static LOONGARCH_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-end
];

#[rustfmt::skip]
const IBMZ_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
// tidy-alphabetical-start
("backchain", Unstable(sym::s390x_target_feature), &[]),
("concurrent-functions", Unstable(sym::s390x_target_feature), &[]),
("deflate-conversion", Unstable(sym::s390x_target_feature), &[]),
("enhanced-sort", Unstable(sym::s390x_target_feature), &[]),
("guarded-storage", Unstable(sym::s390x_target_feature), &[]),
("high-word", Unstable(sym::s390x_target_feature), &[]),
// LLVM does not define message-security-assist-extension versions 1, 2, 6, 10 and 11.
("message-security-assist-extension12", Unstable(sym::s390x_target_feature), &[]),
("message-security-assist-extension3", Unstable(sym::s390x_target_feature), &[]),
("message-security-assist-extension4", Unstable(sym::s390x_target_feature), &[]),
("message-security-assist-extension5", Unstable(sym::s390x_target_feature), &[]),
("message-security-assist-extension8", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3"]),
("message-security-assist-extension9", Unstable(sym::s390x_target_feature), &["message-security-assist-extension3", "message-security-assist-extension4"]),
("miscellaneous-extensions-2", Unstable(sym::s390x_target_feature), &[]),
("miscellaneous-extensions-3", Unstable(sym::s390x_target_feature), &[]),
("miscellaneous-extensions-4", Unstable(sym::s390x_target_feature), &[]),
("nnp-assist", Unstable(sym::s390x_target_feature), &["vector"]),
("transactional-execution", Unstable(sym::s390x_target_feature), &[]),
("vector", Unstable(sym::s390x_target_feature), &[]),
("vector-enhancements-1", Unstable(sym::s390x_target_feature), &["vector"]),
("vector-enhancements-2", Unstable(sym::s390x_target_feature), &["vector-enhancements-1"]),
("vector-enhancements-3", Unstable(sym::s390x_target_feature), &["vector-enhancements-2"]),
("vector-packed-decimal", Unstable(sym::s390x_target_feature), &["vector"]),
(
"vector-packed-decimal-enhancement",
Unstable(sym::s390x_target_feature),
&["vector-packed-decimal"],
),
(
"vector-packed-decimal-enhancement-2",
Unstable(sym::s390x_target_feature),
&["vector-packed-decimal-enhancement"],
),
("vector-packed-decimal-enhancement", Unstable(sym::s390x_target_feature), &["vector-packed-decimal"]),
("vector-packed-decimal-enhancement-2", Unstable(sym::s390x_target_feature), &["vector-packed-decimal-enhancement"]),
("vector-packed-decimal-enhancement-3", Unstable(sym::s390x_target_feature), &["vector-packed-decimal-enhancement-2"]),
// tidy-alphabetical-end
];

Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1416,18 +1416,18 @@ impl<K, V, A: Allocator + Clone> BTreeMap<K, V, A> {
///
/// # Examples
///
/// Splitting a map into even and odd keys, reusing the original map:
///
/// ```
/// #![feature(btree_extract_if)]
/// use std::collections::BTreeMap;
///
/// // Splitting a map into even and odd keys, reusing the original map:
/// let mut map: BTreeMap<i32, i32> = (0..8).map(|x| (x, x)).collect();
/// let evens: BTreeMap<_, _> = map.extract_if(.., |k, _v| k % 2 == 0).collect();
/// let odds = map;
/// assert_eq!(evens.keys().copied().collect::<Vec<_>>(), [0, 2, 4, 6]);
/// assert_eq!(odds.keys().copied().collect::<Vec<_>>(), [1, 3, 5, 7]);
///
/// // Splitting a map into low and high halves, reusing the original map:
/// let mut map: BTreeMap<i32, i32> = (0..8).map(|x| (x, x)).collect();
/// let low: BTreeMap<_, _> = map.extract_if(0..4, |_k, _v| true).collect();
/// let high = map;
Expand Down
10 changes: 5 additions & 5 deletions library/alloc/src/collections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1201,21 +1201,21 @@ impl<T, A: Allocator + Clone> BTreeSet<T, A> {
/// [`retain`]: BTreeSet::retain
/// # Examples
///
/// Splitting a set into even and odd values, reusing the original set:
///
/// ```
/// #![feature(btree_extract_if)]
/// use std::collections::BTreeSet;
///
/// // Splitting a set into even and odd values, reusing the original set:
/// let mut set: BTreeSet<i32> = (0..8).collect();
/// let evens: BTreeSet<_> = set.extract_if(.., |v| v % 2 == 0).collect();
/// let odds = set;
/// assert_eq!(evens.into_iter().collect::<Vec<_>>(), vec![0, 2, 4, 6]);
/// assert_eq!(odds.into_iter().collect::<Vec<_>>(), vec![1, 3, 5, 7]);
///
/// let mut map: BTreeSet<i32> = (0..8).collect();
/// let low: BTreeSet<_> = map.extract_if(0..4, |_v| true).collect();
/// let high = map;
/// // Splitting a set into low and high halves, reusing the original set:
/// let mut set: BTreeSet<i32> = (0..8).collect();
/// let low: BTreeSet<_> = set.extract_if(0..4, |_v| true).collect();
/// let high = set;
/// assert_eq!(low.into_iter().collect::<Vec<_>>(), [0, 1, 2, 3]);
/// assert_eq!(high.into_iter().collect::<Vec<_>>(), [4, 5, 6, 7]);
/// ```
Expand Down
1 change: 0 additions & 1 deletion library/core/src/convert/num.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ impl_from!(u8 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")
impl_from!(u8 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u8 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u8 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u16 => f16, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u16 => f32, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u16 => f64, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
impl_from!(u16 => f128, #[stable(feature = "lossless_float_conv", since = "1.6.0")]);
Expand Down
4 changes: 3 additions & 1 deletion src/tools/clippy/clippy_utils/src/ast_utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -960,5 +960,7 @@ pub fn eq_attr_args(l: &AttrArgs, r: &AttrArgs) -> bool {
}

pub fn eq_delim_args(l: &DelimArgs, r: &DelimArgs) -> bool {
l.delim == r.delim && l.tokens.eq_unspanned(&r.tokens)
l.delim == r.delim
&& l.tokens.len() == r.tokens.len()
&& l.tokens.iter().zip(r.tokens.iter()).all(|(a, b)| a.eq_unspanned(b))
}
12 changes: 12 additions & 0 deletions tests/ui/check-cfg/target_feature.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`c`
`cache`
`cmpxchg16b`
`concurrent-functions`
`crc`
`crt-static`
`cssc`
Expand Down Expand Up @@ -159,6 +160,15 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`lzcnt`
`m`
`mclass`
`message-security-assist-extension12`
`message-security-assist-extension3`
`message-security-assist-extension4`
`message-security-assist-extension5`
`message-security-assist-extension8`
`message-security-assist-extension9`
`miscellaneous-extensions-2`
`miscellaneous-extensions-3`
`miscellaneous-extensions-4`
`mops`
`movbe`
`movrs`
Expand Down Expand Up @@ -287,9 +297,11 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
`vector`
`vector-enhancements-1`
`vector-enhancements-2`
`vector-enhancements-3`
`vector-packed-decimal`
`vector-packed-decimal-enhancement`
`vector-packed-decimal-enhancement-2`
`vector-packed-decimal-enhancement-3`
`vfp2`
`vfp3`
`vfp4`
Expand Down
1 change: 1 addition & 0 deletions tests/ui/issues/issue-10806.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition: 2015
//@ run-pass
#![allow(unused_imports)]

Expand Down
1 change: 1 addition & 0 deletions tests/ui/issues/issue-12729.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition: 2015
//@ check-pass
#![allow(dead_code)]

Expand Down
1 change: 1 addition & 0 deletions tests/ui/issues/issue-13105.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition: 2015
//@ check-pass

trait Foo {
Expand Down
1 change: 1 addition & 0 deletions tests/ui/issues/issue-13775.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition: 2015
//@ check-pass

trait Foo {
Expand Down
1 change: 1 addition & 0 deletions tests/ui/issues/issue-15774.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition: 2015
//@ run-pass

#![deny(warnings)]
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-20427.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ mod reuse {

pub fn check<u16>() {
assert_eq!(size_of::<u8>(), 8);
assert_eq!(size_of::<::u64>(), 0);
assert_eq!(size_of::<crate::u64>(), 0);
assert_eq!(size_of::<i16>(), 3 * size_of::<*const ()>());
assert_eq!(size_of::<u16>(), 0);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-28983.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ impl Test for u32 {

pub mod export {
#[no_mangle]
pub extern "C" fn issue_28983(t: <u32 as ::Test>::T) -> i32 { t*3 }
pub extern "C" fn issue_28983(t: <u32 as crate::Test>::T) -> i32 { t*3 }
}

// to test both exporting and importing functions, import
Expand Down
6 changes: 3 additions & 3 deletions tests/ui/issues/issue-31776.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct S;

mod m {
fn f() {
impl ::S {
impl crate::S {
pub fn s(&self) {}
}
}
Expand All @@ -24,7 +24,7 @@ pub struct S1;
fn f() {
pub struct Z;

impl ::Tr for ::S1 {
impl crate::Tr for crate::S1 {
type A = Z; // Private-in-public error unless `struct Z` is pub
}
}
Expand All @@ -43,7 +43,7 @@ mod m1 {
pub field: u8
}

impl ::Tr1 for ::S2 {
impl crate::Tr1 for crate::S2 {
type A = Z;
fn pull(&self) -> Self::A { Z{field: 10} }
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-32797.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod bar {

pub use baz::*;
mod baz {
pub use main as f;
pub use crate::main as f;
}

pub fn main() {}
1 change: 1 addition & 0 deletions tests/ui/issues/issue-34074.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition: 2015
//@ check-pass
// Make sure several unnamed function parameters don't conflict with each other

Expand Down
2 changes: 1 addition & 1 deletion tests/ui/issues/issue-41053.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ impl Iterator for Foo {
type Item = Box<dyn Trait>;
fn next(&mut self) -> Option<Box<dyn Trait>> {
extern crate issue_41053;
impl ::Trait for issue_41053::Test {
impl crate::Trait for issue_41053::Test {
fn foo(&self) {}
}
Some(Box::new(issue_41053::Test))
Expand Down
24 changes: 12 additions & 12 deletions tests/ui/issues/issue-47364.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ pub enum IResult<I,O> {
Incomplete(u32, u64)
}

pub fn multispace<T: Copy>(input: T) -> ::IResult<i8, i8> {
::IResult::Done(0, 0)
pub fn multispace<T: Copy>(input: T) -> crate::IResult<i8, i8> {
crate::IResult::Done(0, 0)
}

mod nom_sql {
fn where_clause(i: &[u8]) -> ::IResult<&[u8], Option<String>> {
let X = match ::multispace(i) {
::IResult::Done(..) => ::IResult::Done(i, None::<String>),
_ => ::IResult::Error(::Err::NodePosition(0)),
fn where_clause(i: &[u8]) -> crate::IResult<&[u8], Option<String>> {
let X = match crate::multispace(i) {
crate::IResult::Done(..) => crate::IResult::Done(i, None::<String>),
_ => crate::IResult::Error(crate::Err::NodePosition(0)),
};
match X {
::IResult::Done(_, _) => ::IResult::Done(i, None),
crate::IResult::Done(_, _) => crate::IResult::Done(i, None),
_ => X
}
}
Expand All @@ -39,16 +39,16 @@ mod nom_sql {
match {
where_clause(i)
} {
::IResult::Done(_, o) => ::IResult::Done(i, Some(o)),
::IResult::Error(_) => ::IResult::Done(i, None),
_ => ::IResult::Incomplete(0, 0),
crate::IResult::Done(_, o) => crate::IResult::Done(i, Some(o)),
crate::IResult::Error(_) => crate::IResult::Done(i, None),
_ => crate::IResult::Incomplete(0, 0),
}
} {
::IResult::Done(z, _) => ::IResult::Done(z, None::<String>),
crate::IResult::Done(z, _) => crate::IResult::Done(z, None::<String>),
_ => return ()
};
match Y {
::IResult::Done(x, _) => {
crate::IResult::Done(x, _) => {
let bytes = b"; ";
let len = x.len();
bytes[len];
Expand Down
14 changes: 7 additions & 7 deletions tests/ui/issues/issue-50187.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ mod macro_ns {
}

mod merge2 {
pub use type_ns::A;
pub use value_ns::A;
pub use crate::type_ns::A;
pub use crate::value_ns::A;
}
mod merge3 {
pub use type_ns::A;
pub use value_ns::A;
pub use macro_ns::A;
pub use crate::type_ns::A;
pub use crate::value_ns::A;
pub use crate::macro_ns::A;
}

mod use2 {
pub use merge2::A;
pub use crate::merge2::A;
}
mod use3 {
pub use merge3::A;
pub use crate::merge3::A;
}

fn main() {
Expand Down
1 change: 1 addition & 0 deletions tests/ui/issues/issue-50571.fixed
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition: 2015
//@ run-rustfix

#![allow(dead_code)]
Expand Down
1 change: 1 addition & 0 deletions tests/ui/issues/issue-50571.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ edition: 2015
//@ run-rustfix

#![allow(dead_code)]
Expand Down
Loading
Loading