Skip to content

Add negative test coverage for -Clink-self-contained and -Zlinker-features #140997

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2025
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `*lld` for codegen option `link-self-contained` - one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw` was expected

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `` for codegen option `link-self-contained` - one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw` was expected

23 changes: 23 additions & 0 deletions tests/ui/linking/link-self-contained-malformed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//! Check that malformed `-Clink-self-contained` invocations are properly rejected.
//@ revisions: no_value
//@[no_value] compile-flags: -Clink-self-contained=
//[no_value]~? ERROR incorrect value `` for codegen option `link-self-contained`

//@ revisions: invalid_modifier
//@[invalid_modifier] compile-flags: -Clink-self-contained=*lld
//[invalid_modifier]~? ERROR incorrect value `*lld` for codegen option `link-self-contained`

//@ revisions: unknown_value
//@[unknown_value] compile-flags: -Clink-self-contained=unknown
//[unknown_value]~? ERROR incorrect value `unknown` for codegen option `link-self-contained`

//@ revisions: unknown_modifier_value
//@[unknown_modifier_value] compile-flags: -Clink-self-contained=-unknown
//[unknown_modifier_value]~? ERROR incorrect value `-unknown` for codegen option `link-self-contained`

//@ revisions: unknown_boolean
//@[unknown_boolean] compile-flags: -Clink-self-contained=maybe
//[unknown_boolean]~? ERROR incorrect value `maybe` for codegen option `link-self-contained`

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `maybe` for codegen option `link-self-contained` - one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw` was expected

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `-unknown` for codegen option `link-self-contained` - one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw` was expected

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `unknown` for codegen option `link-self-contained` - one of: `y`, `yes`, `on`, `n`, `no`, `off`, or a list of enabled (`+` prefix) and disabled (`-` prefix) components: `crto`, `libc`, `unwind`, `linker`, `sanitizers`, `mingw` was expected

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `*lld` for unstable option `linker-features` - a list of enabled (`+` prefix) and disabled (`-` prefix) features: `lld` was expected

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `-lld@+lld` for unstable option `linker-features` - a list of enabled (`+` prefix) and disabled (`-` prefix) features: `lld` was expected

2 changes: 2 additions & 0 deletions tests/ui/linking/linker-features-malformed.no_value.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `` for unstable option `linker-features` - a list of enabled (`+` prefix) and disabled (`-` prefix) features: `lld` was expected

27 changes: 27 additions & 0 deletions tests/ui/linking/linker-features-malformed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//! Check that malformed `-Zlinker-features` flags are properly rejected.

//@ revisions: no_value
//@[no_value] compile-flags: -Zlinker-features=
//[no_value]~? ERROR incorrect value `` for unstable option `linker-features`

//@ revisions: invalid_modifier
//@[invalid_modifier] compile-flags: -Zlinker-features=*lld
//[invalid_modifier]~? ERROR incorrect value `*lld` for unstable option `linker-features`

//@ revisions: unknown_value
//@[unknown_value] compile-flags: -Zlinker-features=unknown
//[unknown_value]~? ERROR incorrect value `unknown` for unstable option `linker-features`

//@ revisions: unknown_modifier_value
//@[unknown_modifier_value] compile-flags: -Zlinker-features=-unknown
//[unknown_modifier_value]~? ERROR incorrect value `-unknown` for unstable option `linker-features`

//@ revisions: unknown_boolean
//@[unknown_boolean] compile-flags: -Zlinker-features=maybe
//[unknown_boolean]~? ERROR incorrect value `maybe` for unstable option `linker-features`

//@ revisions: invalid_separator
//@[invalid_separator] compile-flags: -Zlinker-features=-lld@+lld
//[invalid_separator]~? ERROR incorrect value `-lld@+lld` for unstable option `linker-features`

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `maybe` for unstable option `linker-features` - a list of enabled (`+` prefix) and disabled (`-` prefix) features: `lld` was expected

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `-unknown` for unstable option `linker-features` - a list of enabled (`+` prefix) and disabled (`-` prefix) features: `lld` was expected

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
error: incorrect value `unknown` for unstable option `linker-features` - a list of enabled (`+` prefix) and disabled (`-` prefix) features: `lld` was expected

Loading