Closed
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)
Description
The project below fails to build using rustc -o bin/logging2 crate.rc with error main function not found. If rustc -o bin/logging2 --lib crate.rc is used it complains about missing crate link meta 'name', using 'logging2' as default and missing crate link meta 'vers', using '0.0' as default.
Makefile:
RUSTC ?= rustc
dummy1 := $(shell mkdir bin 2> /dev/null)
all:
$(RUSTC) -o bin/logging2 crate.rc
#$(RUSTC) -o bin/logging2 --lib crate.rc
check:
$(RUSTC) -o bin/test-logging2 --test crate.rc
export RUST_LOG=test-logging2::logging2=3 && ./bin/test-logging2
clean:
rm -rf bin
crate.rc:
use std;
#[link(name = "logging2",
vers = "0.1",
uuid = "91E62841-B9F3-4721-97C6-621BEEE2DA1B")]
#[crate_type = "lib"]
mod logging2;
logging2.rs:
#[test]
fn test_logging()
{
error!("error level");
warn!("warn level");
info!("info level");
}
This is with a rust from master on Sep 1, 2012.
Metadata
Metadata
Assignees
Labels
A-attributesArea: Attributes (`#[…]`, `#![…]`)Area: Attributes (`#[…]`, `#![…]`)
Activity
jesse99 commentedon Sep 2, 2012
Stuff like
#[warn(deprecated_pattern)]is also being ignored. Was able to get those, at least, working using the -W rust command-line switch.brson commentedon Sep 2, 2012
This is likely because of the placement of the crate attributes. As written they are actually being applied to the logging2 mod.
This way they will apply to the crate:
I know this is really unintuitive behavior. There's some discussion in #2569.
jesse99 commentedon Sep 3, 2012
Good call. The original code had
use std;as the very first thing which lead toexpected outer commenterrors. Adding an outer comment (//! or /*! */ I think) did not get rid of the error and in my flailing around I wound up getting rid of a compiler error by removing the semi-colons.It is unintuitive which might be OK if the error messages were clear enough to allow users to figure out the problem and the solution, but that is far from the case.
msullivan commentedon Jul 1, 2013
So, is this actually a bug? Or is it just a consequence of #2569?
klutzy commentedon Sep 30, 2013
I think misplaced
crate_modandlinkshould be error regardless of syntax we will use.auto merge of #10316 : klutzy/rust/attr-lint, r=cmr
Auto merge of rust-lang#3348 - RalfJung:miri-thread-logging, r=RalfJung
Add support for global transformations (rust-lang#3348)
Merge pull request rust-lang#3348 from matklad/single-line