Skip to content
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

Rollup of 8 pull requests #128796

Merged
merged 39 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift click to select a range
50835bf
impl Default for collection iterators that don't already have it
clarfonthey Jul 27, 2024
0b99720
Okay, I guess I have to give these a different feature name
clarfonthey Jul 27, 2024
ba0d6c9
Update generate-copyright
jonathanpallant Jul 4, 2024
204e3ea
generate-copyright: Produce HTML, not Markdown
jonathanpallant Jul 29, 2024
56f8479
generate-copyright: Fix typo
jonathanpallant Jul 30, 2024
dbab595
generate-copyright: use cargo-metadata
jonathanpallant Jul 30, 2024
f7e6bf6
generate-copyright: use rinja to format the output
jonathanpallant Jul 30, 2024
37ab090
REUSE.toml: Copyright text isn't parsed as Markdown.
jonathanpallant Jul 30, 2024
30ac7c9
generate-copyright: Render Node with rinja too.
jonathanpallant Jul 31, 2024
5277b67
generate-copyright: gather files inside interesting folders
jonathanpallant Aug 6, 2024
4e24e9b
Update to rinja 0.3
jonathanpallant Aug 6, 2024
99579f3
Apparently library/std is now part of a workspace at library/
jonathanpallant Aug 6, 2024
b174cf8
Integrate crlf directly into related test file instead via of .gitatt…
yaahc Aug 6, 2024
74653b6
Add implied target features to target_feature attribute
calebzulawski Jul 26, 2024
22c5952
Add test to ensure implied target features work with asm, and fix fai…
calebzulawski Jul 26, 2024
520a5a5
Fix codegen tests
calebzulawski Jul 26, 2024
c866e1f
Add missing features
calebzulawski Jul 29, 2024
34f29a2
Add sse4.2 due to #128426
calebzulawski Jul 31, 2024
3c48f65
Bless tests
calebzulawski Jul 31, 2024
fbd618d
Refactor and fill out target feature lists
calebzulawski Aug 2, 2024
484aca8
Don't use LLVM's target features
calebzulawski Aug 3, 2024
a25da07
Don't use LLVM to compute -Ctarget-feature
calebzulawski Aug 4, 2024
5006711
Remove redundant implied features
calebzulawski Aug 4, 2024
6b96a60
Add implied features to non-target-feature functions
calebzulawski Aug 4, 2024
83276f5
Hide implicit target features from diagnostics when possible
calebzulawski Aug 5, 2024
0b98a0c
Fix typo
calebzulawski Aug 5, 2024
8818c95
Disallow enabling features without their implied features
calebzulawski Aug 6, 2024
d1d21ed
rustc_codegen_ssa: Set architecture for object crate for 32-bit SPARC
glaubitz Aug 7, 2024
c189796
unused_parens: do not lint against parens around &raw
RalfJung Aug 7, 2024
8c06dc4
make `import.vis` is not mutable
bvanjoi Aug 6, 2024
273c67d
codegen: better centralize function attribute computation
RalfJung Aug 5, 2024
904f579
Rollup merge of #128221 - calebzulawski:implied-target-features, r=Am…
matthiaskrgr Aug 7, 2024
2ee9678
Rollup merge of #128261 - clarfonthey:iter-default, r=dtolnay
matthiaskrgr Aug 7, 2024
e342295
Rollup merge of #128353 - ferrocene:jonathanpallant/add-dependencies-…
matthiaskrgr Aug 7, 2024
8f39b86
Rollup merge of #128679 - RalfJung:codegen-fn-attrs, r=nikic
matthiaskrgr Aug 7, 2024
8f5b50d
Rollup merge of #128732 - bvanjoi:immutable-import-vis, r=petrochenkov
matthiaskrgr Aug 7, 2024
e5a3c32
Rollup merge of #128755 - yaahc:jj-crlf, r=estebank
matthiaskrgr Aug 7, 2024
04ab8e3
Rollup merge of #128772 - glaubitz:sparc-elf-fix, r=nagisa
matthiaskrgr Aug 7, 2024
aba506b
Rollup merge of #128782 - RalfJung:raw-addr-of-parens, r=compiler-errors
matthiaskrgr Aug 7, 2024
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
Prev Previous commit
Next Next commit
generate-copyright: Render Node with rinja too.
  • Loading branch information
