Auto merge of #76159 - matklad:rollup-8jydjg3, r=matklad
Rollup of 5 pull requests Successful merges: - #75938 (Added some `min_const_generics` revisions into `const_generics` tests) - #76050 (Remove unused function) - #76075 (datastructures: replace `once_cell` crate with an impl from std) - #76115 (Restore public visibility on some parsing functions for rustfmt) - #76127 (rustbuild: Remove one LLD workaround) Failed merges: r? @ghost
This commit is contained in:
commit
1fd8636d24
122 changed files with 915 additions and 668 deletions
|
@ -3420,7 +3420,6 @@ dependencies = [
|
|||
"lazy_static",
|
||||
"libc",
|
||||
"measureme",
|
||||
"once_cell",
|
||||
"parking_lot 0.10.2",
|
||||
"rustc-hash",
|
||||
"rustc-rayon",
|
||||
|
|
|
@ -13,7 +13,6 @@ indexmap = "1.5.1"
|
|||
tracing = "0.1"
|
||||
jobserver_crate = { version = "0.1.13", package = "jobserver" }
|
||||
lazy_static = "1"
|
||||
once_cell = { version = "1", features = ["parking_lot"] }
|
||||
rustc_serialize = { path = "../rustc_serialize" }
|
||||
rustc_macros = { path = "../rustc_macros" }
|
||||
rustc_graphviz = { path = "../rustc_graphviz" }
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#![feature(extend_one)]
|
||||
#![feature(const_panic)]
|
||||
#![feature(const_generics)]
|
||||
#![feature(once_cell)]
|
||||
#![allow(rustc::default_hash_types)]
|
||||
|
||||
#[macro_use]
|
||||
|
|
|
@ -229,7 +229,7 @@ cfg_if! {
|
|||
pub use std::cell::RefMut as LockGuard;
|
||||
pub use std::cell::RefMut as MappedLockGuard;
|
||||
|
||||
pub use once_cell::unsync::OnceCell;
|
||||
pub use std::lazy::OnceCell;
|
||||
|
||||
use std::cell::RefCell as InnerRwLock;
|
||||
use std::cell::RefCell as InnerLock;
|
||||
|
@ -314,7 +314,7 @@ cfg_if! {
|
|||
pub use parking_lot::MutexGuard as LockGuard;
|
||||
pub use parking_lot::MappedMutexGuard as MappedLockGuard;
|
||||
|
||||
pub use once_cell::sync::OnceCell;
|
||||
pub use std::lazy::SyncOnceCell as OnceCell;
|
||||
|
||||
pub use std::sync::atomic::{AtomicBool, AtomicUsize, AtomicU32, AtomicU64};
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
|
||||
#![feature(nll)]
|
||||
#![feature(once_cell)]
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
#[macro_use]
|
||||
|
|
|
@ -39,11 +39,6 @@ mod tests;
|
|||
mod parse {
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
#[cfg(test)]
|
||||
mod lexer {
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod tokenstream {
|
||||
|
|
|
@ -1,252 +0,0 @@
|
|||
use rustc_ast::ast::AttrStyle;
|
||||
use rustc_ast::token::{self, CommentKind, Token, TokenKind};
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use rustc_errors::{emitter::EmitterWriter, Handler};
|
||||
use rustc_parse::lexer::StringReader;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::source_map::{FilePathMapping, SourceMap};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_span::with_default_session_globals;
|
||||
use rustc_span::{BytePos, Span};
|
||||
|
||||
use std::io;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn mk_sess(sm: Lrc<SourceMap>) -> ParseSess {
|
||||
let emitter = EmitterWriter::new(
|
||||
Box::new(io::sink()),
|
||||
Some(sm.clone()),
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
None,
|
||||
false,
|
||||
);
|
||||
ParseSess::with_span_handler(Handler::with_emitter(true, None, Box::new(emitter)), sm)
|
||||
}
|
||||
|
||||
// Creates a string reader for the given string.
|
||||
fn setup<'a>(sm: &SourceMap, sess: &'a ParseSess, teststr: String) -> StringReader<'a> {
|
||||
let sf = sm.new_source_file(PathBuf::from(teststr.clone()).into(), teststr);
|
||||
StringReader::new(sess, sf, None)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn t1() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
let mut string_reader = setup(
|
||||
&sm,
|
||||
&sh,
|
||||
"/* my source file */ fn main() { println!(\"zebra\"); }\n".to_string(),
|
||||
);
|
||||
assert_eq!(string_reader.next_token(), token::Comment);
|
||||
assert_eq!(string_reader.next_token(), token::Whitespace);
|
||||
let tok1 = string_reader.next_token();
|
||||
let tok2 = Token::new(mk_ident("fn"), Span::with_root_ctxt(BytePos(21), BytePos(23)));
|
||||
assert_eq!(tok1.kind, tok2.kind);
|
||||
assert_eq!(tok1.span, tok2.span);
|
||||
assert_eq!(string_reader.next_token(), token::Whitespace);
|
||||
// Read another token.
|
||||
let tok3 = string_reader.next_token();
|
||||
assert_eq!(string_reader.pos(), BytePos(28));
|
||||
let tok4 = Token::new(mk_ident("main"), Span::with_root_ctxt(BytePos(24), BytePos(28)));
|
||||
assert_eq!(tok3.kind, tok4.kind);
|
||||
assert_eq!(tok3.span, tok4.span);
|
||||
|
||||
assert_eq!(string_reader.next_token(), token::OpenDelim(token::Paren));
|
||||
assert_eq!(string_reader.pos(), BytePos(29))
|
||||
})
|
||||
}
|
||||
|
||||
// Checks that the given reader produces the desired stream
|
||||
// of tokens (stop checking after exhausting `expected`).
|
||||
fn check_tokenization(mut string_reader: StringReader<'_>, expected: Vec<TokenKind>) {
|
||||
for expected_tok in &expected {
|
||||
assert_eq!(&string_reader.next_token(), expected_tok);
|
||||
}
|
||||
}
|
||||
|
||||
// Makes the identifier by looking up the string in the interner.
|
||||
fn mk_ident(id: &str) -> TokenKind {
|
||||
token::Ident(Symbol::intern(id), false)
|
||||
}
|
||||
|
||||
fn mk_lit(kind: token::LitKind, symbol: &str, suffix: Option<&str>) -> TokenKind {
|
||||
TokenKind::lit(kind, Symbol::intern(symbol), suffix.map(Symbol::intern))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doublecolon_parsing() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
check_tokenization(
|
||||
setup(&sm, &sh, "a b".to_string()),
|
||||
vec![mk_ident("a"), token::Whitespace, mk_ident("b")],
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doublecolon_parsing_2() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
check_tokenization(
|
||||
setup(&sm, &sh, "a::b".to_string()),
|
||||
vec![mk_ident("a"), token::Colon, token::Colon, mk_ident("b")],
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doublecolon_parsing_3() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
check_tokenization(
|
||||
setup(&sm, &sh, "a ::b".to_string()),
|
||||
vec![mk_ident("a"), token::Whitespace, token::Colon, token::Colon, mk_ident("b")],
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn doublecolon_parsing_4() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
check_tokenization(
|
||||
setup(&sm, &sh, "a:: b".to_string()),
|
||||
vec![mk_ident("a"), token::Colon, token::Colon, token::Whitespace, mk_ident("b")],
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn character_a() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
assert_eq!(setup(&sm, &sh, "'a'".to_string()).next_token(), mk_lit(token::Char, "a", None),);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn character_space() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
assert_eq!(setup(&sm, &sh, "' '".to_string()).next_token(), mk_lit(token::Char, " ", None),);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn character_escaped() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
assert_eq!(
|
||||
setup(&sm, &sh, "'\\n'".to_string()).next_token(),
|
||||
mk_lit(token::Char, "\\n", None),
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lifetime_name() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
assert_eq!(
|
||||
setup(&sm, &sh, "'abc".to_string()).next_token(),
|
||||
token::Lifetime(Symbol::intern("'abc")),
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn raw_string() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
assert_eq!(
|
||||
setup(&sm, &sh, "r###\"\"#a\\b\x00c\"\"###".to_string()).next_token(),
|
||||
mk_lit(token::StrRaw(3), "\"#a\\b\x00c\"", None),
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn literal_suffixes() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
macro_rules! test {
|
||||
($input: expr, $tok_type: ident, $tok_contents: expr) => {{
|
||||
assert_eq!(
|
||||
setup(&sm, &sh, format!("{}suffix", $input)).next_token(),
|
||||
mk_lit(token::$tok_type, $tok_contents, Some("suffix")),
|
||||
);
|
||||
// with a whitespace separator
|
||||
assert_eq!(
|
||||
setup(&sm, &sh, format!("{} suffix", $input)).next_token(),
|
||||
mk_lit(token::$tok_type, $tok_contents, None),
|
||||
);
|
||||
}};
|
||||
}
|
||||
|
||||
test!("'a'", Char, "a");
|
||||
test!("b'a'", Byte, "a");
|
||||
test!("\"a\"", Str, "a");
|
||||
test!("b\"a\"", ByteStr, "a");
|
||||
test!("1234", Integer, "1234");
|
||||
test!("0b101", Integer, "0b101");
|
||||
test!("0xABC", Integer, "0xABC");
|
||||
test!("1.0", Float, "1.0");
|
||||
test!("1.0e10", Float, "1.0e10");
|
||||
|
||||
assert_eq!(
|
||||
setup(&sm, &sh, "2us".to_string()).next_token(),
|
||||
mk_lit(token::Integer, "2", Some("us")),
|
||||
);
|
||||
assert_eq!(
|
||||
setup(&sm, &sh, "r###\"raw\"###suffix".to_string()).next_token(),
|
||||
mk_lit(token::StrRaw(3), "raw", Some("suffix")),
|
||||
);
|
||||
assert_eq!(
|
||||
setup(&sm, &sh, "br###\"raw\"###suffix".to_string()).next_token(),
|
||||
mk_lit(token::ByteStrRaw(3), "raw", Some("suffix")),
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nested_block_comments() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
let mut lexer = setup(&sm, &sh, "/* /* */ */'a'".to_string());
|
||||
assert_eq!(lexer.next_token(), token::Comment);
|
||||
assert_eq!(lexer.next_token(), mk_lit(token::Char, "a", None));
|
||||
})
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn crlf_comments() {
|
||||
with_default_session_globals(|| {
|
||||
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
|
||||
let sh = mk_sess(sm.clone());
|
||||
let mut lexer = setup(&sm, &sh, "// test\r\n/// test\r\n".to_string());
|
||||
let comment = lexer.next_token();
|
||||
assert_eq!(comment.kind, token::Comment);
|
||||
assert_eq!((comment.span.lo(), comment.span.hi()), (BytePos(0), BytePos(7)));
|
||||
assert_eq!(lexer.next_token(), token::Whitespace);
|
||||
assert_eq!(
|
||||
lexer.next_token(),
|
||||
token::DocComment(CommentKind::Line, AttrStyle::Outer, Symbol::intern(" test"))
|
||||
);
|
||||
})
|
||||
}
|
|
@ -4,6 +4,7 @@
|
|||
#![feature(nll)]
|
||||
#![feature(generator_trait)]
|
||||
#![feature(generators)]
|
||||
#![feature(once_cell)]
|
||||
#![recursion_limit = "256"]
|
||||
|
||||
mod callbacks;
|
||||
|
|
|
@ -128,6 +128,34 @@ fn check_lexing(src: &str, expect: Expect) {
|
|||
expect.assert_eq(&actual)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn smoke_test() {
|
||||
check_lexing(
|
||||
"/* my source file */ fn main() { println!(\"zebra\"); }\n",
|
||||
expect![[r#"
|
||||
Token { kind: BlockComment { doc_style: None, terminated: true }, len: 20 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Ident, len: 2 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Ident, len: 4 }
|
||||
Token { kind: OpenParen, len: 1 }
|
||||
Token { kind: CloseParen, len: 1 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: OpenBrace, len: 1 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Ident, len: 7 }
|
||||
Token { kind: Bang, len: 1 }
|
||||
Token { kind: OpenParen, len: 1 }
|
||||
Token { kind: Literal { kind: Str { terminated: true }, suffix_start: 7 }, len: 7 }
|
||||
Token { kind: CloseParen, len: 1 }
|
||||
Token { kind: Semi, len: 1 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: CloseBrace, len: 1 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn comment_flavors() {
|
||||
check_lexing(
|
||||
|
@ -165,3 +193,95 @@ fn comment_flavors() {
|
|||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nested_block_comments() {
|
||||
check_lexing(
|
||||
"/* /* */ */'a'",
|
||||
expect![[r#"
|
||||
Token { kind: BlockComment { doc_style: None, terminated: true }, len: 11 }
|
||||
Token { kind: Literal { kind: Char { terminated: true }, suffix_start: 3 }, len: 3 }
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn characters() {
|
||||
check_lexing(
|
||||
"'a' ' ' '\\n'",
|
||||
expect![[r#"
|
||||
Token { kind: Literal { kind: Char { terminated: true }, suffix_start: 3 }, len: 3 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: Char { terminated: true }, suffix_start: 3 }, len: 3 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: Char { terminated: true }, suffix_start: 4 }, len: 4 }
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn lifetime() {
|
||||
check_lexing(
|
||||
"'abc",
|
||||
expect![[r#"
|
||||
Token { kind: Lifetime { starts_with_number: false }, len: 4 }
|
||||
"#]],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn raw_string() {
|
||||
check_lexing(
|
||||
"r###\"\"#a\\b\x00c\"\"###",
|
||||
expect![[r#"
|
||||
Token { kind: Literal { kind: RawStr { n_hashes: 3, err: None }, suffix_start: 17 }, len: 17 }
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn literal_suffixes() {
|
||||
check_lexing(
|
||||
r####"
|
||||
'a'
|
||||
b'a'
|
||||
"a"
|
||||
b"a"
|
||||
1234
|
||||
0b101
|
||||
0xABC
|
||||
1.0
|
||||
1.0e10
|
||||
2us
|
||||
r###"raw"###suffix
|
||||
br###"raw"###suffix
|
||||
"####,
|
||||
expect![[r#"
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: Char { terminated: true }, suffix_start: 3 }, len: 3 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: Byte { terminated: true }, suffix_start: 4 }, len: 4 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: Str { terminated: true }, suffix_start: 3 }, len: 3 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: ByteStr { terminated: true }, suffix_start: 4 }, len: 4 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: Int { base: Decimal, empty_int: false }, suffix_start: 4 }, len: 4 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: Int { base: Binary, empty_int: false }, suffix_start: 5 }, len: 5 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: Int { base: Hexadecimal, empty_int: false }, suffix_start: 5 }, len: 5 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: Float { base: Decimal, empty_exponent: false }, suffix_start: 3 }, len: 3 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: Float { base: Decimal, empty_exponent: false }, suffix_start: 6 }, len: 6 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: Int { base: Decimal, empty_int: false }, suffix_start: 1 }, len: 3 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: RawStr { n_hashes: 3, err: None }, suffix_start: 12 }, len: 18 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
Token { kind: Literal { kind: RawByteStr { n_hashes: 3, err: None }, suffix_start: 13 }, len: 19 }
|
||||
Token { kind: Whitespace, len: 1 }
|
||||
"#]],
|
||||
)
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#![feature(exhaustive_patterns)]
|
||||
#![feature(extern_types)]
|
||||
#![feature(nll)]
|
||||
#![feature(once_cell)]
|
||||
#![feature(option_expect_none)]
|
||||
#![feature(or_patterns)]
|
||||
#![feature(min_specialization)]
|
||||
|
|
|
@ -439,10 +439,6 @@ impl<'a> StringReader<'a> {
|
|||
(lit_kind, id)
|
||||
}
|
||||
|
||||
pub fn pos(&self) -> BytePos {
|
||||
self.pos
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn src_index(&self, pos: BytePos) -> usize {
|
||||
(pos - self.start_pos).to_usize()
|
||||
|
|
|
@ -1014,7 +1014,8 @@ impl<'a> Parser<'a> {
|
|||
/// If the following element can't be a tuple (i.e., it's a function definition), then
|
||||
/// it's not a tuple struct field), and the contents within the parentheses isn't valid,
|
||||
/// so emit a proper diagnostic.
|
||||
pub(crate) fn parse_visibility(&mut self, fbt: FollowedByType) -> PResult<'a, Visibility> {
|
||||
// Public for rustfmt usage.
|
||||
pub fn parse_visibility(&mut self, fbt: FollowedByType) -> PResult<'a, Visibility> {
|
||||
maybe_whole!(self, NtVis, |x| x);
|
||||
|
||||
self.expected_tokens.push(TokenType::Keyword(kw::Crate));
|
||||
|
|
|
@ -21,7 +21,8 @@ use std::mem;
|
|||
impl<'a> Parser<'a> {
|
||||
/// Parses a statement. This stops just before trailing semicolons on everything but items.
|
||||
/// e.g., a `StmtKind::Semi` parses to a `StmtKind::Expr`, leaving the trailing `;` unconsumed.
|
||||
pub(super) fn parse_stmt(&mut self) -> PResult<'a, Option<Stmt>> {
|
||||
// Public for rustfmt usage.
|
||||
pub fn parse_stmt(&mut self) -> PResult<'a, Option<Stmt>> {
|
||||
Ok(self.parse_stmt_without_recovery().unwrap_or_else(|mut e| {
|
||||
e.emit();
|
||||
self.recover_stmt_(SemiColonMode::Break, BlockMode::Ignore);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(once_cell)]
|
||||
#![feature(or_patterns)]
|
||||
|
||||
#[macro_use]
|
||||
|
|
|
@ -1041,15 +1041,11 @@ impl<'a> Builder<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
// FIXME: Don't use LLD with MSVC if we're compiling libtest, since it fails to link it.
|
||||
// See https://github.com/rust-lang/rust/issues/68647.
|
||||
let can_use_lld = mode != Mode::Std;
|
||||
|
||||
if let Some(host_linker) = self.linker(compiler.host, can_use_lld) {
|
||||
if let Some(host_linker) = self.linker(compiler.host, true) {
|
||||
cargo.env("RUSTC_HOST_LINKER", host_linker);
|
||||
}
|
||||
|
||||
if let Some(target_linker) = self.linker(target, can_use_lld) {
|
||||
if let Some(target_linker) = self.linker(target, true) {
|
||||
let target = crate::envify(&target.triple);
|
||||
cargo.env(&format!("CARGO_TARGET_{}_LINKER", target), target_linker);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/argument_order.rs:9:32
|
||||
--> $DIR/argument_order.rs:12:32
|
||||
|
|
||||
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then consts and types: `<'a, 'b, const N: usize, T, const M: usize, U>`
|
||||
|
||||
error[E0747]: lifetime provided when a type was expected
|
||||
--> $DIR/argument_order.rs:16:23
|
||||
--> $DIR/argument_order.rs:20:23
|
||||
|
|
||||
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
|
||||
| ^^^^^^^
|
30
src/test/ui/const-generics/argument_order.min.stderr
Normal file
30
src/test/ui/const-generics/argument_order.min.stderr
Normal file
|
@ -0,0 +1,30 @@
|
|||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/argument_order.rs:6:28
|
||||
|
|
||||
LL | struct Bad<const N: usize, T> {
|
||||
| -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>`
|
||||
|
||||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/argument_order.rs:12:32
|
||||
|
|
||||
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
| -----------------^^-----^^-------------------- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>`
|
||||
|
||||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/argument_order.rs:12:36
|
||||
|
|
||||
LL | struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
| ---------------------^----------------------^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, 'b, T, U, const N: usize, const M: usize>`
|
||||
|
||||
error[E0747]: lifetime provided when a type was expected
|
||||
--> $DIR/argument_order.rs:20:23
|
||||
|
|
||||
LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: lifetime arguments must be provided before type arguments
|
||||
= help: reorder the arguments: lifetimes, then types, then consts: `<'a, 'b, T, U, N, M>`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0747`.
|
|
@ -1,13 +1,17 @@
|
|||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct Bad<const N: usize, T> {
|
||||
//[min]~^ ERROR type parameters must be declared prior to const parameters
|
||||
arr: [u8; { N }],
|
||||
another: T,
|
||||
}
|
||||
|
||||
struct AlsoBad<const N: usize, 'a, T, 'b, const M: usize, U> {
|
||||
//~^ ERROR lifetime parameters must be declared prior
|
||||
//[min]~^^ ERROR type parameters must be declared prior to const parameters
|
||||
a: &'a T,
|
||||
b: &'b U,
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// run-pass
|
||||
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/array-wrapper-struct-ctor.rs:3:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// check-pass
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
// This test confirms that the types can be inferred correctly for this example with const
|
||||
// generics. Previously this would ICE, and more recently error.
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/cannot-infer-type-for-const-param.rs:2:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
error[E0747]: constant provided when a type was expected
|
||||
--> $DIR/const-arg-type-arg-misordered.rs:6:35
|
||||
--> $DIR/const-arg-type-arg-misordered.rs:8:35
|
||||
|
|
||||
LL | fn foo<const N: usize>() -> Array<N, ()> {
|
||||
| ^
|
|
@ -0,0 +1,12 @@
|
|||
error[E0747]: constant provided when a type was expected
|
||||
--> $DIR/const-arg-type-arg-misordered.rs:8:35
|
||||
|
|
||||
LL | fn foo<const N: usize>() -> Array<N, ()> {
|
||||
| ^
|
||||
|
|
||||
= note: type arguments must be provided before constant arguments
|
||||
= help: reorder the arguments: types, then consts: `<T, N>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0747`.
|
|
@ -1,9 +1,12 @@
|
|||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
type Array<T, const N: usize> = [T; N];
|
||||
|
||||
fn foo<const N: usize>() -> Array<N, ()> { //~ ERROR constant provided when a type was expected
|
||||
fn foo<const N: usize>() -> Array<N, ()> {
|
||||
//~^ ERROR constant provided when a type was expected
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/const-param-before-other-params.rs:4:21
|
||||
--> $DIR/const-param-before-other-params.rs:6:21
|
||||
|
|
||||
LL | fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
| --------------^^- help: reorder the parameters: lifetimes, then consts and types: `<'a, const X: ()>`
|
|
@ -0,0 +1,32 @@
|
|||
error: lifetime parameters must be declared prior to const parameters
|
||||
--> $DIR/const-param-before-other-params.rs:6:21
|
||||
|
|
||||
LL | fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
| --------------^^- help: reorder the parameters: lifetimes, then types, then consts: `<'a, const X: ()>`
|
||||
|
||||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/const-param-before-other-params.rs:11:21
|
||||
|
|
||||
LL | fn foo<const X: (), T>(_: &T) {}
|
||||
| --------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const X: ()>`
|
||||
|
||||
error: `()` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-before-other-params.rs:6:17
|
||||
|
|
||||
LL | fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
| ^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `()` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-param-before-other-params.rs:11:17
|
||||
|
|
||||
LL | fn foo<const X: (), T>(_: &T) {}
|
||||
| ^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
|
@ -1,10 +1,15 @@
|
|||
#![allow(incomplete_features)]
|
||||
#![feature(const_generics)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
fn bar<const X: (), 'a>(_: &'a ()) {
|
||||
//~^ ERROR lifetime parameters must be declared prior to const parameters
|
||||
//[min]~^^ ERROR `()` is forbidden as the type of a const generic parameter
|
||||
}
|
||||
|
||||
fn foo<const X: (), T>(_: &T) {}
|
||||
//[min]~^ ERROR type parameters must be declared prior to const parameters
|
||||
//[min]~^^ ERROR `()` is forbidden as the type of a const generic parameter
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
|
||||
--> $DIR/issue-63322-forbid-dyn.rs:10:18
|
||||
|
|
||||
LL | fn test<const T: &'static dyn A>() {
|
||||
| ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0741`.
|
|
@ -0,0 +1,18 @@
|
|||
error: `&'static (dyn A + 'static)` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-63322-forbid-dyn.rs:10:18
|
||||
|
|
||||
LL | fn test<const T: &'static dyn A>() {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
|
||||
--> $DIR/issue-63322-forbid-dyn.rs:10:18
|
||||
|
|
||||
LL | fn test<const T: &'static dyn A>() {
|
||||
| ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0741`.
|
|
@ -1,5 +1,7 @@
|
|||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
trait A {}
|
||||
struct B;
|
||||
|
@ -7,6 +9,7 @@ impl A for B {}
|
|||
|
||||
fn test<const T: &'static dyn A>() {
|
||||
//~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` to be used
|
||||
//[min]~^^ ERROR `&'static (dyn A + 'static)` is forbidden
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/issue-63322-forbid-dyn.rs:1:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
error[E0741]: `&'static (dyn A + 'static)` must be annotated with `#[derive(PartialEq, Eq)]` to be used as the type of a const parameter
|
||||
--> $DIR/issue-63322-forbid-dyn.rs:8:18
|
||||
|
|
||||
LL | fn test<const T: &'static dyn A>() {
|
||||
| ^^^^^^^^^^^^^^ `&'static (dyn A + 'static)` doesn't derive both `PartialEq` and `Eq`
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
||||
For more information about this error, try `rustc --explain E0741`.
|
|
@ -1,5 +1,5 @@
|
|||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/issue-64494.rs:14:53
|
||||
--> $DIR/issue-64494.rs:16:53
|
||||
|
|
||||
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
||||
| ^^^^
|
||||
|
@ -7,7 +7,7 @@ LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
|||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/issue-64494.rs:16:53
|
||||
--> $DIR/issue-64494.rs:19:53
|
||||
|
|
||||
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
||||
| ^^^^
|
28
src/test/ui/const-generics/issues/issue-64494.min.stderr
Normal file
28
src/test/ui/const-generics/issues/issue-64494.min.stderr
Normal file
|
@ -0,0 +1,28 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
--> $DIR/issue-64494.rs:16:38
|
||||
|
|
||||
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
||||
| ^^^^^^ non-trivial anonymous constants must not depend on the parameter `T`
|
||||
|
|
||||
= help: it is currently only allowed to use either `T` or `{ T }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
--> $DIR/issue-64494.rs:19:38
|
||||
|
|
||||
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
||||
| ^^^^^^ non-trivial anonymous constants must not depend on the parameter `T`
|
||||
|
|
||||
= help: it is currently only allowed to use either `T` or `{ T }` as generic constants
|
||||
|
||||
error[E0119]: conflicting implementations of trait `MyTrait`:
|
||||
--> $DIR/issue-64494.rs:19:1
|
||||
|
|
||||
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
||||
| ------------------------------------ first implementation here
|
||||
...
|
||||
LL | impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0119`.
|
|
@ -1,5 +1,7 @@
|
|||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
trait Foo {
|
||||
const VAL: usize;
|
||||
|
@ -12,8 +14,11 @@ struct Is<const T: bool>;
|
|||
impl True for Is<{true}> {}
|
||||
|
||||
impl<T: Foo> MyTrait for T where Is<{T::VAL == 5}>: True {}
|
||||
//~^ ERROR constant expression depends on a generic parameter
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
impl<T: Foo> MyTrait for T where Is<{T::VAL == 6}>: True {}
|
||||
//~^ ERROR constant expression depends on a generic parameter
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~| ERROR conflicting implementations of trait `MyTrait`
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct Foo<const D: usize> {
|
||||
state: Option<[u8; D]>,
|
||||
|
|
10
src/test/ui/const-generics/issues/issue-66205.full.stderr
Normal file
10
src/test/ui/const-generics/issues/issue-66205.full.stderr
Normal file
|
@ -0,0 +1,10 @@
|
|||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/issue-66205.rs:8:12
|
||||
|
|
||||
LL | fact::<{ N - 1 }>();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: aborting due to previous error
|
||||
|
10
src/test/ui/const-generics/issues/issue-66205.min.stderr
Normal file
10
src/test/ui/const-generics/issues/issue-66205.min.stderr
Normal file
|
@ -0,0 +1,10 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
--> $DIR/issue-66205.rs:8:14
|
||||
|
|
||||
LL | fact::<{ N - 1 }>();
|
||||
| ^ non-trivial anonymous constants must not depend on the parameter `N`
|
||||
|
|
||||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,10 +1,13 @@
|
|||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
#![allow(dead_code, unconditional_recursion)]
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
|
||||
fn fact<const N: usize>() {
|
||||
fact::<{ N - 1 }>();
|
||||
//~^ ERROR constant expression depends on a generic parameter
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/issue-66205.rs:2:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/issue-66205.rs:6:12
|
||||
|
|
||||
LL | fact::<{ N - 1 }>();
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
pub struct Tuple;
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/issue-66906.rs:3:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
trait Baz {
|
||||
type Quaks;
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/issue-67185-1.rs:3:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// check-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
pub struct S(u8);
|
||||
|
||||
|
|
11
src/test/ui/const-generics/issues/issue-68615-adt.min.stderr
Normal file
11
src/test/ui/const-generics/issues/issue-68615-adt.min.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error: `[usize; 0]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-68615-adt.rs:7:23
|
||||
|
|
||||
LL | struct Const<const V: [usize; 0]> {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
// check-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// [full] check-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct Const<const V: [usize; 0]> {}
|
||||
//[min]~^ ERROR `[usize; 0]` is forbidden as the type of a const generic parameter
|
||||
type MyConst = Const<{ [] }>;
|
||||
|
||||
fn main() {
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
error: `[usize; 0]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-68615-array.rs:7:21
|
||||
|
|
||||
LL | struct Foo<const V: [usize; 0] > {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,8 +1,11 @@
|
|||
// check-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// [full] check-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct Foo<const V: [usize; 0] > {}
|
||||
//[min]~^ ERROR `[usize; 0]` is forbidden as the type of a const generic parameter
|
||||
|
||||
type MyFoo = Foo<{ [] }>;
|
||||
|
||||
|
|
10
src/test/ui/const-generics/issues/issue-68977.full.stderr
Normal file
10
src/test/ui/const-generics/issues/issue-68977.full.stderr
Normal file
|
@ -0,0 +1,10 @@
|
|||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/issue-68977.rs:35:44
|
||||
|
|
||||
LL | FxpStorageHelper<INT_BITS, FRAC_BITS>: FxpStorage,
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: aborting due to previous error
|
||||
|
18
src/test/ui/const-generics/issues/issue-68977.min.stderr
Normal file
18
src/test/ui/const-generics/issues/issue-68977.min.stderr
Normal file
|
@ -0,0 +1,18 @@
|
|||
error: generic parameters must not be used inside of non trivial constant values
|
||||
--> $DIR/issue-68977.rs:29:17
|
||||
|
|
||||
LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||
| ^^^^^^^^ non-trivial anonymous constants must not depend on the parameter `INT_BITS`
|
||||
|
|
||||
= help: it is currently only allowed to use either `INT_BITS` or `{ INT_BITS }` as generic constants
|
||||
|
||||
error: generic parameters must not be used inside of non trivial constant values
|
||||
--> $DIR/issue-68977.rs:29:28
|
||||
|
|
||||
LL | PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||
| ^^^^^^^^^ non-trivial anonymous constants must not depend on the parameter `FRAC_BITS`
|
||||
|
|
||||
= help: it is currently only allowed to use either `FRAC_BITS` or `{ FRAC_BITS }` as generic constants
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct PhantomU8<const X: u8>;
|
||||
|
||||
|
@ -25,11 +27,13 @@ fxp_storage_impls! {
|
|||
|
||||
type FxpStorageHelper<const INT_BITS: u8, const FRAC_BITS: u8> =
|
||||
PhantomU8<{(INT_BITS + FRAC_BITS + 7) / 8}>;
|
||||
//[min]~^ ERROR generic parameters must not be used inside of non trivial constant values
|
||||
//[min]~| ERROR generic parameters must not be used inside of non trivial constant values
|
||||
|
||||
struct Fxp<const INT_BITS: u8, const FRAC_BITS: u8>
|
||||
where
|
||||
FxpStorageHelper<INT_BITS, FRAC_BITS>: FxpStorage,
|
||||
//~^ ERROR constant expression depends on a generic parameter
|
||||
//[full]~^ ERROR constant expression depends on a generic parameter
|
||||
{
|
||||
storage: <FxpStorageHelper<INT_BITS, FRAC_BITS> as FxpStorage>::SInt,
|
||||
}
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/issue-68977.rs:1:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/issue-68977.rs:31:44
|
||||
|
|
||||
LL | FxpStorageHelper<INT_BITS, FRAC_BITS>: FxpStorage,
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// run-pass
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
const L: usize = 4;
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/issue-70125-1.rs:2:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
// run-pass
|
||||
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
fn main() {
|
||||
<()>::foo();
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/issue-70125-2.rs:3:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
pub trait Trait<const N: usize>: From<<Self as Trait<N>>::Item> {
|
||||
type Item;
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/issue-70167.rs:3:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
error[E0770]: the type of const parameters must not depend on other generic parameters
|
||||
--> $DIR/issue-71169.rs:4:43
|
||||
--> $DIR/issue-71169.rs:6:43
|
||||
|
|
||||
LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
|
||||
| ^^^ the type must not depend on the parameter `LEN`
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/issue-71169.rs:8:14
|
||||
--> $DIR/issue-71169.rs:11:14
|
||||
|
|
||||
LL | foo::<4, DATA>();
|
||||
| ^^^^
|
18
src/test/ui/const-generics/issues/issue-71169.min.stderr
Normal file
18
src/test/ui/const-generics/issues/issue-71169.min.stderr
Normal file
|
@ -0,0 +1,18 @@
|
|||
error[E0770]: the type of const parameters must not depend on other generic parameters
|
||||
--> $DIR/issue-71169.rs:6:43
|
||||
|
|
||||
LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
|
||||
| ^^^ the type must not depend on the parameter `LEN`
|
||||
|
||||
error: `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-71169.rs:6:38
|
||||
|
|
||||
LL | fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
|
||||
| ^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0770`.
|
|
@ -1,10 +1,13 @@
|
|||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
fn foo<const LEN: usize, const DATA: [u8; LEN]>() {}
|
||||
//~^ ERROR the type of const parameters must not
|
||||
//[min]~^^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
fn main() {
|
||||
const DATA: [u8; 4] = *b"ABCD";
|
||||
foo::<4, DATA>();
|
||||
//~^ ERROR constant expression depends on
|
||||
//[full]~^ ERROR constant expression depends on
|
||||
}
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
error[E0770]: the type of const parameters must not depend on other generic parameters
|
||||
--> $DIR/issue-71381.rs:13:82
|
||||
--> $DIR/issue-71381.rs:15:82
|
||||
|
|
||||
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
|
||||
| ^^^^ the type must not depend on the parameter `Args`
|
||||
|
||||
error[E0770]: the type of const parameters must not depend on other generic parameters
|
||||
--> $DIR/issue-71381.rs:22:40
|
||||
--> $DIR/issue-71381.rs:24:40
|
||||
|
|
||||
LL | const FN: unsafe extern "C" fn(Args),
|
||||
| ^^^^ the type must not depend on the parameter `Args`
|
||||
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71381.rs:13:61
|
||||
--> $DIR/issue-71381.rs:15:61
|
||||
|
|
||||
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71381.rs:22:19
|
||||
--> $DIR/issue-71381.rs:24:19
|
||||
|
|
||||
LL | const FN: unsafe extern "C" fn(Args),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
27
src/test/ui/const-generics/issues/issue-71381.min.stderr
Normal file
27
src/test/ui/const-generics/issues/issue-71381.min.stderr
Normal file
|
@ -0,0 +1,27 @@
|
|||
error[E0770]: the type of const parameters must not depend on other generic parameters
|
||||
--> $DIR/issue-71381.rs:15:82
|
||||
|
|
||||
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
|
||||
| ^^^^ the type must not depend on the parameter `Args`
|
||||
|
||||
error[E0770]: the type of const parameters must not depend on other generic parameters
|
||||
--> $DIR/issue-71381.rs:24:40
|
||||
|
|
||||
LL | const FN: unsafe extern "C" fn(Args),
|
||||
| ^^^^ the type must not depend on the parameter `Args`
|
||||
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71381.rs:15:61
|
||||
|
|
||||
LL | pub fn call_me<Args: Sized, const IDX: usize, const FN: unsafe extern "C" fn(Args)>(&self) {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71381.rs:24:19
|
||||
|
|
||||
LL | const FN: unsafe extern "C" fn(Args),
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0770`.
|
|
@ -1,5 +1,7 @@
|
|||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct Test(*const usize);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71382.rs:15:23
|
||||
--> $DIR/issue-71382.rs:17:23
|
||||
|
|
||||
LL | fn test<const FN: fn()>(&self) {
|
||||
| ^^^^
|
8
src/test/ui/const-generics/issues/issue-71382.min.stderr
Normal file
8
src/test/ui/const-generics/issues/issue-71382.min.stderr
Normal file
|
@ -0,0 +1,8 @@
|
|||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71382.rs:17:23
|
||||
|
|
||||
LL | fn test<const FN: fn()>(&self) {
|
||||
| ^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct Test();
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
error[E0770]: the type of const parameters must not depend on other generic parameters
|
||||
--> $DIR/issue-71611.rs:4:31
|
||||
--> $DIR/issue-71611.rs:6:31
|
||||
|
|
||||
LL | fn func<A, const F: fn(inner: A)>(outer: A) {
|
||||
| ^ the type must not depend on the parameter `A`
|
||||
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71611.rs:4:21
|
||||
--> $DIR/issue-71611.rs:6:21
|
||||
|
|
||||
LL | fn func<A, const F: fn(inner: A)>(outer: A) {
|
||||
| ^^^^^^^^^^^^
|
15
src/test/ui/const-generics/issues/issue-71611.min.stderr
Normal file
15
src/test/ui/const-generics/issues/issue-71611.min.stderr
Normal file
|
@ -0,0 +1,15 @@
|
|||
error[E0770]: the type of const parameters must not depend on other generic parameters
|
||||
--> $DIR/issue-71611.rs:6:31
|
||||
|
|
||||
LL | fn func<A, const F: fn(inner: A)>(outer: A) {
|
||||
| ^ the type must not depend on the parameter `A`
|
||||
|
||||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-71611.rs:6:21
|
||||
|
|
||||
LL | fn func<A, const F: fn(inner: A)>(outer: A) {
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0770`.
|
|
@ -1,5 +1,7 @@
|
|||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
fn func<A, const F: fn(inner: A)>(outer: A) {
|
||||
//~^ ERROR: using function pointers as const generic parameters is forbidden
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-72352.rs:6:42
|
||||
--> $DIR/issue-72352.rs:8:42
|
||||
|
|
||||
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
8
src/test/ui/const-generics/issues/issue-72352.min.stderr
Normal file
8
src/test/ui/const-generics/issues/issue-72352.min.stderr
Normal file
|
@ -0,0 +1,8 @@
|
|||
error: using function pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-72352.rs:8:42
|
||||
|
|
||||
LL | unsafe fn unsafely_do_the_thing<const F: fn(&CStr) -> usize>(ptr: *const i8) -> usize {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
use std::ffi::{CStr, CString};
|
||||
|
||||
|
|
11
src/test/ui/const-generics/issues/issue-73491.min.stderr
Normal file
11
src/test/ui/const-generics/issues/issue-73491.min.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error: `[u32; _]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-73491.rs:9:19
|
||||
|
|
||||
LL | fn hoge<const IN: [u32; LEN]>() {}
|
||||
| ^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
// check-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// [full] check-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
const LEN: usize = 1024;
|
||||
|
||||
fn hoge<const IN: [u32; LEN]>() {}
|
||||
//[min]~^ ERROR `[u32; _]` is forbidden as the type of a const generic parameter
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
error: using raw pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-73508.rs:6:33
|
||||
|
|
||||
LL | pub const fn func_name<const X: *const u32>() {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
8
src/test/ui/const-generics/issues/issue-73508.min.stderr
Normal file
8
src/test/ui/const-generics/issues/issue-73508.min.stderr
Normal file
|
@ -0,0 +1,8 @@
|
|||
error: using raw pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-73508.rs:6:33
|
||||
|
|
||||
LL | pub const fn func_name<const X: *const u32>() {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
#![feature(const_generics)] //~ WARN the feature `const_generics` is incomplete
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
pub const fn func_name<const X: *const u32>() {}
|
||||
//~^ ERROR using raw pointers
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/issue-73508.rs:1:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
error: using raw pointers as const generic parameters is forbidden
|
||||
--> $DIR/issue-73508.rs:3:33
|
||||
|
|
||||
LL | pub const fn func_name<const X: *const u32>() {}
|
||||
| ^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error; 1 warning emitted
|
||||
|
20
src/test/ui/const-generics/issues/issue-74101.min.stderr
Normal file
20
src/test/ui/const-generics/issues/issue-74101.min.stderr
Normal file
|
@ -0,0 +1,20 @@
|
|||
error: `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74101.rs:7:18
|
||||
|
|
||||
LL | fn test<const N: [u8; 1 + 2]>() {}
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74101.rs:10:21
|
||||
|
|
||||
LL | struct Foo<const N: [u8; 1 + 2]>;
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
|
@ -1,9 +1,13 @@
|
|||
// check-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// [full] check-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
fn test<const N: [u8; 1 + 2]>() {}
|
||||
//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
|
||||
struct Foo<const N: [u8; 1 + 2]>;
|
||||
//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
|
||||
fn main() {}
|
||||
|
|
11
src/test/ui/const-generics/issues/issue-74255.min.stderr
Normal file
11
src/test/ui/const-generics/issues/issue-74255.min.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error: `IceEnum` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-74255.rs:15:31
|
||||
|
|
||||
LL | fn ice_struct_fn<const I: IceEnum>() {}
|
||||
| ^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// check-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(dead_code, incomplete_features)]
|
||||
// [full] check-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
#[derive(PartialEq, Eq)]
|
||||
enum IceEnum {
|
||||
|
@ -11,6 +13,7 @@ struct IceStruct;
|
|||
|
||||
impl IceStruct {
|
||||
fn ice_struct_fn<const I: IceEnum>() {}
|
||||
//[min]~^ ERROR `IceEnum` is forbidden as the type of a const generic parameter
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
|
11
src/test/ui/const-generics/issues/issue-75047.min.stderr
Normal file
11
src/test/ui/const-generics/issues/issue-75047.min.stderr
Normal file
|
@ -0,0 +1,11 @@
|
|||
error: `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/issue-75047.rs:15:21
|
||||
|
|
||||
LL | struct Foo<const N: [u8; Bar::<u32>::value()]>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
// check-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// [full] check-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct Bar<T>(T);
|
||||
|
||||
|
@ -11,5 +13,6 @@ impl<T> Bar<T> {
|
|||
}
|
||||
|
||||
struct Foo<const N: [u8; Bar::<u32>::value()]>;
|
||||
//[min]~^ ERROR `[u8; _]` is forbidden as the type of a const generic parameter
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// check-pass
|
||||
|
||||
#![feature(const_generics)]
|
||||
//~^ WARN the feature `const_generics` is incomplete
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
trait T<const A: usize> {
|
||||
fn f();
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
warning: the feature `const_generics` is incomplete and may not be safe to use and/or cause compiler crashes
|
||||
--> $DIR/issue70273-assoc-fn.rs:3:12
|
||||
|
|
||||
LL | #![feature(const_generics)]
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: `#[warn(incomplete_features)]` on by default
|
||||
= note: see issue #44580 <https://github.com/rust-lang/rust/issues/44580> for more information
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
error: `std::ops::Range<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:8:24
|
||||
|
|
||||
LL | struct _Range<const R: std::ops::Range<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `std::ops::RangeFrom<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:13:28
|
||||
|
|
||||
LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `std::ops::RangeFull` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:18:28
|
||||
|
|
||||
LL | struct _RangeFull<const R: std::ops::RangeFull>;
|
||||
| ^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `std::ops::RangeInclusive<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:24:33
|
||||
|
|
||||
LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `std::ops::RangeTo<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:29:26
|
||||
|
|
||||
LL | struct _RangeTo<const R: std::ops::RangeTo<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: `std::ops::RangeToInclusive<usize>` is forbidden as the type of a const generic parameter
|
||||
--> $DIR/const-generics-range.rs:34:35
|
||||
|
|
||||
LL | struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: the only supported types are integers, `bool` and `char`
|
||||
= note: more complex types are supported with `#[feature(const_generics)]`
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
|
@ -1,30 +1,38 @@
|
|||
// check-pass
|
||||
#![allow(incomplete_features)]
|
||||
#![feature(const_generics)]
|
||||
// [full] check-pass
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
// `Range` should be usable within const generics:
|
||||
struct _Range<const R: std::ops::Range<usize>>;
|
||||
//[min]~^ ERROR `std::ops::Range<usize>` is forbidden
|
||||
const RANGE : _Range<{ 0 .. 1000 }> = _Range;
|
||||
|
||||
// `RangeFrom` should be usable within const generics:
|
||||
struct _RangeFrom<const R: std::ops::RangeFrom<usize>>;
|
||||
//[min]~^ ERROR `std::ops::RangeFrom<usize>` is forbidden
|
||||
const RANGE_FROM : _RangeFrom<{ 0 .. }> = _RangeFrom;
|
||||
|
||||
// `RangeFull` should be usable within const generics:
|
||||
struct _RangeFull<const R: std::ops::RangeFull>;
|
||||
//[min]~^ ERROR `std::ops::RangeFull` is forbidden
|
||||
const RANGE_FULL : _RangeFull<{ .. }> = _RangeFull;
|
||||
|
||||
// Regression test for #70155
|
||||
// `RangeInclusive` should be usable within const generics:
|
||||
struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>;
|
||||
//[min]~^ ERROR `std::ops::RangeInclusive<usize>` is forbidden
|
||||
const RANGE_INCLUSIVE : _RangeInclusive<{ 0 ..= 999 }> = _RangeInclusive;
|
||||
|
||||
// `RangeTo` should be usable within const generics:
|
||||
struct _RangeTo<const R: std::ops::RangeTo<usize>>;
|
||||
//[min]~^ ERROR `std::ops::RangeTo<usize>` is forbidden
|
||||
const RANGE_TO : _RangeTo<{ .. 1000 }> = _RangeTo;
|
||||
|
||||
// `RangeToInclusive` should be usable within const generics:
|
||||
struct _RangeToInclusive<const R: std::ops::RangeToInclusive<usize>>;
|
||||
//[min]~^ ERROR `std::ops::RangeToInclusive<usize>` is forbidden
|
||||
const RANGE_TO_INCLUSIVE : _RangeToInclusive<{ ..= 999 }> = _RangeToInclusive;
|
||||
|
||||
pub fn main() {}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
error: type parameters must be declared prior to const parameters
|
||||
--> $DIR/type-after-const-ok.rs:9:26
|
||||
|
|
||||
LL | struct A<const N: usize, T>(T);
|
||||
| -----------------^- help: reorder the parameters: lifetimes, then types, then consts: `<T, const N: usize>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
// run-pass
|
||||
// [full] run-pass
|
||||
// revisions: full min
|
||||
// Verifies that having generic parameters after constants is permitted
|
||||
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
#[allow(dead_code)]
|
||||
struct A<const N: usize, T>(T);
|
||||
//[min]~^ ERROR type parameters must be declared prior to const parameters
|
||||
|
||||
fn main() {}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// run-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
trait SliceExt<T: Clone> {
|
||||
fn array_windows<'a, const N: usize>(&'a self) -> ArrayWindows<'a, T, N>;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// run-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
trait T {
|
||||
fn test<const A: i32>(&self) -> i32 { A }
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// check-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct X;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// check-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct A<const N: usize>;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// run-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
trait IterExt: Sized + Iterator {
|
||||
fn default_for_size<const N: usize>(self) -> [Self::Item; N]
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
// check-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
struct Struct<const N: usize>;
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// run-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
trait ConstChunksExactTrait<T> {
|
||||
fn const_chunks_exact<const N: usize>(&self) -> ConstChunksExact<'_, T, {N}>;
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
// check-pass
|
||||
#![feature(const_generics)]
|
||||
#![allow(incomplete_features)]
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue