11938 Commits

Author SHA1 Message Date
Ed Page
4a0b8948dd refactor(add): Pull out feature count for reuse 2025-02-18 12:42:52 -06:00
Orion Gonzalez
280bc1f68b docs: Improve comments 2025-02-17 22:19:32 +01:00
Weihang Lo
3b784a42e3
fix(embedded): Handle more parsing corner cases (#15187)
### What does this PR try to resolve?

This is part of #12207. I found these while implementing frontmatter
support within rustc.

I'll likely do another pass when I finish rustc support to
- Unify tests between cargo and rustc
- Improve error messages

### How should we test and review this PR?

### Additional information
2025-02-16 05:05:53 +00:00
Eric Huss
0a4aff2e78
docs: docs for -Zfeature-unification (#15189)
### What does this PR try to resolve?

Follow-up of <https://github.com/rust-lang/cargo/pull/15157>.
Add missing docs for <https://github.com/rust-lang/cargo/issues/14774>.

### How should we test and review this PR?

```
mdbook serve src/doc
```
2025-02-15 15:02:31 +00:00
Max Heller
5e55f526ca
Fix man page with paragraph outside of option block 2025-02-15 08:10:14 -05:00
Weihang Lo
3f49ca8132
docs: docs for -Zfeature-unification 2025-02-14 23:41:21 -05:00
brian m. carlson
7cd88900d3
util: provide a better error message for invalid SSH URLs
It's very common for users to attempt to use the pseudo-URLs that GitHub
or other providers provide in the form
`git@github.com:rust-lang/rust.git` as a source in Cargo.toml, which are
the default format accepted by OpenSSH. Unfortunately, these are not
actually URLs, and unsurprisingly, the `url` crate doesn't accept them.

However, our error message is unhelpful and looks like this:

    invalid url `git@github.com:rust-lang/rust.git`: relative URL without a base

This is technically true, but we can do better.  The user actually wants
to write a real SSH URL, so if the non-URL starts with `git@`, let's
rewrite it into a real URL for them to help them and include that in the
error message.

`git@` is the prefix used by all major forges, as well as the default
configuration for do-it-yourself implementations like Gitolite.  While
other options are possible, they are much less common, and this is an
extremely easy and cheap heuristic that does not necessitate complicated
parsing, but which we can change in the future should that be necessary.

This also avoids the problem where users try to turn the pseudo-URL into
a real URL by just prepending `ssh://`, which causes an error message
about the invalid port number due to the colon which they have not
changed.  Since they can just copy and paste the proposed answer,
they'll be less likely to attempt this invalid approach.
2025-02-14 19:43:16 +00:00
Ed Page
fd2000b106 fix(embedded): Allow non-starting dashes in frontmatter 2025-02-14 10:23:10 -06:00
Ed Page
b14a5f4ae9 fix(embedded): Don't parse indented frontmatter 2025-02-14 10:10:35 -06:00
Ed Page
a00d0bade5 refactor(embedded): Name the steps when trimming 2025-02-14 10:09:35 -06:00
Ed Page
544013e786 refactor(embedded): Clarify the parser 2025-02-14 10:06:57 -06:00
Ed Page
e148c3d3e1 refactor(embedded): Extract shebang splitting
This is intended to make the code more closely match rustc
2025-02-14 10:04:57 -06:00
Ed Page
fbd2993c3d test(embedded): Add more frontmatter cases 2025-02-13 15:55:48 -06:00
Fluid
eb5c9a8fa5 update the right file & cargo build-man 2025-02-13 23:51:41 +02:00
Fluid
485a1b198a cargo build-man 2025-02-13 23:48:02 +02:00
Fluid
f6262a4eef fix 2025-02-13 23:43:17 +02:00
Weihang Lo
c52d4da4e6
refactor: Consolidate creation of SourceId from manifest path (#15172)
### What does this PR try to resolve?

This preps more features for cargo-script support and makes it clearer
where we don't yet support it.

### How should we test and review this PR?

### Additional information
2025-02-12 00:41:17 +00:00
Ed Page
48224c19c6 docs(embedded): Note the shebang deviation
rustc considers the following valid and without a shebang:
```rust

// Hello

[allow(dead_code)]

fn main() {
    println!("Hello, world!");
}
```
and
```rustc
[allow(dead_code)]

fn main() {
    println!("Hello, world!");
}
```

In both cases, we consider it to have a shebang.  This commit documents
that intention.

We could add our own heuristics
(e.g. `#!` with only whitespace is not a shebang)
but we should either be a subset or intentionally different than rustc
(e.g. require a non `[`-prefixes interpreter)
rather than do both.

This will be reflected in the tracking issue which will handle the final
decision for the team on this matter.

Fixes #15170
2025-02-11 15:30:47 -06:00
Ed Page
080f7474aa refactor: Consolidate to SourceId::from_manifest_path 2025-02-11 14:05:57 -06:00
Ed Page
5a351405dc refactor: Centralize SourceId creation for manifests 2025-02-11 14:00:10 -06:00
Eric Huss
b64750d83d
refactor(embedded): Integrate cargo-script logic into main parser (#15168)
### What does this PR try to resolve?

This is a part of #12207

Now that the experiment is over and we can be intrusive, this merges all
of the permanent cargo-script manifest logic into the regular manifest
loading code path with the goal of reducing the number of places people
need to be aware to check to know how things work so we're less likely
to overlook them (e.g. `package.name`s being optional). This should also
make error reporting better as we will eventually only use the real
manifest users specify, instead of one with a lot of edits by us.

This comes at the cost of some uglier code needed to check some of these
cases.

### How should we test and review this PR?

### Additional information
2025-02-11 14:54:56 +00:00
Andrew Liu
a471adbd2c feat: implement workspace feature unification 2025-02-11 15:10:39 +09:00
Ed Page
0ee181e986 refactor(embedded): Clarify functions limited role 2025-02-10 14:32:49 -06:00
Ed Page
a81650c84c refactor(embedded): Move embedded validation to to_real_manifest
This is where a lot of the other logic like it is
2025-02-10 14:29:15 -06:00
Ed Page
dffd0fd4c7 refactor(embedded): Move workspace to normalization 2025-02-10 14:29:15 -06:00
Ed Page
3582b788cd refactor(embedded): Move package to normalization 2025-02-10 14:29:15 -06:00
Ed Page
8a40b36fdc refactor(embedded): Move package.name to normalization 2025-02-10 14:29:15 -06:00
Ed Page
6ec8da96f4 fix(schema): Mark package.name as optional 2025-02-10 14:29:15 -06:00
Ed Page
911f174832 refactor(embedded): Move package.edition to normalization 2025-02-10 14:29:14 -06:00
Ed Page
f6b9c8f874 refactor(embedded): Move package.auto* to normalization 2025-02-10 14:28:27 -06:00
Ed Page
9527082298 refactor(embedded): Move package.build to normalization 2025-02-10 14:28:27 -06:00
Ed Page
f2a20cf3c1 refactor(toml): Track the normalized name, not original 2025-02-10 14:28:27 -06:00
Ed Page
7cd183386f refactor(toml): Track the normalized name, not original 2025-02-10 14:28:27 -06:00
Ed Page
4da874fae0 refactor(toml): Centralize package name lookup 2025-02-10 14:28:27 -06:00
Ed Page
8d6985679f refactor(toml): Centralize package name lookup 2025-02-10 14:28:27 -06:00
Ed Page
21f008e30c refactor(toml): Pull out field normalization for TomlPackage 2025-02-10 14:28:27 -06:00
Ed Page
b6619af363 refactor(toml): Ensure package normalization has access to the file name 2025-02-10 14:28:27 -06:00
Ed Page
c1db5cf99c refactor(toml): Centralize is_embedded query
Need access to this in more places.  I decided to centralize it (instead
of adding more calls) because of the fact that it touches the
filesystem.
2025-02-10 14:28:27 -06:00
Ed Page
d398ce60b1 fix(embedded): Make errors consistent 2025-02-10 14:28:21 -06:00
Weihang Lo
f7c9066169
fix: align first line of unordered list with following
This looks more nature.
Most of other popular softwares follow the same style.
For example, git-merge, tar, and bash.
2025-02-09 10:15:42 -05:00
Ed Page
2928e32734
Simplify backtrack (#15150)
### What does this PR try to resolve?

Some very small simplifications made while poking around the resolver. I
was trying to understand when we would end up hitting a `continue` in
the code. The easiest way was to run the tests with a panic instead.
Turns out I was right, we cannot/(can no longer) hit that code path.
Which allowed us to simplify some other surrounding code.

### How should we test and review this PR?

All tests pass on each commit.

### Additional information
2025-02-07 16:50:22 +00:00
Weihang Lo
49e5d24870
Don't use on Solaris libc::LOCK_* which were removed from libc in ver… (#15143)
Relevant libc change was:
251e8e839a
2025-02-07 13:14:25 +00:00
Petr Sumbera
1cc87c914f Don't use on Solaris libc::LOCK_* which were removed from libc in version 0.2.162 2025-02-07 08:03:26 +00:00
Jacob Finkelman
8014091612 reorganize the loop 2025-02-06 22:07:05 +00:00
Jacob Finkelman
a9da3c8345
to to too
Co-authored-by: Ed Page <eopage@gmail.com>
2025-02-06 16:44:19 -05:00
Jacob Finkelman
2cce8b4be9 deduplicate the check 2025-02-06 20:03:12 +00:00
Jacob Finkelman
0716b882ba move code out of loop 2025-02-06 19:35:07 +00:00
Jacob Finkelman
3cf5cc37f7 insurer code is dead by runing tests with a panic! call 2025-02-06 19:31:25 +00:00
Ed Page
027b415b52
feat: emit error if package not found within workspace (#15071)
### What does this PR try to resolve?

Fixes https://github.com/rust-lang/cargo/issues/12978

currently, if `--package `and `--workspace` passe in the same time, the
`--package` will be ignore even the package doesnt exist in the
workspace, this PR regards this behavior as an error

### How should we test and review this PR?

one commit add test, one commit fixes the issue.

### Additional information
2025-02-06 02:47:38 +00:00
Yihai Lin
23ab2afc25 feat: package doesnt exist in workspace is regarded as an error 2025-02-06 10:07:22 +08:00