jonathanpallant committed Aug 6, 2024
commit 30ac7c9a817793a86d870eeab5a8238acb29b186
46 changes: 42 additions & 4 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1407,9 1407,9 @@ version = "0.1.0"
dependencies = [
"anyhow",
"cargo_metadata 0.18.1",
"rinja 0.2.0",
"serde",
"serde_json",
"tempfile",
"thiserror",
]

Expand Down Expand Up @@ -3100,14 3100,43 @@ dependencies = [
"walkdir",
]

[[package]]
name = "rinja"
version = "0.2.0"
source = "registry https://github.com/rust-lang/crates.io-index"
checksum = "d2d47a46d7729e891c8accf260e9daa02ae6d570aa2a94fb1fb27eb5364a2323"
dependencies = [
"humansize",
"num-traits",
"percent-encoding",
"rinja_derive 0.2.0",
]

[[package]]
name = "rinja"
version = "0.3.0"
source = "registry https://github.com/rust-lang/crates.io-index"
checksum = "6d3762e3740cdbf2fd2be465cc2c26d643ad17353cc2e0223d211c1b096118bd"
dependencies = [
"itoa",
"rinja_derive",
"rinja_derive 0.3.0",
]

[[package]]
name = "rinja_derive"
version = "0.2.0"
source = "registry https://github.com/rust-lang/crates.io-index"
checksum = "44dae9afe59d58ed8d988d67d1945f3638125d2fd2104058399382e11bd3ea2a"
dependencies = [
"basic-toml",
"mime",
"mime_guess",
"once_map",
"proc-macro2",
"quote",
"rinja_parser 0.2.0",
"serde",
"syn 2.0.67",
]

[[package]]
Expand All @@ -3123,11 3152,20 @@ dependencies = [
"once_map",
"proc-macro2",
"quote",
"rinja_parser",
"rinja_parser 0.3.0",
"serde",
"syn 2.0.67",
]

[[package]]
name = "rinja_parser"
version = "0.2.0"
source = "registry https://github.com/rust-lang/crates.io-index"
checksum = "1b1771c78cd5d3b1646ef8d8f2ed100db936e8b291d3cc06e92a339ff346858c"
dependencies = [
"nom",
]

[[package]]
name = "rinja_parser"
version = "0.3.0"
Expand Down Expand Up @@ -4606,7 4644,7 @@ dependencies = [
"minifier",
"pulldown-cmark 0.9.6",
"regex",
"rinja",
"rinja 0.3.0",
"rustdoc-json-types",
"serde",
"serde_json",
Expand Down
2 changes: 0 additions & 2 deletions src/tools/generate-copyright/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 9,7 @@ description = "Produces a manifest of all the copyrighted materials in the Rust
[dependencies]
anyhow = "1.0.65"
cargo_metadata = "0.18.1"
html-escape = "0.2.13"
rinja = "0.2.0"
serde = { version = "1.0.147", features = ["derive"] }
serde_json = "1.0.85"
tempfile = "3"
thiserror = "1"
73 changes: 2 additions & 71 deletions src/tools/generate-copyright/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,85 62,16 @@ struct Metadata {
}

/// Describes one node in our metadata tree
#[derive(serde::Deserialize)]
#[derive(serde::Deserialize, rinja::Template)]
#[serde(rename_all = "kebab-case", tag = "type")]
#[template(path = "Node.html")]
pub(crate) enum Node {
Root { children: Vec<Node> },
Directory { name: String, children: Vec<Node>, license: Option<License> },
File { name: String, license: License },
Group { files: Vec<String>, directories: Vec<String>, license: License },
}

fn with_box<F>(fmt: &mut std::fmt::Formatter<'_>, inner: F) -> std::fmt::Result
where
F: FnOnce(&mut std::fmt::Formatter<'_>) -> std::fmt::Result,
{
writeln!(fmt, r#"<div style="border:1px solid black; padding: 5px;">"#)?;
inner(fmt)?;
writeln!(fmt, "</div>")?;
Ok(())
}

impl std::fmt::Display for Node {
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Node::Root { children } => {
if children.len() > 1 {
with_box(fmt, |f| {
for child in children {
writeln!(f, "{child}")?;
}
Ok(())
})
} else {
for child in children {
writeln!(fmt, "{child}")?;
}
Ok(())
}
}
Node::Directory { name, children, license } => with_box(fmt, |f| {
render_tree_license(std::iter::once(name), license.as_ref(), f)?;
if !children.is_empty() {
writeln!(f, "<p><b>Exceptions:</b></p>")?;
for child in children {
writeln!(f, "{child}")?;
}
}
Ok(())
}),
Node::Group { files, directories, license } => with_box(fmt, |f| {
render_tree_license(directories.iter().chain(files.iter()), Some(license), f)
}),
Node::File { name, license } => {
with_box(fmt, |f| render_tree_license(std::iter::once(name), Some(license), f))
}
}
}
}

/// Draw a series of sibling files/folders, as HTML, into the given formatter.
fn render_tree_license<'a>(
names: impl Iterator<Item = &'a String>,
license: Option<&License>,
f: &mut std::fmt::Formatter<'_>,
) -> std::fmt::Result {
writeln!(f, "<p><b>File/Directory:</b> ")?;
for name in names {
writeln!(f, "<code>{}</code>", html_escape::encode_text(&name))?;
}
writeln!(f, "</p>")?;

if let Some(license) = license {
writeln!(f, "<p><b>License:</b> {}</p>", html_escape::encode_text(&license.spdx))?;
for copyright in license.copyright.iter() {
writeln!(f, "<p><b>Copyright:</b> {}</p>", html_escape::encode_text(&copyright))?;
}
}

Ok(())
}

/// A License has an SPDX license name and a list of copyright holders.
#[derive(serde::Deserialize)]
struct License {
Expand Down
71 changes: 71 additions & 0 deletions src/tools/generate-copyright/templates/Node.html
Original file line number Diff line number Diff line change
@@ -0,0 1,71 @@
{% match self %}

{% when Node::Root { children } %}

{% for child in children %}
{{ child|safe }}
{% endfor %}

{% when Node::Directory { name, children, license } %}

<div style="border:1px solid black; padding: 5px;">

<p>
<b>File/Directory:</b> <code>{{ name }}</code>
</p>

{% if let Some(license) = license %}

<p><b>License:</b> {{ license.spdx }}</p>
{% for copyright in license.copyright.iter() %}
<p><b>Copyright:</b> {{ copyright }}</p>
{% endfor %}

{% endif %}

{% if !children.is_empty() %}

<p><b>Exceptions:</b></p>
{% for child in children %}
{{ child|safe }}
{% endfor %}

{% endif %}

</div>

{% when Node::File { name, license } %}

<div style="border:1px solid black; padding: 5px;">
<p>
<b>File/Directory:</b> <code>{{ name }}</code>
</p>

<p><b>License:</b> {{ license.spdx }}</p>
{% for copyright in license.copyright.iter() %}
<p><b>Copyright:</b> {{ copyright }}</p>
{% endfor %}
</div>

{% when Node::Group { files, directories, license } %}

<div style="border:1px solid black; padding: 5px;">

<p>
<b>File/Directory:</b>
{% for name in files %}
<code>{{ name }}</code>
{% endfor %}
{% for name in directories %}
<code>{{ name }}</code>
{% endfor %}
</p>

<p><b>License:</b> {{ license.spdx }}</p>
{% for copyright in license.copyright.iter() %}
<p><b>Copyright:</b> {{ copyright }}</p>
{% endfor %}

</div>

{% endmatch %}